Background:
-C++
-KOP Gyro
-4-Slot cRIO
-Gyro plugged into Analog Channel 1:1
Issue:
After calling gyro.Reset(), it takes approximately 50 to 100 ms for the gyro to zero.
Symptoms:
Our Auto control (where the gyro interface lives) is running in a separate task than MyRobot. MyRobot (when running in auto mode) calls a series of actions, in this case turning the robot to a specified angle.
For each spin request, a new task is created and the gyro is reset immediately after the task runs.
The condition to end the task and permit the next to begin is based on the proximity to the angle goal (in this case within 1 degree). When this occurs, the task exits and is deleted.
One such sequence was to spin the robot Counterclockwise 45 degrees, then Clockwise 45 degrees, for a total of 4 cycles. In competition, this is a very impractical function, but this was used to measure spatial accuracy after several consecutive spins.
So the odd part is that once one spin task is completed, MyRobot calls another. Using a console print of the gyro angle right after the gyro.Reset() at the top of the task shows that the gyro has not yet reset. The issue is that if the gyro has not reset, when the task exit condition is reached, it is incorrectly satisfied and the task exits without doing the intended function.
Through experimentation, adding a simple Wait(x) after the gyro.Reset() in the task allows proper “time” for the gyro to complete the reset. we found the time x to be a little flaky at 50ms and pretty stable at 100ms.
In the end…
After doing some digging, after Reset() is called a few other tasks are generated in the AnalogChannel class, so maybe some delay is inherent with this. It’s unlikely that this is a practical issue, I would just like to understand the mechanics behind this and create a discussion on the behind the scenes Gyro implementation.
Thanks in advance for any advice