I am new with java with no mentor to teach me. I am trying to get an encoder to relay data and to be able to program one. When I try to use the FRC tutorials I end up with errors and have trouble figuring out the issue. If you can help that would be great. I will insert the code below. Thanks
2016 Code.txt (2.19 KB)
2016 Code.txt (2.19 KB)
I assume the error you are getting is when you call enc.start(), since you are never initializing the enc variable. You declare it up top at:
Encoder enc;
You also need to initialize it, similarly to how you have initialized your Talon and CANTalon variables.
If you are trying to use an encoder for a motor connected to a talon, you should just be able to receive values from the encoder through the motor object. For instance if you have an encoder on “winch” you should be able to use
winch.getEncPosition() or winch.getEncVelocity()
to get values from the encoder. Also you must use CANTalon and not just Talon to get values from the encoders.
Ok it look right now… but how would I program the motor to only go ‘X’ amount of rpm.
Paragraph 10.3 of the Software Reference Manual, available for download at the manufacturer’s website.
Thanks Ether for that great refernce but what they show what to do goes against what others and the frc tutorial shows. If I am correct then I would need to define and encoder in my code which the CTR manual doesn’t.
*First let me make sure about some things I am assuming but which you have not explicitly stated.
You are using TalonSRX motor controller, yes?
Your encoder is wired to the TalonSRX (not the roboRIO), yes?
You are using CAN (not PWM) to command the TalonSRX, yes?
If so, refer to paragraph 3.2 in the Software Reference Manual
I believe you can set the number of counts per revolution if that’s what you’re looking for. just use
motor.configEncoderCodesPerRev(insert desired counts per rev)
I beileve I have figured it out last night when I was working if not I will be back with questions. Thanks
In the meantime, would you please answer the questions in my previous post, and also tell us what you figured out.