Offline
Newbie
Karma: 0
Posts: 40
|
 |
« on: January 21, 2013, 01:00:50 am » |
Hello...
I am working on Arduino mega 2560 (Mega ADK) for my project... and am trying to interface it by ADXL335. I am getting reading i guess they are in mV...i really want to understand how can i convert them into G's.
For the time being i used the sample code which exists in the arduino software itself...and am going to develop it later to use it in my system.
Thank you in advance for you assistance....and any further information regarding this accelerometer, difficulties you guys faced and things i should take into consideration when am dealing with it....
I would really appreciate if anyone of you provide me with any further information regarding ADXL335
Thank you again
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: January 21, 2013, 03:18:58 am » |
I am getting reading i guess they are in mV.. Why guess? Your code should tell you (it doesn't tell us anything, because we can't see it) Somewhere in the accelerometer's datasheet will be a sensitivity figure, giving the number of counts or mV per g. That will tell you how to convert mV to ms -2
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 40
|
 |
« Reply #2 on: January 21, 2013, 03:59:53 am » |
Thank you for your reply  This is the sample code i got from the library, just reading the analog port and display them... const int xpin = A3; // x-axis of the accelerometer const int ypin = A2; // y-axis const int zpin = A1; // z-axis
void setup() { Serial.begin(9600); }
void loop() { // print the sensor values:
Serial.print(analogRead(xpin)); Serial.print("\t"); Serial.print(analogRead(ypin)); Serial.print("\t"); Serial.print(analogRead(zpin));
Serial.println(); delay(100); }
I got the clue of how to convert the readings... i will post the reading as soon as i modify the code Thank you
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #3 on: January 21, 2013, 04:04:50 am » |
OK, so the readings are not in mV, they're raw readings. If you want mV, they you need to multiply the raw readings by 5.0 / 1023.0. Once you've got that fixed, then you need to plug in the sensitivity value from the datasheet. There'll also be an offset to be applied, because the accelerations will be +/-, but the accelerometer will only give positive voltages.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 40
|
 |
« Reply #4 on: January 21, 2013, 04:56:45 am » |
Regarding the sensitivity values which one should i use (max=330 , min=270 , typical=300) ? Providing that am using 3.3v to power the accelerometer and the arduino board is powered by I2C cable.
and the offset will be solved by subtracting the zero bias voltage from the voltage i will get in mV , am i right ?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #5 on: January 21, 2013, 05:00:14 am » |
Regarding the sensitivity values which one should i use (max=330 , min=270 , typical=300) ? Use the Z axis to calibrate it. With the accelerometer on a level stable surface, the Z axis should read exactly 1g (or -1g depending on orientation) the arduino board is powered by I2C cable USB, surely? And yes, the offset is usually half the supply voltage.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 40
|
 |
« Reply #6 on: January 21, 2013, 06:46:16 am » |
unfortunately am getting random numbers for all axises (ranging from 197 till 479 ) yes am using USB  I really appreciate your help
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #7 on: January 21, 2013, 06:51:28 am » |
unfortunately am getting random numbers for all axises (ranging from 197 till 479 )
Double check your connections (do your pins match the pins you're reading?) and ensure you've got a solid ground connection between your Arduino and your accelerometer. Any strong sources of interference nearby? Maybe concentrate on a single axis.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 40
|
 |
« Reply #8 on: January 21, 2013, 07:59:42 am » |
connections are correct...yes you are right the accelerometer is not exactly fixed to a solid ground...i will find solution for that now
if i add capacitors for noise blocking, is that going to affect my readings positively ?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 40
|
 |
« Reply #9 on: January 22, 2013, 08:45:37 am » |
Hey AWOL, i am getting some steady readings for raw values...and am trying to get the values in G's, but all what i can read are "zeros" can you please figure out what is the problem: this programe turn on led if adxl readings in G exceeds 2 const int xpin = A0; const int ypin = A1; const int zpin = A2; int ledpin = 2; const float power_supply = 5.0; const float sensor_power_supply = 3.3; const float zero_bias = sensor_power_supply / 2;
const int threshold_x = 2; const int threshold_y = 2; const int threshold_z = 2;
void setup() { Serial.begin (9600); pinMode(ledpin, OUTPUT); Serial.print ("x axis \t\t"); Serial.print ("y axis \t\t"); Serial.print ("z axis \t\t"); Serial.println(); delay(1000); } void loop() { Serial.print(analogRead(xpin)); Serial.print ("\t\t"); Serial.print(analogRead(ypin)); Serial.print ("\t\t"); Serial.print(analogRead(zpin)); Serial.print("\n\n"); float voltage_x = (analogRead(xpin)) * power_supply / 1023.0; float x = (voltage_x - zero_bias) / 320; Serial.print(x); Serial.print ("\t\t"); float voltage_y = (analogRead(ypin)) * power_supply / 1023.0; float y = (voltage_y - zero_bias) / 320; Serial.print(y); Serial.print ("\t\t"); float voltage_z = (analogRead(zpin)) * power_supply / 1023.0; float z = (voltage_z - zero_bias) / 320; Serial.print(z); Serial.print("\n_________________________________________________________________\n"); delay(2000);
if ( ( x > threshold_x) ||(y > threshold_y) || (z > threshold_z)) { Serial.println(); digitalWrite(ledpin, HIGH); delay(5000); digitalWrite(ledpin, LOW);
} }
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #10 on: January 22, 2013, 08:49:01 am » |
Are you saying the raw voltages are zero, or the calculated g values are zero?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 40
|
 |
« Reply #11 on: January 23, 2013, 12:44:47 am » |
am getting zeros for G values
|
|
|
|
|
Logged
|
|
|
|
|
|