United States
Offline
Jr. Member
Karma: 0
Posts: 99
Indubitably
|
 |
« on: November 06, 2011, 04:29:05 pm » |
I have the Sparkfun Breakout of the ADXL335 triple axis accelerometer. http://www.sparkfun.com/products/9269I have it configured on my UNO according to the Arduino tutorial. http://www.arduino.cc/en/Tutorial/ADXL3xxThe problem I am experiencing is that the readings are not behaving anything at all like expected. Initially, if I tilted the accelerometer forward or back, the y reading would increase or decrease respectively, the z reading would decrease in either direction, and the x reading would not be affected. If I tilted the accelerometer right or left, the x reading would decrease or increase respectively, the z reading would decrease in both situations, and the y reading would not be affected. Now, when I tilt the accelerometer in any direction, all three readings decrease. Any ideas as to why the change in behavior?
|
|
|
|
|
Logged
|
fuzzball27 >>-->
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: November 06, 2011, 04:59:50 pm » |
Have you checked that gravity is working normally where you are?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
United States
Offline
Jr. Member
Karma: 0
Posts: 99
Indubitably
|
 |
« Reply #2 on: November 06, 2011, 05:15:51 pm » |
What do you mean? Are you joking?
|
|
|
|
|
Logged
|
fuzzball27 >>-->
|
|
|
|
0
Offline
God Member
Karma: 6
Posts: 918
Arduino rocks
|
 |
« Reply #3 on: November 07, 2011, 01:37:42 pm » |
on accelerometers.. (that I have played with).. in the datasheets.. it explains that the force of gravity (g) will always have a 'pull' on the chip..
usually these values/threshold needs to be zero'd (accounted for) out to get a firm/correct reading
not sure if this will help or not.. since your stating the same behavior is NOW giving different results.
|
|
|
|
|
Logged
|
|
|
|
|
United States
Offline
Jr. Member
Karma: 0
Posts: 99
Indubitably
|
 |
« Reply #4 on: November 07, 2011, 05:30:26 pm » |
Do you mean accounted for in programming or hardware? I'm displaying raw analog values with Serial.println(analogRead(either x,y,or z pin));
|
|
|
|
|
Logged
|
fuzzball27 >>-->
|
|
|
|
United States
Offline
Jr. Member
Karma: 0
Posts: 99
Indubitably
|
 |
« Reply #5 on: November 07, 2011, 05:32:11 pm » |
In the datasheets.. it explains that the force of gravity (g) will always have a 'pull' on the chip..
Just to be clear: I understand that x, y, and z will always give readings.
|
|
|
|
|
Logged
|
fuzzball27 >>-->
|
|
|
|
0
Offline
God Member
Karma: 6
Posts: 918
Arduino rocks
|
 |
« Reply #6 on: November 07, 2011, 06:18:36 pm » |
You'd have to check you specific accelerometer datasheet..
but the one I used to play with..
yes.
(depending on the orientation/location/mounting of the accelerometer).. you get readings on the board while doing nothing. this is gravity doing its job I guess.
You will need to account for/subtract (whatever) this 'constant' G-force in your code..
(unless you need/want it of course)
I can play with mine more once I get home..
|
|
|
|
|
Logged
|
|
|
|
|
United States
Offline
Jr. Member
Karma: 0
Posts: 99
Indubitably
|
 |
« Reply #7 on: November 08, 2011, 09:03:02 am » |
Oh yes I see what you're saying. Using the data sheet was actually how I found out my accelerometer isn't working as expected.
|
|
|
|
|
Logged
|
fuzzball27 >>-->
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5936
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #8 on: November 08, 2011, 11:25:48 am » |
I had an adxl321, I think, and then I shorted it. It died. No more reading in any axis. Is that a possibility? That was painful $30 loss for not disconnecting power while making changes.
|
|
|
|
|
Logged
|
|
|
|
|
United States
Offline
Jr. Member
Karma: 0
Posts: 99
Indubitably
|
 |
« Reply #9 on: November 08, 2011, 02:21:40 pm » |
It died. No more reading in any axis. Is that a possibility?
Fortunately I'm still getting consistant readings. The problem is that they are all at their maximum reading when the accelerometer is level, and they all drop if I tilt the accelerometer in any direction.
|
|
|
|
|
Logged
|
fuzzball27 >>-->
|
|
|
|
United States
Offline
Jr. Member
Karma: 0
Posts: 99
Indubitably
|
 |
« Reply #10 on: November 08, 2011, 02:47:56 pm » |
I tried switching from the AnalogOut Power configuration (from the directions in the Arduino tutorial) to the 3.3v port configuration. The x and z pins are now working as expected, but the y pin is still behaving strangely. It is increasing and decreasing as if it were the x pin...?
|
|
|
|
|
Logged
|
fuzzball27 >>-->
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5936
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #11 on: November 08, 2011, 03:07:49 pm » |
AnalogOut or maybe more appropriately called EXTERNAL will require you to connect a voltage to AREF pin otherwise all readings are 1023. That explained your previous observation. For the z axis, I'm not sure. What happens if you swap the channels between the z and x or y? Will the reading still be changing as if it were the x-axis?
|
|
|
|
|
Logged
|
|
|
|
|
United States
Offline
Jr. Member
Karma: 0
Posts: 99
Indubitably
|
 |
« Reply #12 on: November 08, 2011, 05:55:14 pm » |
AnalogOut or maybe more appropriately called EXTERNAL will require you to connect a voltage to AREF pin otherwise all readings are 1023. That explained your previous observation.
For future reference, I'm assuming that it would be appropriate to attach 3.3v pin to the AREF pin for the AnalogOut feature to use 3.3v? For the z axis, I'm not sure. What happens if you swap the channels between the z and x or y? Will the reading still be changing as if it were the x-axis? Unfortunately the y pin has changed it's behavior for the worse. It gives random values from an average by ±200 (raw value). It's behavior is the same when I switch the z and y pins (to be clear, I remembered to switch the way I read the serial monitor, and I checked that all hardware was wired in accordance with the programmed pins.)
|
|
|
|
|
Logged
|
fuzzball27 >>-->
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 35
Posts: 5936
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #13 on: November 08, 2011, 06:17:42 pm » |
Yes, your way of using the AREF is correct. For the large fluctuation, I am suspecting poor contact between the output and the input. Are you using a breadboard arduino? How are you connecting your wires? Pictures will save 1K words.
|
|
|
|
|
Logged
|
|
|
|
|
Worcester, MA
Offline
God Member
Karma: 2
Posts: 619
Arduino rocks
|
 |
« Reply #14 on: November 09, 2011, 08:17:36 am » |
Since it's an analog accelerometer, the easiest way to test it is to connect the power (3.3v) to the accelerometer and put a meter on the X, Y and Z pins. If the readings are stable on the meter and vary according to tilt then you can be fairly sure the accelerometer is working and the problem lies in your interface. If the readings are not consistent with what the datasheet says then there is a problem with the accelerometer.
|
|
|
|
|
Logged
|
|
|
|
|
|