2023-03-24 08:43 AM
Hi
I have a STM32L433 processor on a 4 layer board with own ground plane, and below is circuit for VDDA input. I have set the VREF+ to 2.5v, and checked this with my meter, and its perfect (and isnt connected to anything).
I placed an accurate 1.026v DC onto the analogue input , and used an easy HAL example (12 bit) to read the ADC. I read the digital value of 1988 , which works out to 1.213v (2.5/4096)*1988 , which isnt the same. Looking on the scope, and the signal looks clean , and same with the power input 3.3v. I dont understand why it isnt accurate. Anyone any idea?
MX_ADC1_Init();
HAL_ADCEx_Calibration_Start(&hadc1,ADC_SINGLE_ENDED);
while (1)
{
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1,HAL_MAX_DELAY);
raw=HAL_ADC_GetValue(&hadc1);
}
2023-03-24 10:12 AM
first check: is your Vref really used -> connect adc in to vref+ , read; then to gnd, read. 4096+0? (about +/- few counts).
then with cer.cap 100nF or so, on adc in to gnd, put the test voltage...read.
2023-03-24 02:05 PM
Show you VREF+ circuit, and show how you have your 1.026V ref connected (1.026V really? or was that a typo on 1.024V?). If you VREF+ is drooping (not enough capacitance, or caps too far from VREF+ pin) that could explain the difference.
2023-03-25 04:39 AM
What's the impedance of the 1.026V source? Try increasing sampling time, see datasheet.
JW
2023-03-25 01:41 PM
Hi
Im not great with impedance , but what I am trying to do is measure the input voltage. See below picture. The output of the divider goes right into the ADC. If I stuck it through an opamp as a buffer, would this improve it?
Cheers
Scott
2023-03-26 02:23 AM
The reason why input impedance matters is, that it has to fully charge the sampling capacitor during the sampling phase.
Opamp follower is never a bad idea, but if high input impedance and too short sampling time is the primary problem, it should be enough to increase the sampling time.
JW
2023-03-26 02:42 AM
Hi
Thanks for the reply. As I was using the HAL (easier for testing), I set the sample rate to 247 and 640 , but still had the same result.
Strange that I read 1.213v from a 1.026v input, I would have thought it would be the other way around.
Cheers
Scott
2023-03-26 10:20 AM
See Section 3.17 in the data sheet.
The answer comes out real close if you are on the internal 2.048V reference buffer.
A resistor divider external buffer may need the Figure 5 capacitors to provide a clean reference. A 1.0 uF will probably be OK for the mystery capacitor.
2023-03-26 02:44 PM
Oh, it didn't occur to me that VREF+ is not connected to an external 2.5V reference, but is fed from the internal reference instead...
In that case, the "mystery capacitor" actually needs to have a relatively precise value (actually 1.0uF as said by @raptorhal2 in parallel with the 100nF ceramics is just OK).
JW
2023-03-27 12:17 AM
Hi
Sorry, I forgot to add the below to my picture above (see below). As per manual I have 100nf and 1uf to vref. As you see I already have a 1uf added.
Best Regards
Scott