[STROBE WARNING!] I threw this together from an old toy’s motor, old printer’s iR sensor, pizza box and some other things, to try out the PID controller algorithm after discovering it on Wikipedia and seeing that there was pseudocode, meaning that I didn’t have to get a PhD in mathematics to be able to read the crazy-looking formulas that Wikipedia seems to be so fond of.
I had planned to screen-capture my program while recording but completely forgot to at the time, so please try to survive my camcorder pointing at my laptop screen…
Here, the PID controller is trying to keep the motor at a precise speed (and get it there as quickly as possible). It doesn’t work well half the time because the L298 (H-bridge), responsible for switching power to the motor, doesn’t seem to like making the motor brake. That means it speeds up much more quickly than it slows down, which the algorithm doesn’t like (it’s designed for linear systems) – it basically ends up trying too hard to slow down, resulting in a big undershoot. I might be able to somewhat compensate for that in code.
I might try this with a Sabertooth motor speed controller (as used in my old singing motors project) in place of the L298, which can certainly force a motor to stop spinning, but the Sabertooth gives such a boost to the motor to get it up to speed that 90% of the PID’s job becomes redundant… Oh well, at least it’d be able to hit any given note without me having to calibrate it first like I did with the singing motors. By the way, that’s why this system measures speed in Hz – I originally intended for it to play music like a new kind of “singing motor”.
Originally, I planned to use a 3-pin computer fan instead of this motor, using the tachometer pin to measure the speed, but that required me to have a common ground for the motor and the tachometer, and I didn’t have the right components available (I only had N-channel MOSFETs, but I needed a P-channel MOSFET). So I ended up throwing my own motor assembly together and using an N-channel MOSFET only (could only turn power on/off, not brake), which the PID system didn’t like. I thought the L298 would fix that problem, since it’d allow the PID system to reverse power to the motor and brake it, but it turns out it’s too weak to have much of an effect after all… =/
Part 2/2 will show it running at full speed (with a more powerful PSU), show a much more naïve speed controller algorithm for the lulz, and just clear up a couple of details.
, https://i.ytimg.com/vi/CKYR8au2nfE/hqdefault.jpg
source
Hello
Where to get the PID thing software please
Hello,
Can you share the code in Visual Basic and arduino?
oh my god ….
But good, so far 🙂
Have you seen these cheap PID control boards and motor driver kit? http://www.massmind.org/techref/io/SERVO/BOBPID.htm I'm soldering one up now to test it. It looks promising.
Your kD is WAAAAAYY off.
Did you make the GUI too?
Nice demo! The GUI is fantastic. By the way, do you have anti-windup in your PID code? That will help with the overshoot and undershoot you are seeing. I can see from your plot that the integral error is increasing or decreasing even when the motor current is saturated. This is wind-up. You can see the effect in my video: https://www.youtube.com/watch?v=fusr9eTceEo Good luck!
Don't put it in the carpet ! You'll maby fry it XD
Hi! Nice project!
What is the make of your strobe light please, were can I buy one ?
sir can you please provide source code for ur project,vb6 and c embedded
Hey man, very interesting tutorial to understand:) but im guessing what is the name of the graphical display you are using ? Is it similar to processing Front-End for the PID Library ?
I presume you are using a brushless setup…. With the "braking" (reverse/slowing) it has to get rid of the generated charge from switching it's pulses to spin… on multirotor ESC, activate breaking can fire other electrical parts without protection and this may be the reason of heat/not working
GUI is very good
Are you planning to post the source for the host gui and the arduino firmware? I've been printing PID values to a serial terminal in my own PID project, but having control and status all in one GUI window would make PID tuning much easier!
the system isnt overcompensating, dc motors desaccelerate more than the accelerate because of the back emf. Try setting the pwm to 255 and then set it to -255 (change direction) once it reaches top speed. Watch the angle of the speed graph, you should see its way steeper before it reaches 0.
PID assumes a perfect linear world, dc motors on pwm are all but linear.
PID speed control isnt such a problem, try doing precise position control (add another sensor 90* out of phase aka quadrature encoder) and then youll see how awful to control they are.