Hello
I need help finding a PID motor controller
I don’t know what brand/type I should buy
also, the information I get when searching it up is vague so if anyone knows what to get or what to do please reply to this thread
Thanks!
If you’re looking for a motor controller that will run the PID loop internally, then the CTRE Talon SRX will do that. Note, though, that this is really only intended for use in the FRC infrastructure.
If you’re trying to grok what PID is, then this video does a really good job.
Here’s the intuition: you figure out what number you want to be at. The further your measurement is from your target, the more you try to bring it back. (that’s the “P” part.) The longer your measurement stays on one side of the target, the more you try to bring it back (that’s the “I” part.) And, the more your measurement is moving away from your target, the more you try to bring it back (that’s the “D” part.)
So, you want to be going 30 mph, but find yourself going 10 mph? You push the gas. You’re driving and you notice that you’ve been going 10 mph for a while and seem to be stuck. So you push the gas even more. If you want to be going 30, but are instead slowing down from 10 mph to 5 mph, you push the gas even further.
There’s two questions to answer that may be helpful:
- FRC-legal, or not? If you don’t need it to be FRC-legal, a few other options open up. (RoboClaw comes to mind.)
- Brushed, or brushless motor? It makes a difference for some controllers.
Then there’s some other questions once those are answered.
A PID Motor controller isn’t a piece of hardware. You can get a motor controller that works with the WPIlib, then in software implement a PID control loop.
PIDs are a software thing, not a hardware thing.
FRC or FTC?
For PID, the hardware thing you need is a sensor, to measure whatever you are trying to control – such as the position of am arm or turret, or the velocity of a wheel. Some motor controllers/motors have these built in, and can run the PID algorithm internally. But, in some cases, you really want an external sensor. So more information would be helpful here.
There are motor controllers TalonFX TalonSRX Spark MAX that have onboard PID that takes the rio out of the loop if the sensor is connected to the controller.
Thanks clarifying mentor just told me do research and the web didn’t help much
Frc and brushless
FRC legal options are Rev’s NEO motor or NEO-550 motor (with SparkMax controller) or CTRE’s Falcon 500 motor (with integrated controller).
That’s, not exactly how PID control loops work. It’s an extremely deep hole to dive into but essentially it’s a complex math algorithm that calculates how “far away” your current position/velocity is proportional to what you want it to be. There isn’t such thing as “onboard PID” because it’s something that is implemented by the software. TalonSRX’s have the capability to implement PID loops (meaning in the software/firmware packages have the ability to process what you are telling it to do), but that doesn’t mean that they can do it independently. When a motor controller has onboard PID, it means that they have the ability to use CTRE’s PID control without needing to install extra software packages. Also, PID needs encoders to work (it gathers data for calculating position/velocity) so an SRX can’t do control loops without supporting hardware.
That wasn’t how I understood the onboard PID. The controllers are processors that have their own integrated software (firmware) To use the integrated onboard pid you have to use an attached or integrated encoder. I thought it was offloaded from the RIO. I could be wrong about this but I though there were actual PID controls integrated into the firmware that could read integrated or attached encoders and perform the PID algorithm independent from the rio (After the P,I andD values were set that is. In CTR’sdocumentation they say closed loop controls update every 1ms and the control loop speed of the rio is 20ms. I am fairly sure the controllers are doing the pid processing
I suggest you look at the documentation for onboard PID as this is incorrect. This is indeed running on the controller itself.
The primary advantages of using this method is that it doesn’t need the round trip back to the RIO and that it is normally run at a much faster update rate. I am not saying there aren’t other things to watch out for or disadvantages but going down that rabbit hole is probably outside this thread.
Edit: I would also like to dispel FRC “PID is really complicated” myth. In FRC generally you should (please argue with @calcmogul if you disagree) be using P-Only loops with feed forward. This doesn’t involve any complex math and I find it is pretty intuitive for people to understand. I completely agree that there is still a lot of learning this takes to implement, but understanding FRC PID is not mathematically complicated (no integrals or derivatives)
Yeah, I forgot about that part. The calculate method in PIDController is only 20 lines of code. That is the whole algorithm. Now tuning your values can be complicated (probably not as hard as I make it) but the algorithm itself is basic. Way less complicated than the insurance pricing algorithms I deal with daily.
I’m a couple minutes slow to hit enter and got beaten but:
I’m not sure where you are drawing the boundary for “onboard.”
My simple view of the Talon SRX/FX is everything inside the case is onboard and includes the high power switching electronics and a computer with programming called firmware to do calculations and control the power switching. The roboRIO doesn’t help with those calculations that include the standard formulation of a PIDF controller.
- How is the closed loop implemented?
…
The verbatim implementation in the Talon firmware is displayed below.
It’s not. The video I posted above does a really good explanation of what’s going on.
It’s not helpful that the I and D stand for calculus terms – that’s the thing that makes people think “Oh, this is going to be really hard math.” Thinking intuitively about what each one of those terms is trying to do instead of words like integration and differentiation is a better approach, at least for high school kids who might be only part way through Algebra.
Here is a very simple and explicit group of pseudocode that can be easily understood by the layman:
Kp - proportional gain
Ki - integral gain
Kd - derivative gain
dt - loop interval time
previous_error := 0
integral := 0
loop:
error := setpoint − measured_value
proportional := error;
integral := integral + error × dt
derivative := (error − previous_error) / dt
output := Kp × proportional + Ki × integral + Kd × derivative
previous_error := error
wait(dt)
goto loop
Most teams probably lay between @Alex_Y hundreds of times and slightly tweak P
and my took me about 3 minutes to tune
. (We use PID and students struggle to try to get it right but tuning PID isn’t a huge concern - we can’t make reliable crimped electrical connections.)
Also, RE: PID is just software… my lawn mower engine’s governor would like a word.
The software interpretation is common and usually what folks see in FRC. But it isn’t generally correct, and would require the “in FRC…” qualifier.
I also concur. However, I want to also emphasize that for a high school student to fully understand and apply it well is an accomplishment to be proud of.
It’s not easy to do well in the real world. It is however very approachable, even with only “a standard high school education”.
The provocative statement was made apparently by a student; give him a break and explain:
Governor (device) - Wikipedia.
Pneumatic : the governor mechanism detects air flow from the flywheel blower used to cool an air-cooled engine. The typical design includes an air vane mounted inside the engine’s blower housing and linked to the carburetor’s throttle shaft. A spring pulls the throttle open and, as the engine gains speed, increased air flow from the blower forces the vane back against the spring, partially closing the throttle. Eventually, a point of equilibrium will be reached and the engine will run at a relatively constant speed.
My control math is too long ago. Is this FRC team use close enough to say FRC has pneumatic/mechanical PID in some way? (Or using just springs.)