ADC simultaneous sampling?
ADC simultaneous sampling?
Hi all,
I'd like to measure the phase of a 50Hz ac waveform relative to another.
I think that simultaneous sampling would be the best way to do that which the MCU on the pyboard supports.
Is there any support for this feature?
If not, is there another way to acheive it?
Thanks,
Craig
I'd like to measure the phase of a 50Hz ac waveform relative to another.
I think that simultaneous sampling would be the best way to do that which the MCU on the pyboard supports.
Is there any support for this feature?
If not, is there another way to acheive it?
Thanks,
Craig
Re: ADC simultaneous sampling?
As a general principle if you don't have simultaneous sampling you figure out the delay between the channels (usually nChannels/fs for consecutive channels) and shift your waveforms accordingly in post-processing.
Re: ADC simultaneous sampling?
MicroPython doesn't support simultaneous sampling on the pyboard. Theoretically it's possible by using two different ADC blocks (IIRC there are 3 on the STM32F405) and using one of the trigger modes to get them to start sampling at the same time.
You might be able to get something to work by tweaking the ADC registers directly using the stm module.
You might be able to get something to work by tweaking the ADC registers directly using the stm module.
Re: ADC simultaneous sampling?
That sounds interesting.
A quick google brought me here: http://wiki.micropython.org/platforms/b ... ard/modstm
Am I looking in the right place?
Thanks
Craig
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: ADC simultaneous sampling?
You might consider the ADC.read_timed_multi method. This was intended for exactly this purpose, it produces good phase measurements at frequencies over 50KHz. The sampling isn't simultaneous but relative to 50Hz it's extremely close.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: ADC simultaneous sampling?
STM32 does have a hardware injected peripheral that will read a number of ADC in a row as fast as possible then use DMA to transfer each result. I assume the ADC.read_timed_multi uses this injected/DMA method??pythoncoder wrote: ↑Sat Jan 19, 2019 12:12 pmYou might consider the ADC.read_timed_multi method. This was intended for exactly this purpose, it produces good phase measurements at frequencies over 50KHz. The sampling isn't simultaneous but relative to 50Hz it's extremely close.
Timing of min requirements for ADC conversions from the STM32F4 reference manual
12 bits: 3 + 12 = 15 ADCCLK cycles
10 bits: 3 + 10 = 13 ADCCLK cycles
8 bits: 3 + 8 = 11 ADCCLK cycles
6 bits: 3 + 6 = 9 ADCCLK cycles
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: ADC simultaneous sampling?
It doesn't use DMA and (like read_timed) is a blocking method. A nonblocking DMA equivalent would be great if someone has the skill to write it I simply adapted the existing read_timed code.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: ADC simultaneous sampling?
I am so bogged down at work (my real job that pays the bills) and also with too many projects currently on the go I am unliely to take on a project like this anytime soon.pythoncoder wrote: ↑Sun Jan 20, 2019 11:38 amIt doesn't use DMA and (like read_timed) is a blocking method. A nonblocking DMA equivalent would be great if someone has the skill to write it I simply adapted the existing read_timed code.
It would be an interesting project for me to take on though. I have already been using ADCs to read a touch screen, and have been using DMA to transfer data from 8bit camera interface DCMI to 16 bit screen interface FMC and have also been using timers for lots of things setting them up by setting up the registers in C on a STM32F407. I think the most difficult thing would be to work out how to make a good python interface.
Re: ADC simultaneous sampling?
Thanks for this, I don't know why I didn't find this myself in the docs!pythoncoder wrote: ↑Sat Jan 19, 2019 12:12 pmYou might consider the ADC.read_timed_multi method. This was intended for exactly this purpose, it produces good phase measurements at frequencies over 50KHz. The sampling isn't simultaneous but relative to 50Hz it's extremely close.