CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
Detector_Bias.h
Go to the documentation of this file.
1
2#include "stdint.h"
3#include <stdbool.h>
4
5/// \file
6
7// Bias constants
8//!< Attenuation for bias reading
9#define bias_reading_attenuation_extern ((1.8 + 18)/1.8 )*1024.0
10#define bias_reading_attenuation ((1.5 + 8.2)/1.5 )*1024.0
11//!< Trimmer coarse step in microV/step at the reading attenuation node
12//#define trimmer_bias_coarse_step (float) ((10.0*20.0/22.0/255.0)*(10.0/1.5)/bias_reading_attenuation* 1e6 )
13#define trimmer_bias_coarse_step (float) ((10.0*20.0/22.0/255.0)*(10.0/1.5)* 1e6 ) /*237 mV/count*/
14//!< Trimmer fine step in microV/step
15//#define trimmer_bias_fine_step (float) ((10.0*20.0/22.0/255.0)*(10e3/(10e3+1e6))*(10.0+1.5)/1.5/bias_reading_attenuation*1e6 )
16#define trimmer_bias_fine_step (float) ((10.0*20.0/22.0/255.0)*(10e3/(10e3+1e6))*(10.0+1.5)/1.5*1e6 ) /*2.7 mV/count*/
17#define trimmer_bias_coarse_pos 0
18#define trimmer_bias_fine_pos 2
19#define trimmer_bias_coarse_neg 1
20#define trimmer_bias_fine_neg 3
21
22#define Detector_min_voltage_for_switch (int32_t) 1e6 /*!< lower threshold for detetctor bias switching */
23#define Detector_max_voltage_for_switch (int32_t) 6e6 /*!< upper threshold for detetctor bias switching */
24#define Detector_max_limit_to_rail (int32_t) 0.3e6 /*!< difference between the bias and the maximum settable bias, in uV */
25
26
27//CROSS
28
29//!< Minimum settbale voltage error for detector bias above
30#define minimum_error_detector_voltage 10000 /*Minimum settbale voltage error for detector bias above */
31
33 int16_t numeratore;
34 int16_t denominatore;
35};
36
38 int32_t slope_coarse_positiva;
39// int32_t coefficiente_raccordo_slope_coarse; //=(slope_coarse_pos<<10)/(slope_coarse_neg), ricordarsi di dividere per 2^10 quando si usa
40 int32_t slope_coarse_negativa;
41 int32_t slope_fine_positiva;
42// int32_t coefficiente_raccordo_slope_fine; //=(slope_fine_pos<<10)/(slope_fine_neg), ricordarsi di dividere per 2^10 quando si usa
43 int32_t slope_fine_negativa;
44// int8_t offset_coarse_neg;
45// int8_t offset_fine_neg;
46};
47
48typedef struct EPROM_detector_ EPROM_detector__ ;
49
50extern volatile struct detector_SAR_ini_type { // SAR ini register
51 uint8_t starting_value_pos;
52 uint8_t starting_value_neg;
53 uint8_t starting_exp_value_pos;
54 uint8_t starting_exp_value_neg;
55 uint8_t target_non_raggiunto_pos;
56 uint8_t target_non_raggiunto_neg;
57} Detector_SAR_ini[];
58
59extern int32_t Detector_bias_target[]; //!< This is the detector bias target, not the bias set.
63extern const int32_t Detector_positive_coarse_step_trimmer[];
64extern const int32_t Detector_positive_fine_step_trimmer[];
65extern const int32_t Detector_negative_coarse_step_trimmer[];
66extern const int32_t Detector_negative_fine_step_trimmer[];
67
68
73static void Detector_aggiusta_offset_SAR(EPROM_detector__ *EPROM_detector_sar, uint8_t scheda_su_scheda_giu_);
74static void misura_il_valore_trimmer_detector(EPROM_detector__ *EPROM_detector_slope, uint8_t scheda_su_scheda_giu_, uint8_t canali_da_regolare, uint8_t trimmer_da_scrivere);
75static bool Detector_verifica_Vbias(uint8_t scheda_su_giu, bool si_commuta);
76
77//Queste sono definite in Detectro_Relays_managing.h
78////! [detector_trimmer]
79//#define detector_trimmer_bias_coarse_pos 0 //!< 0
80//#define detector_trimmer_bias_fine_pos 2 /*!< 2 */
81//#define detector_trimmer_bias_fine_neg 3 /*!< 3 */
82//#define detector_trimmer_bias_coarse_neg 1 /*!< 1 */
83////! [detector_trimmer]
84
85#define detector_OA_inverting_gain_x_1000 6666 /*!< this is the inverting-gain of the OA: 2 MegaOhm / 300KOhm *1000, where the *1000 is for staying with int */
86#define detector_OA_non_inverting_gain_x_1000 7666 /*!< this is the non-inverting gain of the OA: (2 MegaOhm / 300KOhm +1)*1000, where the *1000 is for staying with int */
87#define detector_fine_trimmer_attenuation 101 /*!< the inverse of attenuation between the trimmer and the oa input: = (10 kohm / 1 MegaOhm)^-1 */
88#define detector_attenuazione_della_lettura_x_1000 7250 /*!< inverse of the reading attenuation outout =(16k /(100k + 16k))^-1 */
89#define detector_trimmer_attenuation_x_1000 909 /*!< inverse of the trimmer attenuation (there are 1k + 1k in series to the 20k trimmer) =( (20k + 2k)/20k ) */
90
91#define Detector_default_coarse_trimmer 233e5
92#define Detector_default_fine_trimmer 2720
93
94#define Detector_scrivi_il_trimmer 1 /*!< trimmer writing flag */
95#define Detector_leggi_il_trimmer 0 /*!< trimmer reading flag */
96
97//Trimmer for bias
98#define Detector_trimmer_coarse_bias_pos (uint8_t)0 /*!< '' */
99#define Detector_trimmer_coarse_bias_neg (uint8_t)1 /*!< '' */
100#define Detector_trimmer_fine_bias_pos (uint8_t)2 /*!< '' */
101#define Detector_trimmer_fine_bias_neg (uint8_t) 3 /*!< '' */
102
103extern uint8_t detector_Relay_state[]; /*!< Bit0=1 if the detector is connected to the preamplifier,
104 Bit1=1 if the large load resistors are used,
105 Bit2=1 if the external bias is selected,
106 Bit3=1 if the detector bias is inverted*/
107
108////These definition are to be used with detector_Relay_state[]
109//#define detector_connected (uint8_t)(1<<0) /*!< '' */
110//#define detector_large_load_resistor_used (uint8_t)(1<<1) /*!< '' */
111//#define detector_external_bias_selected (uint8_t)(1<<2) /*!< '' */
112//#define detector_the_detectro_bias_is_inverted (uint8_t)(1<<3) /*!< '' */
113
114
115
116//fine CROSS
117
119 int16_t coarse_pos;
120 int16_t fine_pos ;
121 int16_t coarse_neg;
122 int16_t fine_neg;
123} ;
124
125extern int trimmer_bias_coarse_step_actual[];
126extern int trimmer_bias_fine_step_actual[];
127
128extern int Detector_Voltage_Bias[];
129extern struct detector_trimmer_type detector_Trimmer_bias[2] ;
130
132void imposta_il_trimmer_del_bias(int16_t *Valori_per_i_trimmer, long int discrepanza, int trimmer_bias_coarse_step_singolo, int trimmer_bias_fine_step_singolo);
133void instruction_Vbias_target(void);
int32_t Detector_bias_target[]
This is the detector bias target, not the bias set.
void instr_detector_scrittura_lettura_trimmer_bias_function(void)
This is an instruction via CAN bus to read/write the detector trimmers. It calls the detector_scrittu...
uint8_t detector_Relay_state[]
The state of the Detector realis is considerede. Note that this is the wanted working condition....
void imposta_il_trimmer_del_bias(int16_t *Valori_per_i_trimmer, long int discrepanza, int trimmer_bias_coarse_step_singolo, int trimmer_bias_fine_step_singolo)
Trimmer settings for the function instruction_Detector_bias()
void instruction_Detector_bias(void)
The detector bias is set at the value passed from the CAN.
int Detector_Voltage_Bias[]
The bias voltage applied to the detectors.
void instr_detector_Vbias_we_want_to_set_function(void)
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_...
const struct Detector_coefficiente_type Detector_coarse_trimmer_normalizing_factor[]
Coarse trimmer, negative side, normalizing factor with repect to the positive side.
void instruction_Vbias_target(void)
The detector bias will be set at the value passed from the CAN if, after this setting,...
const struct Detector_coefficiente_type Detector_small_res_normalizing_factor[]
Small Load resistor, negative side, normalizing factor with repect to the positive resistors.
void instr_Relays_driver_set_reset_channel_function(void)
Function to set the relais for detector bias.
const struct Detector_coefficiente_type Detector_large_res_normalizing_factor[]
Large Load resistor, negative side, normalizing factor with repect to the positive resistors.