Vex Gyro Returns Random Values

Hi,
My team and I are trying to implement the Vex Gyro in our robot.
However, when we began to test the Gyro, it returned weird values – for example, it acts like a random number generator as it is giving back numbers ranging from 8 to 3000ish (small numbers to large numbers, and the values were never negative) even when the robot is still. The numbers also change in this range every half second or so.
I looked into it as being a drift issue, however the drift issue seems to happen over a longer period of time, unlike what we are encountering as the values change from low to high in less than a second.
I do not believe that the programming is the problem because we are reading the values straight from the debugger.
Would it be possible that the Gyro sensor itself is the issue? Or is there another factor?
Thanks,
Team 1010 :slight_smile:

Is it possible that it’s actually returning values closer to 3600? Is it possible that your gyro is “pointing” close to its zero starting point, so because there is some random noise in the measurements, your “point” is flipping back and forth over the zero point 3599… 3600… 1… 2… 3… 4…
In other words, are you witnessing a rollover condition on something that has a little noise in it?

This might depend on whatever your code is doing. Maybe have a look at this:
http://www.robotc.net/blog/2011/10/13/programming-the-vex-gyro-in-robotc/

I had a similar problem (I use easyC). The problem was my laptop, and thus the gyro, was on a rickety table, so “zero” was actually moving, and so at actual zero, the values did something similar. I don’t know if this is your problem, but keep the gyro still when initializing it.

I don’t think so because it returned numbers that were inbetween, such as 1000, 2000, etc.

Have you tried running a program that does nothing but display gyro values? In other words, don’t have all the other code, such as driver control, etc., running, but just use a small program focused on the gyro output. If you have already tried that and it’s still glitching, you might consider posting your code for the software gurus to have a look at.

Another minor possibility: do you have the gyro leads running anywhere close to motor leads? I think it’s theoretically possible to get crosstalk, though not likely.

I would try initializing the gyro your self, that can be done in the “pre-auton” task, the code for this is below, If the gyro is not initialized properly, you can get some odd results, for example if you do not initialize it at all, error can build up over multiple runs, the rollover can happen at odd points, and, most commonly for me, the values just increase continually

SensorType[in1] = sensorNone;
wait1Msec(500);
playTone(600,25);

//Reconfigure Analog Port 1 as a Gyro sensor and allow time for ROBOTC to calibrate it
SensorType[in1] = sensorGyro;
playTone(400,35);
wait1Msec(1000);
playTone(700,20);

//Adjust SensorScale to correct the scaling for your gyro
   // this must be found by trial and error

SensorScale[in1] = 260;
//Adjust SensorFullCount to set the "rollover" point. 3600 sets the rollover point to +/-3600
SensorFullCount[in1] = 3600;
playTone(700,15);

ok so for the parameter “sensor scale” will change the values that come out of your gyro, so if you were to turn the robot in a complete circle, if you sensor scale was wrong, it will not read 3600, it would read something else, so use some trial and error to find the right value for that so that when you turn 360 degrees the gyro reads 3600

also every where is says “in1” that Is the port your gyro is in, so this could be “in2” , “in3”, “in4” … ect

Yeah, we did that, initializing the gyro and all, however, I do not think that it is due to accumulated error as the values just keep switching from large numbers to small numbers.
Thanks for the suggestion though :slight_smile:

Unless you desperately need a gyro for something like position tracking, just use encoders. I have never had a gyro work either old or fresh out of the box.They are very finicky, and even with stuff like the QCC2 gyro lib, they still have noise and errors.

Here is how I minimized the effects of electrical induced voltages and mechanical vibration on my Vex Gyroscope:

  1. The purpose of a relatively large mass is to provide a dampner to the normally vibrating robot platform. I mounted a 4-pound weight, already being used for robot ballast, on 2 rubber shock absorbers (made from 1" foam pipe insulation). I attached the weight on top of the 2 vertically-mounted 3"-high foam pipe-insulation cylinders with a hot-glue gun.

  2. On top of the metal weight (a flywheel from an old reel-to-reel tape player), I mounted two small vertical springs (1/4" diameter x 1" high) to further mechanically isolate the gyroscope circuit. Then I glued the Gyro to the springs.

  3. To isolate the Gyro from noise (vibrations) transmitted through the air, I cut pieces of 3/4"-thick Styrofoam and built a foam box around the gyro on top of the springs, leaving only a small slit in the top for the Gyro connection cable.

  4. I electrically isolated the Gyro circuit board by completely covering the foam box with the aluminum foil duct tape. I cut strips of foil tape and completely wrapped the 3-wire Gyro cable, to electrically isolate and shield it from any outside electrically-induced voltage (specially that produced by the PWM motor outputs from my Cortex controller).

After running for about 10 hours cumulative, I have not had any problems with this Gyro. It acts rock solid, always returning the same angle for the same degrees turn. I see no difference from angles measured with the robot motors off and turning the robot by hand, than those angles measured with the robot motors running.

What code where you using?