5

I can build a PID controller in the Haskell FRP library netwire using loop from the ArrowLoop instance provided for Wires.

I can also implement switching between controllers or between a controller and a manual input using switch.

How can I implement bumpless transfer, for example using the "tracking" strategy explained here (or in any number of control engineering articles/books)? Another strategy might be acceptable if it has good performance, but the tracking approach is appealing for my application because it also address anti-windup.

I'm having trouble squinting at the block diagram hard enough to make it look like the type of two (or one?) loop applications.

Doug McClean
  • 13,739
  • 4
  • 43
  • 68
  • 1
    Which diagram? The diagram for the entire plant or the diagram for the internals of the PID controller with tracking? – Cirdec Jul 24 '14 at 15:42
  • The one for the internals. I was actually noticing when I got further along that the one for the entire plant isn't a loop in my software because only the plant closes it. So I input a roll rate and output an aileron command, from the perspective of the software that isn't a loop. It's only the real world/simulator that makes the aileron command affect the roll rate. – Doug McClean Jul 24 '14 at 17:05

1 Answers1

2

There are two loops in each diagram. It's helpful when finding loops to redraw the diagrams so that all of the inputs enter the same sides of all of the elements, all of the outputs leave the same other sides, and, if possible, minimize line crossings. In these diagrams, inputs enter the bottom, left, or top of an element, and outputs leave to the right.

The overall system has one loop, feeding the output of the process into the subtraction for the error comparison:

Overall PID process

The control system has one loop, feeding the final control output after selection of controller (the PID controller or the manual control) into the tracking PID controller. The overall output is the Output on the far right.

Manually overridden PID Controller

The tracking PID controller has two loops. One is the feedback loop for the derivative. The loop for the derivative could disappear inside another component. The other loop feeds back the output of the PID controller into the comparison between the PID controller's output and the control output actually controlling the process. Note that the order of the P,D,and I branches is different in this diagram to remove the line crossings

Tracking PID controller

Notice that if the tracking PID controller had its own Output connected to Track, the difference from the first subtraction would be 0, and the integration branch would be unchanged by the addition of 0.

Cirdec
  • 23,492
  • 2
  • 45
  • 94
  • That's a great explanation, thanks very much! How did you make these diagrams? Also what's the `N` gain for? – Doug McClean Jul 24 '14 at 17:20
  • 1
    I used Dia to make the diagrams. The gain `N` is part of the derivative. The filter coefficient `N` changes where the pole location of the filter is in Simulink's design for a PID controller, which you referenced. http://www.mathworks.com/help/simulink/slref/pidcontroller.html#br9ejg0-18 There are other designs for a PID controller. Since everything is a linear operation, the gains can be placed after the integrating and differentiating operations, and any low pass filter can be used between the derivative and the final sum. The triangle with a rectangle to its left is integration. – Cirdec Jul 24 '14 at 17:26
  • 1
    Here's another design, with differentiation completely separated from filtering. http://www.embedded.com/design/real-time-and-performance/4007575/The-basics-of-control-system-design-Part-5--Tuning-a-PID-Controller. In this design, the track feedback would need to be fed into the sum on the integral branch, after being scaled by an additional tracking input coefficient of `1/Ki` or `1/(Ki*Kp)` depending on where the `Kp` gain is located. – Cirdec Jul 24 '14 at 17:33
  • Ah, indeed. For now I am just using netwire's `derivative` which uses the difference between the last two time steps. I got confused because the design that I linked was for continuous time and FRP only pretends to be continuous time. It might turn out that to make useful use of the D term I need to smooth that derivative somehow, though, I will make a note of that for when it is doing twitchy things later. – Doug McClean Jul 24 '14 at 17:37