Aquarium Dosing Controller Model

samba_dad

Active Member
View Badges
Joined
Jun 6, 2014
Messages
475
Reaction score
155
Location
Huntsville, Alabama
Rating - 0%
0   0   0
Okay gear heads and engineers...I have put together a simple PID controller model to control the alkalinity of my 65g reef tank and I would like your feedback. This is most likely going to be the basis for a midterm or final exam for a DSP course I am teaching this summer.

The first step was to come up with the differential equation that models the alkalinity levels within the tank. I made quite a few assumptions here that may not be accurate. The equation I used was a simple first order ordinary differential equation of the form (recall your favorite word problems from DE class - dy/dt=rate in-rate out)

dy/dt=g*u(t)-k

where y(t) represents the output which is current alkalinity level in dKH in the tank, u(t) is the input amount in mL of alkalinity added to the tank each day through dosing, g is a gain that converts dosage amount in mL to dKH provided by the vendor and scaled for my size tank (e.g. In my case I use Red Sea supplements and they state 1mL/100L=0.034dKH and I just scaled this for my 65g tank and 15g sump), k is the amount of daily consumption by the corals I measure in my tank (e.g. stop dosing for 4 days and calculate daily average consumption rate by taking the difference of the readings after and before and divide by 4). This equation represents the "plant/process" model we wish to control with an input of daily alkalinity dosed in mL and an output of tank alkalinity in dKH where the unit conversions are accounted for with the model

The PID controller is designed to operate on the error or difference between a desired alkalinity level (called the set point) and the actual alkalinity level in the tank. Basically, it applies a gain that is (P)roportional to the error, proportional to the (I)ntegral of the error, and proportional to the (D)erivative of the error. Also, we must apply a non linearity to the controller to limit the dosing amount to only positive levels because we cannot "undose" or extract alkalinity from the tank. In addition, the model has initial conditions for initial alkalinity levels in dKH for the tank under control. Once we set this up, we can apply all types of control theory to tune these gains to achieve desired results.

I put all of this together in a MATLAB/Simulink model as shown below.
dbe5af54a81a564e460fa1fdf2fd489f.jpg


I based this controller implementation on a daily update. In other words, I assume we only measure once per day and adjust dosing amounts on those daily measurements. The results of the simulation are shown below...

d0e279b13c26073ed1f9bc67b24bd47b.jpg

166a3ef163649f3051b2bd917f7064c6.jpg

2462d9b497a72f908e4db087dc484a3b.jpg


With the gains I used for the PID controller, everything is settled within 7 days to close to the desired set point. What's powerful about this approach is that we can now insert some disturbance inputs that can account for measurement error and inaccuracies in our process model and still maintain robust control.

Now imagine this. What if we could get fairly accurate measurements multiple times per day. We could much more quickly obtain desired set point values and keep them there. Most SPS have problems on rapid increases of alkalinity and this would have to be rate limited to ensure we do not harm our livestock. Whatever happened to Mindstream anyway?

Anyway, please send me your feedback. I know there are plenty of control freaks and gear heads out there who will have some good ideas. I love this hobby!
 
Have you considered a CA reactor?

Not yet. The only difference would be identifying the mathematical model that relates amount of solenoid time "on" to amount of dKH added. This could be obtained experimentally if this is an unknown relationship. Randy Holmes-Farley may know if that exists. I will ask him.
 
KHG auto Alk dosing.
You wouldn't have heard about it as it is as it is a Chinese unit. Has been in use for several years in beta testing.
Cost is $1063.00 dollars. [emoji3]

44dd2100f5e95560a0024517ea82c0ab.jpg
 

IF YOU HAD TO TAKE A REEFING EXAM, WOULD YOU PASS?

  • Yes!

    Votes: 32 45.7%
  • Not yet, but I have one that I want to buy in mind!

    Votes: 9 12.9%
  • No.

    Votes: 26 37.1%
  • Other (please explain).

    Votes: 3 4.3%

New Posts

Back
Top