Using PID with Talon SRX and Mag Encoder

Hi all,

We are still trying to control an arm with Talon SRXs and CTRE’s magnetic encoders. We would like to be able to move the y-axis on a joystick, have the arm move up to a set position (currently in rotations because I can’t find a way to change it), and hold there until the joystick is moved again. I have a bunch of questions concerning how to go about this. I have read both Talon SRX manuals several times (Software Ref and Motion Profile).

  1. Right now, I am using the Talon SRX configured with Percent VBus in Begin. In TeleOp, I have logic that causes the arm to move up to a certain point and then stop. However, when the joystick is moved, it moves rapidly and doesn’t hold it’s position, although the brake is enabled in the RoboRIO web dashboard.

I feel like I am going about this wrong, and that I should have the Talon set to Position in Begin, but whenever I do this I can’t get a response.

  1. There is also a block for the Talon SRX called “Set PID”. I’ve been watching a lot of videos and reading a lot of posts about this, but I still don’t understand the first thing about PID. It can be configured in the Web Dashboard and through the block, but how would I activate it with the joystick if I used the Web Dashboard? Also, I think it would control the movement of the arm, but are there units to the values of P, I, and D so that I can figure out how to set them?

From watching a video, I believe P is the desired position, and I and D adjust around the position to get closer to the desired position. If I wired the joystick’s y-axis to the P value and somehow converted the joystick value to rotations or degrees, would this work? If so, how would I set I and D?

As you can tell, I am really confused trying to figure out how to implement this. Any examples or explanations would be greatly appreciated. Thank you.

Did you try the manufacturer’s website which has documentation and examples?

Since you have read the manuals, I will try to tie it all together for you as best I can. Ignore motion profile. It would be an advanced approach.

In brief terms, setting the brake on the talons only holds position in a kind of passive mode. the motor resists turning, but it is not powered and keeping your position.

You need to have the motor actively running to keep the arm in position. Here’s the basic approach for you. You do need to use position control PID. Here are two videos to explain (P is not for position).


and go to about 4:00 on this one to see how changing the PID constants affects the behavior

You set the Talon SRX to position control and feed it (motor output VI) the position (in native talon units) you want it to control to and it goes there. You get the positions by moving your arm in manual mode and reading the positions from the web dashboard. Use the Set PID VI to set the PID constants.

Some words of caution. Be very careful. You can easily break your arm. If the position is wrong or the PID constants are wrong, the arm will get jammed against whatever physical limits you have and probably break something. Start with very small P, have the motors disconnected and probe to see what the code is telling the talon to do and the status output VI to see what throttle is being applied and see if that matches what you think should be happening. Reduce the P if large throttle outputs are being observed. Use graphical outputs to see target position and actual position. Connect the motor and proceed to tune as per the second video. Always be ready to disable at a moments notice. Because of different behavior up and down, an arm is going to be very challenging to position control.

Sorry this is so brief, but I need to get rolling to the Palmetto Regional.