ADC Setup

This commit is contained in:
Ben V. Brown
2022-06-16 20:18:37 +10:00
parent df1c7c4659
commit 74b74c3e35
3 changed files with 7 additions and 7 deletions

View File

@@ -174,4 +174,4 @@ uint16_t getADCHandleTemp(uint8_t sample) { return ADC_Temp.average(); }
uint16_t getADCVin(uint8_t sample) { return ADC_Vin.average(); }
// Returns either average or instant value. When sample is set the samples from the injected ADC are copied to the filter and then the raw reading is returned
uint16_t getTipRawTemp(uint8_t sample) { return ADC_Tip.average(); }
uint16_t getTipRawTemp(uint8_t sample) { return ADC_Tip.average() >> 1; }

View File

@@ -60,8 +60,8 @@ void setup_pwm(void) {
}
const ADC_Chan_Type adc_tip_pos_chans[]
= {TIP_TEMP_ADC_CHANNEL, TMP36_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, VIN_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, TMP36_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, VIN_ADC_CHANNEL, VIN_ADC_CHANNEL};
const ADC_Chan_Type adc_tip_neg_chans[] = {ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND};
= {TIP_TEMP_ADC_CHANNEL, TMP36_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, VIN_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, TMP36_ADC_CHANNEL, TIP_TEMP_ADC_CHANNEL, VIN_ADC_CHANNEL};
const ADC_Chan_Type adc_tip_neg_chans[] = {ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND, ADC_CHAN_GND};
static_assert(sizeof(adc_tip_pos_chans) == sizeof(adc_tip_neg_chans));
void setup_adc(void) {
@@ -75,7 +75,7 @@ void setup_adc(void) {
adc_cfg.clkDiv = ADC_CLK_DIV_4;
adc_cfg.vref = ADC_VREF_3P2V;
adc_cfg.resWidth = ADC_DATA_WIDTH_16_WITH_128_AVERAGE;
adc_cfg.resWidth = ADC_DATA_WIDTH_14_WITH_64_AVERAGE;
adc_cfg.inputMode = ADC_INPUT_SINGLE_END;
adc_cfg.v18Sel = ADC_V18_SEL_1P72V;
adc_cfg.v11Sel = ADC_V11_SEL_1P1V;
@@ -93,7 +93,7 @@ void setup_adc(void) {
ADC_Init(&adc_cfg);
adc_fifo_cfg.dmaEn = DISABLE;
adc_fifo_cfg.fifoThreshold = ADC_FIFO_THRESHOLD_4;
adc_fifo_cfg.fifoThreshold = ADC_FIFO_THRESHOLD_8;
ADC_FIFO_Cfg(&adc_fifo_cfg);
ADC_MIC_Bias_Disable();
ADC_Tsen_Disable();

View File

@@ -105,7 +105,7 @@
#define ANIMATION_LOOP 1 // 0: off 1: on
#define ANIMATION_SPEED settingOffSpeed_t::MEDIUM
#define OP_AMP_Rf_Pinecil 866 * 1000 // 750 Kilo-ohms -> From schematic, R1
#define OP_AMP_Rf_Pinecil 680 * 1000 // 700 Kilo-ohms -> From schematic, R1
#define OP_AMP_Rin_Pinecil 2370 // 2.37 Kilo-ohms -> From schematic, R2
#define OP_AMP_GAIN_STAGE_PINECIL (1 + (OP_AMP_Rf_Pinecil / OP_AMP_Rin_Pinecil))
@@ -116,7 +116,7 @@
#ifdef MODEL_Magic
#define ADC_VDD_MV 3300 // ADC max reading millivolts
#define ADC_MAX_READING 42000 // Maximum reading of the adc
#define ADC_MAX_READING (62000 >> 1) // Maximum reading of the adc
#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C
#define VOLTAGE_DIV 600 // 600 - Default divider from schematic
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV