Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   i2c gyro (http://www.chiefdelphi.com/forums/showthread.php?t=91231)

Zme 08-02-2011 07:31

i2c gyro
 
the electrical team got a shiny new i2c gyro, just one problem.... i need the angular displacement and not the angular rate that it provides.
I understand the concept of integrating it with respect to time to get the angular displacement but this creates another problem.
The KOP gyro does this in the code is through an accumulator hooked up to analog channel one and i can't find a way to hook up an i2c input to the same kind of accumulator.
Is there a relatively easy way to do this to an i2c gyro or should I start working out a different way to do this?

Joe Ross 08-02-2011 10:25

Re: i2c gyro
 
There isn't any way to get the data from the i2c gyro to the FPGA accumulators. You'll have to write your own integration routine. It may be easier to convince the electrical team that an analog gyro is better.

Alan Anderson 08-02-2011 11:08

Re: i2c gyro
 
Quote:

Originally Posted by Joe Ross (Post 1018358)
It may be easier to convince the electrical team that an analog gyro is better.

Especially considering the fact that one came in the Kit of Parts.

Zme 08-02-2011 11:44

Re: i2c gyro
 
i have code written for this gyro, was wondering if there was an easier way to go about it. we've had issues with the KOP gyro and turn rates as well as drift so something a bit nicer was needed, they thought they give us a challenge i guess.
thanks for the advice

mikets 08-02-2011 12:03

Re: i2c gyro
 
Last year just for the fun of it, we have written a TrcGyro class subclassing the WPILib gyro so that we can add GetAngularVelocity and GetAngularAcceleration, not that we really need them. Strange that the WPILib used the accumulater to integrate for the angular displacement but never give you the raw angular velocity. So I wrote the class to differentiate the angular displacement to get back angular velocity. If you take this code, change the differentiator to integrator, create a member variable to remember the previous angular velocity and change the algorithm from dividing to multiplying, then you have an integrator.
http://proj.titanrobotics.net/hg/Frc...clib/TrcGyro.h

If you really want to see how to do the integration, we have written a gyro module for the FTC using RobotC. Look at the GyroTask function. You can find it here. As a bonus, this code does gyro calibration to determine the bias as well as the noise level.
http://proj.titanrobotics.net/hg/Frc...lib.nxt/gyro.h

Zme 08-02-2011 15:25

Re: i2c gyro
 
thanks for the source, the gyro calibration was something that i had thought about doing but not gotten to thinking about the specifics. having an example to look at helps a lot!

mikets 08-02-2011 15:34

Re: i2c gyro
 
Just thought of one more example. We also have an accelerometer class that does the integration (in fact double integration) to get velocity and displacement. This may be a better example because it's for WindRiver and it also contains the calibration code.
http://proj.titanrobotics.net/hg/Frc...lib/TrcAccel.h


All times are GMT -5. The time now is 13:38.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi