Go to Post It's over, done, let's move on and be positive. Next year maybe everything will be perfect. :cool: - Ed Sparks [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 01-15-2016, 09:08 PM
feoniks4505 feoniks4505 is offline
Registered User
FRC #4505 (MECHDonogh Eagles)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Maryland
Posts: 6
feoniks4505 is an unknown quantity at this point
Encoder Issues

Hey, so we are trying to hook up our encoders, and we have them working while they are hooked up to the Roborio, but we don't get any values while we are hooked up to our CAN Talon. We've checked several diagrams and our wiring, and those don't appear to be the issue. Any help you could supply would be greatly appreciated. Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 01-15-2016, 09:11 PM
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 232
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Encoder Issues

Quote:
Originally Posted by feoniks4505 View Post
Hey, so we are trying to hook up our encoders, and we have them working while they are hooked up to the Roborio, but we don't get any values while we are hooked up to our CAN Talon. We've checked several diagrams and our wiring, and those don't appear to be the issue. Any help you could supply would be greatly appreciated. Thanks!
Whenever you have a problem it is ALWAYS helpful to post code that goes with it.
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #3   Spotlight this post!  
Unread 01-16-2016, 12:27 PM
feoniks4505 feoniks4505 is offline
Registered User
FRC #4505 (MECHDonogh Eagles)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Maryland
Posts: 6
feoniks4505 is an unknown quantity at this point
Re: Encoder Issues

Here is our execute method in our sensor-reading command:
Code:
protected void execute() {
    	SmartDashboard.putNumber("Encoder Raw", Robot.sensors.getRaw());
    	SmartDashboard.putNumber("Encoder Rate", Robot.sensors.getRate());
    	SmartDashboard.putNumber("Encoder Distance" ,Robot.sensors.getDistance());
    }
Here are the definitions for those methods in our sensor subclass:
Code:
public double getRate() {
    	return canEncoder.getRate();
    }

    public double getDistance() {
    	return canEncoder.getDistance();
    }
    
    public double getRaw() {
    	return canEncoder.getRaw();
    }
And here is where we define our Talon and Encoder:
Code:
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        motorsCANTalon = new CANTalon(0);
        LiveWindow.addActuator("Motors", "CAN Talon", motorsCANTalon);
        
        sensorscanEncoder = new Encoder(0, 1, false, EncodingType.k4X);
        LiveWindow.addSensor("Sensors", "canEncoder", sensorscanEncoder);
        sensorscanEncoder.setDistancePerPulse(1.0);
        sensorscanEncoder.setPIDSourceType(PIDSourceType.kRate);

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        motorsCANTalon.reverseSensor(true);
        motorsCANTalon.setFeedbackDevice(FeedbackDevice.QuadEncoder);
        motorsCANTalon.configEncoderCodesPerRev(360);
        motorsCANTalon.setPosition(0);
        motorsCANTalon.setForwardSoftLimit(15.0);
        motorsCANTalon.setReverseSoftLimit(-15);
Is there something we are doing wrong? Anything we need to initialize so that we'll get values off the breakout?
Reply With Quote
  #4   Spotlight this post!  
Unread 01-16-2016, 02:55 PM
ozrien's Avatar
ozrien ozrien is offline
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 516
ozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant futureozrien has a brilliant future
Re: Encoder Issues

Hey feoniks4505,

The Encoder class is for encoders wired to the roboRIO...
Code:
sensorscanEncoder = new Encoder(0, 1, false, EncodingType.k4X);
I think motorsCANTalon.getPosition() and motorsCANTalon.getSpeed() are what you want. Remember the sensor data comes from the Talon, to the RIO, which is where your code runs.

Checkout section 5.3 in the Talon SRX Software reference manual to see all the getters.

And when you are ready to use the internal closed-loop features of the Talon, check out the examples in section 12.

Also for the future, if anyone has a doubt of wiring-issue-versus-software-issue, use the self-test feature (Section 2.4) to see what the Talon sees for sensor data. Then you can rule out wiring versus software. Self-test works even if there is no-code.
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 08:00 AM.

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