SO we are trying to use encoders for the first time.
Current setup is a Grayhill on each side of our drive train, wire with 5 pin connector(leaving 4th pin empty) to the talon SRX encoder breakout board. I then use a 10 pin ribbon cable to the Talon SRX connector.
Using the web dashboard, i can see the encoder value. If i manually spin and refresh, i can see the value has changed… so i am assuming that the mechanical and wiring portion is good for now.
We are using Java Command Based… I have a few questions… All our code was “borrow” from an other team online and since we are new to java, i am not that good in totally getting it ! lol but we are trying hard!
Question #1
I have the following in my RobotMap class…
encoderRight = new Encoder(0, 1, true, Encoder.EncodingType.k4X);
encoderRight.setPIDSourceType(PIDSourceType.kDisplacement);
encoderRight.setDistancePerPulse(1.0 / tinch);
encoderRight.reset();
encoderLeft = new Encoder(2, 3, false, Encoder.EncodingType.k4X);
encoderLeft.setPIDSourceType(PIDSourceType.kDisplacement);
encoderLeft.setDistancePerPulse(1.0 / tinch);
encoderLeft.reset();
While i understand the team that create that code is using the DIO input on Roborio (that will be the 0, 1 & 2,3 right?), what should i put in there if i am using the CAN breakout board…?
Question #2
I am trying to display value on my Smardashboard… Every time i add this code, it makes my teleop crash… Basically enable for a few seconds, then disable itself…
public void teleopPeriodic() {
Scheduler.getInstance().run();
SmartDashboard.putNumber("encoder value right", (RobotMap.encoderRight.get()));
SmartDashboard.putNumber("encoder value left", (RobotMap.encoderLeft.get()));
}
Thank you!!!