Hi, I have an Arduino Duemilanove and a ADXL335 accelerometer with a Spark fun breakout board. Im having a fair bit of trouble getting any meaningful data out of the chip. It seems to be telling me things that defy the laws of physics as well as constantly fluctuating up and down randomly. I want to get the value in g's so i can use it as a tilt sensor. it will not have to ever deal with moving around or anything so it can take as long as it likes to output an accurate reading.
Im connecting the x.y,z pins to analog inputs 0,1 and 2. also vcc to 3.3v and Gnd to Gnd.
I have been searching the internet for the last 6 hours and come up empty. the turial on this website for the 3xx's series of accelerometers has the same problems.
Hi buddy i am also facing same problem, searched alot on the net but didn't get any thing supportive, i decided to try these tacts
1.It would be good idea to take an average reading (say 100) of output, by putting for loop. in the skech.
by putting 100nf capacitor, to avoid flucuation in out put voltage,
Hey, I found that i was using some dodgy soldering which was causing the chip to not really be connected to my board when i thought it was which was causing all the confusion.
As i need mine to be pretty accurate im now focusing on how to get 3v(not 3.3V) out of my arduino board. while 3.3v will get it working fine(not 5V!) the data sheet lists no scaling factor for that voltage.
using a average is defiantly a good idea. let me know how you go with using a cap, what advantage would that have over software averaging? I can imagine that in some circumstances it would not be good (detecting sudden quick movements) but as i am trying to make a static tilt sensor it doesnt sound like a bad idea.
Yes but the ratio changes for different voltages non linearly and is only 300mV/g at 3V. at 3.7V it is 330mV/g. but no relationship to indicate the relationship is linear is given.
The ADXL335 output is ratiometric, therefore, the output sensitivity (or scale factor) varies proportionally to the supply voltage. At VS = 3.6 V, the output sensitivity is typi- cally 360 mV/g. At VS = 2 V, the output sensitivity is typically 195 mV/g.
BTW, the bandwidth-limiting capacitors are very important.
yea i understand that it is ratiometric but how can you work out what the ratio is at 3.3V when the data sheet only tells you the ratio the output follows at 3.6V(and 2V). while the output follows a linear relationship with input(ratiometric) we don't know what that ratio is at any other voltage other then those it lists in the data sheet. no relationship between the ratio and input voltage is given(as far as i can tell).
Sorry i got my values mixed up but it doesn't change what im trying to say.
Im new to all this but i think im reading this right.
Also i think he was talking about caps to 'smooth' out the voltage output from the chip. Im not sure how exactly that would work but i don't think he was talking about the bandwidth setting ones(which are soldered straight on the breakout board i have anyway)
My accelerometer is still giving inconsistent reading, implemented this codes to filter the reading, it takes 20 readings > sortes them in ascending order > takes 10 readings from sample[5] to sample[15].
anybody with some good idea ????
for(i=0; i < 20; i++) // take 20 sample readings
{
sensorValue = analogRead(analogInPin); // read the analog in value:
sample = 0.75*( 220 - sensorValue); // considering 220 is value at Horizantal position
}
*for(i=0; i < 20; i++) // BUBBLE SORTINHG *
for(j=0; j < 20; j++)*
{*
if( sample[j] > sample[j+1])*
{ temp = sample[j];*
sample[j] = sample[j+1];*
sample[j+1] = temp; *
}*
} *
for ( i=5; i <= 15; i++) // sum of angle values from*
_ angle = angle + sample*;*_
i also have the same problem with you guys. i am using 2 axis accelerometer that is memsic 2125. the output is in PWM.
as for now, my problem is the accelerometer keep changing output data. inconsistent whilst the accelerometer is static. after ive researched some in the internet, i manage got some clues that are
using op-amp to filter the noise - but i didnt really sure
using capacitor and resistor to filter the noise.
using averages. same as above, i also thinked about that. because it didnt need any hardware, just programming.
Easy buddy........here is the complete code. . . . . . .
sombody plz let me know hot to insert an image in a Post/Reply :-[
/*
Analog input, measures angle
created 16 may 2010
by Ehkrap Tnahsarp
*/
const int analogInPin = 0; // Analog input pin that the potentiometer is attached to
float sensorValue = 0;
int angle = 0;
int sample[20];
int i, j, temp;
void setup() {
Serial.begin(9600); // initialize serial communications at 9600 bps:
}
void loop() {
for(i=0; i < 20; i++) // take 20 sample readings
{
sensorValue = analogRead(analogInPin); // read the analog in value:
sample[i] = 0.75*( 220 - sensorValue); // considering 220 is value at Horizantal position
}
for(i=0; i < 20; i++) // BUBBLE SORTINHG puts readings in ascending order
for(j=0; j < 20; j++)
{
if( sample[j] > sample[j+1])
{ temp = sample[j];
sample[j] = sample[j+1];
sample[j+1] = temp;
}
}
for ( i=5; i <= 15; i++) // sum of angle values eleminating first five and last five
angle = angle + sample[i]; // inconsistance readings
angle = angle/10; // Average of angle
Serial.print("\t angle = "); // Print the output
Serial.print(angle);
} // end of loop
Instead of looking at the output after averaging the samples try printing just the ADC value (0-1023) and see if that number is stable, if not then the problem maybe in your calculations. If that number is not stable then just connect a volt meter directly to the output of the ADXL335 and verify if the voltage is steady.
if we were to plot this Resolution vs Vs we could see that the slope is constant therefore giving us a linear relationship between different values for Vs and proving our method to be right.
I looked everywhere to figure out how to get g value to output from the sensor at 3.3v and found nothing so i hope this helps.
-Alan
*also, for the guy having trouble with the memsic 2125, that accelerometer is a bit different, it works with heat and thermistors and is a digital accelerometer. what you have to do is measure the pulses it outputs using "pulsein" i think, there is an example sketch on the memsic 2125 in the arduino IDE under "sensors" take a look at that.
I am experimenting with this sensor too (the adxl335) and I never understood how to read the values correctly. I have done this, for now, with the map() function...