"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.I speak for myself, not Arduino.

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 )

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

WillR

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.

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 5111G 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 5111G 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

WillR

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...

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.

lebenj

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 inputand 1,815 is for an 3,6v inputso this relation is not exactly linear. but around 3,3V we can say it's linear :-), no??