Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Encoder Issues (http://www.chiefdelphi.com/forums/showthread.php?t=141819)

feoniks4505 15-01-2016 21:08

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!

TimTheGreat 15-01-2016 21:11

Re: Encoder Issues
 
Quote:

Originally Posted by feoniks4505 (Post 1524564)
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.

feoniks4505 16-01-2016 12:27

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?

ozrien 16-01-2016 14:55

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.


All times are GMT -5. The time now is 10:25.

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