CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
Preamplifier_Gain.c
Go to the documentation of this file.
1
2#include "tutti_gli_header.h"
3
4
5/*****DOCUMENTAZIONE DOXYGEN (premi il - a sinistra per ridurla a icona) il manuale html \'e nella cartella************/
6/// \file
7
8/*!
9\page Preamplifier_Gain_page Preamplifier_Gain
10\brief <span style="color:red;"> <b> Preamfier gain setting </b> </span>
11
12*\tableofcontents
13
14 \b SUMMARY:
15*\arg \ref pre_gain_operation
16*\arg \ref pre_gain_fw
17
18*\section pre_gain_operation User use of preamplifier gain
19<hr width="75%" size="10" align="left">
20
21\n Preamplifier gain set is equivalent to PGA_set_reset_pre_PGA_gain(). The function name this time is
22preamplifier_set_reset_pre_gain(uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t set_2_reset_1_idle_0 ), where
23the parameter \b set_2_reset_1_idle_0 is not the gain value and it is suggested to use the following definitions for it:
24- #preamplifier_Gain_alto , the gain is 210 V/V
25- #preamplifier_Gain_basso , the gain is 21 V/V
26- #preamplifier_Gain_set_idle , switch to idle (done by the function at the end of every setting)
27
28\n Here an example to set high gain:
29<span style="color:orange;"> <I>
30\code {.c}
31preamplifier_set_reset_pre_gain ( scheda_su_scheda_giu, canale, preamplifier_Gain_alto );
32\endcode
33</I> </span>
34
35*\section pre_gain_fw Preamplifier gain fw
36<hr width="75%" size="10" align="left">
37
38\n The code of the function is:
39\snippetlineno Preamplifier_Gain.c fun_preamplifier_set_reset_pre_gain
40
41\n The codes for mamnaging the preamplifier gain are:
42 - \ref Preamplifier_Gain.c
43 - \ref Preamplifier_Gain.h
44
45*/
46
47
48/*! \brief Here the 2 digital signals of the preamplifier's trimmer are exploited to set the gain of the preamplifier itself
49
50 *\param[in] scheda_su_scheda_giu one of the 2 boards that the postfrontend manages
51 *\param[in] canale the channel for which we need to manage the trimmer
52 *\param[in] set_2_reset_1_idle_0 use here the definitions:
53 - #preamplifier_Gain_alto
54 - #preamplifier_Gain_basso
55 - #preamplifier_Gain_set_idle
56 *\return No Parameters
57
58 *\snippetlineno Preamplifier_Gain.c fun_preamplifier_set_reset_pre_gain
59 */
60 //! <!-- [fun_preamplifier_set_reset_pre_gain] -->
61void preamplifier_set_reset_pre_gain (uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t set_2_reset_1_idle_0 ){
62
63 uint8_t spedizione[2];
64 if(scheda_su_scheda_giu) scheda_su_scheda_giu=6;
65
66 spedizione[1] = contenuto_trimmer_preamplifier[canale + scheda_su_scheda_giu][0] ; //The trimmer content has to be
67 //written each time the digital signals are set/reset
68
69 I2C_mux_select_ch( scheda_su_scheda_giu, I2C_mainboard, address_preamplifier_trimmer[canale].quale_I2C); //Select the I2C to be used
70
71 if( set_2_reset_1_idle_0) { //We operate only if we have to set
72
73 spedizione[0] = set_2_reset_1_idle_0 << 1 ; //The 2 bits are at position 1 and 2 of the byte
74
75
76 I2C_mux->MasterTransmit( (uint8_t) address_preamplifier_trimmer[canale].indirizzo_I2C , spedizione, 2,false); //Write the selected trimmer of the selcted channel
77
78 while( I2C_mux->GetStatus().busy); // White transmission complete
79
82 }
83
84 spedizione[0] =preamplifier_Gain_set_idle; // Both switches OFF, this operation is made always and can be made at the initialization
85
86 I2C_mux->MasterTransmit( (uint8_t) address_preamplifier_trimmer[canale].indirizzo_I2C , spedizione, 1,false); ///Set the trimmer to read
87
88 while( I2C_mux->GetStatus().busy); // White transmission complete
89
90 I2C_mux->MasterReceive( address_preamplifier_trimmer[canale].indirizzo_I2C, &tappo, 1,false); //Read back, the trimmer value
91
92 while( I2C_mux->GetStatus().busy){};
93
94 contenuto_trimmer_preamplifier[canale + scheda_su_scheda_giu][0] = tappo;
95}
96 //! <!-- [fun_preamplifier_set_reset_pre_gain] -->
97
98
99
#define wait_time_for_rele_setting
[ref_spi_clock_for_relais]
volatile uint32_t Error_bad_operation
exploited to mark the errors
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.
@ I2C_Error_trimmer_0
trimmer ch0
@ error_address_I2C0
Error register A for I2C0.
void I2C_mux_select_ch(uint8_t scheda_su_scheda_giu, uint8_t mainboard_postmainboard, uint8_t canale_da_abilitare)
The I2C mux.
Definition: I2C_mux.c:100
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_set_idle
. *‍/
void Aspetta_tanti_ms(int millisecondi)
The timing function.
Definition: Timer.c:52
const struct address_detector_bias_trimmer_type address_preamplifier_trimmer[6]
Preamplifier trimmer addresses
Definition: Trimmer.c:139
uint8_t volatile contenuto_trimmer_preamplifier[12][4]
Definition: Trimmer.c:179