I’m programming in easy-C with a gyro. I had a simple autonomous function initialize the gyro, wait 1200 milliseconds, start the gyro, then go to a loop where it got the gyro value and printed it to screen. No matter how I turned the gyro, it only gave a readout of zero. I then downloaded the same code but without the 1.2 second wait, and it worked fine. When I try to embed this code into the rest of my autonomous code, it does not work. Can anyone help me?
That’s a little confusing. The Initialize routine actually waits until the robot has been turned on for a second (settling time for vibration), then it does a one second calibration where it computes the average non-moving value. So you shouldn’t need to 1.2 second wait.
I’m not sure why adding it changes anything, but you can look at a pretty simple sample program here that does work:
http://users.wpi.edu/~bamiller/WPILib/Samples.html
Please let us know if you find a bug in something that is causing your problem.
We are having a similar problem. We are using WPILIB with Eclipse. We are also using the KOP gyro’s and gear tooth sensors. We tested them all individually with WPILIB and they worked great. When we started integrating the different features together we started getting very strange and intermittent results. For example, after reset, we would get just a single value that would never change as we rotated the yaw rate sensor. By just moving two lines of code down a couple lines (code that registered interrupts for the IR sensor was moved from the end of Initialize() to the start of Autonomous()), the gyro started working again. We started back from scratch and started adding functionality. Now the gear tooth sensors don’t work at all. That code related to the gear tooth sensors is identical to what it used to be when it worked. It made us think of the memory corruption back in 2006 with the “8.2/8.3 battery voltage bug”. Is there anything we need to do for that bug when using WPILib or do you have any other suggestions.
We fixed the problem that was creating the erratic behavior. We had a short in two of our PWM cables (we made them ourselves). After removing those faulty cables, the code worked fine.
well, there doesn’t appear to be a short in our wires…
If we add a few lines of code in autonomous that initailize and start the gyro, then inside a whileloop that will be constantly running (While 1) that gets the gyro and prints it to screen, then the gyro works. For some reason, it is only working in this scenario, we have the same settings for the start and initalize, and the same port, it still does not work. This is very frustrating :mad: