Hi VEX forum… I have a few questions about gyro sensor.
First, How do I zero a gyroscope like how I would zero an encoder?
Can I use the SensorValue[Gyro] = 0; command to do this? Is this a command that can be executed in a short amount of time? Or is this more like re-initializing the gyroscope and it takes a few seconds?
Without using the command mentioned above, I still managed to pull together a small program that lets me manually reset gyro… I guess that Robotc does the same thing.
int gyrooutput;
int gyrocurrentvalue = 0;
void resetGyro (int value = 0)
{
gyrocurrentvalue = SensorValue[Gyro] + value;
}
task GyroProcessingBlock ()
{
while (true)
{
gyrooutput = SensorValue[Gyro] - gyrocurrentvalue;
}
}
Just an idea that I had a long time ago. You use the global variable called gyrooutput as the sensor value. But today as I actually tested this out on LCD, there is a glitch. I display the gyro output on LCD, and every time I use the zero gyro command, the display of gyrooutput on LCD glitches between the real value and the processed output value, which is very weird…
The following is the command I run in a loop to display gyro values:
void DisplayGyroValue ()
{
displayLCDCenteredString(0,"GyroRaw GyroFine");
displayLCDNumber(1,0,SensorValue[Gyro],5);
displayLCDNumber(1,7,gyrooutput,5);
if (nLCDButtons == 2)
{
resetGyro();
}
}
So is it my gyro processing loop’s issue, the LCD display program’s issue, or something else? Seems like two tasks are conflicting and they are both commanding the LCD, but I don’t see how this can happen.
Thanks!