Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Technical Discussion (http://www.chiefdelphi.com/forums/forumdisplay.php?f=22)
-   -   Trouble with ADXRS453 Gyro (http://www.chiefdelphi.com/forums/showthread.php?t=133198)

alopex_rex 19-01-2015 21:39

Trouble with ADXRS453 Gyro
 
This year we're trying to use an ADXRS453 gyro on our robot. (With this eval board.) Yesterday we wired it up and managed to communicate with using the WPILib SPI class. We simply read the sensor data every time TeleopPeriodic was called, and integrated the results to get a measure of our heading. This worked extremely well, as in, the heading would not change at all while the gyro was sitting still, and changed as we would expect it to when we rotated it.

Then we go to work with it today, without changing the program, and it drifts like crazy. (Like, a degree every couple of seconds.) We wrote code to try and compensate for it, by sampling the rate for a couple seconds while it's still, and the values still oscillate and drift while the gyro is sitting still.

In another thread, members of several teams said they had used this gyro with success. Any idea what's going on? Any wisdom you can share about how to work with it?

thatprogrammer 19-01-2015 21:47

Re: Trouble with ADXRS453 Gyro
 
Posting your code would help. :]

Tom Line 19-01-2015 21:50

Re: Trouble with ADXRS453 Gyro
 
Please post your code as you go. We've got a couple of these gyros on the way as well, and are curious as to how to go about computing bias, etc.

alopex_rex 19-01-2015 22:11

Re: Trouble with ADXRS453 Gyro
 
As of this posting, a little bit out of date, (also generally rough) but here you go:
https://github.com/FRC830/2015Robot/tree/master/util

ADXRS450Gyro.h and ADXRS450Gyro.cpp are the relevant files. The ADXRS450Gyro::Update() function gets called in TeleopPeriodic.

wireties 07-02-2015 12:03

Re: Trouble with ADXRS453 Gyro
 
I took the previous posters code and improved it a bit - the drift is more than acceptable.

https://github.com/FRC1296/RHSRobot2.../ADXRS453Z.cpp

Enjoy

duane 07-02-2015 19:31

Re: Trouble with ADXRS453 Gyro
 
Thank you for sharing the code for the gyro. A couple of comments:

You used a Task and Timers rather than a notifier. Seems like a notifier could make the code easier, but there are also two timers which indeed complicate a bit. Are two timers needed? I'd have to read closer to work it out.

The floating point values are floats instead of doubles. Any particular reason? I'm used to thinking of doubles as being just fine for most uses. WPI Lib seems to use doubles everywhere.

The float values are being updated from a task and read from the robot loop. I think a mutex is needed to protect the values being read. Keep in mind that this year, we really do have multiple processors which means we should pay attention to atomic operations. I don't think a double or float is atomic.

This should be great for us to get going with the gyros.

I'll be happy to contribute to any changes we make.

...Duane
ps Gotta luv github!

wireties 08-02-2015 18:32

Re: Trouble with ADXRS453 Gyro
 
Quote:

Originally Posted by duane (Post 1439939)
Thank you for sharing the code for the gyro. A couple of comments:

no problem

Quote:

Originally Posted by duane (Post 1439939)
You used a Task and Timers rather than a notifier. Seems like a notifier could make the code easier, but there are also two timers which indeed complicate a bit. Are two timers needed? I'd have to read closer to work it out.

I did not change the original code all that much. The changes you recommend make sense. One could use a single timer for both the calibration and update functions. I've not used a WPI notifier yet. Is it a wrapper for a counting semaphore? The gyro started working right and I wanted to get it to the students to work on their autonomous behaviours.

Quote:

Originally Posted by duane (Post 1439939)
The floating point values are floats instead of doubles. Any particular reason? I'm used to thinking of doubles as being just fine for most uses. WPI Lib seems to use doubles everywhere.

I did not think the precision was necessary. One can only "point" the robot with a certain amount of accuracy anyways. Doubles will work.

Quote:

Originally Posted by duane (Post 1439939)
The float values are being updated from a task and read from the robot loop. I think a mutex is needed to protect the values being read. Keep in mind that this year, we really do have multiple processors which means we should pay attention to atomic operations. I don't think a double or float is atomic.

Floats are atomic as they are word-sized on a 32-bit machine. But a more portable implementation would protect the data - good idea.

Quote:

Originally Posted by duane (Post 1439939)
This should be great for us to get going with the gyros.

I'll be happy to contribute to any changes we make.

good luck!

adding averaging would be nice

Quote:

Originally Posted by duane (Post 1439939)
ps Gotta luv github!

ditto

orangelight 17-03-2015 15:29

Re: Trouble with ADXRS453 Gyro
 
Does anyone have the source code for java?


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

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