6 years, 5 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

6 years, 5 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

Accepted Answer

Okay I will check it out. Thank you

posted by Santosh Kulkarni 17 Feb 2015

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 Erik - 17 Feb 2015
6 years, 5 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 Santosh Kulkarni 16 Feb 2015

Have 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 Erik - 16 Feb 2015

Erik, Why not fReescale? NXP? Nordic?

posted by Martin Kojtal 16 Feb 2015

Because Freescale reaches 800kS/s according to datasheet. LPC11u24 has 400kS/s. I thought LPC1768 200kS/s, etc. STM have several MS/s. Nordic too lazy to check.

That said I doubt you would really need such sampling rates for blood pressure measurements.

posted by Erik - 16 Feb 2015
6 years, 5 months ago.

Are you testing Soricidae? Theese mice have heartbeat > 1KHz.

I have observed the wave on a DSO when I sampled at 500ksps and I am not able to distinguish the pulses and hence looking for a higher sampling rate.

posted by Santosh Kulkarni 16 Feb 2015