CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
Istruzioni.h
Go to the documentation of this file.
1
2
3#include "stdint.h"
4#include "stdbool.h"
5
6
7 /// \file
8
9/*********************************************************
10Variabili da spostare Gianlu
11**********************************************************/
12#define saturazione_positiva (int) 4.5e6
13#define saturazione_negativa (int) -4.5e6
14
15/*********************************************************
16Variabili di Gianlu
17**********************************************************/
18//Posizione dei Byte di istruzioni nel CAN message
19#define istruzione_codice 7 /*!< '' */
20#define istruzione_byte_0 2 /*!< '' */
21#define istruzione_byte_1 3 /*!< '' */
22#define istruzione_byte_2 4 /*!< '' */
23#define istruzione_byte_3 5 /*!< '' */
24#define istruzione_byte_4_e_scelta_canale 6 /*!< '' */
25#define byte_istr_dati_0 0 /*!< '' */
26#define byte_istr_dati_1 1 /*!< '' */
27#define byte_istr_dati_2 2 /*!< '' */
28#define byte_istr_dati_3 3 /*!< '' */
29
30//INIZIO CROSS
31
32/*! \brief instr_NO_operation has the value of zero and the follwoing instructions are increased by one at each step.
33
34The last enum line, instr_Trimmer_setting, is not an instruction but the information of the total number of instructions.
35*/
36#define instr_canale_1 1<<0 /*!< '' */
37#define instr_canale_2 1<<1 /*!< '' */
38#define instr_canale_3 1<<2 /*!< '' */
39#define instr_canale_4 1<<3 /*!< '' */
40#define instr_canale_5 1<<4 /*!< '' */
41#define instr_canale_6 1<<5 /*!< '' */
42#define instr_scheda_up 1<<7 /*!< '' */
43#define instr_all_channels instr_canale_1 | instr_canale_2 | instr_canale_3 | instr_canale_4 | instr_canale_5 | instr_canale_6 /*!< '' */
44#define instr_scheda_down 0 /*!< '' */
45
46#define write_trimmer (1<<6)
47#define board_up (1<<7)
48
49
50/*! \brief Node voltages that can be read from an external ADC
51
52
53 *\snippet Istruzioni.h enum_node_voltage_pga
54 */
55 //! <!-- [enum_node_voltage_pga] -->
57 node_voltage_PGA_offset=0, //!< Starting Offset for this set of nodes
58 node_voltage_PGA_ch_0 = node_voltage_PGA_offset, //!< Node voltage selection of PGA differential or positive
63 node_voltage_PGA_ch_5, //!< Node voltage selection of PGA 5
64 node_voltage_PGA_neg_ch_0, //!< Negative output for PGA
71// node_voltage_PGA_ch_0_up , //!< Node voltage selection of PGA 6+0 board up
72// node_voltage_PGA_ch_1_up , //!< ...
73// node_voltage_PGA_ch_2_up , //!< ...
74// node_voltage_PGA_ch_3_up , //!< ...
75// node_voltage_PGA_ch_4_up , //!< ...
76// node_voltage_PGA_ch_5_up //!< Node voltage selection of PGA 6+5 board up
77};
78 //! <!-- [enum_node_voltage_pga] -->
79
80 /*! \snippet Istruzioni.h enum_node_voltage_PreOut
81 */
82 //! <!-- [enum_node_voltage_PreOut] -->
84 node_voltage_PreOut_offset=12, //!< Starting Offset for this set of nodes
85 node_voltage_PreOut_ch_0 =node_voltage_PreOut_offset , //!< Node voltage selection of differential or positive PreOut 0, offset from 12
90 node_voltage_PreOut_ch_5, //!< Node voltage selection of PreOut 12+5 board down
91 node_voltage_PreOut_neg_ch_0 , //!< Node voltage selection of negative PreOut
97// node_voltage_PreOut_ch_0_up , //!< Node voltage selection of PreOut 12+6 board up
98// node_voltage_PreOut_ch_1_up , //!< ...
99// node_voltage_PreOut_ch_2_up , //!< ...
100// node_voltage_PreOut_ch_3_up , //!< ...
101// node_voltage_PreOut_ch_4_up , //!< ...
102// node_voltage_PreOut_ch_5_up //!< Node voltage selection of PreOt 12+6+5 board up
104 //! <!-- [enum_node_voltage_PreOut] -->
105
106
107 /*! \snippet Istruzioni.h enum_node_voltage_PowerSupply
108 */
109 //! <!-- [enum_node_voltage_PowerSupply] -->
111 node_voltage_PowSupp_offset= 24, //!< Starting Offset for this set of nodes
115 node_voltage_sense_Vreg_n, //!< Measured from postmainboardo only
116 node_voltage_sense_Vreg_p, //!< Measured from postmainboardo only
117 node_voltage_sense_GND //!< Measured from postmainboardo only
119//! <!-- [enum_node_voltage_PowerSupply] -->
120
121///*! \brief instr_NO_operation has the value of zero and the follwoing instructions are increased by one at each step.
122
123//The last enum line, instr_Trimmer_setting, is not an instruction but the information of the total number of instructions.
124//*/
125//enum instructions {
126// instr_NO_operation , //!< NOP, in future release the fw version will be replayed
127// instr_ADC_LETTURA , //!< ADC reading, the following byte from the CAN set the reading node
128// instr_CONTROLLO_RELE , //!< Relay settings according to the second byte from the CAN
129// instr_PGA_GAIN , //!< .
130// instr_detector_Vbias_we_want_to_set , //!< .
131// instr_Vbias_set , //!< .
132// instr_preamplifier_temperature_meas , //!< .
133// instr_Power_supply_ON_OFF , //!< .
134// instr_Shut_Down_ON_OFF , //!< .
135// instr_OFFSET_ADJ , //!< .
136// instr_preamplifier_memory , //!< .
137// instr_measure_pre_bias_coefficients , //!< .
138// instr_Some_parameters_to_set , //!< here some usefull parameters can be set, such as wait times, etc.
139// instr_inizializza_tutto_da_zero, //!< .
140// instr_ricalibrazione_scheda, //!< .
141// instr_Vbias_and_OFFSET_SET , //!< .
142// instr_Drift_compensation , //!< .
143// The_total_number_of_instrucions, //!< This is the total numebr of instructions, not an instruction
144// instr_Trimmer_setting
145//} ;
146
147
148extern void (*ptr_istruzioni[]) (void);
157void instr_PGA_DAC_GAIN_CROSS_function(void);
159
160//FINE CROSS
161
162//Nodi di lettura dell'ADC
163//Sintassi nodi: 0xML, con 1<=M<=4 \'e il mux, mentre 0<=L<=7 \'e la linea del mux selezionata.
164/*! \brief Measurement nodes for ADC are defined below
165mux 1 */
166#define ADC_GND_con_10k 16 /* or 0x10 */
167#define ADC_Vdig5V_micro_passed 17 /* or 0x11 */
168#define ADC_Vcc 18 /* or 0x12 */
169#define ADC_Vee 19 /* or 0x13 */
170#define ADC_JFET_c_ch1_S2 20 /* or 0x14 cold electronics*/
171#define ADC_PRE_term_ch1 21 /* or 0x15 */
172#define ADC_ADC_PGA_pos_in_ch1 22 /* or 0x16 pre output*/
173#define ADC_ADC_PGA_neg_in_ch1 23 /* or 0x17 pre out*/
174//! \brief mux 2
175#define ADC_Misura_bias_10_att_ch1_p 32 /* or 0x20 */
176#define ADC_Misura_bias_10_att_ch1_n 33 /* or 0x21 */
177#define ADC_Misura_bias_20_att_ch1_p 34 /* or 0x22 NOTE: used to measure external Vbol pos*/
178#define ADC_Misura_bias_20_att_ch1_n 35 /* or 0x23 NOTE: used to measure external Vbol neg*/
179#define ADC_CommonMode_ch1 36 /* or 0x24 */
180#define ADC_CommonMode_ch2 37 /* or 0x25 */
181#define ADC_ADC_PGA_pos_out_ch1 38 /* or 0x26 */
182#define ADC_ADC_PGA_neg_out_ch1 39 /* or 0x27 */
183//! \brief mux 3
184#define ADC_Vdig5V_micro_in 48 /* or 0x30 floating? */
185#define ADC_Vcc_in 49 /* or 0x31 floating? */
186#define ADC_Vee_in 50 /* or 0x32 floating? */
187#define ADC_Vref_pos_in 51 /* or 0x33 floating? */
188#define ADC_Vref_neg_in 52 /* or 0x34 floating? */
189#define ADC_PRE_term_ch2 53 /* or 0x35 */
190#define ADC_ADC_PGA_pos_in_ch0 54 /* or 0x36 pre output*/
191#define ADC_ADC_PGA_neg_in_ch0 55 /* or 0x37 pre out*/
192//! \brief mux 4
193#define ADC_Misura_bias_10_att_ch0_p 64 /* or 0x40 */
194#define ADC_Misura_bias_10_att_ch0_n 65 /* or 0x41 */
195#define ADC_Misura_bias_20_att_ch0_p 66 /* or 0x42 NOTE: Used to calibrate Rmul of ADC*/
196#define ADC_Misura_bias_20_att_ch0_n 67 /* or 0x43 */
197#define ADC_JFET_c_ch0_S1 68 /* or 0x44 cold electronics*/
198#define ADC_JFET_c_ch0_S2 69 /* or 0x45 cold electronics*/
199#define ADC_ADC_PGA_pos_out_ch0 70 /* or 0x46 */
200#define ADC_ADC_PGA_neg_out_ch0 71 /* or 0x47 */
201
202
203extern int wait_for_ADC_setting; //!< This is the time elapsed before the ADC starts to measure after that the Mux has been set.
204extern int valore_target_per_offset[];
205
206enum parameters_to_set{
207set_value_for_wait_for_ADC_setting //<! Value in ms to wait from Mux set to ADC measurement
208};
209
210
211
212/************************************************
213FINE Variabili di Gianlu
214*************************************************/
215
216
217/************************************************
218Funzioni di Gianlu
219*************************************************/
220
222void instruction_lettura_ADC(void);
223//int lettura_ADC( char sottoistruzione);
224//void instruction_Detector_PGA_Rele(void);
225
228void Misura_della_temperatura(int *misura_temperatura_locale);
229//void instruction_Power_supply_control(void);
230//void Spegnimento_delle_alimentazioni_analogiche(void);
231//void Accensione_delle_alimentazioni_analogiche(void);
234void Detector_PGA_Rele( char discriminazione);
235void aggiustamento_SAR(bool *saturazione_canale, int attesa, char *nodo_di_misura_1);
236void offset_Adjust_core(char chi_aggiustiamo, int *valore_target_per_ch, char *nodo_di_misura_1, char *nodo_di_misura_2, \
237 int tolleranza, int *coarse_trimmer_step, int *fine_trimmer_step, unsigned int attesa,int *misura_finale);
238void attiva_il_CMRR( char chi_aggiustiamo /*1 per canale 0, 2 per canale 1, 3 per entrambi i canali*/, char attivare_si_no);
239
240
241
242
243
244/************************************************
245FINE Funzioni di Gianlu
246*************************************************/
247
248enum instructions_position {
249 instr_base ,
250 instr_ADC_LETTURA_mux_selection ,
251 instr_ADC_LETTURA_adc_line_selection
252};
253
254enum instructions_position_rele {
255
256 instr_CONTROLLO_RELE_Rele_canale = 1 ,
257 instr_CONTROLLO_RELE_quale_rele ,
258 instr_CONTROLLO_RELE_che_fare
259};
260
261enum instructions_position_PGA {
262
263 instr_PGA_GAIN_quale_canale = 1 ,
264
265};
266
267enum instructions_position_Vbias {
268
269 instr_Vbias_set_quale_canale = 1 ,
270
271};
272
273enum instructions_position_temp {
274
275 instr_preamplifier_temperature_meas_quale_canale = 1 ,
276
277};
278
279enum instructions_position_power {
280
281 instr_Power_supply_ON_OFF_power_ON_OFF = 1 ,
282
283};
284enum power_ON_OFF {
285
286 Power_OFF ,
287 Power_ON
288
289};
290
291enum instructions_position_shut_down {
292
293 instr_Shut_Down_ON_OFF_Shut_Down_ON_OFF = 1 ,
294
295};
296
297enum instructions_position_Vbias_and_offset {
298
299 instr_Vbias_and_OFFSET_SET_canale_0_1 = 1 ,
300
301};
302
303enum instructions_position_trimmer_setting {
304
305 instr_Trimmer_setting_canale_e_cosa = 1 ,
306
307};
308
309
310enum shut_down_ON_OFF {
311
312 instr_Shut_Down_ON_OFF_ShutDown_ON ,
313 instr_Shut_Down_ON_OFF_ShutDown_OFF
314
315};
316
317enum mux {
318 //mux_0 , //non presente
319 mux_1 =1,
320 mux_2 ,
321 mux_3 ,
322 mux_4
323};
324
325enum ADC_sel_line {
326 //adc_line_0 , //non presente
327 adc_line_1 =1 ,
328 adc_line_2 ,
329 adc_line_3 ,
330 adc_line_4 ,
331 adc_line_5 ,
332 adc_line_6 ,
333 adc_line_7 ,
334 adc_line_8
335};
336
337enum Canale_per_rele {
338 rele_S1 =1 ,
339 rele_S2 ,
340 rele_S3 ,
341 rele_K4 ,
342 rele_K2
343};
344
345enum Canale_per_rele_1 {
346 rele_S4 =1 ,
347 rele_S5 ,
348 rele_S6 ,
349 rele_K5 ,
350 rele_K3
351};
352
353enum rele_stato_0_stato_1 {
354 rele_stato_0 ,
355 rele_stato_1
356};
357
358enum quale_canale {
359 canale_0 ,
360 canale_1
361};
362
363enum trimmer_set{
364 canale_0_trimmer_2 ,
365 canale_0_trimmer_0 ,
366 canale_1_trimmer_2 ,
367 canale_1_trimmer_0
368};
369
370
void instr_readback_variables_function(void)
readback of some parameters
Definition: Istruzioni.c:179
void Setting_of_the_pointer_for_command_parser(void)
The pointer to the instruction functions is constructed here.
Definition: Istruzioni.c:33
void instr_readback_node_voltages_function(void)
readback of some node voltages from external ADC
Definition: Istruzioni.c:232
void instr_connect_disconnect_mux_node_function(void)
Routing of available node voltage to outout by means of the analog mux.
Definition: Istruzioni.c:446
void instr_PGA_gain_set_function(void)
PGA gain set.
Definition: Istruzioni.c:330
void instr_preamplifier_gain_low_high_set_function(void)
preamplifier gain set large or small
Definition: Istruzioni.c:304
void instr_preamplifier_memory_function(void)
Definition: Istruzioni.c:275
void instr_preamplifier_temperature_meas_function(void)
Definition: Istruzioni.c:248
void(* ptr_istruzioni[The_total_number_of_instrucions])(void)
This is the pointer array to the instructions set: the byte istruzione_codice of the CAN message is t...
Definition: Istruzioni.c:24
void instr_PGA_set_reset_pre_PGA_gain_function(void)
PGA input stage gain set.
Definition: Istruzioni.c:396
void instruction_Misura_della_temperatura(void)
The temperature from both preamplifier is read.
Definition: Istruzioni.c:735
void instruction_lettura_ADC(void)
ADC instrunction implementation with node selection.
Definition: Istruzioni.c:472
void instr_NO_operation_function(void)
The NOP sends backs the fw version.
Definition: Istruzioni.c:99
void instr_Shut_Down_ON_OFF_function(void)
μ-controller power down ON/OFF
Definition: Istruzioni.c:116
node_voltage_PreOut
Definition: Istruzioni.h:83
@ node_voltage_PreOut_ch_4
...
Definition: Istruzioni.h:89
@ node_voltage_PreOut_neg_ch_4
...
Definition: Istruzioni.h:95
@ node_voltage_PreOut_ch_5
Node voltage selection of PreOut 12+5 board down.
Definition: Istruzioni.h:90
@ node_voltage_PreOut_ch_0
Node voltage selection of differential or positive PreOut 0, offset from 12.
Definition: Istruzioni.h:85
@ node_voltage_PreOut_ch_2
...
Definition: Istruzioni.h:87
@ node_voltage_PreOut_neg_ch_5
...
Definition: Istruzioni.h:96
@ node_voltage_PreOut_neg_ch_0
Node voltage selection of negative PreOut.
Definition: Istruzioni.h:91
@ node_voltage_PreOut_neg_ch_1
...
Definition: Istruzioni.h:92
@ node_voltage_PreOut_ch_3
...
Definition: Istruzioni.h:88
@ node_voltage_PreOut_neg_ch_3
...
Definition: Istruzioni.h:94
@ node_voltage_PreOut_ch_1
...
Definition: Istruzioni.h:86
@ node_voltage_PreOut_neg_ch_2
...
Definition: Istruzioni.h:93
@ node_voltage_PreOut_offset
Starting Offset for this set of nodes.
Definition: Istruzioni.h:84
int wait_for_ADC_setting
This is the time elapsed before the ADC starts to measure after that the Mux has been set.
node_voltage_PowerSupply
Definition: Istruzioni.h:110
@ node_voltage_PowSupp_offset
Starting Offset for this set of nodes.
Definition: Istruzioni.h:111
@ node_voltage_Vdig
...
Definition: Istruzioni.h:114
@ node_voltage_sense_Vreg_n
Measured from postmainboardo only.
Definition: Istruzioni.h:115
@ node_voltage_Vee
...
Definition: Istruzioni.h:113
@ node_voltage_sense_GND
Measured from postmainboardo only.
Definition: Istruzioni.h:117
@ node_voltage_sense_Vreg_p
Measured from postmainboardo only.
Definition: Istruzioni.h:116
@ node_voltage_Vcc
Offset starts at 24.
Definition: Istruzioni.h:112
node_voltage_pga
Node voltages that can be read from an external ADC.
Definition: Istruzioni.h:56
@ node_voltage_PGA_neg_ch_4
...
Definition: Istruzioni.h:68
@ node_voltage_PGA_neg_ch_5
...
Definition: Istruzioni.h:69
@ node_voltage_PGA_ch_1
...
Definition: Istruzioni.h:59
@ node_voltage_PGA_ch_4
...
Definition: Istruzioni.h:62
@ node_voltage_PGA_ch_2
...
Definition: Istruzioni.h:60
@ node_voltage_PGA_neg_ch_1
...
Definition: Istruzioni.h:65
@ node_voltage_PGA_neg_ch_6
...
Definition: Istruzioni.h:70
@ node_voltage_PGA_ch_5
Node voltage selection of PGA 5.
Definition: Istruzioni.h:63
@ node_voltage_PGA_neg_ch_0
Negative output for PGA.
Definition: Istruzioni.h:64
@ node_voltage_PGA_ch_0
Node voltage selection of PGA differential or positive.
Definition: Istruzioni.h:58
@ node_voltage_PGA_neg_ch_3
...
Definition: Istruzioni.h:67
@ node_voltage_PGA_ch_3
...
Definition: Istruzioni.h:61
@ node_voltage_PGA_neg_ch_2
...
Definition: Istruzioni.h:66
@ node_voltage_PGA_offset
Starting Offset for this set of nodes.
Definition: Istruzioni.h:57
void instruction_Offset_compensation(void)
Output offset voltage compensation.
Definition: Istruzioni.c:902
void aggiustamento_SAR(bool *saturazione_canale, int attesa, char *nodo_di_misura_1)
When the preamplifier output is saturated we start with the standard SAR.
Definition: Istruzioni.c:1262
void instruction_Some_parameters_to_set(void)
Some usefull parematers can be set here.
Definition: Istruzioni.c:577