How do you know the ADC_VREF is different each time, and why would that be ?the internal temperature is calculated using ADC_VREF, which is different each time.
If your hardware is using a regulator to provide a supply voltage for your electronics from the battery then its output voltage should be consistent. If ADC_VREF is derived from that then that too should be consistent.
If ADC_VREF really is changing you seem to have three options - First provide a proper or hacked voltage reference to ADC_VREF to improve things.
Using a simple LED has worked for me -
Code:
3V3 >-----------------. : .|. : 200R |_| : __ | 35 :ADC_AVDD <----.----|__|----^-----( O----. | 1R : __|__ __|__ : \ / RED --.-- 2.2uF : _\ /_ LED | : | 0V >----^------------------( O----' 33 :
Other ADC inputs will need to have their voltages kept below whatever ADC_VREF is.
Second, leave ADC_VREF as it is, connect a voltage reference to a spare ADC channel.
Again, using a LED has worked for me, but not sure what value R I used -
Code:
35 : ___ ADC_VREF ---->( O----|___|---.------. : | __|__ ADCx <----( O------------' \ / RED : _\ /_ LED : | 0V -----( O-------------------' 33 :
Otherwise use an external sensor instead of the on-chip one.
When reading any ADC some time after previously reading an ADC, always do a double read and use the last value read. This will avoid the error from the ADC Sample and Hold cpacitor having crept up over time.
Taking multiple readings and averaging them may also help.
As noted the on-chip temperature sensor isn't great, delivers only a small change for a large temperature change. I recall it's 1-bit ADC reading change for every 0.5 C, approximately 1.0 F, temperature change with ADC_VREF of 3V3. A lower ADC_VREF will improve that.
Statistics: Posted by hippy — Mon Jul 22, 2024 11:29 am