Go Down

Topic: Analogic 3 axis accelerometer data reading (Read 4590 times) previous topic - next topic

lebenj

ok, thanks,

but i get negative value before using pi or 100000.....

but arduino must be logic!!! so i will find my mistake, because it's sure there is one :D :D

regards

lebenj



YESSSSSSS!!!!

it works much better!!!!

so to explain, what i add in mind, i was trying to calcul everything with integer numbers to keep speed and accuracy  at the maximum,

anyway, for the moment, i found a solution, THANKS A LOT AWOL and jraskell :D :D

AWOL

Quote
i was trying to calcul everything with integer numbers to keep speed

But you've got a 500ms delay in there!
"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.

lebenj


yes i know,
but this 500ms are at the end of the loop, so when i'm doing it one more time to get a new mesure.
and to read on the serial monitor. (between 2 samples to get the average value, i need more speed (i know, there is a small ms value also :D :D )

and this is the first part of my project,
for the moment, with the "float" i have more than enough speed, but when i will add more things, i hope it will not be to slow!

thanks again for your big help

regards,

lebenj


some news of my code.
i still have problems, but it's interesting!
the X ans Y 0g value are good (around 512)
but my 1G value on Z is strangely far from the theory: in theory i must have 512 - 248 (for 800mv/g) = 263

maybe my 3,3V is not so good??

have to work on it....

lebenj



now, my code looks working almost as i want, i'm not really sure about the accuracy, but for the moment it's enough.

now i'm working with a servo and one channel of my Spektrum RC receiver.... looks strange, i meet jitters problems because the digital input is not fixed!!!!

if put a fixed position of the servo only with the servo librarie, it works perfectly...
sor for the moment i see that my problem is the read value of the ppm signal wich is not constant.....

so i will post in another thread about this.

regards

WillR

I am using the same sensor. I get a value of about 650 for the ZAXIS.

Maybe you have your sensor upside down...

I am using the Sparkfun breakout board and can see the writing on top. I can also see the sensor as I look down on the breadboard.

To stabilize the reading you will have to use a moving average. Experiment with values of say 3 , 9 and 16 for the number of readings included. Of course the moving average may be limited by the response time required. If I recall correctly you can read every 70 micro-seconds from that sensor.

Your vector calculation will only be accurate for the force applied in a given direction -- it will not provide orientation. You will need other sensors for that as I am sure you know.

You may want to consider the BMA180 Accelerometer I2C sensor and using Jurgens library -- see other threads.

My work shows that the ADXL335 is lower noise as well. Not as good as the BMA180 though.

Just another Hacker

lebenj


you have much more knowledge than me.
but the result depend of your voltage reference, mapped on the 0 - 1023 value.
as generaly (like me actually) the arduino board is 5V, and the accelerometer is 3,3V

also the sensibility (V / g ) depend a lot.

for my MMA7260Q at 1,5G, the sensitivity is 0,8V/g

so for a 5V reference:
0G must be around 337
1G must be around 501 or 174 (depense of the side of the accelerometer)

using the AREF pin at 3,3V:
0G must be aroud 511
1G must be around 759 or 263 (depense of the side of the accelerometer)


for the ADXL335, at 3,3V, the sensibility is 0,33v/g

so for a 5V reference:
0G must be around 337
1G must be around 405 or 270 (depense of the side of the accelerometer)

using the AREF pin at 3,3V:
0G must be aroud 511
1G must be around 613 or 409 (depense of the side of the accelerometer)

can you tell me:
wich accelerometer are you using and if it has a Gselect, wich you are using?
wich voltage are you using for your accelerometer?
wich voltage is your arduino board?
if you use the AREF funcion

may be we could find an explanation for your result on Z around 650?



WillR

#23
Mar 17, 2011, 03:45 am Last Edit: Mar 17, 2011, 03:57 am by WillR Reason: 1
Her is the info...

The board is the MEGA 2560 with an external supply and yes I use 3.3V and AREF...

MMA7361Q, Yes it is set to 1.5G.

http://www.sparkfun.com/products/9652

Yes I am using AREF. Yes the readings I get are correct say 680 if you don't like 650. The sensor was sitting a little crooked...

The X and Y sit about 500 - 529 -- depends on how level the board is...

So say that 0G is about 512.... then

1.6V, 1.7V, and 2.2V are the x-y-z readings.... I am clearly off-kilter a bit... :D

So looking at the Y Voltage....2.2V - 1.65V = .55V

0.55V/1.65V * 512(BITS) = 170 (BITS)  which get added to the center point...

512 + 170 = 682 BITS

So I would say that the reading is about right.

Now for 800mv per G yes I should be getting 0.800V/1.65V = .5 == 256 bits (mas o menos)

512 + 256 = 768 BITS

So maybe if the sensor was not tilted a bit you would be right.

It does not really matter as I am just measuring deviations (shocks -- low frequency noise actually) so the math and graphing package I wrote re-centers the axes and does the deviation calculations etc.... IOW auto-calibrating... And it is sitting on a breadboard anyway -- not in the measurement bracket.

hope that helps...

The 3.3V is a bit off 3.308 so my AREF is not perfect.... But it is good enough for my purposes.

PS: Check the specification sheet -- and pay attention to the normal ranges....

Because... at 0G the voltage should range between 1.485V to 1.815   NOMINAL is 1.65.

This is engineering/applied science -- not pure science. You always have to account for the error or deviation from the nominal.
Just another Hacker

lebenj

i think your values are good.
and your message helps me :-)

but


The 3.3V is a bit off 3.308 so my AREF is not perfect.... But it is good enough for my purposes.

PS: Check the specification sheet -- and pay attention to the normal ranges....

Because... at 0G the voltage should range between 1.485V to 1.815   NOMINAL is 1.65.

This is engineering/applied science -- not pure science. You always have to account for the error or deviation from the nominal.


the 0g voltage range depend of your voltage input accuracy.
in theory, the 0g voltage must be :  input voltage / 2 =   3,308 /2 = 1,6504 V wich mapped on the 0-1023 must be 510
1,485 is for a 2,2V input
and 1,815 is for an 3,6v input
so  this relation is not exactly linear. but around 3,3V we can say it's linear  :-), no??

sensitivity change by the same way also with input voltage...


that's also why the "auto zero calibration" looks important.  (http://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf)

thay talk about that at the end of the page 3, point 5 and 6... wich is referenced about the 0g voltage.

thanks for your help.

Benjamin

WillR

And just to make it easy for people...

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KIT3376MMA73x1L

The Auto Zero Calibration Pdf...
http://cache.freescale.com/files/sensors/doc/app_note/AN3447.pdf?fpsp=1
Just another Hacker

Allar

May I see Your recent revision of your code i'm starting to work with acceleration and i would like to test out your code.

Go Up