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.
9 years, 9 months ago.
Configuring ADC
Can anyone please help me with configuring the ADC of FRDMKL25Z board. I am connecting the output of a pressure sensor to the ADC input pin and I need to sample the data at a rate of 1MHz and also display the DC value.
3 Answers
9 years, 9 months ago.
Hi,
In my main.cpp of oscilloscope program, I tried to make ADC as fast as I could
but all I could achieve was around 15us ~ 20us/sample for 2ch.
20us/sample for safer side, which is about 50K samples/second.
So probably you may be able to go around 100K samples/second for 1ch
with similar approach.
To go even faster, probably you need to kick DMA directly from ADC and store data in memory before displaying it.
As Erik-san has already mentioned, the maximum sampling rate of the ADC is around 800ksps for 12bit or less.
And I have never been able to achieve it.
So if you really need to achieve 1Msps, you should try other hardware whose ADC is guaranteed for 1Msps or more.
void initADC(void) { if (numAnalogIn > 0) { ach[0] = new AnalogIn(PTB0) ; } if (numAnalogIn > 1) { ach[1] = new AnalogIn(PTB1) ; } ADC0->CFG1 = ADC0->CFG1 & ( ~( 0x80 // LDLPC = 0 ; no low-power mode | 0x60 // ADIV = 1 | 0x10 // Sample time short | 0x03 // input clock = BUS CLK ) ) ; // clkdiv <= 1 ADC0->CFG2 = ADC0->CFG2 | 0x03 ; // Logsample Time 11 = 2 extra ADCK ADC0->SC3 = ADC0->SC3 & (~(0x03)) ; // hardware avarage off }
moto
You can also choose to run the ADC in continious mode. On the Freescale devices this can only be done using one channel (but as you indicate, multiple channels is slower and I don't think required here). The advantage is that you can at any time read the latest conversion without waiting. The downside is that you do not know exactly when that conversion happened, and of course while you can read as often as you want, the actual conversion do not happen quicker. There is less overhead though since it immediatly starts the next conversion after the previous, without waiting on the user to start it.
posted by 17 Feb 20159 years, 9 months ago.
Quick check shows the maximum conversion speed to be 800kS/s. But in general: Are you sure you need 1MHz conversion rate? Unless you really got a very special setup I don't see any case where a pressure sensor requires such a sampling rate.
Yes I need a high sampling rate as I am extracting oscillometric data required to determine the human blood pressure and this data appears for a very short duration of time and none of the samples must be missed for highly accurate measurements.
posted by 16 Feb 2015Have you already observed a waveform on for example an oscilloscope and checked the frequency domain contents, and which of those contents you actually need. While not familiar with the exact requirements, 1MHz conversion for blood pressure measurements seem overkill to me.
If you really need it, STM ones can reach it for sure.
posted by 16 Feb 2015