10 years, 1 month ago.

sample time use in analogin?

HI everyone, right now i am doing a PID wit the FRDM-KL25Z but i need the sample time used in the AnalogIn Function. if anybody can help me.. please.

1 Answer

10 years, 1 month ago.

AnalogIn requires something like 40us on the KL25Z. The sample time depends on how often you call it. You can for example use a Timer to measure it.

https://mbed.org/users/Sissors/code/FastAnalogIn/ can also be used, it continious mode it requires something like 2us for a read, in non-continious mode roughly 10us.

Accepted Answer

ok, lets say this is my code AnalogIn ain1(PTB0); AnalogIn ain2(PTB1); AnalogIn ain3(PTB2); char valor; int main(void) { while(true) {

pc.printf(" %f ",(ain3.read()*5+ain2.read()*5+ain1.read()*5)/3); wait(.1); } }

how long will it takes for the adc to read each sample. what about the convertion time.. as far as i know in Codewarrior you set that when you are setting the adc configuration. please help me

posted by oscar rodriguez 13 Mar 2014

S you do 3 conversions, each takes roughly 40us. Then you have wait 0.1, which is 100000us. That dominates your sample time.

posted by Erik - 13 Mar 2014