0

I have five accelrometer sensors (MMA 7361) connected to the analog channels of Arduino Duemilanove. I am using the following code to read the data. (I am reading from only one axis from each sensor.)

#include <avr/io.h>
#include <avr/wdt.h>
int sensorValue = 0; // value read from the pot
void setup() 
{
 Serial.begin(9600); // initialize serial communications at 9600 bps:
}
void loop() 
{
 // read the analog values:
 int i=1;
 Serial.print("ACS#");
 for(i=0;i<5;i++)
 {
 sensorValue = analogRead(i);
 Serial.print(sensorValue);
 Serial.print("#");
 delay(10);
 }
 Serial.println("");
}

I am using a delay of 10 after reading each sensor. What should the value of the delay I should be using after reading one sensor to get the correct values from the sensors?

3
  • 1
    Why do you need any delay? Commented Jan 9, 2015 at 17:39
  • No delay is needed. Note however that the serial communication might not be able to keep up. If that happens your Serial.print calls will block/delay until the TX-buffer is no longer full. No big deal, but might be useful to know. Commented Jan 9, 2015 at 19:13
  • What are you trying to do with the data? This will help us give you an answer about sample rates Commented May 11, 2015 at 12:33

1 Answer 1

1

A delay is not needed.

What can be more beneficial, though, is making a dummy reading between each real reading. This gives the ADC more of a chance to settle on the right reading without the Sample and Hold capacitor being influenced by the previous reading.

The simplest way is just to duplicate your analogRead line so it's done twice.

answered Jan 9, 2015 at 17:43
3
  • what is the time required for the ADC to settle on the right reading? Commented Jan 9, 2015 at 18:10
  • You'll find that kind of information in the datasheet. Cross-reference that with the analogRead() code to see what the current settings are. Commented Jan 9, 2015 at 18:23
  • @ukg You don't need to wait for the ADC to settle for any of the readings, each pin uses a different ADC, and they are continuously tracking the input. Commented Apr 9, 2015 at 21:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.