Hi,
I am building a selfbalancing wheeled inverted pendulum. I am using the IMU from sparkfun http://www.sparkfun.com/commerce/produc ... cts_id=741. It has ADXL330 accelerometer and IDG300 gyroscope. I am using dsPIC30F4011. I am attaching the model which I programmed into the dsPIC but it's not working properly. I have the following problems.
1. Regarding bias removal. Should I just use the value specified by the datasheet ?
2. The estimated angles are not in degrees. They keep varying always. The accelerometer angle estimation is giving a value of 65000 .. !! What should I do so that I get the values in degrees
3. The gyroscope angle estimation is also not in angles.
4. the complimentary filter does not give the same value at zero degree. !!
I just want the output in angles. What are the values I should change and how ? Kindly help me.
Help using angle estimation

 Posts: 3
 Joined: Tue Feb 24, 2009 9:01 am
Help using angle estimation
 Attachments

 angle_estimator.mdl
 (72.8 KiB) Downloaded 188 times

 Site Admin  Expert
 Posts: 616
 Joined: Wed Mar 07, 2007 11:23 pm
 Location: Bayonne France
 Contact:
Re: Help using angle estimation
Hi Karthikeyan,
To resume, you are to adapt the complementary filter presented on the wiki for the Spark "IMU 5 Degrees of Freedom" card.
Anyway,
 Calculations are in double thus no problems about fixed point overflow or so on...
 The bias you set for both accelerometers and the gyro is weird. Log data for each : *the gyro *the Z accel and *the X accel (with the two accelerometers axis horizontal to measure 0g and no gravity) The mean of theses logged data is the bias to remove from the data. (You could find it wth docs, but for sure it will not be exact)
 You must find the gain of the gyro to express the value is degree/s. This should be in by the doc byt should be refine by hand (have a look on the provided simulation, I rotate My rate gyro by a precise 90°, and I integrated the valud and find the gain necessary to get a 90° integral.)
Few recommendation:
 have a look on the data in step by step (using the Tx Output Multiplexed for Matlab/Labview with many input for example)
 Check that both the output of both "filters" (angle computed from gyro and accel)
 remember to check that the algorithm is executed within one time step time! (Many solution to check that the algorithm comply with the real time constraint with the blockset)
Anyway, that may be quite a lot of testing (programming, loggind data, reprogramming...)
It is much better to log data once and to do simulation using logged data. Care about sampling time must be taken while logging data... (Please have a look on the complementary filter page and feel free to ask question, many point may be not clear, or difficult to understand despite my proficient English level
I would be glad if you make that algorithm working on the spark fun board (The dsPIC blockset demo version gives the possibility to do it).
Once the IMU works, you may consider transforming the floating point algorithm into a fixed point algorithm. That should give you enough power for the stabilisation of the pendulum. (Not sure that complex control algorithm will works with double data type at 1KHz. You also may have the pendulum controller running at a lower rate than the IMU (that would be a multirate simulink model)
I hope that help !
That is a fun project, I would be happy to have news from it.
Lubin
To resume, you are to adapt the complementary filter presented on the wiki for the Spark "IMU 5 Degrees of Freedom" card.
I like "just"karthikeyan wrote:just want the output in angles
Anyway,
 Calculations are in double thus no problems about fixed point overflow or so on...
 The bias you set for both accelerometers and the gyro is weird. Log data for each : *the gyro *the Z accel and *the X accel (with the two accelerometers axis horizontal to measure 0g and no gravity) The mean of theses logged data is the bias to remove from the data. (You could find it wth docs, but for sure it will not be exact)
 You must find the gain of the gyro to express the value is degree/s. This should be in by the doc byt should be refine by hand (have a look on the provided simulation, I rotate My rate gyro by a precise 90°, and I integrated the valud and find the gain necessary to get a 90° integral.)
Few recommendation:
 have a look on the data in step by step (using the Tx Output Multiplexed for Matlab/Labview with many input for example)
 Check that both the output of both "filters" (angle computed from gyro and accel)
 remember to check that the algorithm is executed within one time step time! (Many solution to check that the algorithm comply with the real time constraint with the blockset)
Anyway, that may be quite a lot of testing (programming, loggind data, reprogramming...)
It is much better to log data once and to do simulation using logged data. Care about sampling time must be taken while logging data... (Please have a look on the complementary filter page and feel free to ask question, many point may be not clear, or difficult to understand despite my proficient English level
I would be glad if you make that algorithm working on the spark fun board (The dsPIC blockset demo version gives the possibility to do it).
Once the IMU works, you may consider transforming the floating point algorithm into a fixed point algorithm. That should give you enough power for the stabilisation of the pendulum. (Not sure that complex control algorithm will works with double data type at 1KHz. You also may have the pendulum controller running at a lower rate than the IMU (that would be a multirate simulink model)
I hope that help !
That is a fun project, I would be happy to have news from it.
Lubin
Who is online
Users browsing this forum: No registered users and 2 guests