PIC suitable for IMU

Autonomous Robot, Manual Robot, DC Motor Driver, Stepper Motor Driver, Servo, Multi PWM chip.....

Re: PIC suitable for IMU

Postby watisthis » Sun Jan 03, 2010 3:48 pm

hello all... im using this IMU thing...
how do i get the angle measure by gyro..
i know that it needs kind of integration, but how can i do it?? i mean in programming?? what algorithm should i use
watisthis
Newbie
 
Posts: 10
Joined: Sun Jan 03, 2010 3:28 pm

Re: PIC suitable for IMU

Postby aurora » Mon Jan 04, 2010 12:06 am

Gyro sensor detects the rate of change of angle. IF you refer to the datasheet, you will find the factored analog signal, i.e. 2.0mV/deg/sec. Typical neutral reading at 1.5v.

Using the uC, you poll for analog reading from the gyro. at 1.502V, you know that your robot is rotating at 1deg/sec clockwise (or anticlockwise). At 1.6V, it rotate at 300 deg/sec, and voltage less than 1.5v means it rotate at opposite direction).

Once you have the measurement, here comes the hard part. :ugeek: There is no rule as to how you wish the robot (or helicopter in this case) to respond when it detect a change in rotation.

A bit of background on helicopter. As the top propeller rotates, it generate a counter reaction torque, which result in the body to rotate in the opposite rotation. Hence, the helicopter is fixed with a tail propeller, to provide thrust so that the body will not rotate. (If you observe in movies, the helicopter will start to spin when the tail propeller malfunction)

Therefore, using the z-axis accelerometer to detect the acceleration in z-axis, you common the main rotor (main propeller) to control the speed, hence your helicopter will be able to level at certain height. Using the z-axis gyro reading, you set the speed of the tail rotor, how much thrust it need to spin so that the helicopter will not spin. Alternatively, you can use trial and error to find out the correct rotor speed.

You might also want to read up some basic feedback controller concept, i.e. the PID controller. PID controller is one of the many (probably most used) control algorithm. Programming PID controller is quite easy actually, there are plenty of code examples. Another part of your code will require some amount of signal processing algorithm (filter) of the analog signal.

By the way, for your helicopter, how many axis you wish to control? up, down, turn left, turn right, rotate left, right, etc...? The more you wish to control, the more difficult it's going to be.
aurora
Discoverer
 
Posts: 126
Joined: Sun Jun 07, 2009 4:52 pm

Re: PIC suitable for IMU

Postby watisthis » Wed Jan 06, 2010 10:12 am

thanks for your answer...
actually what i'm really need is to convert IMU raw value into their respective angle... i read that i should integrate the value with respect to time... but practically, how can i do it? how do i program my PIC to integrate the angular velocity (value) of IMU so that i will get the angle? what code should i use?

earlier in this thread i read about kalman filter, i already research on this matter and found out that it can give precise value of angle using combination of IMU data... but the problem start is how to get the angle? how to integrate the angular velocity?

p/s
..what i'm doing is analysis of this IMU, the ANGLE
watisthis
Newbie
 
Posts: 10
Joined: Sun Jan 03, 2010 3:28 pm

Re: PIC suitable for IMU

Postby aurora » Wed Jan 06, 2010 4:55 pm

May I know what is your background? What is your knowledge level for mechanical/electronics/physics? Sorry if the following is too easy/difficult, cause I don't really know where to start. ;)

IMU 5 DOF has 2 sensors onboard, (2 black chips): the accelerometer and gyrometer.
Angle is measured through accelerometer via x-axis and y-axis. It is measured in g. You will need some physic background if you want to read the angle. Anyway, good news is, you don't need to use the accelerometer. For angular speed, just get the reading directly from the sensor for gyro, you don't have to integrate the value.

Default (at 0 deg/s) is 1.5v. For each increment/decrement of 1 deg/s, it will increase by 2mV. Have you check the datasheet Information is in Page 2, under sensitivity.

Connect the gyro output pin to analog pin (AN0 - AN6) of PIC16F877. In terms of code, you need to write a code to read the voltage. There are abundance of code example (with circuit diagram) for analog. Which code to use, will depends on what compiler (software) you will be using.
aurora
Discoverer
 
Posts: 126
Joined: Sun Jun 07, 2009 4:52 pm

Re: PIC suitable for IMU

Postby watisthis » Wed Jan 06, 2010 10:06 pm

thanks for your fast reply.. i'm electrical eng. student
like i said before, i already know that the gyro output is angular rate, i already figure out the connection and conversion from adc value to respective voltage value...

yes,, what i need know is how to do integration on the angular rate value so that i get the angle...
watisthis
Newbie
 
Posts: 10
Joined: Sun Jan 03, 2010 3:28 pm

Re: PIC suitable for IMU

Postby aurora » Thu Jan 07, 2010 1:05 am

To measure angle, you use the accelerometer reading, not gyro. Just do an inverse sine on the g value, it will gives you the angle. 8-)
aurora
Discoverer
 
Posts: 126
Joined: Sun Jun 07, 2009 4:52 pm

Re: PIC suitable for IMU

Postby waiweng83 » Thu Jan 07, 2010 11:52 am

aurora WROTE:To measure angle, you use the accelerometer reading, not gyro. Just do an inverse sine on the g value, it will gives you the angle. 8-)


This is only true in static condition (when the accelerometer only measures the acceleration caused by gravity alone). If the robot is moving, the g value measured by the accelerometer is not caused by the gravity alone, it's caused by the sum of gravity acceleration vector and dynamic acceleration vector. Thus, the calculated angle will not be accurate.

yes,, what i need know is how to do integration on the angular rate value so that i get the angle...


To do integration in digital form, you will need to determine the rate your integration code will be running. Let say you will read the gyro sensor every 0.01 second.

Then the angle should be:

angle += (angular rate) * 0.01;

Please bear in mind that the integrated angle is only correct in a short period. The reading of gyro will drift, and noise will be integrated together as well. That's why we need accelerometer to compensate the drifting over the long run. This is where the Kalman Filter comes into play.

Anyway, please read the article in Cytron's Robot Head To Toe Magazine volume 1. It described this topic in details. Good luck :)
With the power of dream, nothing is impossible...
User avatar
waiweng83
Moderator
 
Posts: 157
Joined: Wed Apr 15, 2009 2:17 pm

Re: PIC suitable for IMU

Postby A380 » Thu Jan 07, 2010 12:32 pm

watisthis WROTE:yes,, what i need know is how to do integration on the angular rate value so that i get the angle...


the output from gyro is angular rate, right? you need to read the output periodically let say every one millisecond.

At first, you need to convert the analog output voltage to degree per second. Then this value multiply by 0.001 (one millisecond) and summing the previous one.
[degree/sec]x[sec]=[degree]

every one millisecond do this
{
-convert analog voltage to degree per second, let say is r
-angle=r*0.001
-angle_now=angle_now+angle
}

Basically is like this. :lol:
User avatar
A380
Discoverer
 
Posts: 119
Joined: Tue May 19, 2009 2:44 pm
Location: Malaysia

Re: PIC suitable for IMU

Postby watisthis » Thu Jan 07, 2010 10:28 pm

just what i need,, thank you all...
before, i'm quite confuse because i can't find any syntax to do integration :oops:

one more thing.. for the kalman filter, i read it somewhere that i should synchro the reading taken from gyro and accelerometer,, means that the rate the pic taken reading from accelerometer should be the same as gyro..... that what i think??? is that right :?:
watisthis
Newbie
 
Posts: 10
Joined: Sun Jan 03, 2010 3:28 pm

Re: PIC suitable for IMU

Postby A380 » Wed Jan 13, 2010 2:10 pm

watisthis WROTE:one more thing.. for the kalman filter, i read it somewhere that i should synchro the reading taken from gyro and accelerometer,, means that the rate the pic taken reading from accelerometer should be the same as gyro..... that what i think??? is that right :?:


you are right. in order word, when PIC update the accelerometer value, gyro value should be updated at that time.
User avatar
A380
Discoverer
 
Posts: 119
Joined: Tue May 19, 2009 2:44 pm
Location: Malaysia

Previous

Return to Robot Controller

Who is online

Users browsing this forum: No registered users and 5 guests

cron