Accelerometer

14 Apr 2010

Hi im pretty new to progaming as a whole, currently studying Electronics over at anglia ruskin. We have a project using LIS302 and Nokia LCD and I am trying to use little bit of trig to get accurate tilt for X and Y which will be passed to display function ......

I have the trig function running and seems to be good. Basiclly using all 3 axis to overcome lack of resolution past 60 degrees pos and neg.

My question is how do i run calibrate function? I need to setup a function to calibrate x y z axis and place this offset into accessable int/float location to allow me to read full tilt ( currently X runs -80 ish to +80 ish and Y 70 +-, think this is mainly due to lack of calibration of Z axis) current funcction generates angle in radians and then converts to degrees. I am also going o do moving average using info i have found on here and other sources.

something like

Float array of 5 data points

start loop of 5

read output acc.x

put into array at loop (i)

average over 5 (i know that for first 5 runs this will give incorect readings)

reset loop which will cause over write of array location 0

continue.

Does this sound ok ish

Anyway I will post my code after submiting the assignment  .I hope to be a long term member of the Mbed comunity contributing as well as just playing :)

 

Danny

15 Apr 2010

Hi Daniel,

I recall that Simon Ford done some work on averaging values that might help you. Look here...

http://mbed.org/forum/mbed/topic/165/?page=1#comment-658

Hope that helps

Martin

17 Apr 2010

Thanks Martin,

 

Sorry, i thought i replied but it seems to have disapeared!

Yep I looked at what Simon wrote but i didnt see the example code until you pointed me there again :) so thanks for that. Think I have got my head around the averaging going to type up and run a little loop to see if it works. Looked through simons posts on the library files for the  LIS302 and have tried altering acc.calibrate values ( and they seem to work) but I cannot figure out a way to automate the process as a function.

Anyway thanks your reply helped alot

 

Danny