Go to Post Remember to have fun! That's what the FIRST experience should be for you- a lot of fun while doing a lot of learning. - smurfgirl [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-12-2013, 17:10
samn122 samn122 is offline
Registered User
FRC #0334
 
Join Date: Mar 2013
Location: Brooklyn
Posts: 4
samn122 has a spectacular aura aboutsamn122 has a spectacular aura about
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 09-12-2013, 18:45
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Gyroscope Not Returning Degrees

Quote:
Originally Posted by samn122 View Post
the gyro is connected correctly and mounted on the robot.
How is it connected?

Quote:
Originally Posted by samn122 View Post
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 View Post
We tested sample code and read the manual but we're still having a problem.
Please post the code you've tried.
Reply With Quote
  #3   Spotlight this post!  
Unread 09-12-2013, 21:43
samn122 samn122 is offline
Registered User
FRC #0334
 
Join Date: Mar 2013
Location: Brooklyn
Posts: 4
samn122 has a spectacular aura aboutsamn122 has a spectacular aura about
Re: Gyroscope Not Returning Degrees

Quote:
Originally Posted by Joe Ross View Post
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 View Post
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 View Post
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();
    }
}

Last edited by samn122 : 09-12-2013 at 21:50.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-12-2013, 22:57
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Gyroscope Not Returning Degrees

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.
Attached Thumbnails
Click image for larger version

Name:	gyro_wiring_labview.png
Views:	35
Size:	19.0 KB
ID:	15527  

Last edited by Joe Ross : 09-12-2013 at 23:06.
Reply With Quote
  #5   Spotlight this post!  
Unread 10-12-2013, 13:04
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 443
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
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.
__________________
http://team2168.org
Reply With Quote
  #6   Spotlight this post!  
Unread 10-12-2013, 20:22
samn122 samn122 is offline
Registered User
FRC #0334
 
Join Date: Mar 2013
Location: Brooklyn
Posts: 4
samn122 has a spectacular aura aboutsamn122 has a spectacular aura about
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.
Reply With Quote
  #7   Spotlight this post!  
Unread 10-12-2013, 20:38
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Gyroscope Not Returning Degrees

Quote:
Originally Posted by samn122 View Post
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.


Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 00:42.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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