Log in

View Full Version : ACCELEROMETER! && GYRO!!!????


magical hands
28-01-2006, 13:32
I know the acceleration but how can i know the value of time??????? since
acceleration = velocity/ time^2. I know the acceleration but how can i find the time or time^2????? my accelerometer is running at 200 Hz.

Also, the gyro returns the angle as 1026 something? How can an angle be greater than 360? So for example if i want to use my gyro to see the robot's heading angle how can i do it??

Please and Thank you for the help

E-mail: jigarjuhi@yahoo.ca

Joohoo
28-01-2006, 14:13
acceleration = velocity/ time^2. I know the acceleration but how can i find the time or time^2????? my accelerometer is running at 200 Hz.


Kevin has an interupt file, that has all the timers you would need there


Also, the gyro returns the angle as 1026 something? How can an angle be greater than 360? So for example if i want to use my gyro to see the robot's heading angle how can i do it??

the gyro only gives the change in the value not the degrees that is at. I'm not sure on how to find th angle yet as that i am working on it as well ;-)

KenWittlief
28-01-2006, 15:57
yes the gyro puts out a number proportional to its full scale reading. You need to check the spec sheet for the part, its on the www.analog.com website.

depending on whether you scale the input signal or not, you may want to spin the robot (or the sensor) at a fixed rate and measure the actual signal the sensor puts out.

or if you are integrating the gyro output to get compass heading, turn the robot exactly 90 degrees and see what the change in your accumulated heading number is. Then you will know how many 'counts' equals one degree.

Salik Syed
28-01-2006, 22:37
it shouldn't read greater than 1024 though... it is a 10 bit sensor !?!?

anyways what ken suggested is the best idea.

set up a long variable then basically just add up the gyro signal to it @ a set interval.
then turn the robot 90 degrees and see what the long variables value is.

yoyodyne
28-01-2006, 23:38
it shouldn't read greater than 1024 though... it is a 10 bit sensor !?!?

anyways what ken suggested is the best idea.

set up a long variable then basically just add up the gyro signal to it @ a set interval.
then turn the robot 90 degrees and see what the long variables value is.

If you are using Kevin Watson's code, then the output is either in:

// Pick the angular unit by removing the // from one of these two lines.
#define MILLIRADIANS
// #define TENTHS_OF_A_DEGREE

I have not fully analyzed the code so I don't know for sure how it rolls over when it crosses zero but it probably does. If you choose milliratians then the output should go to 2*PI*1000, about 6200, if tenths of degree then 3600 or so.

magical hands
29-01-2006, 14:03
I just want to know how can i find out the time in accelerometer? like i understand the fact that their is a timer but can anyone please explain how this timer works? what is the default time? and how can someone change the timing. I am sure many people are having same problems and thats why we see people getting confused between acceleration and distance. They know how to derive distance from acceleration but they just cannot figure out the variables.
Once again we know the acceleration but we don't know the time so can anyone please figure out how can we find this time? and how can we change this time!

Thanks once again for all the help! :)

KenWittlief
29-01-2006, 14:43
I think I understand your question. When you read the accelerometers or the gyro that is the instantainous value at that point in time

the question is, how often is your SW reading the sensor output? (how many mS between readings?) This depends on where you put the read-ADC command in your code, and how long it takes for you code to loop through from start to end.

There are ways you can measure this directly. If you toggle an output port bit each time you read the sensors, then you can measure the frequency of that toggling bit with an oscilloscope, or with a digital volt meter that has a frequency function. Since you are toggling the bit on each sensor read your sample rate will be twice the frequency of the output bit. (Frequency is positive edge to postive edge, and you are reading the sensor at both the postive edge and the negative edge of your toggling output bit).

If you do this make sure your robot is running the code that will be running during operation. If your code is doing a lot of calculations, that could slow down the main-code loop cycle time.

BTW: I cant believe I missed this in your first post. V=A*T

A = V / T

magical hands
29-01-2006, 15:33
since master code runs only like at 2.26 milliseconds or something. but we can assume that the accelerometer gives out values at every 2.26 m/s therefore we can say that velocity = acceleration/processor time^2. If i am wrong please correct me :) Thank you once again guys!

6600gt
29-01-2006, 18:16
since master code runs only like at 2.26 milliseconds or something. but we can assume that the accelerometer gives out values at every 2.26 m/s therefore we can say that velocity = acceleration/processor time^2. If i am wrong please correct me :) Thank you once again guys!

Its 26.2 ms and its a bad way to keep track of time. Use a timer instead.
Kevin's interrupt code should help you with this.

KenWittlief
29-01-2006, 18:31
since master code runs only like at 2.26 milliseconds or something. but we can assume that the accelerometer gives out values at every 2.26 m/s therefore we can say that velocity = acceleration/processor time^2. If i am wrong please correct me :) Thank you once again guys!

No, velocity = Vo + A * T (T = SW loop cycle time)

Vo is the velocity at the last time you sampled the sensor, you need to integrate A*T to get velocity (integrate means keep a running summation: add A * T to a variable that is initialized = 0 when you know the bot is not moving).

Validius
29-01-2006, 19:19
for a great piece of gyro code refer to this: http://www.chiefdelphi.com/forums/papers.php?s=&action=single&paperid=579