Gyro not proprely reading

I know a gyro post was just made, but this problem is different from the other guy’s.

The value from gyro.getAngle() is steadily increasing although the gyro is not being moved. At first it starts out at 0 and then it goes up slightly, then by the time it gets to 1 its rising very quickly.

We’ve tried everything: Switching the gyro to a different analog port, Switching the PWM cable, changing our code, swapping out the gyro, calibrating the gyro…

I just have no idea what the issue could be. I’ve read many guides and I’ve followed them to the tee. My question is is there any other trouble shooting things I can do?

I’ve posted all of my code for reference, with the gyro code commented out. (The angle reading still went up just the same though)


/**
 * FRC 2078 Robot using Mecanum Drive and Camera 
 */
public class Robot extends SampleRobot {
	Gyro gyro;
    RobotDrive robotDrive;
    Joystick stick;
    CameraServer server;

    // Channels for the wheels
    final int frontLeftChannel	= 0;
    final int rearLeftChannel	= 1;
    final int frontRightChannel	= 2;
    final int rearRightChannel	= 3;
    
    // The channel on the driver station that the joystick is connected to
    final int joystickChannel	= 0;
    
    /** 
     * Constructor for the robot
     */
    public Robot() {
        server = CameraServer.getInstance();
        server.setQuality(50);
        //the camera name (ex "cam0") can be found through the roborio web interface
        server.startAutomaticCapture("cam0");
        
        //Create Robot Drive
    	robotDrive = new RobotDrive(frontLeftChannel, rearLeftChannel, frontRightChannel, rearRightChannel);
    	robotDrive.setExpiration(0.1);
        robotDrive.setInvertedMotor(MotorType.kFrontLeft, true);	// invert the left side motors
    	robotDrive.setInvertedMotor(MotorType.kRearLeft, true);		// you may need to change or remove this to match your robot
        gyro = new Gyro(1);
        stick = new Joystick(joystickChannel);
    }
        
    /**
     * Runs the motors with Mecanum drive.
     */
    public void operatorControl() {
        robotDrive.setSafetyEnabled(true);
        gyro.reset();
        
        boolean buttonFour;
        buttonFour = stick.getRawButton(4);
        boolean buttonFive;
        buttonFive = stick.getRawButton(5);
        boolean forceTurn = false;
        
        double turn = 0;
        
        while (isOperatorControl() && isEnabled()) {
        	SmartDashboard.putNumber("Angle", gyro.getAngle());
        	buttonFour = stick.getRawButton(4);
        	buttonFive = stick.getRawButton(5);
        	
        	/*
        	if (Math.abs(gyro.getAngle()) > 1) {
        		
        	//	turn = (-gyro.getAngle()/45);
        		turn = 0;
        		
        	} else {
        	*/
        		if (buttonFour) {
        			turn = -.5;
        			forceTurn = true;
        		} else {
	        		if (buttonFive){
	        			turn = .5;
	        			forceTurn = true;
	        		} else
	        			turn = 0;
        		}
        		/*
        	}        			
//        		*/
        	
        	
        	// Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
        	// This sample does not use field-oriented drive, so the gyro input is set to zero.
            
        	//positive Z turns right
        	//negative Z turns left
        	while (stick.getRawButton(4) || stick.getRawButton(5)){
               	robotDrive.mecanumDrive_Cartesian(stick.getX(), stick.getY(), turn, 0);
                SmartDashboard.putNumber("Angle", gyro.getAngle());
                Timer.delay(0.005);	// wait 5ms to avoid hogging CPU cycles
                gyro.reset();
        	}
        	
        	if (!stick.getRawButton(4) && !stick.getRawButton(5)){
        		robotDrive.mecanumDrive_Cartesian(stick.getX(), stick.getY(), turn, 0);
        		SmartDashboard.putNumber("Angle", gyro.getAngle());
        		Timer.delay(0.005);	// wait 5ms to avoid hogging CPU cycles
        	}
        	
            if (forceTurn){
            	Timer.delay(.25);
            	gyro.reset();
            	forceTurn = false;
            }
        }
    }
}

*While you’re waiting for responses, here is a link to some threads that might be of interest.

I’m guessing I’m the “other” guy - Yeah, I also noticed I have an issue like this as well in the DriverStation log, where when I print out the gyro.getAngle(); - it’s a decimal value increasing steadily, and then really fast with no apparent change in the robot’s orientation. We’ve also tried all possible combinations with the wires and are getting same results. I even went as far as disconnecting the gyro altogether and I was still getting these concurrent values.