2020-06-30 09:32 AM
Hi I'm currentlz working on STM32G071RB nucleo board to measure five different voltages across a laser within the ON duration of the Laser i.e 20us using DMA. My ADC finishes conversion every 17us(checked using LED in the ADCconcmplt callback). When there is no time constraint(i.e when the laser is always ON) the ADC gives out the correct voltages across 5 nodes but when I try to read the ADC voltages within 20us it appears that the ADC voltages at two nodes are almost halfed. I'm using an exti to trigger the ADC. I collect the ADC smples in the ADCconvcmplt call back and I use a timer of 1s to average the samples collected. Any inputs regarding this is really appreciated. I tried debugging the software but is of no help. kindly help me with your suggestions
2020-06-30 12:50 PM
How do you know it's giving you incorrect values? Can you show a scope plot of the event?
The ADC in the STM32G0 is a SAR type ADC. It's not going to be awesome at a single measurement like this, particular if the event has noise associated with it and with a limited sample time. There's not going to be an easy answer here. Ensure your ADC inputs are sufficiently low impedance.
2020-07-02 01:20 AM
Thanks for your response. I have attached screenshot from the osci and the the five node voltages from the terminal. In the osci plot the yellow plot corresponds to the duty cycle of the Laser within which all the 5 voltages have to be scanned and the red voltage is the toggle led function placed in the ADCconvcmplt callback. Whne the laser is always on (i.e when the yellow line is consatnt at 5v) I get the correct voltage readings (verified using a multimeter) also shown the terminal plot CW_mode.jpg, but when I try to turn the laser ON and OFF at a high modulation rate(1KHz-20KHz) I get incorrect readings or I'm sampling at the wrong instant.
2020-07-02 01:34 AM
2020-07-02 01:35 AM
2020-07-02 01:56 AM
The HAL callback mechanism has a couple of μs overhead, so you might get wrong values in the callback if the conversion sequence is started every 20 μs and takes 17 μs.
2020-07-02 02:57 AM
When the ADC is triggered by EXTI, the overhead from HAL isn't going to affect when the conversion happens.
2020-07-02 02:59 AM
I notice the red pulses and yellow pulses do not line up. If you're triggering on a rising edge of the yellow signal, there should only be one ADC conversion cycle. Seems like it's triggering more often than this. In other words, it doesn't look like your ADC conversions are synced to the laser pulse at all.
I would slow down the pulse frequency to see if they sync up and to make sure they're being triggered on the correct edge.
2020-07-02 03:08 AM
I have never said that.
It affects when the results are read.
2020-07-02 03:21 AM
I have used the osci in single mode and I'm triggering the ADC on the falling edge of ext11 and also my ADC is running in continuos mode. Could you please elaborate on the errors arising from my approach. In the call back I'm just summing the samples transferred by the DMA after conversion. Do I have to Stop my ADC in the call back and start it again?
Thank you berendi and TDK