Go Down

Topic: Measuring tilt with an MMA7260Q accelerometer (Read 3 times) previous topic - next topic

deviukk

Thx for the replies!

I'll try this as soon as possible and post the result here.


Fabio Varesano

@liudr he is actually offsetting 1650 mV from the read value so it seems that he implemented what you suggested.

lebenj

hi,

i'm also working on a tilt sensor but with a MMA7361.
the code must be quite the same, as my code works more or less the same also with an ADXL335. just changing constant like sensibility.

for the moment, the result of my code is really far from perfection. but maybe together we will find a good compromise.

actually i'm working on the "tilt sensing", but it's just a first step of what i'm trying to do...

http://arduino.cc/forum/index.php/topic,52514.0.html

the posted code, here, is really bad, i will post my last one tonight, please get a look on it....

regards

Benjamin



deviukk

#8
Mar 09, 2011, 11:55 am Last Edit: Mar 09, 2011, 11:59 am by deviukk Reason: 1

Code: [Select]
Ax = x-Voff/sens;

You are using the read value (x above) as it would be expressed in mV as the other numbers. But this is not the case. analogRead() will return a value from 0 to 1024 proportional to the voltage on the associated pin.

The following holds true:
read value from analogRead() : 1024 = read value in mV : 3.3 V (provided that you connected the AREF to 3.3V)

so if you want x expressed in mV..
x = (analogRead() / 1024) * 3300mV

Hope this helps,

Fabio Varesano


Hi, I tried this but with no good results.. The outputs in mV from x = (analogRead() / 1024) * 3300mV are (when flattened):

x ~ 1020
y ~ 1050
z ~ 1650

When using the same code for calculating the angles:

x ~ 27.5°
y ~ 28.3°
z ~ 48.5°

What would be the right output when the accelerometer is flattened? Im using range of 1.5g. So does this mean that I can't measure big angles (no problem for my project, just asking)?

Thx!

deviukk


hi,

i'm also working on a tilt sensor but with a MMA7361.
the code must be quite the same, as my code works more or less the same also with an ADXL335. just changing constant like sensibility.

for the moment, the result of my code is really far from perfection. but maybe together we will find a good compromise.

actually i'm working on the "tilt sensing", but it's just a first step of what i'm trying to do...

http://arduino.cc/forum/index.php/topic,52514.0.html

the posted code, here, is really bad, i will post my last one tonight, please get a look on it....

regards

Benjamin






Hi, if you have a working code for this kind of accelerometer, this would really help me :)

Go Up