Anti Windup Control of a Tank  
Author's Data: Housam BINOUS
Department of Chemical Engineering
National Institute of Applied Sciences and Technology
Tunis, TUNISIA
Email: binoushousam@yahoo.com

Feed flowrate is constant equal to 1

(Subscript[q, 0])[t_] := UnitStep[t]

Numerical solution of the governing equation for (Subscript[A, 1])=4 and (Subscript[k, 1])=0.5

(Subscript[A, 1]) = 4; (Subscript[k, 1]) = 0.5;

sol1 = 
      NDSolve[{(Subscript[q, 0])[t] - (Subscript[k, 1]) (Sqrt[(Subscript[h, 1])])[t] == (Subscript[A, 1]) 
              D[(Subscript[h, 1])[t], {t, 1}], 
(Subscript[h, 1])[0] == 
            0}, {(Subscript[h, 1])[t]}, {t, 0, 1000}]

Plotting height of the tank versus time

plt1 = 
      Plot[{(Subscript[h, 1])[t] /. sol1}, {t, 0, 200}, 
        PlotStyle -> {RGBColor[1, 0, 0]}]

Control of the height of the tank (set point equal to 2) by manipulating the feed flow rate using a proportional controller.

Proportional controller gain (Subscript[K, p]) = 5

(Subscript[K, p]) = 5; hset = 2;

Feed flowrate

(Subscript[q, 0])[t_] := Max[0, 1 + (Subscript[K, p]) (hset - (Subscript[h, 1])[t])]

Numerical solution of the governing equation for (Subscript[A, 1])=4, and (Subscript[k, 1]) = 0.5

sol2 = 
      NDSolve[{(Subscript[q, 0])[t] - (Subscript[k, 1]) (Sqrt[(Subscript[h, 1])])[t] == (Subscript[A, 1]) 
              D[(Subscript[h, 1])[t], {t, 1}], 
(Subscript[h, 1])[0] == 
            0}, {(Subscript[h, 1])[t]}, {t, 0, 1000}]

Plotting heights of the tanks versus time

plt2 = 
      Plot[{(Subscript[h, 1])[t] /. sol2}, {t, 0, 10}, 
        PlotStyle -> {RGBColor[1, 0, 0]}, 
        PlotRange ->  All]

Plotting controller's output (manipulated input) versus time

plt3 = 
      Plot[(Subscript[K, p]) (hset - (Subscript[h, 1])[t]) /. sol2, {t, 0, 10}, 
        PlotStyle -> {RGBColor[1, 0, 0]}, 
        PlotRange ->  All]

Feed flowrate for anti windup case

(Subscript[q, 0])[t_] := Max[0, 1 + u[(Subscript[K, p]) (hset - (Subscript[h, 1])[t])]]

umax = 3; umin = -0.5;

u[x_] := If[x > umax, umax, If[x < umin, umin, x]]

Numerical solution of the governing equations for (Subscript[A, 1])=4, and (Subscript[k, 1]) = 0.5

sol3 = 
      NDSolve[{(Subscript[q, 0])[t] - (Subscript[k, 1]) (Sqrt[(Subscript[h, 1])])[t] == (Subscript[A, 1]) 
              D[(Subscript[h, 1])[t], {t, 1}], 
(Subscript[h, 1])[0] == 
            0}, {(Subscript[h, 1])[t]}, {t, 0, 1000}]

Plotting heights of the tanks versus time

plt4 = 
      Plot[{(Subscript[h, 1])[t] /. sol3}, {t, 0, 10}, 
        PlotStyle -> {RGBColor[0, 0, 1]}, 
        PlotRange ->  All]

Plotting controller's output  (manipulated input) versus time

plt5 = 
      Plot[u[(Subscript[K, p]) (hset - (Subscript[h, 1])[t])] /. sol3, {t, 0, 10}, 
        PlotStyle -> {RGBColor[0, 0, 1]}, 
        PlotRange ->  All]

Comparing both strategies

Show[plt2, plt4]

Show[plt3, plt5]

Both cases (with and without anti windup) with PI controller

Feed flowrate

(Subscript[q, 0])[t_] := 
      Max[0, 1 + (Subscript[K, p]) (hset - (Subscript[h, 1])[t]) + 
          (Subscript[K, p])/(Subscript[τ, I]) int[t]]

(Subscript[τ, I]) = 2;

Numerical solution of the governing equations for (Subscript[A, 1])=4 and (Subscript[k, 1]) = 0.5.

sol4 = 
      NDSolve[{(Subscript[q, 0])[t] - (Subscript[k, 1]) (Sqrt[(Subscript[h, 1])])[t] == (Subscript[A, 1]) 
              D[(Subscript[h, 1])[t], {t, 1}], 
D[
              int[t], {t, 1}] == hset - (Subscript[h, 1])[t], (Subscript[h, 1])[0] == 0, 
          int[0] == 0}, {(Subscript[h, 1])[t], int[t]}, {t, 0, 1000}]

Plotting heights of the two tanks versus time

plt6 = 
      Plot[{(Subscript[h, 1])[t] /. sol4}, {t, 0, 20}, 
        PlotStyle -> {RGBColor[1, 0, 0]}, 
        PlotRange ->  All]

Plotting controller's output (manipulated input) versus time

plt7 = 
      Plot[(Subscript[K, p]) (hset - (Subscript[h, 1])[t]) + (Subscript[K, p])/(Subscript[τ, I]) int[t] /. 
          sol4, {t, 0, 10}, PlotStyle -> {RGBColor[1, 0, 0]}, 
        PlotRange ->  All]

Feed flowrate for anti windup case

(Subscript[q, 0])[t_] := 
      Max[0, 1 + 
          u[(Subscript[K, p]) (hset - (Subscript[h, 1])[t]) + 
              (Subscript[K, p])/(Subscript[τ, I]) int[t]]]

umax = 3; umin = -1.0;

u[x_] := If[x > umax, umax, If[x < umin, umin, x]]

Numerical solution of the governing equations for (Subscript[A, 1])=4 and (Subscript[k, 1]) = 0.5.

sol5 = 
      NDSolve[{(Subscript[q, 0])[t] - (Subscript[k, 1]) (Sqrt[(Subscript[h, 1])])[t] == (Subscript[A, 1]) 
              D[(Subscript[h, 1])[t], {t, 1}], 
D[
              int[t], {t, 1}] == hset - (Subscript[h, 1])[t], (Subscript[h, 1])[0] == 0, 
          int[0] == 0}, {(Subscript[h, 1])[t], int[t]}, {t, 0, 1000}]

Plotting heights of the two tanks versus time

plt8 = 
      Plot[{(Subscript[h, 1])[t] /. sol5}, {t, 0, 50}, 
        PlotStyle -> {RGBColor[0, 0, 1]}, 
        PlotRange ->  All]

Plotting controller's output (manipulated input) versus time

plt9 = 
      Plot[u[(Subscript[K, p]) (hset - (Subscript[h, 1])[t]) + (Subscript[K, p])/(Subscript[τ, I]) int[t]] /. 
          sol5, {t, 0, 20}, PlotStyle -> {RGBColor[0, 0, 1]}, 
        PlotRange ->  All]

Comparing both strategies

Show[plt6, plt8]

Show[plt7, plt9]