|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Could someone please provide some example code for controlling a flywheel with an SRX to run at a certain velocity? We have an encoder hooked up to the wheel, but we're currently waiting for a breakout board to come in for soldering, so if it's possible, I'd appreciate the code being without an encoder for now.
|
|
#2
|
||||
|
||||
|
Re: Talon SRX Velocity Control
Hi Abelbae, Welcome to CD. Can you try going to the product's website?
|
|
#3
|
|||
|
|||
|
Re: Talon SRX Velocity Control
Start with the provided reference material at http://www.ctr-electronics.com/talon...ical_resources
When you tune it, start with the F parameter then P. If you really need the last 0.1% you could add a small I term. The new SRX code has a parameters for "peak/nominal closed-loop output". I have not used this before, but it would have solved an issue I had years ago with the older Jaguars. When driving a flywheel, there is significant inertia and if the loop overshoots, the control loop will try to slow the wheel down, potentially by trying to turn it backwards. Reversing the motor while the flywheel blew half the H-bridge driver inside the speed controller. So, I will amend my recommendation. The F term is the Forward (open-loop) parameter. 1) set P,I,D,F to zero 2) command 800 speed (assuming full range +/- 1023) 3) find a value for F which gets you to the target RPM 4) query what the voltage for that RPM is (Vnom) 5) ConfigPeakOutputVoltage(+12, +Vnom/2) 6) find a value for P that maintains the RPM over changes in load 7) if required, tune I for more accurate nominal values Especially if you use the I term, you may also want to play with the new ConfNominalOutputVoltage command to create a "good enough" voltage band around your desired RPM. This could help if you have minor oscillations near your target RPM. |
|
#4
|
|||
|
|||
|
Re: Talon SRX Velocity Control
Thank you for the information. I'm figuring it out right now, but sadly I won't be able to test it for a few days, as the team is currently getting the electrical on the robot. I'll post more if I have any questions.
|
|
#5
|
|||
|
|||
|
Re: Talon SRX Velocity Control
gpetilli,
Thank you for posting your tuning steps. I've tried to use them and I am getting unusual results and hoping you might be able to provide some guidance. We are using velocity closed loop mode, CTRE Mag encoder in Relative. I've set PIDF all to zero, set a RPM speed of 1000 RPM and increased F to 0.84 to obtain ~1006 RPM. Once I start to increase P - in this case 0-> 0.1 the speed slows down to to 600 RPM. If I add some I, the motor goes to max reverse speed (~1200). Any help would be appreciated. Thanks, bohdand |
|
#6
|
||||
|
||||
|
Re: Talon SRX Velocity Control
Grab a screenshot of the roboRIO-web-based config Self Test when the closed-loop is misbehaving and post it here.
|
|
#7
|
||||
|
||||
|
Re: Talon SRX Velocity Control
Sounds your motor and sensor are not in-phase.
gpetilli's procedure is helpful, but not quite complete. Take a look at section 12.4 for a complete walk through of velocity close-loop (Talon SRX Software reference manual). Also section 16.31 "My Closed-Loop is not working? Now what?" |
|
#8
|
|||
|
|||
|
Re: Talon SRX Velocity Control
Quote:
The steps I gave are fairly generic and intended to help you through the basic thought process, you should use the more detailed debugging instructions in the CTRE documentation. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|