Hi,
I want to confirm one issue, if we have Arduino ADC clock (200KHz) then one clock period is (1/200000)=5 microsecond ??
then the conversion time will be 13*5=65 microsecond ??
if I use the below code
void loop ()
{
Sample=analogread(0);
delay(1);
}
That's mean i have read each 1.065 milisecond instead of each 65 microsecond ?? and finally i will get ~1KHz sample/second instead of ~15KHz sample /second .
Thanks
Arduino ADC clock with delay
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: Arduino ADC clock with delay
The read is not synchronous with the conversion cycle, so that assumption is false. However, there is some overhead in the analogRead function, so you are correct in that the read-time is non-zero.That's mean i have read each 1.065 milisecond instead of each 65 microsecond ??
If you have a 1 ms delay, your sample interval must be > 1 ms so your sample rate will be < 1KHz. If you want a more precise sample rate, you should use timers and perform the analogRead in the timer interrupt service routine. Here is a good tutorial on using timers. http://letsmakerobots.com/node/28278and finally i will get ~1KHz sample/second instead of ~15KHz sample /second .
-
- Posts: 18
- Joined: Wed Aug 21, 2013 7:17 am
Re: Arduino ADC clock with delay
I think i wasn't clear in my previous post, what i meant was when the read command executed it needs 65 microsecond conversion time, then the loop will start again after a very small duration to read another sample and convert it, but when i use delay the duration between each read will increase ,finally i will get less number of samples and that's what i want. in other words the ADC will read data each 1milisecond .
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: Arduino ADC clock with delay
The ADC on the Arduino is configured for continuous conversions and the read time is not synchronous to the conversion. The Arduino analogRead function takes about 100 microseconds. http://arduino.cc/en/Reference/analogReadwhen the read command executed it needs 65 microsecond conversion time
Those two statements are contradictory. If you add the 1 ms delay to the analogRead time, the analogRead interval will be > 1 millisecond.when i use delay the duration between each read will increase ,finally i will get less number of samples and that's what i want. in other words the ADC will read data each 1milisecond .
-
- Posts: 18
- Joined: Wed Aug 21, 2013 7:17 am
Re: Arduino ADC clock with delay
Sir i have input signal with 150 Hz, and the Fs should be >=300Hz, but the less sampling ratio for the ADC is 62500/13=4800 sample/second
usually the ADC read input signal and then convert it, so we will pass through two steps
1- read input signal
2- convert input
read data is not sync with ADC conversion,but each input read needs 65 micsecond to be converted, what i want to do is decrements the input read by increasing reading interval so we will have less than 1K input read/second .
void loop ()
{
Sample=analogread(0);
delay(1);
}
usually the ADC read input signal and then convert it, so we will pass through two steps
1- read input signal
2- convert input
read data is not sync with ADC conversion,but each input read needs 65 micsecond to be converted, what i want to do is decrements the input read by increasing reading interval so we will have less than 1K input read/second .
void loop ()
{
Sample=analogread(0);
delay(1);
}
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: Arduino ADC clock with delay
Yes, that code should give you a sample rate of about 909Hz.so we will have less than 1K input read/second
-
- Posts: 18
- Joined: Wed Aug 21, 2013 7:17 am
Re: Arduino ADC clock with delay
Thank you sir, that's what i was looking for
Please be positive and constructive with your questions and comments.