CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches

◆ PGA_GAIN()

void PGA_GAIN ( uint8_t  scheda_su_scheda_giu,
uint8_t  canale,
uint8_t  guadagno_da_impostare 
)

It sets the PGA gain irrespective of the offset.

Parameters
[in]scheda_su_scheda_giuis the board up or down
[in]canalechi_aggiustiamo which channels to adjust
[in]guadagno_da_impostarethe gain to set
Returns
No Parameters.
292void PGA_GAIN(uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t guadagno_da_impostare){
293// uint16_t valore_da_trasmettere;
294// char ii;
295 uint8_t PGA_si_NO=1;
296
297
298// valore_da_trasmettere = vettore_istruzioni[byte_istr_dati_0] + ( vettore_istruzioni[byte_istr_dati_1]<< 8);
299 if( guadagno_da_impostare<=guadagno_minimo_PGA) guadagno_da_impostare=guadagno_minimo_PGA ;
300 if( guadagno_da_impostare > massimo_guadagno_impostabile ) guadagno_da_impostare =massimo_guadagno_impostabile ;
301
302// for(ii=0;ii<2;ii++){
303// if ( (canale >> ii) & 1) {
304// if ( guadagno_da_impostare < gain_pre_PGA_x_2){
305// //Rele gain PGA a 1
306// Detector_PGA_Rele( ( (ii<<4) | 8));
307// }else{
308// //Rele gain PGA a 1 o 10
309// if ( vettore_istruzioni[istruzione_byte_3] ){
310// // Gain PGA rele a 10
311// Detector_PGA_Rele( ( (ii<<4) | 9));
312// PGA_si_NO=10;
313// }else{
314// // Gain PGA rele a 1
315// Detector_PGA_Rele( ( (ii<<4) | 8));
316// }
317// }
318//}
319//}
320 //IL guadagno minimo del PGA al momento \'e 4, sta nella variabile guadagno_minimo_PGA
321 unsigned short PGA_code = ((fondo_scala_DAC_PGA * guadagno_minimo_PGA) * PGA_si_NO / guadagno_da_impostare) ;
322
323
324
325 SPIdrv->Uninitialize(); // Al DAC servono dati di 16 bit
326 SPI_Inizialize_per_il_DAC(); //DAC operated at 16 bits
327
328// GPIO_PinWrite(local_pin_port.porta_num, local_pin_port.pin_num, 0); // Viene abbassato il Chip Sel del DAC del canale 0
329// Dobbiamo aggiungere il chip select qui
330 I2C_to_Parallel_set_PCA9554_outputs_values( scheda_su_scheda_giu, PGA_DAC_chip_select[canale].I2C_to_parallel_chip_num, \
331 PGA_DAC_chip_select[canale].I2C_to_parallel_chip__pin_num );
333 SPItx_16_per_il_DAC( (PGA_code<<4) & 0x3FFF); //Il <<4 \'e la richiesat del dac
334 Aspetta_tanti_ms(10); // Bisogna aspettare almeno 5 ms prima di inviare un'altra istruzione
335// GPIO_PinWrite(local_pin_port.porta_num, local_pin_port.pin_num, 1); // Viene alzato il Chip Sel del DAC del canale 0
336// Dobbiamo aggiungere il chip un-select qui
337 I2C_to_Parallel_set_PCA9554_outputs_values( scheda_su_scheda_giu, PGA_DAC_chip_select[canale].I2C_to_parallel_chip_num, \
338 I2C_to_Parallel_ini_set[PGA_DAC_chip_select[canale].I2C_to_parallel_chip_num] );
339 Aspetta_tanti_ms(10); // Bisogna aspettare almeno 5 ms prima di inviare un'altra istruzione
340
341 SPIdrv->Uninitialize(); // Si ritorna alla SPI a 8 bit
343 //actual PGA gain
344}
uint8_t massimo_guadagno_impostabile
Definition: DAC_PGA.c:89
uint8_t guadagno_minimo_PGA
Definition: DAC_PGA.c:88
void PGA_GAIN(uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t guadagno_da_impostare)
It sets the PGA gain irrespective of the offset.
Definition: DAC_PGA.c:292
void I2C_to_Parallel_set_PCA9554_outputs_values(uint8_t scheda_su_scheda_giu, uint8_t select_PCA, uint8_t value)
The function I2C_to_Parallel_set_PCA9554_outputs_values allow to set the output pin of the I2C to par...
const uint8_t I2C_to_Parallel_ini_set[4]
...
void SPI_Inizialize_per_il_DAC(void)
SPI is initialized here for DAC. Remember to set the variable SPI_speed before the call....
Definition: Spi.c:237
void SPI_Inizialize(void)
SPI is initialized here. Its ise t at 8 bits and 100 KHz, as default.
Definition: Spi.c:205
void Aspetta_tanti_ms(int millisecondi)
The timing function.
Definition: Timer.c:52

Definition at line 292 of file DAC_PGA.c.