Software integration of VersaPlanetary encoder

Hi guys, my team has bought a versa planetary encoder from vex for the next season, but I don’t know if I have to install something else, because I don’t see it when I’m declareing the main objects.

Assuming you are talking about code, the easiest way to access the encoder is to declare and instantiate the TalonSRX object which the encoder is plugged into, you can then set the type of encoder (configSelectedFeedbackSensor()) and access it (getSelectedSensorPosition()) through that TalonSRX object.

I should note that you do need to have the CTRE vendor library installed.

Mm okey but I have to put that, inide the object??
For example:
public class RobotMap {
public VictorSPX Intake;

public void init(){
Intake = new VictorSPX (1);
}

Where do I have to put that??

You need to use the TalonSRX class, not the VictorSPX class.
Also, make sure the Talon SRX ID you write (the 1 you wrote) is correct. You can check that with the Phoenix Tuner.
After that, you can set the type of encoder as written above.

I highly recommend going through the Phoenix Documentation, especially the Talon SRX bring-up section (but make sure to not skip the other sections). It is very useful in the first steps with this hardware.

1 Like

If you’re not using an SRX (or other controller which accepts an encoder), you can wire the encoder to a couple of DIO ports on the RIO and use the encoder class in WPIlib.

https://docs.wpilib.org/en/latest/docs/software/sensors/encoders-software.html

https://docs.wpilib.org/en/latest/docs/hardware/sensors/encoders-hardware.html

Added: And adding on to what @Billfred said below, the item he listed is just what you need. However the Item I’m listing below is NOT useful for this purpose because it has the wrong gender connector. It’s intended to connect a more generic encoder or potentiometer to the SRX motor controller, at which it does a good job.
Not this one! https://www.andymark.com/products/talon-srx-universal-breakout-board

Relevant item, if you do:

http://www.ctr-electronics.com/net-gadgeteer/modules/breakoutmodule.html

1 Like

There shouldn’t be any code in RobotMap. If you’re using a command based robot ( this would be if you had commands and subsystems ) the code would go in it’s own subsystem. If you’re using simple robot ( no subsystems ), it would go in Robot.

RobotMap is where variables that correspond to hardware ( e.g. CAN IDs ) would go.

1 Like

Ohh okey I got it, how do I have to call it??

What do you mean by “how do I have to call it”?

1 Like

How I have to call the encoder class, create an object.

If you can’t physically connect the encoder to the Talon SRX, you can use the WPILib Encoder class. You can read about it in the link @GeeTwo provided above:

However, if you can connect the encoder directly to the Talon SRX, you don’t need an encoder “object”. You can use the configSelectedFeedbackSensor method of the TalonSRX class instead.

1 Like

Okey guys thanks for your help

1 Like