14#define ADC_communication_reg 0
16#define ADC_to_be_added_to_read 0x40
17#define ADC_data_reg 0x08
18#define ADC_range_reg 0x28
19#define ADC_Conversion_time_reg 0x30
20#define ADC_mode_reg 0x38
21#define ADC_mode_reg_ch0 0x38
22#define ADC_mode_reg_ch1 ADC_mode_reg_ch0 + 2
23#define ADC_channel_data_reg 0x08
24#define ADC_full_scale_correction_register 0x18
25#define ADC_offset_correction_register 0x10
26#define ADC_channel_conversion_time_FW_ch0_register 0x30
27#define ADC_channel_conversion_time_FW_ch1_register ADC_channel_conversion_time_FW_ch0_register + 2
29#define ADC_max_resolution 0xFF
30#define ADC_ZeroScaleCalibration_com 0x82
31#define ADC_Channel_zero_scale_calibration 12
32#define ADC_Channel_full_scale_calibration 14
33#define ADC_idle_com 0x02
34#define ADC_mode_reg_set_single_24bit 0x42
35#define read_from_CH0 0x48
36#define read_from_CH1 (read_from_CH0+2)
50#define ADC_numeratore_PGA 1
51#define ADC_denominatore_PGA 10
52#define ADC_numeratore_PreOut 91
53#define ADC_denominatore_PreOut 410
54#define ADC_numeratore_PowerSupply 91
55#define ADC_denominatore_PowerSupply 410
56#define ADC_numeratore_Vreg 33
57#define ADC_denominatore_Vreg 328
58#define ADC_numeratore_Bias_p 29
59#define ADC_denominatore_Bias_p 4
60#define ADC_numeratore_Bias 11
61#define ADC_denominatore_Bias 41
62#define ADC_numeratore_Res_fisse 10
63#define ADC_denominatore_Res_fisse 41
64#define ADC_molteplicita_node_to_read 6
76extern int32_t
volatile ADC_misura_fatta;
77extern int32_t
volatile ADC_external_measurement;
78extern uint8_t
volatile ADC_external_measured_node;
85int32_t
ADC_lettura(uint8_t scheda_su_scheda_giu, uint8_t node_to_read, uint8_t cosa_fare);
90signed long int ADC_lettura_24bit(
char ADC_0_o_1, uint8_t up_down, uint8_t cosa_fare);
92void ADC_scrittura_registro(
char ADC_0_o_1 , uint8_t up_down, uint8_t registro_ch0, int32_t value_to_write);
98static int32_t ADC_misura_differenziale_single_ended(uint8_t scheda_su_scheda_giu , uint8_t nodo_da_leggere, uint8_t differenziale_1_single_0 );
119#define ADC_power_down_com 0x70
130#define ADC_max_input_range_minus_10_to_10 0
134#define indice_Vbias 0
135#define indice_PoerSupply 1
136#define indice_100_ohm 2
137#define indice_10_Kohm 3
138#define indice_Vbias_extern 4
139#define indice_default 5
141#define ADC_Conversion_time_chop_e_max_filter 0xFF
142#define ADC_Conversion_time_500micros_per_conversion 0x96
143#define ADC_Conversion_time_200micros_per_conversion 0x88
144#define ADC_Conversion_time_80micros_per_conversion 0x82
146#define ADC_reference_voltage 2.5e6
147#define R_ref_10k 10e6
148#define R_series_for_Vbias_extern 1800.0*18000.0/(1800.0+18000.0)*1000
149#define R_series_for_Vbias 1500.0*8200.0/(1500.0+8200.0)*1000
150#define R_series_for_PowerSupply 1e6
152#define RADC_tot 8*Radc_internal
154#define Coefficiente_Vref_Vbias Rmultiplexer + R_series_for_Vbias
155#define Coefficiente_Vmeas_Vbias RADC_tot + Coefficiente_Vref_Vbias
157#define Coefficiente_Vref_Vbias_extern Rmultiplexer + R_series_for_Vbias_extern
158#define Coefficiente_Vmeas_Vbias_extern RADC_tot + Coefficiente_Vref_Vbias_extern
160#define Coefficiente_Vref_PowerSupply Rmultiplexer + R_series_for_PowerSupply
161#define Coefficiente_Vmeas_PowerSupply RADC_tot + Coefficiente_Vref_PowerSupply
163#define Coefficiente_Vref_default Rmultiplexer + 100e3
164#define Coefficiente_Vmeas_deafult RADC_tot + Coefficiente_Vref_default
166#define Coefficiente_Vref_100_ohm Rmultiplexer + 100e3
167#define Coefficiente_Vmeas_100_ohm RADC_tot + Coefficiente_Vref_100_ohm
169#define Coefficiente_Vref_10k_ohm Rmultiplexer + 10000e3
170#define Coefficiente_Vmeas_10k_ohm RADC_tot + Coefficiente_Vref_10k_ohm
174 unsigned int coefficiente_Vmeas;
175 unsigned int coefficiente_Vref;
176 unsigned int partizione_per_1000;
180extern unsigned char coeffcienti_misura_ADC_nodi[];
186void calibrazione_Resistenze_sterne_ADC(
void);
188int correzione_misura_ADC(
char quali_coefficienti,
int misura);
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.
int32_t ADC_misura_differenziale_con_media_generico(uint8_t scheda_su_scheda_giu_, uint8_t preamplifier_externalADC_1_onboardADC_0, uint8_t nodo_da_misurare, uint8_t differenziale1_single_0)
This function sets the original gain when a few LSb have to be determined. The umber of bits is bit_t...
int ADC_compensazione_al_nodo(uint8_t line_to_read, int32_t lettura_ADC, int32_t lettura_offset)
This function allows to read a whatver regsiter of the ADC.
void ADC_Sleep_fun(uint8_t up_down)
ADC is sent to sleep mode.
long long int divisione_di_gianlu(long long int Numeratore, long long int denominatore)
The division operator on 32 or 64 bit, positive/negative integers.
void instr_ADC_LETTURA_function(void)
All the posible nodes voltages can be read with this instruction. Either the internal or an external ...
uint32_t ADC_lettura_registro(char ADC_0_o_1, uint8_t up_down, uint8_t registro_ch0)
This function allows to read a whatver regsiter of the ADC.
void ADC_scrittura_registro(char ADC_0_o_1, uint8_t up_down, uint8_t registro_ch0, int32_t value_to_write)
This function allows to read a whatver regsiter of the ADC.
volatile uint16_t ADC_medie_per_misura
the number of ADC readings to average, the maximum is 400
signed long int ADC_lettura_24bit(char ADC_0_o_1, uint8_t up_down, uint8_t cosa_fare)
ADC Wakeup and 24 bits reading.
void ADC_Wakeup(uint8_t up_down)
ADC Wakeup and 24 bits reading.
unsigned char medie_ADC
The number of averages done is 1 << medie_ADC, or 2^medie_ADC.
const struct ADC_coefficiente_type ADC_coefficiente[]
Node normalizing coeficinets used in ADC_lettura_24bit()
volatile uint8_t ADC_sleep_off
if 0 ADC in sleep when not working, ADC>1 ADC never sleep
volatile bool ADC_non_leggi_lo_offset_se_true
if not necessary, the ADC input offset from buffer is not read
void ADC_selfcal_zero_scale(uint8_t up_down)
ADC self-calibration. ADC needs to be pre-selected.
unsigned int Radc_internal
void ADC_sleep_ON_OFF(uint8_t up_down, uint8_t ON_OFF_NOP)
ADC is set to sleep or awake.
unsigned int Rmultiplexer
This is the multiplexer resistor and the series resistor connected in series to it.