334uint8_t iii,canale, indice, dati_scambio[4], Detector_pre_out_offset_no_change, no_slope=0;
335uint8_t
volatile tx_data_buffer[8],fai_fai=1;
336int8_t variazione, scheda_su_scheda_giu,Detector_offset_starts_at_half_scale;
342 for(iii=0;iii < 8;iii++){
344 tx_data_buffer[iii]=
tx_data[iii];
349 if (Detector_attesa_tra_le_misure==0) Detector_attesa_tra_le_misure=100;
352 if (Detector_error_voltage==0) Detector_error_voltage=200e3;
356 uint8_t Detector_canali_da_regolare_iniziali = Detector_canali_da_regolare;
375#define det_slope_default_coarse (int32_t) -264000
376#define det_slope_default_fine (int32_t) 3000
377EPROM_detector__ EPROM_detector[6]={det_slope_default_coarse,det_slope_default_coarse,det_slope_default_fine,det_slope_default_fine,
378 det_slope_default_coarse,det_slope_default_coarse,det_slope_default_fine,det_slope_default_fine,
379 det_slope_default_coarse,det_slope_default_coarse,det_slope_default_fine,det_slope_default_fine,
380 det_slope_default_coarse,det_slope_default_coarse,det_slope_default_fine,det_slope_default_fine,
381 det_slope_default_coarse,det_slope_default_coarse,det_slope_default_fine,det_slope_default_fine,
382 det_slope_default_coarse,det_slope_default_coarse,det_slope_default_fine,det_slope_default_fine};
388for(iii=0;iii<4;iii++){
393 for(canale=0;canale<6;canale++){
394 if( (Detector_canali_da_regolare >> canale) &1){
397 if(flag_error_verified) Detector_canali_da_regolare =0;
399 if(dati_scambio[0] & (flag_error_verified ==0)){
402 flag_error_verified=0;
412 if( dati_scambio[0] ==0){
414 EPROM_detector[canale].slope_coarse_positiva=*(int32_t *)dati_scambio;
416 EPROM_detector[canale].slope_coarse_negativa= *(int32_t *)dati_scambio;
421 if(flag_error_verified) Detector_canali_da_regolare =0;
423 if(flag_error_verified) Detector_canali_da_regolare =0;
424 if(dati_scambio[0] & (flag_error_verified ==0)){
428 if(scheda_su_scheda_giu)
tx_data[6] += 0x80;
430 if(flag_error_verified) Detector_canali_da_regolare =0;
432 if ( (flag_error_verified ==0)){
434 EPROM_detector[canale].slope_fine_positiva=*(int32_t *)dati_scambio;
436 EPROM_detector[canale].slope_fine_negativa= *(int32_t *)dati_scambio;
441 for(iii=0;iii<8;iii++){
442 tx_data[iii]= tx_data_buffer[iii];
445if (Detector_offset_starts_at_half_scale){
447 for( canale=0;canale<12;canale++){
448 Detector_SAR_ini[canale].starting_value_pos =128;
449 Detector_SAR_ini[canale].starting_value_neg =128;
452 for( canale=0;canale<6;canale++){
458 for( canale=0;canale<6;canale++){
459 if( (Detector_canali_da_regolare >> canale) &1 ){
460 Detector_SAR_ini[canale + scheda_su_scheda_giu].target_non_raggiunto_neg=
true;
461 Detector_SAR_ini[canale +scheda_su_scheda_giu].target_non_raggiunto_pos=
true;
462 Detector_SAR_ini[canale +scheda_su_scheda_giu].starting_exp_value_pos=7;
463 Detector_SAR_ini[canale +scheda_su_scheda_giu].starting_exp_value_neg=7;
470 if(Detector_pre_out_offset_no_change){
471 for( canale=0;canale<6;canale++){
472 if( (Detector_canali_da_regolare >> canale) &1 ){
478if(flag_error_verified==0){
479 for(canale=0; canale< 6; canale++){
481 indice= canale + scheda_su_scheda_giu;
484 if(flag_error_verified) Detector_canali_da_regolare =0;
496 for(canale=0; canale< 6; canale++){
498 indice= canale + scheda_su_scheda_giu;
499 if(Detector_pre_out_offset_no_change==0)
PGA_GAIN_CROSS( scheda_su_scheda_giu , canale , Detector_PGA_settled_gain_old[indice] );
502 if(Detector_pre_out_offset_no_change){
503 uint8_t istruzione_old[8];
504 for(iii=0;iii<8;iii++){
507 for(iii=0;iii<6;iii++){
508 PGA_settled_gain[iii+scheda_su_scheda_giu]= Detector_PGA_settled_gain_old[iii+scheda_su_scheda_giu];
520 for(iii=0;iii<8;iii++){
525 for(iii=0;iii < 8 ;iii++){
526 tx_data[iii]= tx_data_buffer[iii];
529 tx_data[6] = Detector_canali_da_regolare & 0x3F;
530 tx_data[5] = Detector_error_voltage / 1000;
int32_t ADC_misura_differenziale_con_media_generico(uint8_t scheda_su_scheda_giu_, uint8_t preamplifier_externalADC_1_onboardADC_0, uint8_t nodo_da_misurare, uint8_t differenziale_1_single_0)
This function sets the original gain when a few LSb have to be determined. The umber of bits is bit_t...
volatile uint16_t ADC_medie_per_misura
the number of ADC readings to average, the maximum is 400
@ instr_output_offset_to_be_set
Adjust the ouput voltage that was previously set at instr_ouput_offset_we_want_to_set.
uint8_t tx_data[8]
Transmission data vector.
void PGA_GAIN_CROSS(uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t PGA_gain_to_set)
Here the 2 digital signals from the trimmer are exploited to set the gain of the input stage of the P...
uint8_t guadagno_minimo_PGA
uint8_t PGA_settled_gain[12]
PGA set gain.
static void Detector_aggiusta_offset_SAR(EPROM_detector__ *EPROM_detector_sar, uint8_t scheda_su_scheda_giu_)
This function provide the output offset with the fast SAR method: only a few LS bits are left for thi...
void instr_Vbias_to_be_set_function(void)
The detector bias will be set at the value set with the function instr_detector_Vbias_we_want_to_set_...
#define minimum_error_detector_voltage
< Minimum settbale voltage error for detector bias above
#define Detector_trimmer_coarse_bias_pos
#define Detector_trimmer_coarse_bias_neg
void Error_imposta_la_istruzione(void)
Function to be located at the end of every instruction to mark the error, if any.
void ERROR_codifica_errore(uint8_t scheda_su_scheda_giu, unsigned char error_addres, unsigned char code_to_shift, uint8_t reset_count_se_0)
If an error is found its flag is codified here.
@ Detector_bias_slopes_not_available
One or more channels have not the slope set.
@ error_address_Bias_adjustment
Error register for channel detector bias adjustment.
void EPROM_lettura_M24C32_64(uint8_t scheda_su_scheda_giu_, uint8_t mainboard_postmainboard, uint8_t canale, short indirizzo_memoria, uint8_t *dati_letti)
Read from preamplifier and on-board flashes.
@ Memory_detector_negative_address_coarse_trimmer_slope_bias
coarse slope for detector negative trimmer bias
@ Memory_detector_positive_address_coarse_trimmer_slope_bias
coarse slope for detector positive trimmer bias
@ Memory_detector_negative_address_fine_trimmer_slope_bias
fine slope for detector negative trimmer bias
@ Memory_detector_fine_slope_calibration_ON_0_OFF_ff
slope detector negative trimmer active if zero
@ Memory_detector_coarse_slope_calibration_ON_0_OFF_ff
slope detector positive trimmer active if zero
@ Memory_detector_positive_address_fine_trimmer_slope_bias
fine slope for detector positive trimmer bias
void preamplifier_set_reset_pre_gain(uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t set_2_reset_1_idle_0)
Here the 2 digital signals of the preamplifier's trimmer are exploited to set the gain of the preampl...
#define preamplifier_Gain_basso
. */
#define preamplifier_Gain_alto
. */
void instr_output_offset_to_be_set_function(void)
The detector bias will be set at the value set with the function instr_detector_Vbias_we_want_to_set_...
int32_t preamplifier_Output_offset_target[12]
Offset target values.
void instr_DetBias_trimmer_calibration_function(void)
The fine and coarse trimmers for Detector bias adjustment are calibrated here
uint8_t contenuto_trimmer_detector[12][4]
Content of the trimmer for detector bias system.
volatile int8_t vettore_istruzioni[8]
This is a copy of the received 8 bytes from the CAN.