Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 12 months ago. This question has been closed. Reason: PROBLEM SOLVED
How to Measure a waveform with exactly 32 samples per period?
I have an ADC set up and is measuring an input voltage waveform and displaying to an LCD. The waveform I am measuring has a period which varies regularly. Even when the period varies I want to get 32 samples for each period of the waveform. Is there any way of setting the ADC to gather 32 samples per period? Do I need to use a Ticker?
I think I need to calculate the period of the waveform each cycle and then divide this period by 32 and use this value to trigger a Ticker? Does anybody have any example code that does this as I'm confused on how to implement it. Any help would be greatly appreciated.
6 years, 12 months ago.
There is no automatic way to do it. You can calculate the period and then use a ticker, or just oversample alot and interpolate afterwards, but that takes alot of processing power.
If you want it that way you will indeed need to make a function first which gets the period, and then sets the ticker accordingly. But what kind of waveform are you measuring, why does itneed to be 32 samples exactly, and which kind of range of periods do you have?