move calibration values to defines
This commit is contained in:
@@ -8,10 +8,15 @@
|
||||
|
||||
#define AVRG 512
|
||||
|
||||
#define SUPPLY_VOLTS 3.3
|
||||
#define REF_OHMS 993.5
|
||||
|
||||
#define ADC_0V_COUNT 170
|
||||
#define ADC_MAX_VOLT 1.95
|
||||
|
||||
volatile uint16_t adc_buffer[AVRG];
|
||||
volatile float ch_values[9];
|
||||
|
||||
|
||||
void init_clk(void)
|
||||
{
|
||||
// ========= System Clock configuration =========
|
||||
@@ -160,10 +165,10 @@ ISR(DMA_CH0_vect){
|
||||
ADCA.CH0.MUXCTRL = pin << ADC_CH_MUXPOS_gp; // give MUX time to switch during averaging
|
||||
float temp = avrg(adc_buffer, AVRG);
|
||||
|
||||
temp = temp - 170;
|
||||
temp = (temp)/ 3926 * 1.95;
|
||||
temp = (temp*993.5)/(3.3-temp);
|
||||
temp = (temp-100)/0.3927;
|
||||
temp = temp - ADC_0V_COUNT;
|
||||
temp = (temp)/ (4096-ADC_0V_COUNT) * ADC_MAX_VOLT;
|
||||
temp = (temp * REF_OHMS)/(SUPPLY_VOLTS - temp);
|
||||
temp = (temp-100)/0.3927; //pt100 formula
|
||||
ch_values[old_pin] = temp;
|
||||
|
||||
DMA.CH0.TRIGSRC = DMA_CH_TRIGSRC_ADCA_CH0_gc;
|
||||
|
||||
Reference in New Issue
Block a user