Go Down

Topic: lilypad accelerometer (Read 5898 times) previous topic - next topic

Smuorfy

hi,

i'm using a lilypad accelerometer and reading the values of x,y and z but i don't know how to convert the values into gravity values, these are the results i'm getting every 0,3 secs:

x: 311 y: 307 z: 384

x: 314 y: 304 z: 391

x: 320 y: 328 z: 370

x: 309 y: 341 z: 377

x: 317 y: 340 z: 375

x: 313 y: 320 z: 381

x: 321 y: 319 z: 378

x: 320 y: 323 z: 371

x: 304 y: 309 z: 378

x: 314 y: 316 z: 374


moving it around, it only stay's in the 300's, is it normal?

and i want to do this "convert analog voltage to a gravity amount and use trigonometry to calculate a true 'angle'" can someone help me?

thankz

leahb

to do this properly you're going to want to take a careful look at the adxl330 datasheet (http://www.sparkfun.com/datasheets/Components/ADXL330_0.pdf).  You want to start by mapping sensor numbers to acceleration due to gravity.  You will get 1g of acceleration on the Z axis when the acclerometer is perfectly still & flat (on a table or something) and 0g of acceleration on the X and Y axes.  See image below for orienting the other axes:



good luck & post back with your code when you work it out ;-)

cheers

Smuorfy

Thanks for your reply leah, i'll try to do it, when i have the code i'll post it here (;

jmknapp

#3
Apr 16, 2008, 09:38 pm Last Edit: Apr 16, 2008, 09:45 pm by jmknapp Reason: 1
I just went through this with the SparkFun Tri-Ax accelerometer. As leahb says, basically what you want to do is hold the device still in each of 6 orientations (e.g., z- axis straight up and z-axis straight down) to get the minimum and maximum readings for -1 g and +1 g.

E.g., for the Tri-Ax, I got analogRead() values of 520 with the z-axis pointing down and 182 with the z-axis pointing up. For a given analogRead() value Z then, the formula for g force would be the straight line:

gz = mZ + b

where:
gz = acceleration along the z-axis in g's

m = 2/(max - min) = 2/(520 - 182) = 0.005917

and b = 1 - m*max = 1 - 0.005917*520 = -2.076

For the tilt angles, given g readings of gx, gy and gz calculated as above as floats, and using the math library (#include <math.h>):

rho = pitch angle of x-axis relative to ground = atan2(gx,sqrt(gy*gy + gz*gz))
phi = roll angle of y-axis relative to ground = atan2(gy,sqrt(gx*gx + gz*gz))
theta = angle of z-axis relative to gravity = atan2(sqrt(gx*gx + gy*gy),gz))

atan2() returns the angle in radians -PI to +PI, so multiply by 360.0/(2*PI) to convert to degrees.

MLuckham

I used your method of calculating pitchand roll in my project http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231185714/30, thanks a lot!

halley

Also see my semi-generic Accelerometer class at http://www.arduino.cc/playground/Main/ADXL330

DM01

Hi guys.
u think it is possible to use accelerometers for static inclination measurements?
Cheers
Dan (a total newbie)

jezuz

im just gonna mention this - but when u said "moving around" i hope u meant tilting it, not literally moving it from side to side... cause that would barely register any change... cause the accelerometer, i am sorry to say, measures acceleration, otherwise known as gforce, not change in position... thus if u "move around" the accelerometer from side to side, ure only accelerating for a small period of time, and thus by the time the program updates(prints out values), the value will prolly be back to the standard value, or somewhere around it... (thus u get the "around 300" on ure serial monitor)

Yeswant Abhimanyu

hello

I am currently doing a 2 wheeled balancing cart project and i have a few doubts about the IMU. i have a IMU 5DOF frm sparkfun. it has X, Y, Z, XRATE AND YRATE. On reading a few threads here i have understood that the accelerometer gives me the acceleration and hence the tilt angle can be calculated.

what i dont understand is what do i get from the rate gyro?? all i know is when i connect it to the arduino, the serial monitor shows a voltage! how do i convert this into the angular velocity?? and why do we need to calculate this angular velocity?? i read that the rate gyro id used to calculate the angular velocity (angular rate), but dunno how to get it!!
plz help

thank u in advance

kay

Hello all,
   I just got stuck in reading accelerometer's x, y, z-axis value,
   In fact, I'm not sure that should I plug lilypad's "+" to arduino's  
   5V and "-" to GND pin? thanks!

   kay
   
   
   

kay

well~ I got the answer ;P

holmeskara

I'm sorry total noob, but why does m=2 in the equation?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy