2
\$\begingroup\$

I am building a two-wheels self-balancing robot and using PID controller to control its speed. The measured value is the encoder signals from the Hall sensors on the back of the DC geared motors. But in my notes, it mentions only to use PI controller, meaning that the Derivative term is set to zero. But i can't understand why? Isn't it better to use a full PID controller to achieve the best results?

I researched online and the best explanation i could find is that for a PI controller which controls the speed, there is a need for faster response so the Derivative term can be omitted. But i am not convinced of this explanation... Maybe someone can offer a better and more complete explanation?

Also, for the angle balancing part, why is the PD controller preferred instead of PI controller and why not use full PID?

\$\endgroup\$
  • \$\begingroup\$ Well, it's your notes, otherwise I would've said "and what does the author of these notes say?". Maybe the hint lies in what downsides a D-component to a controller can be: Do you really want the thing to react aggressively to quickly changing input? \$\endgroup\$ – Marcus Müller Oct 13 '19 at 13:41
  • \$\begingroup\$ Derivative, in a controller, predicts future behaviour, which is useful when the application involves balancing an unstable equilibrium. Integration is less useful in such applications since it looks backwards at what's already happened. \$\endgroup\$ – Chu Oct 13 '19 at 15:49
  • \$\begingroup\$ I guess a balance is an integrator. A PID controller is not a almighty device that you put inside and it will always perform better than any other controller. It has to be chosen with regard of the system type. \$\endgroup\$ – Marko Buršič Oct 13 '19 at 20:13
4
\$\begingroup\$

You do already have a D-term when control velocity. It is the differentiation of the position, so no need to do double differentiation - not stable.

schematic

simulate this circuit – Schematic created using CircuitLab

EDIT:

User DKNguyen has probably found a good reason why PI instead of PID is used: Let' take for exapmle a real servo driver having 62.5us sampling time for current controller, 125us for speed controller and 1ms for position controller. Now, the most straightforward to tune is the current controller. You can compute the Kp, Ti directly from motor resistance and inductance.

The velocity parameters are more tricky, the load and its inertia comes to play here. The algorithm for an integrator can suffer from precision while doing computation. Tiny increments could not be summed in a floating point number. But the real pain is to make a differentiation. In a book it was mentioned that sampling time has to be somewhere from 1/5 to 1/20 of dominant system time for PID controller to work as expected. Thus, high sample rate could spoil the PID, which in servo drive has a fixed sampling time.

\$\endgroup\$
  • 1
    \$\begingroup\$ Surely that isn't true if the controlled parameter is the velocity. Your statement would be correct if position was the controlled variable. \$\endgroup\$ – Kevin White Oct 13 '19 at 16:36
  • \$\begingroup\$ @KevinWhite I'm not sure about your statement. It's making me confused. For this speed PI controller, considering the encoder count in a time interval, t, the differentiation will give the speed and this represents the negative feedback signal. For the Proportional term, the speed value is used, and for the Integral term, the distance is used, which is the number of encoder ticks before the differentiation. For a position controller, then the encoder counts can be used directly without differentiation, shown as dp/dt. \$\endgroup\$ – WiredMaker Oct 13 '19 at 17:43
  • \$\begingroup\$ @KevinWhite yes but the encoder is actually differentiating already since it is a position measure. But yeah if you measure something else then ok. \$\endgroup\$ – joojaa Oct 13 '19 at 18:20
  • \$\begingroup\$ @WiredMaker Yes, some of position controllers use that approach. They do all in one PID controller: position setpoint and feedback is the actual position, the output of the controller is setpoint speed (motor voltage). Professional drivers have a position P-controller, then velocity PI-controller, then current PI-controller all of them having feedforward terms. I will edit the answer with a probable cause of using PI rather than PID, user DKNyugen gave me an idea. \$\endgroup\$ – Marko Buršič Oct 13 '19 at 19:50
  • \$\begingroup\$ I added information to the first post about the measured value (negative feedback signal) coming from the Hall sensors installed at the back of the DC geared motors. These Hall sensors are only counting the number of pulses in a specific time interval. This would be an indication of displacement given the number of encoder ticks for one wheel revolution and knowing the diameter of wheel. But i think, it could also be speed, since the time interval is known. \$\endgroup\$ – WiredMaker Oct 13 '19 at 20:04
2
\$\begingroup\$

The D term is very sensitive to noise so can be difficult to deal with since noise can be a relatively high frequency, especially if your sample rates are higher since it captures more of the noise and steep slopes.

You can see this by taking a real waveform with noise on it and graphing it's derivative with high sample rates. The slopes of the noise completely overwhelm the derivative waveform.

And then go and reduce the number of samples (not filtering or anything, just remove every second sample, or remove 2 out of 3, or every 4 out of 5 samples, and then graph the derivative of that. It's much more representative of the waveform simply because the slope betweens points is now shallower due to less samples spaced farther apart in time.

\$\endgroup\$
  • \$\begingroup\$ However, differentiation need not be noisy if it's inherent in a process - for example a tachogenerator provides a clean velocity signal. \$\endgroup\$ – Chu Oct 13 '19 at 16:01
  • \$\begingroup\$ @Chu it depends on the process. The OP asked why is the D term omitted sometimes. I'm saying that sometimes it's more trouble than it's worth due to sensitivity to noise. \$\endgroup\$ – DKNguyen Oct 13 '19 at 16:03
  • \$\begingroup\$ The process outlined in the question is an electro-mechanical control system, so there's not necessarily any mathematical differentiation going on. \$\endgroup\$ – Chu Oct 13 '19 at 16:04
  • \$\begingroup\$ The first order approach to the D in PID is simply the difference between consecutive samples isn't it? \$\endgroup\$ – vicatcu Oct 14 '19 at 1:14
  • \$\begingroup\$ @vicatcu It sure is, but immediate short term influence of noise on adjacent samples don't have to represent the longer term trend of those samples. Like a stock market graph. You could get a negative slope between adjacent samples when the overall slope of the output over several samples is actually positive. If you don't handle things properly, your system will try and act on it. \$\endgroup\$ – DKNguyen Oct 14 '19 at 1:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.