Gyro drifting help

I know there’s already conversations about gyros out there, and I have searched them, but I guess I’ve missed the info I’m looking for.
I am using a gyro, and it drifts in one direction by about 11 after every cycle. I tried to code a button to add 11 to the pidRequestedValue for the PID task that controls the movement, to no avail. Can someone please help?

are you resetting the port when you start the program?

I was with a button

Have you initialized it? By resetting the port?

Our team linked the gyroscope to our shaft encoders on the wheels to stabilize the drift. If this is in your programming ballpark, then give it a shot. Im pretty sure you know how to reset the gyrosenser and not to move it during calibration. Moving 11 units per cycle is a lot, in the case of my experience with them.

I don’t have an encoder

Try changing the gyro’s sensorscale.

I have. 1 to 800 don’t help. Ami doing it wrong?

Ok, my values when I used the gyrosenser were from -3600 to 3600. I will make a checklist in order for you to test.

  1. is the black wire to the little b on the board?
  2. Did you initialize it in your program?
  3. Is there any other wires near the Gyro wires?
  4. How many times did you test the drift and was there any significant changes between power cycles, wire movement, ect?
  5. Are there metal contact points near the gyro, like 1-10 mm away.

It sounds like a calibration problem as it adds to one direction consistently. Run a command similar to ResetSensor.

I’m a builder coding out of necessity, please explain

Ok, there is a command that you can execute during robot operation that will set your gyroscope’s value to zero. I reread the original question and did you mean the gyroscope value, when turning on the cortex, was 11 or it goes up by 11 for every code execution? If its the first option, you can create a varible = 0, then add the gyroscope value, finally add or subtact 11 to get the true orientation.

This will set the gyro to zero without recalibrating it. The effect is instantaneous.

SensorValue[gyro] = 0;

Note that a big source of drift with this type of gyro is vibration. The gyro should be mounted on VEX rubber links or suspended in a rubber band sling.

@jpearman tested a couple of different drift solutions and determined isolating the gyro from vibration is very helpful.

Here’s the thread:

I was referring to the starting value, not drift. Thats why I clarified the question.

Starting value was 0. I will try insulating it from vibration and see if that helps. There’s no code for the calibration, just the 2 sec-1118msec to be exact- wait time, correct?

Resetting the port as in:


    displayLCDString(0,0,"calibrate"); // don't touch the robot
    SensorType[gyroSensor] = sensorNone;
    wait(1, seconds);
    SensorType[gyroSensor] = sensorGyro;
    wait(2.5, seconds);
    displayLCDString(0,0,"done        ");

Where do I need to place that in my code?

I FIXED IT. AGH I HATE CODING IT’S SO STUPID!
The problem was i was redefining that pidKP value, the slow down rate, in driver control per input while it was already defined in the PID task. IDK why it was causing such bad drift and only in one direction, but it’s snot now.

I lied I didn’t fix it. Anyone know how to make the task zero out the sensor then move to a certain value? Rn I’m doing it with a button but I really don’t want to waste that time.
Edit:

I didn’t mean coding is stupid, but that the problem I created was.