How to design DC Motor speed control, using PID

dcpid controllerspeed

I am looking to control the speed of a DC Motor using PID, it is speed control. I understand how the PID works, but i have a few questions. Like,how would I find my gains for each of the PID, what values of resistors and caps would I use? Also, would a simple 5V DC motor be suffice? If anyone has done something like this, a circuit schematic would be great. Thanks

Best Answer

Generally you find the PID gain values by structured experimentation, something like this:

  1. Start with only a P gain (I and D = 0), and make it as high as possible with little or no overshoot.

  2. Add a little I gain. Make it as high as possible without producing more than just a little ringing.

  3. Up the P gain a little. This will usually add a little stability now that the I term is there.

  4. Iterate with the P and I terms to get the fastest settling time with whatever overshoot you can tolerate.

  5. You can either stop here, or try to add a little D term. The polarity of the D term depends on how exactly you implemented the equations. A little D can add some stability, which allows you to make the P and I terms a bit more aggressive. The point of the D term is basically to say if I'm already heading in the right direction, decrease the drive. However, D is susceptible to noise. Making it too high will cause the output to sortof "vibrate", which is basically amplifying the sensor noise onto the output. A little D can be useful if you need the last bit of performance, but a lot of implementations leave it out.

I notice you plan on doing this all in analog electronics. This makes no sense, especially for something slow like a motor. For efficiency, you will want to drive the motor with PWM. The natural way to do this is the motor speed sensor feeds into a microcontroller A/D. The micro does the PID calculations and uses that to adjust the PWM duty cycle. It can also do the direction changing with the H bridge, guarantee break before make, etc. There are many small and cheap micros with A/D and PWM hardware built in. Some even have H bridge drive PWM outputs. This is such a common problem that there are whole subfamilies of micros optimized for this.

The compute power you need is modest. Back in the late 1990s I used a PIC 16F877 to run two layered PID control loops that drove a DC motor. The inner loop controlled the position of the motor and output PWM to the H bridge. The outer loop controlled the speed of a gasoline engine and output a position value to the inner loop. The PID computations were done in 24 bit floating point. We used 8 ms per iteration, which left a little time to do all the other low priority tasks. That micro was running at its maximum speed of 5 MIPS. That is quite slow by today's standards. Lots of micros are quite capable of doing what you need.

Doing this in analog will take more board space, take more components, be much harder to tweak, and does not provide a convenient interface to the motor driver power stage. It just doesn't make sense.