Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpSyntax › analogRead frequency

Page Index Toggle Pages: 1
analogRead frequency (Read 3639 times)
04/07/08 at 18:30:38

SKJG   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 2
*
 
Hi.. 
I need to make a 'first' post in order to get privileges so that I can place an order for the Wiringmini... so here goes...  What is the 'frequency' of analogRead... is it purely determined by program load?  or can it be called with interrupts ?  Specifically, my interest is in possibly oversampling so that I can increase A/D resolution.. 



thanks,
steve
 
IP Logged
 
Reply #1 - 04/08/08 at 04:08:13

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
analogRead() can be invoked in the loop() method, which means it will be called as many times as you want.

void loop() {
  val = analogRead(0);
  Serial.print(val, DEC);
  delay(100);
}

you´ll get about 10 reads per second with the code above.
 
IP Logged
 
Reply #2 - 04/08/08 at 22:39:19

SKJG   Offline
YaBB Newbies
I Love YaBB 2!

Posts: 2
*
 
Hi...
On reflection, it appears I was 'specific' about the wrong question...  Sorry about that...    I'm interested in using an accelerometer as a feedback device for a voice coil motor which will be driven using the analogWrite function (I'm actually interested in 'positive' feedback in this application).  So my real question had to do with length of time required for an analogRead function relative to the time required for one cycle of PWM.      

Your answer did give me some ideas on how to handle the problem...

thanks
steve
 
IP Logged
 
Page Index Toggle Pages: 1