Problems with the gyro

Our team is having problems with our gyro. We are using the KOP gyro with Kevin Watson’s gyro code. I’m pretty sure everything’s been implemented properly. We tried to just compile the code that Kevin provided, and the output results don’t make sense.

The gyro_angle output starts are zero. What happens from there varies. I haven’t been able to find a definate pattern. Sometimes when we turn it the output displays exactly what we feel it should. However, other times, the results don’t make any sense. We might turn the gyro (slowly), and the gyro_angle does not change at all, while sometimes we can set the gyro down on a table and the gyro_angle goes wild and gives random values.

We can’t really pinpoint the cause of the problem, but if any of you have encountered anything close, please share. Thanks for all of your help.

erratic behaviour sounds like a bad connection between the gyro and either the power, or the analog signals to the RC.

The signals are analog, and you have to make sure you dont corrupt them, like tie-wrapping them to the power leads for the motors or other wires carrying heavy current.

Also make sure the gyro is getting the correct voltage on its power pins.

also, are you sure you are turning the gyro on the right axis? it only senses rotation on one axis.

When the terminal output indicates that the gyro is in fact turning, then yes, the voltage changes appropriately. However, the voltage doesn’t always change when the gyro is turned, and the output on the terminal supports this. Also, there is no interference with other high-current wires becase the gyro and controller are temporarily disconnected from the robot.

Also, we looked at the documentation about the gyro, and when we rotate it about the axis normal to the specifications, the gyro angle did not change. However, when we rotated it along a different axis, the gyro angle would change. But once more, this change is not always the correct angle.

Would you recommend trying out a new gyro? If so, are there any good recommendations?

do you have a way to look at the voltage coming out of the gyro board?

that would isolate the problem: is the sensor output working correctly?

is the ADC input channel on the RC working correctly (have you tried a different input channel on the RC?)

is your code reading the input all the time, or maybe some other function in the code is interfering with the gyro input routine?

Well, yes, we did measure the voltage at the gyro board. This gives us the right voltage values, but not neccessarily at the right times. The voltage values at the gyro board matches up with the terminal output, but neither match up with the motion of the gyro.

I tried attaching the gyro to other analog inputs. I must be doing this wrong (or the gyro is broken). In Kevin’s code, the only part I should change to switch the analog input port is the #define in gyro.h, right? I tried switching this from “1” to “2”, and now there is NO output. The same thing happened on input port 3.

Lastly, there should not be a section of code that is conflicting. Once again, we are using Kevin’s code. These problems occur when there are no modifications whatsoever to Kevin’s code.

EDIT: While researching all we could, we finally came across the documentation that said the YRG is silkscreened incorrectly. So, our white wire and red wire were swapped on the gyro. We’re done working for the day, but tomorrow we’ll swap these two, and see if the gyro works (hopefully we haven’t blown it). We’ll post back tomorrow with an update. Thanks for all of your help.

It didn’t work because the ADC software, by default, only samples one channel. If you move the gyro to ADC channel 2, you’ll need to edit adc.h to sample at least two channels.

-Kevin

Well, earlier today, we switched around the red and white wires, and now the gyro works wonderfully. Thanks for all of your help, and Kevin, we’ll take that into consideration if we add any more analog input devices.

this is why reading the documentation is vital.