Немного подправил расчёт изоляции.
This commit is contained in:
		
							parent
							
								
									9ec74ad0fb
								
							
						
					
					
						commit
						40d7446c5a
					
				
							
								
								
									
										21
									
								
								isolatio.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								isolatio.c
									
									
									
									
									
								
							@ -16,7 +16,6 @@ OPTOCANAL opt[2];
 | 
				
			|||||||
ISOLATION isolation1 = ISOLATION_DEFAULT;
 | 
					ISOLATION isolation1 = ISOLATION_DEFAULT;
 | 
				
			||||||
ISOLATION isolation2 = ISOLATION_DEFAULT;
 | 
					ISOLATION isolation2 = ISOLATION_DEFAULT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void calibrateIsolation();
 | 
					 | 
				
			||||||
void init_isolation_struct(void);
 | 
					void init_isolation_struct(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DCLK(int i, int x)
 | 
					void DCLK(int i, int x)
 | 
				
			||||||
@ -177,8 +176,8 @@ void timer_Init()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int calibration1 = 0; 	//Ï× 31 - 0; 32 - (-2); 21 - 1
 | 
					int isol_calibration[2] = {0, 0}; 	//Ï× 31 - 0; 32 - (-2); 21 - 1
 | 
				
			||||||
int calibration2 = 0;	//Ï× 31 - 3; 32 - (-4);	//21 - 1
 | 
														//Ï× 31 - 3; 32 - (-4);	//21 - 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void init_isolation_struct(void)
 | 
					void init_isolation_struct(void)
 | 
				
			||||||
@ -260,8 +259,8 @@ void isolation_calc(void)
 | 
				
			|||||||
		    buff[l] = isolation1.buff[k];
 | 
							    buff[l] = isolation1.buff[k];
 | 
				
			||||||
		    k++;
 | 
							    k++;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		isolation1.max_val = buff[5];
 | 
							isolation1.max_val = buff[4];
 | 
				
			||||||
        isolation1.min_val = buff[IS_BUFF_SIZE - 5];
 | 
					        isolation1.min_val = buff[IS_BUFF_SIZE - 4];
 | 
				
			||||||
		k = 0;
 | 
							k = 0;
 | 
				
			||||||
//        while(k < IS_BUFF_SIZE)
 | 
					//        while(k < IS_BUFF_SIZE)
 | 
				
			||||||
//        {
 | 
					//        {
 | 
				
			||||||
@ -276,7 +275,7 @@ void isolation_calc(void)
 | 
				
			|||||||
		tmp_delta = isolation1.max_val - isolation1.min_val;
 | 
							tmp_delta = isolation1.max_val - isolation1.min_val;
 | 
				
			||||||
		if(!isolation1.f_not_ready)
 | 
							if(!isolation1.f_not_ready)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			isolation1.row_MOms = tmp_delta ? COEFF_ACP_TO_MOMx10_1 / (tmp_delta << 10) - 200 + calibration1
 | 
								isolation1.row_MOms = tmp_delta ? COEFF_ACP_TO_MOMx10_1 / (tmp_delta << 10) - 200 + isol_calibration[0]
 | 
				
			||||||
														: isolation1.row_MOms;
 | 
																			: isolation1.row_MOms;
 | 
				
			||||||
			if (isolation1.row_MOms > isolation1.MOms_x_10) {
 | 
								if (isolation1.row_MOms > isolation1.MOms_x_10) {
 | 
				
			||||||
			    isolation1.MOms_x_10 += 2;   //isolation1.row_MOms;
 | 
								    isolation1.MOms_x_10 += 2;   //isolation1.row_MOms;
 | 
				
			||||||
@ -284,7 +283,7 @@ void isolation_calc(void)
 | 
				
			|||||||
			else if (isolation1.row_MOms < isolation1.MOms_x_10) {isolation1.MOms_x_10 -= 1;}
 | 
								else if (isolation1.row_MOms < isolation1.MOms_x_10) {isolation1.MOms_x_10 -= 1;}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			isolation1.MOms_x_10 = tmp_delta ? COEFF_ACP_TO_MOMx10_1 / (tmp_delta << 10) - 200 + calibration1
 | 
								isolation1.MOms_x_10 = tmp_delta ? COEFF_ACP_TO_MOMx10_1 / (tmp_delta << 10) - 200 + isol_calibration[0]
 | 
				
			||||||
														: isolation1.MOms_x_10;
 | 
																			: isolation1.MOms_x_10;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (isolation1.MOms_x_10 > 50) { isolation1.MOms_x_10 = 50;}
 | 
							if (isolation1.MOms_x_10 > 50) { isolation1.MOms_x_10 = 50;}
 | 
				
			||||||
@ -337,8 +336,8 @@ void isolation_calc(void)
 | 
				
			|||||||
            buff[l] = isolation2.buff[k];
 | 
					            buff[l] = isolation2.buff[k];
 | 
				
			||||||
            k++;
 | 
					            k++;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        isolation2.max_val = buff[5];
 | 
					        isolation2.max_val = buff[4];
 | 
				
			||||||
        isolation2.min_val = buff[IS_BUFF_SIZE - 5];
 | 
					        isolation2.min_val = buff[IS_BUFF_SIZE - 4];
 | 
				
			||||||
        //
 | 
					        //
 | 
				
			||||||
//		k = 0;
 | 
					//		k = 0;
 | 
				
			||||||
//		while(k < IS_BUFF_SIZE)
 | 
					//		while(k < IS_BUFF_SIZE)
 | 
				
			||||||
@ -362,14 +361,14 @@ void isolation_calc(void)
 | 
				
			|||||||
//		}
 | 
					//		}
 | 
				
			||||||
		tmp_delta = isolation2.max_val - isolation2.min_val;
 | 
							tmp_delta = isolation2.max_val - isolation2.min_val;
 | 
				
			||||||
		if(!isolation2.f_not_ready) {
 | 
							if(!isolation2.f_not_ready) {
 | 
				
			||||||
			isolation2.row_MOms = tmp_delta ? (COEFF_ACP_TO_MOMx10_2) / (tmp_delta << 10) - 200 + calibration2	//1668494131L
 | 
								isolation2.row_MOms = tmp_delta ? (COEFF_ACP_TO_MOMx10_2) / (tmp_delta << 10) - 200 + isol_calibration[1]	//1668494131L
 | 
				
			||||||
					: isolation2.row_MOms;
 | 
										: isolation2.row_MOms;
 | 
				
			||||||
			if (isolation2.row_MOms > isolation2.MOms_x_10 ) {
 | 
								if (isolation2.row_MOms > isolation2.MOms_x_10 ) {
 | 
				
			||||||
				isolation2.MOms_x_10 += 2;	// isolation2.row_MOms;
 | 
									isolation2.MOms_x_10 += 2;	// isolation2.row_MOms;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else if (isolation2.row_MOms < isolation2.MOms_x_10 ) {isolation2.MOms_x_10 -= 1; }
 | 
								else if (isolation2.row_MOms < isolation2.MOms_x_10 ) {isolation2.MOms_x_10 -= 1; }
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			isolation2.MOms_x_10 = tmp_delta ? (COEFF_ACP_TO_MOMx10_2) / (tmp_delta << 10) - 200 + calibration2
 | 
								isolation2.MOms_x_10 = tmp_delta ? (COEFF_ACP_TO_MOMx10_2) / (tmp_delta << 10) - 200 + isol_calibration[1]
 | 
				
			||||||
											: isolation2.MOms_x_10;
 | 
																: isolation2.MOms_x_10;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (isolation2.MOms_x_10 > 50) { isolation2.MOms_x_10 = 50;}
 | 
							if (isolation2.MOms_x_10 > 50) { isolation2.MOms_x_10 = 50;}
 | 
				
			||||||
 | 
				
			|||||||
@ -24,13 +24,15 @@ typedef struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	unsigned int pause_counter;
 | 
						unsigned int pause_counter;
 | 
				
			||||||
	unsigned int pause_time;
 | 
						unsigned int pause_time;
 | 
				
			||||||
	unsigned long adc_value;
 | 
						long long adc_value;
 | 
				
			||||||
}ISOLATION;
 | 
					}ISOLATION;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define ISOLATION_DEFAULT	{{0,0,0,0,0,0,0,0}, 0, 0, 0, 0, 0, 0, 0, 0}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern ISOLATION isolation1;
 | 
					extern ISOLATION isolation1;
 | 
				
			||||||
extern ISOLATION isolation2;
 | 
					extern ISOLATION isolation2;
 | 
				
			||||||
 | 
					extern int isol_calibration[2];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define ISOLATION_DEFAULT	{{0,0,0,0,0,0,0,0}, 0, 0, 0, 0, 0, 0, 0, 0}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void isolation_calc(void);
 | 
					void isolation_calc(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user