Re: Use Tetrix Encoders to Hold Positions?
Our robotics library has a PID motor module that does that. The PID motor module supports a Tetrix motor with encoder. It provides a function call SetTarget that allow you to specify what position you want the motor to move to. The function has a lot of options such as if it should hold the position after it gets there. If you are controlling an arm that lift against gravity, you may need to actively hold the arm up even if you reach the target position. The library module is doing its own PID control, not using the nMotorEncoderTarget that's built-in to RobotC. We found that the RobotC built-in PID doesn't do what we need because it doesn't allow you to tune the PID constants which is crucial for maintaining the stability of the arm. Our PID motor module also supports upper and lower limit switches and a Zero calibration function. So at the beginning, you can call Zero calibration that moves the arm to the "home" position. Once it touches the limit switch, the zero position is reset. From there, you will be able to set the target position where you want it.