Problems with SparkMAX position mode

Greetings -

I have been unsuccessful getting a SparkMAX to work in position mode. I’m using C++. I can read and set the encoder value. Velocity mode works just fine. I am using the line of code from the RevRobotics example to position the motor.

m_pidController.SetReference(rotations, rev::ControlType::kPosition);

Setting rotations to one (1) and issuing the above command starts the motor turning. The problem is it does not stop. Will someone shed some light on what might be the issue?

Thanks

I don’t work with the Maxes but there should be a way to tell if it is in setpoint, at which point you can stop the motors.

I think you need to specify which PID slot you are using, which is the 3rd parameter in the setReference() method. I don’t know C++ well, so here’s the Java code.

m_pidController.setReference(goal, ControlType.kPosition, Constants.dPos_Slot);

This appears to be an overloaded function. The call I made only had two parameters: revolutions and type of motion. I’m guessing if the PID slot is not specified, a default slot is used.

I changed my call to use control type to be kSmartMotion. Motor moves to desired location now. Thanks for the help.