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

◆ ADC_lettura()

int32_t ADC_lettura ( uint8_t  scheda_su_scheda_giu_,
uint8_t  node_to_read,
uint8_t  cosa_fare 
)

This function allows to read the voltage of any of the selectable nodes.

Parameters
[in]scheda_su_scheda_giu_: which boards: up or down
[in]node_to_read: which of the 49 nodes to read
[in]cosa_fare: cosa_fare=1 measurement is launched, but the result is not waited;
cosa_fare=2 measurement is launched and the result is waited;
cosa_fare=3 only the result is waited
Returns
ADC_misura_fatta : the measurement result
710int32_t ADC_lettura(uint8_t scheda_su_scheda_giu_, uint8_t node_to_read, uint8_t cosa_fare){
711 //Da implementare: lettura di un qualsiasi nodo con ADC interno
712 status = SPIdrv->Control(SPI_control_for_relay_driver,spi_clock_for_relais);
713 if(scheda_su_scheda_giu_>1)scheda_su_scheda_giu_=1;
714 if( cosa_fare <=2){
715 //Si seleziona l'analog mux sulla mainboard, se serve
716 if ( (node_to_read >= node_voltage_Analog_Mux_0_offset ) ){//Questo \'e il mux della mainboard A
717 Analog_mux_line_to_select_deselect(scheda_su_scheda_giu_, node_to_read & 0xF, 1);
718 }
719 //si seleziona l'analog mux sulla postmainboard
720 Analog_mux_line_to_select_deselect_for_postmainboard ( scheda_su_scheda_giu_, node_to_read, 1 ) ;
721 //si toglie la res da 10k, questo viene fatto all'interno della funzione della lettura ADC
722 //si seleziona l' ADC
723 //si spara la misura in parallelo
724 ADC_misura_fatta = ADC_lettura_24bit( node_to_read, scheda_su_scheda_giu_, cosa_fare); //Lancio la misura con (2)(non in parallelo) o senza (1) polling
725 }
726
727 if ( cosa_fare ==3){
728 //si leggono solo gli ADC
729 ADC_misura_fatta = ADC_lettura_24bit( node_to_read, scheda_su_scheda_giu_, 3 );
730 }
731 if( cosa_fare>=2){
732 //Si de-seleziona l'analog mux sulla mainboard, se serve
733 if ( (node_to_read >= node_voltage_Analog_Mux_0_offset ) ){//Questo \'e il mux della mainboard A
734 Analog_mux_line_to_select_deselect(scheda_su_scheda_giu_, node_to_read & 0xF, 0);
735 }
736 //si de-seleziona l'analog mux sulla postmainboard
737 Analog_mux_line_to_select_deselect_for_postmainboard ( scheda_su_scheda_giu_, node_to_read, 0 ) ;
738 }
739// uint8_t numeratore=1, denominatore=1; //Attenuation is always 1 but with detector bias
740// if( (node_to_read >=node_voltage_Analog_Mux_0_offset) && (node_to_read <=(node_voltage_Analog_Mux_0_offset +14))){ //14=12 bias voltage + 2 external bias
741// numeratore=ADC_numeratore_Bias;
742// denominatore= ADC_denominatore_Bias;
743// }
744// ADC_misura_fatta = (ADC_misura_fatta *numeratore) / denominatore;
745// ADC_misura_fatta = (ADC_misura_fatta * ADC_coefficiente[node_to_read / ADC_molteplicita_node_to_read].numeratore )\
746// / ADC_coefficiente[node_to_read / ADC_molteplicita_node_to_read].denominatore ;
747
748 return ADC_misura_fatta;
749}
long int ADC_lettura_24bit(char line_to_read_to_select_ADCch0_ADCch1, uint8_t up_down, uint8_t cosa_fare)
ADC Wakeup and 24 bits reading.
Definition: Adc.c:433
int32_t ADC_lettura(uint8_t scheda_su_scheda_giu_, uint8_t node_to_read, uint8_t cosa_fare)
This function allows to read the voltage of any of the selectable nodes.
Definition: Adc.c:710
#define spi_clock_for_relais
[ref_spi_clock_for_relais]
void Analog_mux_line_to_select_deselect(uint8_t scheda_su_scheda_giu, uint8_t line_to_select, uint8_t select_1_deselect_0)
Selection of the line to mesure with the analog MUX of the mainboard, driven by the I2C->parallel mux...
void Analog_mux_line_to_select_deselect_for_postmainboard(uint8_t scheda_su_scheda_giu, uint8_t line_to_select, uint8_t select_1_deselect_0)
Selection of the line to measure with the analog MUX's of the postmainboard, directely driven by the ...
@ node_voltage_Analog_Mux_0_offset
Starting Offset for this set of nodes, 32.
#define SPI_control_for_relay_driver
[ref_SPI_control_for_relay_driver]
Definition: Spi.h:10

Definition at line 710 of file Adc.c.