Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Gyroscope Not Returning Degrees (http://www.chiefdelphi.com/forums/showthread.php?t=122938)

samn122 09-12-2013 17:10

Gyroscope Not Returning Degrees
 
We're programming a gyroscope on the robot and we're not getting a readout in degrees. The sensitivity is set to 0.007 (as referenced in the manual), the gyro is connected correctly and mounted on the robot. The readout we get is also not consistent because it decreases while stationary and we don't think it's drift. We tested sample code and read the manual but we're still having a problem.

Joe Ross 09-12-2013 18:45

Re: Gyroscope Not Returning Degrees
 
Quote:

Originally Posted by samn122 (Post 1310052)
the gyro is connected correctly and mounted on the robot.

How is it connected?

Quote:

Originally Posted by samn122 (Post 1310052)
The readout we get is also not consistent because it decreases while stationary and we don't think it's drift.

Why don't you think it's drift? How fast is it decreasing? What does it do when you rotate the robot?

Quote:

Originally Posted by samn122 (Post 1310052)
We tested sample code and read the manual but we're still having a problem.

Please post the code you've tried.

samn122 09-12-2013 21:43

Re: Gyroscope Not Returning Degrees
 
Quote:

Originally Posted by Joe Ross (Post 1310088)
How is it connected?

The rate header is connected to the analog breakout on port 1. We followed this guide from AndyMark.

Quote:

Originally Posted by Joe Ross (Post 1310088)
Why don't you think it's drift? How fast is it decreasing? What does it do when you rotate the robot?

The values it returns are inconsistent and simply unusuable. We are getting decimal values and after turning the robot a couple of times there would be no significant change. Sometimes it would jump and start increasing in the positive direction and go on indefinitely until the program is stopped. We don't think it's drift (or maybe it might be?) because we don't observe the values decreasing or increasing by a small margin. I will post a screenshot of the values on my next reply.

Quote:

Originally Posted by Joe Ross (Post 1310088)
Please post the code you've tried.

The code we're trying is from Team 2945, found on the fourms. We modified it a little.

Code:

package com.github.manitourobotics.gyroscopetesting;


import edu.wpi.first.wpilibj.AnalogChannel;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;


public class GyroscopeTesting extends IterativeRobot {

    public void robotInit()
    {

    }

    AnalogChannel gyroChannel = new AnalogChannel(1);
   
    Gyro gyro = new Gyro(gyroChannel);
     
    public void teleopInit()
    {
        gyro.reset();
    }

    public void teleopPeriodic()
    {
        gyro.setSensitivity(0.007);
        double gyroAngle = gyro.getAngle();
       
        SmartDashboard.putNumber("Gyro angle", gyroAngle);
        System.out.println("Gyro Angle: " + gyroAngle);
        Scheduler.getInstance().run();
    }
}


Joe Ross 09-12-2013 22:57

Re: Gyroscope Not Returning Degrees
 
1 Attachment(s)
What voltage do you measure with a multimeter between the rate pin and ground? It should be approximately 2.5v.

I like the LabVIEW gyro wiring diagram (attached), as it's a little more clear which wire goes where on the analog breakout.

otherguy 10-12-2013 13:04

Re: Gyroscope Not Returning Degrees
 
I don't have the wpilib source avaialble, so I can't check to see if this should make any difference at all, but is there a reason you're setting the sensitivity repeatedly (in teleop periodic)?

The following is essentially what we've done every year with the gyro:
Code:

import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class GyroscopeTesting extends IterativeRobot {

    Gyro gyro;

    public void robotInit()  {
        gyro = new Gyro(1);
        gyro.setSensitivity(0.0070);
        gyro.reset();
    }

    public void teleopInit() {

    }

    public void teleopPeriodic() {
        double gyroAngle = gyro.getAngle();

        SmartDashboard.putNumber("Gyro angle", gyroAngle);
        System.out.println("Gyro Angle: " + gyroAngle);
    }
}

If that doesn't work then I'd start looking at wiring, or where I think Joe was heading with the voltage check on the rate pin, the sensor itself. The only time I've had a problem with the sensor though is when it was run over by the robot, which has happened more than once.

samn122 10-12-2013 20:22

Re: Gyroscope Not Returning Degrees
 
Thanks for the replies! After testing the gyro with a multimeter and on another cRIO unit, we discovered that the analog breakout was faulty and replaced it with another one. The gyro is working and we're getting a responsive and usable readout.

Ether 10-12-2013 20:38

Re: Gyroscope Not Returning Degrees
 
Quote:

Originally Posted by samn122 (Post 1310591)
After testing the gyro with a multimeter and on another cRIO unit, we discovered that the analog breakout was faulty and replaced it with another one. The gyro is working and we're getting a responsive and usable readout.

Thank you for reporting the resolution of the problem. That's great forum etiquette. Reps to you.




All times are GMT -5. The time now is 22:33.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi