2025-09-16 9:56 PM
Hello,
I have a ADC clock running at 96MHz prescaler divided by 10, 12bit, Sampling time 47.5 Cycles. I am just trying to sample this DC volgtages. I have a battery that has around 20Volts, and I am stepping this voltage down using the voltage divider as U8, U1, U2 to be sampled by the ADC. I have two ADC measuring BN, and Vref to measure the current across the 1Ohm resistor. I am getting consistently accurate values, but I have this random 5mv difference or 30mV spikes that happens out of no where. I am not sure how to fix this to improve my ADC resolution. Could you please give me an idea how to proceed?
I really appreciate the time and effort for this matter
Thank you
2025-09-16 10:00 PM
Is any other ADC running at the same time?
The 'G4 family has several ADC related errata, and a family-specific ADC appnote, try to read them.
JW
2025-09-16 10:11 PM
Now I have set the all the sampling time to 47.5 Cycles, and I am having 5mV fluctuation. Is this the best this adc can do?
2025-09-16 10:12 PM
Hello. I am using ADC1, ADC2, and ADC5. They all have same sampling time and clock dividing presaclers.
Can running 3 ADC at the same time cause this?
So I made all the sampling time to be the same, and I was able to improve to 5mV fluctuations, and I am wondering if this is the maximum resolution I can get?
Thank you
2025-09-16 11:19 PM - edited 2025-09-16 11:19 PM
Is it 5mV at the ADC input, or at the battery? From the graph it appears that it is one ADC bin (i.e. change in LSB), if that's the case, you don't have many other options than filtering/averaging.
I am not an expert just another user, and I don't use the 'G4 family actively.
JW
2025-09-16 11:27 PM
Does "relay" in the schematics mean a magnetic device, i.e. a switch with a coil ?
This can definitely cause such issues when switching.
2025-09-16 11:48 PM
So the 5mv fluctuation is observed when I measure the voltage across 1ohm resistor. I have Vref to be 12V and this is stepped down to like 2V to be measured by stm, and another node measures about 13Volts. I get current based on voltage difference across these two nodes. 5mv fluctuation is when I measure both nodes and subtract from STM side. Are there any way to improve this?
2025-09-16 11:49 PM
Relay is either turned on and off for charging and resting operation. when the charging is happening and collecting current, the relay is off(no current flowing through the coil), and I am using RF based relay to minimizing this effect.
Where do you think this fluctuation is coming from? Is there anyway to optimize my ADC caps or sampling time, prescaler, and frequency?
Any recommendtation would help a lot
2025-09-16 11:49 PM
A few ideas that usually help in this situation:
ADC oversampling / averaging: STM32 ADCs support hardware oversampling, or you can do simple software averaging across multiple samples. This reduces random noise and gives you a more stable reading.
Check with external measurement: Use an oscilloscope or a precision multimeter on the divided battery line and across the shunt to confirm whether the spikes are really present in the analog domain, or if they are only visible in the ADC results.