ADC conversion time

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC conversion time

Jump to solution
1,606 Views
gschelotto
Contributor V

Hello,

I'm testing the ADC component of FRDM-KE02Z and I've set the conversion time and channels as shown

Untitled.png

Then I've created a TU1:TimerUnit_LDD to trigger the ADC conversion every 312.5us and write the next lines in the TU1_OnCounterRestart ISR.

(void)AD1_Measure(TRUE);

(void)AD1_GetValue16(&value[0]);

Finally here's the signal capture on the oscilloscope for checking the ISR process.

pic_124_2.gif

The sampling time and acquired values are okay but I expect an ADC process of 20us as I set 2 channels and a conversion time of 10us. Why I get more than 40us?

regards,

gaston

0 Kudos
1 Solution
966 Views
EarlOrlando
Senior Contributor II

Hello again Gastón,

You were using the High Level Driver, if you use the Logical Level Driver (LLD) you will increase the performance. The LLD needs more configurations but requires less instructions to work. The image below shows how I configured the ADC_LLD.

pastedImage_0.png

It needs that you create a sample group before to start read:

LDD_ADC_TSample samplegroup[2] = {{ADC0_CHANNEL_12}, {ADC0_CHANNEL_13}};

AD1_CreateSampleGroup(AD1_DeviceData, samplegroup, 2);

Every time you start a measure you need to call these two functions:

AD1_StartSingleMeasurement(AD1_DeviceData);

AD1_Main(AD1_DeviceData);

And you can get the results by calling the function below:

AD1_GetMeasuredValues(AD1_DeviceData, value);

From the project that you attached before, the periodic function now looks like this:

void TU1_OnCounterRestart(LDD_TUserData *UserDataPtr)

{

    LED_B_PutVal(LED_B_DeviceData, 1);

    AD1_StartSingleMeasurement(AD1_DeviceData);

    AD1_Main(AD1_DeviceData);

    AD1_GetMeasuredValues(AD1_DeviceData, value);

    LED_B_PutVal(LED_B_DeviceData, 0);

}

Best regards,

Earl.

View solution in original post

0 Kudos
11 Replies
966 Views
EarlOrlando
Senior Contributor II

Hello,

Unfortunately, Processor Expert needs a lot of comparatives and calls to other functions which wastes a lot of time. Every ADC conversion takes 11.81 us but the other 44.19 us are wasted in the processor expert functions and comparatives.

If you need to save that time maybe an ADC + DMA configuration will be helpful.

Best regards,

Earl.

0 Kudos
966 Views
gschelotto
Contributor V

Hello Earl,

Sorry to hear such a poor PE performance for ADC methods (even working at 16MHz of FLL clock) . I'm afraid DMA isn't available on FRDM-KE02Z. But the worse thing is I've decreased the time conversion to 3.5us and unexpectedly get 68us of total acquisition! How is this possible?

I'm puzzled now. Any hints?

regards,

gaston

0 Kudos
966 Views
EarlOrlando
Senior Contributor II

Hello Gastón,

I made a similar project. I configured a pit with an interrupt every 312 us where I clear a GPIO and then I start one ADC conversion. When the ADC conversion finishes in another interrupt I set the GPIO and read the measured value. This takes 29.2 us. I have exactly the same configurations as you with PEx.

pastedImage_0.png

I repeated this process but configuring the ADC time conversion to only 2.5 us and I first started the ADC conversion and then set the GPIO. The result is that the pulse lasts ~10 us. My conclusion is that the ADC performance is not the better but is not as bad as we though because the GPIO toggle takes a lot of time.

Regards,

Earl.

0 Kudos
966 Views
gschelotto
Contributor V

Hello Earl,

I'm sorry, I were wrong with my last assertion about the 3.5us of time conversion. In this case total ADC acquisition takes 56us (not 68us). However the problem persist and no matter how low is the conversion time. The total acquisition is always 56us (I've tested it with 2.5us, 5us and 10us with PE). I see that your setup is not exactly the same as mine. Note that:

  • I have not enabled the AD1_OnEnd interrupt
  • I've configured 2 ADC channels as shown in my first post (I supposse you've done the same)
  • I set the GPIO before start the ADC conversion and clear it after read the last ACD conversion, which involves the total ADC acquisition for the 2 channels. Both methods are placed into the Timer ISR.

Please, could you reproduce this setup?

regards,

gaston

0 Kudos
966 Views
EarlOrlando
Senior Contributor II

Hi Gaston,

To ensure that we have the same setup, could you please share your project?

Regards,

Earl.

0 Kudos
966 Views
gschelotto
Contributor V

Yes Earl, here's my KDS 3.0 project

Dropbox - KE02Z-FRDM.zip

regards,

gaston

0 Kudos
966 Views
EarlOrlando
Senior Contributor II

Hello Gaston,

I debugged the Processor Expert implementation and I confirmed that it is very inefficient. Once the function AD1_Measure function is called the peripheral driver makes some configurations that needs ~20 us before to start the ADC conversion, then the conversion takes ~10 us (two conversions with conversion time of 5 us), then the peripheral driver needs other ~22 us to complete the conversion (FIFO handler and some flags through the function AdcLdd1_Main) and finally needs ~5 us to read the ADC values through the function AD1_GetValue16.

I am afraid that if you need that the conversion ends quickly you will have to implement the ADC driver.

I remain at your service if you have any other question.

Best regards,

Earl.

/* If this post answers your question please click the ​Correct answer​ button. */

0 Kudos
966 Views
gschelotto
Contributor V

Earl, thank you for the clarification. Just a couple of questions:

  • Why I obtain an unique total acquisition time of 56us by configuring a PE conversion time of 2.5us, 5us or even 10us?
  • Could you provide any example using the ADC driver with multiple channels?

regards,

gaston

0 Kudos
967 Views
EarlOrlando
Senior Contributor II

Hello again Gastón,

You were using the High Level Driver, if you use the Logical Level Driver (LLD) you will increase the performance. The LLD needs more configurations but requires less instructions to work. The image below shows how I configured the ADC_LLD.

pastedImage_0.png

It needs that you create a sample group before to start read:

LDD_ADC_TSample samplegroup[2] = {{ADC0_CHANNEL_12}, {ADC0_CHANNEL_13}};

AD1_CreateSampleGroup(AD1_DeviceData, samplegroup, 2);

Every time you start a measure you need to call these two functions:

AD1_StartSingleMeasurement(AD1_DeviceData);

AD1_Main(AD1_DeviceData);

And you can get the results by calling the function below:

AD1_GetMeasuredValues(AD1_DeviceData, value);

From the project that you attached before, the periodic function now looks like this:

void TU1_OnCounterRestart(LDD_TUserData *UserDataPtr)

{

    LED_B_PutVal(LED_B_DeviceData, 1);

    AD1_StartSingleMeasurement(AD1_DeviceData);

    AD1_Main(AD1_DeviceData);

    AD1_GetMeasuredValues(AD1_DeviceData, value);

    LED_B_PutVal(LED_B_DeviceData, 0);

}

Best regards,

Earl.

0 Kudos
966 Views
patricio
Contributor IV

Hello Earl,

I am having almost the same problems as Gaston had. I am working with a FRDM-KL25Z and I need to make many ADC measurements very fast (every 2us) and I am not able to get so fast conversions.

I am a beginner with these micros, and I first started following a very good tutorial "ADC with the Freedom Board" by Erich Styger. I started with the component ADC and the same two methods as Gaston used in his project:

(void)AD1_Measure(TRUE);

(void)AD1_GetValue16(&value[0]);

But I was not able to get so fast conversions. So I tried with the component ADC_LDD and the trueth is that the conversion time was reduced significantly, but not as much as I need.

I only use one channel and I use the same methods of the ADC_LDD you explained to Gaston. Please find below the my clock configuration:

clock configuration.png

So, I make 3000 measurements and the results are stored in an array.

ADC measurements.png

A led is switched on at the begining of the 3000 conversions and it is switched off at the end. Thanks to this led I could measure with the oscilloscope that the 3000

measurements take 24.1ms. So 8us per measurement (not fast enough because I need to drop to 2us).

1.- Is there any way to reduce the conversion time by changing any configuration of the clock?

2.- As you mentioned before, using DMA could be a solution. What I would need is to store automatically the result of the 3000 conversions by DMA. Am I right? Please correct me if I am wrong.

Is there any tutorial or friendly document about how to work with DMA?

Thank you in advance.

Aitor.

0 Kudos
966 Views
gschelotto
Contributor V

Earl, thank you! You've helped me to save a lot of time.

Now I get about 30us to perform 2 channel conversions.

regards,

gaston

0 Kudos