Hello,
My team this year has an elevator system and if the elevator reaches the top position it begins to fall down due to gravity. In the Phoenix Tuner I made the Talons to Brake Mode. Is that all I have to do or do I need to add code. Also we have a limit switch at the bottom. So that when it hits the bottom I can clear all of the encoders, how would I add that in the code. I can’t find any examples online. Help is appreciated!

The brake mode will only slow the elevator but not stop it. You can command the Talon SRX to always give a constant amount of power to the elevator which needs to be equal to the weight of the elevator – use ArbitraryFeedforward for it.

A velocity pid is not necessarily the right tool in this case. The elevator will slowly drift downward as the velocity tries to stay at zero. Position PID is a simple option, but motion magic is your best option.

Thanks for the replies. I also have one more concern. I recently accidentally changed the Start Up settings for the RoboRio by going to the 172.22.11.2 . On the Enable Secure Shell Server (sshd) I accidentally unchecked it and now I can no longer check it again. I check it and press save but it goes back to unchecked once I referesh it. Becuase of this I cant run code on the RoboRio anymore. Help would be greatly appreciated.

I recently accidentally changed the Start Up settings for the RoboRio by going to the 172.22.11.2 . On the Enable Secure Shell Server (sshd) I accidentally unchecked it and now I can no longer check it again

Re-image the RIO.

We had a customer run into this, and had to root-cause it ourselves. That checkbox is broken, once you uncheck sshd, no action will restore it. So don’t press it after you re-image.

How do you use Motion Magic. I am reading all this PID stuff but getting quite confused. Could you perhaps show an example of it in C++. Like if I wanted it to go up 5000 and stay there what would I have to do.

I don’t have a C++ example, but the API calls will be the same (but for Java). You need to configure the Talon with PID constants following the guide here.

Once you have the basics down, you can just use ControlMode.MotionMagic to set your elevator to a certain encoder value (e.g. 5000).

The problem in the OP was that once the elevator hit the target (say 5000 encoder ticks) then gravity was taking over. Which where the feed-forward constant comes in to play. You need to add in enough voltage input to maintain the elevator against gravity (some decimal number that you have calculated, or just observed empirically).

The linked example shows you how to add an auxillary feed forward term, and if you’re looking for more concrete code as to how to just use MotionMagic in general there are a lot of examples but feel free to browse through our Github to see a Java implementation. You’ll see the calibration values we derived, and the Talon configuration steps we use in the DriveTrain subsystem constructor as well as the DriveMM command class that drives our robot a certain distance using MotionMagic.

Like I am reading about Closed Loop. Would that work for me. I have gone to the Phoenix Tuner and entered the P the I and the Feed Forward. Everything else to 0. What would I do from here to lets say get the elevator to go up 5000 ticks.

It’s really important you follow the CTRE instructions, don’t skip steps. If you got this far without doing all the bring-up procedures I would recommend you go back and confirm that you are properly setup.

Note in the code in our Github that I linked for you, there are some magic constant values being assigned to the closed loop slot for our MM commands (kF, kP, kD, kI). You need to do the calculations, and then the tuning of those values before you need to worry about just setting the set points.

Once you have the values calculated according to those steps (don’t skip any of them), then you can just set the motors by calling talon.set(ControlMode.MotionMagic, set_point)

Yes so I have gotten the values. Do I need to put them in code or can I just add them onto the Phoenix Tuner for both Talons used in the elevator. Also the talon.set(ControlMode.MotionMagic, 5000) is java right. For C++ would it be like talon->Set(ControlMode::MotionMagic, 5000) or something.

Thanks for all your help NewtonCrosby. It is a Snow Day here today so I havent been able to test the code but just to clarify. The P and I can be calculated and the Feed Forward all are entered into the Phoenix Tuner to both of the Talons used in the elevator. From there I use the ConrtrolMode::MotionMagic, 5000. To move up 5000 ticks using the PID values?

I highly recommend to do so. If you replace the Talon SRX with another Talon SRX, you just need to re-deploy your code and all your configs will be updated in the new Talon SRX. If you don’t write the configuration in code, you’ll need to replace all constants by yourself in Phoenix Tuner.

However, it is highly recommended to ultimately set them via the software API . This way, in the event a device is replaced, you can rely on your software to properly configured the new device, without having to remember to use Tuner to apply the correct values.

A general recommendation is to:

Configure all devices during robot-bootup using the API,

Use Tuner to dial values quickly during testing/calibration.

Export the settings so they are not lost.

Update your software config values so that Tuner is no longer necessary.