|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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!
|
|
#2
|
||||
|
||||
|
Re: Encoder Issues
Quote:
|
|
#3
|
|||
|
|||
|
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());
}
Code:
public double getRate() {
return canEncoder.getRate();
}
public double getDistance() {
return canEncoder.getDistance();
}
public double getRaw() {
return canEncoder.getRaw();
}
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);
|
|
#4
|
||||
|
||||
|
Re: Encoder Issues
Hey feoniks4505,
The Encoder class is for encoders wired to the roboRIO... Code:
sensorscanEncoder = new Encoder(0, 1, false, EncodingType.k4X); 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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|