Right now, I’m trying to just pause the motors and use the “set position” block to set the Neo encoder to equal the CANcoder. The issue is that it then rapidly spins and doesn’t actually calibrate. How can I make it so it isn’t weird like this?
It sounds like you are changing the encoder location but not the control setpoint. (or maybe the other way around). If you don’t want them to move, you need to set the set point to whatever the current location is,or the current location to the current setpoint, or both at the same time so they are equal.
setPosition: Set the position of the encoder. By default the units are 'rotations' and can be changed by a scale factor using setPositionConversionFactor().
So, make sure you have the units right here. I’d do a stopMotor() before this, and allow time for the mechanism to actually stop, then read the CANcoder and finally, setPosition(). Note that there is going to be a new 2023 firmware release for SPARK MAX – this may contain important changes in this area.
To command a seek to a given position, use setReference(), with either position or “SmartMotion” control – I’d recommend the later. You will have to set the related config parameters beforehand, either in code or by using the REV Hardware Client.
If you can’t get this working as you like with the 2022 firmware, you can run control on the roboRIO just fine. In this case, I’d strongly recommend using profiledPIDController. If you go this way, it will certainly be worth revisiting when the 2023 firmware is released.
I use labview so I’d have to convert this a bit but it might work
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.