So I’m trying to get a single SparkMax to get the motor to go to positions but this is my first time using an encoder and I don’t really know what to do and I can’t find much about it online.
Are you trying to use something like a PID controller to achieve the desired motion?
The general process for working with Spark Max encoders is as follows (example is in Java but c++ is very similar):
// Declare the motor private final CANSparkMax motor = new CANSparkMax(id); // To get the encoder object private final RelativeEncoder encoder = motor.getEncoder(): // If you are using the built in PID controller on the Spark Max private final SparkMaxPIDController controller = motor.getPIDController(); // To get the position of the motor in rotations double encoderPos = encoder.getPosition();
Additionally, Rev provides a bunch of software examples in both Java and C++ to help you get started using Spark Maxs in a bunch of different modes that can be found here.
If you’re looking to move a motor to a specific position, you might want to start with the
Position Closed Loop Control example.
Yea the issue about the SparkMax library is I’m not the greatest at coding and the thing i understand the least is like commands and encoders and things so i have some issues trying to figure out what it is i need from the library and the regular coding term for the thin i want to do.