Showing results for 
Search instead for 
Did you mean: 

integration of gryo and blending with accelerometer problems.

I've been going a little crazy lately trying to get the gyro and accelerometer from my idg300 and adxl335. The sensor raw voltage inputs into the analogue module in my compactrio seem fine. However when i integrate the gryo values after taking away the offset and dividing by the sensitivity i don't get the right answers. They seem to always be roughly 2.4 times smaller than they should be.

I have also tested the accelerometer values which seem fine. I divided the raw voltages by the sensivity and then did the arcsin to find the tilt angle. These came out fine but of-course were noisy results.

Does anyone know why the integrated values could be incorrect? I have tried all different types of integrating in labview and it always comes out with the same results.

Also i'm trying to blend the accelerometer and gyro angles to give an accurate angle that doesn't drift and isn't noisy. I'm using the complimentary filter code in labview that can be found on the internet everywhere:

angle = 0.98*(angle + rate*dt) + 0.02*accelerometer angle


By changing the constants (0.98 and 0.002) i can vary how much of each to blend in but i cannot get rid of the drift(i'm multiplying the gyro angle by 2.4 to give a more accurate angle but not feeding it into the integration so it doesn't affect things) If i use a crazy amount of accelerometer angle then the drift is pretty much gone but the results are too noisy to send to a motor. Does anyone have any idea why this is so? It seems to work for other people's example son the internet.


I've attached a word document of my results throughout the sensor testing.

Many thanks for any help any one can give,

0 Kudos
Message 1 of 5

you will need to post your code.


Its probably a simple fix but a graph of outputs doesn't give us much to guess with. 


MORE: most of the forum participants won't open a MS office file- Post vi's with default data, Snippets are nicer since they can be imbedded into the post,  or a *.png of a screen capture - (just "save as" .pgn via Paint)


Some of us have data plans that count the bytes- and some of us don't have good virus protection.  None of us can fix what we can't see.

"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5

Ok i've attahced the real-time project i'm working on. The main prject is called ballbot_fpga which contains all the vi's. The vi im working on currently is the one called complimentary filter which i've attached along with a screenshot. The other files in the project are to do with previous iterations of the ballbot setup alogn with  a kalman filter/lqr hich was previously used but i couldn't get it to work. I only have a few days left on the job so i'm trying to just egt it up and running-which is what the voltage_control_realtime_pid VI is for once i get the nice sensor values.







0 Kudos
Message 3 of 5

Also just to clarify the vi a bit, the 8.7266 is 1 divided by the sensitivity of the gyro (0.002) mutliplied by pi/180 to get it into radians. Also the accelerometer value is mutliplied by 3.333 which is 1 divided by the sensitivity (0.3). The multiplier of 2.4 in the mathscript node is to get a "correct" integrated gyro term as this multiplier seemed to work, it was found by trial and error.



0 Kudos
Message 4 of 5
Image and video hosting by TinyPic
0 Kudos
Message 5 of 5