# proportional-integral (PI) controller in Vensim

In my last post, I discussed an attempt at designing a PID controller using the Kepler Scientific Workflow system. Here I report on a similar (yet successful) development of a proportional-integral (PI) controller in Vensim PLE. Vensim is a software package for describing and simulating dynamic models, particularly those involving feedback. I’ve often described it as a tool for “point and click differential equations” since it allows users to draw models for simulation using a mouse that would ordinarily require specification as a set of differential equations.

A PI controller is a feedback control system configuration where the difference (error) between a system response and a desired set point is directed toward a proportional multiplier and an integrator. Each of the proportional multiplier and integrator values are in turn multiplied by constants, called “gains”, and then both results are summed together. The resulting value is then directed toward the input of the system. As the system response gets closer to the set point, the calculated input value approaches a constant.

Most real-world instances of PI controllers often have a “D” component as well, and are called “PID” controllers. The “D” stands for “derivative”, but I was not able to make Vensim PLE calculate derivatives so I left this feature out.

The basic system we are controlling looks like: We want to control the value of the reservoir by adjusting the inward flow. The outward flow is not controlled, and it equals a positive constant multiplied by the reservoir’s value. Because the outward flow is greater than zero whenever the reservoir value is greater than zero, we always have to replenish the reservoir using the inward flow if we want its value to stay constant. For this exercise we want to control the inward flow so that the reservoir’s value equals ten. The reservoir’s initial value is zero for this experiment.

We start with a simple proportional controller: Here we have a set point equal to ten. The inward flow is modulated by a constant (Kp) multiplied by the error (set point minus the reservoir value). Simulating the system yields: We can see from these simulation results that the system is unable to track the set point of ten. It manages to achieve a constant value greater than zero however, so we are on the right track.

When we add an integral term to the control system we are able to track the set point. Here the error is integrated and the result is multiplied by gain “Ki”, which then is added to the proportional component and directed toward the system input: Now the reservoir’s value fills to and remains at ten: 