Go Down

##### Apr 04, 2011, 03:41 am
Hi,

I have a Lilypad Accelerometer ADXL355 and a Lilypad ATmega 328.  I have written some code to get LEDs to fade in and out according to tilt on the x and y axis.

My next challenge is go calculate acceleration.  I want to create an outfit for a dancer and when they move fast I want red lights to come on. When they are going at a medium speed, I want green lights to come on.  When they are moving slowly I want blue lights to come on.

I am a real newbie and don't really know where to start in order to calculate the acceleration.  I figure I need a formula for translating the analog values into g force and another for calculating the difference in g force between stationary and movement at different speeds.

#### lesto

#1
##### Apr 04, 2011, 02:14 pm
you know when accelerometer are stationary it will output only 1G on the Y axes..
so read the G for every axes, look if it is enought linear (put x, y at 45° respect ground and see if sqrt(x*x+y*y) are similar to the "free" reading)
then you know the G value
Guida per principianti http://playground.arduino.cc/Italiano/newbie
Unoffical Telegram group https://telegram.me/joinchat/ALRu8ACkdTdXyz-2P7v13A

#2
##### Apr 05, 2011, 02:03 am
Thanks Lesto.

I'm sorry, I'm still pretty confused I am very new to this.  When the accelerometer is stationary shouldn't the output be 0g?

At the moment when I read the data from the sensor when it is stationary and flat I am getting readings of about:  x: 512, y: 512, z: 612.

I want to know how to convert this analog data to g's. It seems so simple, however after much hunting I am still unsure.

#### AWOL

#3
##### Apr 05, 2011, 09:19 am
Quote
I'm sorry, I'm still pretty confused I am very new to this.  When the accelerometer is stationary shouldn't the output be 0g?

No, because some part of it will be racing towards the centre of the Earth.
Or it would be, if the Earth weren't in the way.

If your accelerometer is not exactly at right angles to the perpendicular (which came after Norman, IIRC), then there will be a component of acceleration due to gravity.

Presumably, dangling an accelerometer arbitrarily on a frock, it is going to be difficult to keep it level at all times, so you need to work out which way is down.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

#### lesto

#4
##### Apr 05, 2011, 10:49 amLast Edit: Apr 05, 2011, 11:00 am by lesto Reason: 1

Thanks Lesto.

I'm sorry, I'm still pretty confused I am very new to this.  When the accelerometer is stationary shouldn't the output be 0g?

At the moment when I read the data from the sensor when it is stationary and flat I am getting readings of about:  x: 512, y: 512, z: 612.

I want to know how to convert this analog data to g's. It seems so simple, however after much hunting I am still unsure.

as you can see, on the Z axis you're reading the G (gravity). Your accelerometer seem better than mine, because X==Y, that's a very good output, just try to read G on the X and Y axes to see if the value are the same...
if so:
we can say the zero offset is 512
and we can say 612-512 = 100 = 1G

it was easy, no?
Guida per principianti http://playground.arduino.cc/Italiano/newbie
Unoffical Telegram group https://telegram.me/joinchat/ALRu8ACkdTdXyz-2P7v13A

#### noob

#5
##### Apr 05, 2011, 12:10 pm
Perhaps a diagram will help explain why an acceleromter can give a non 0 value along a axis. Refer to the attached pic.

as for how to convert the accelerometer analog value to g's i refer you to the datasheet, I beleive the idea is to
1) get the digital value from the ADC
2) remove the zero g bias voltage (this is the output voltage for an axis that is not subject to a foce)
3) convert the voltage into g's (use the sensitivity parameter)
NOTE: the sensitivity and zero g bias values is ratiometric therefore it is dependant on the supply voltage to the accelerometer

Go Up

Please enter a valid email to subscribe