Set motor positions using Falcons

looking for help with understanding how to rotate a motor to a set position with the press of one button. We have a Falcon 500 geared that pivots our intake. I would like to be able to press one button to go an out position, and another button that would move it to an in position. To do this I believe I need to use the encoders built into the Falcons and read the position I want the intake at and then take those readings from the encoder and put them into a PID which is what actually moves the motor? Am I correct with that? Are there steps in the process I am missing? Looking for any resources that will help me through this process.

You should be able to use the integrated PID control on the TalonFX (falcon 500) motor controller if you have used TalonSRX integrated PID control before, it is much the same in terms of tuning. If you know how to get your PID constants from sysid it would be best to do that.

I haven’t used much of the integrated sensors on the Falcons. I’m assuming you find the sensors using the Phoneix tuner? Do you have any resources that I could look at to try and understand how to call the controls like the integrated PID and encoders from the flacons into my code?

They have a lot of code examples at their github.

I’m using LabVIEW those are in java. Do you have LabVIEW examples?

You are going to want to reference their docs. But to give you the broad strokes you’ll need to know how to use Phoenix Tuner especially the Config and Self-Test tabs.

Your intake is in the up position when the robot is powered on so your motor will have an encoder value of 0. So the position of the motor will be Zero when you want the intake to be up.

Now you’ll need to figure out the encoder value of the motor when the intake in in what you want to be the down position. Let’s say you eventually discover that value to be 14,523.

So, when you want the intake to be down you’ll command the motor to go to position 14,523.

To make the Falcon do this you’ll need to configure in PID values. More than likely, for what you are doing you may get away with just having a positive P value.

Your first step in making this happen is making sure your Falcons are configured correctly. CTRE calls this “make sure the motor is in phase” and all that means is that when you apply positive voltage to the motor the encoders values go up as the motor spins and when you apply negative voltage the encoder values go down. They tell you how to accomplish this in the “Bring Up” section for Falcons. In “Sensor Options” you just need to worry about the “Talon FX Integrated Sensor”
Falcon Bring Up

So once your Falcon is configured to use Closed Loop control, in your case Positional Control, then start on this section of documentation…
Motor Controller Closed Loop

You’ll eventually also focus on Positional Closed Loop control.
Closed Loop Control

At this point (and for what you need to do probably not at any point worry about Arbitrary Feed Forward or any Feed Forward calculation).

Back to in general. If the two positions you are trying to set for your intake are 0 (for in) and 14523 (for Down) then what you have to think about is this…

When the intake us up and the encoder/position is 0 and I want the intake to be down the I command the motor to position 14523.
Now my error is 14523. So the controller takes the P value you have configured and multiplies it by the error. So let’s say you make a WAG and set your P value is 0.5.

14523 x .5 = 7261.5

CTRE then divides this by 1023 to get the percentage output the motor should run at.
7261.5 / 1023 = 7.09 so it tries to run the motor at 709% so really 100%.

This will probably be bad. This is why the CTRE doc have to try to at least make an educated guess at your initial P value.

When your error is 14523 you say I want the motor to run at 20% to move and start reducing the error. CTRE has you calculate the P needed to do this in the “Dialing kP” section.
(20% X 1023) / 14523 = .01409

So, if this was your situation, when your intake is up (0 position) and you commanded the motor to go to position 14523 then the motor would start out by moving with 20% power but as the motor moves the error reduces so the motor power reduces and you’ll probably come up short.

For an intake this is probably ideal as you may damage your intake if you drive you motor too much.

Hope this helps a little. It can be very confusing at first but once you understand the stuff you need to understand it all becomes pretty straight forward.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.