A day after installing the hardware and upgrading the firmware to control the pH and EC using an Arduino, the results are as expected-the steady state trends just above the setpoint.
Keeping the pH and EC to a desired set point uses a simple on/off approach. The use of a a PID controller was briefly considered and in the spirit of the minimum viable product, I opted for something simple for now.
Armed with three peristaltic pumps and another on way, some scrap wood, and additional code, a functional setup connected to the Arduino based control panel led to the following setup.
Diluting Fertilizers and pH Down solutions
The peristaltic pumps used have a max flow rate of 70 mL/min. Note I received one in the batch that could only pump 27 mL/min so I ended up using that one to control pH.
I opted for constant speed control rather than variable speed and avoided having to deal with PWM and filters to generate the analog output. Based on this information and erring on the safe side, a minimum dispensed volume of 4 ml was assumed. Using trial and error a dilution ratio of 4:1 water:fertilizer and 3:1 water:vinegar make up source to feed the nutrient tank (100 L). Without dilution, the EC and pH spiked as shown below.
As stated early, on/off control frames the approach to keeping the pH and EC at the desired setpoint.
Hand – Dispense fixed volume (mL) and stop. Volume to dispense set from HMI and saved in the Arduino’s non-volatile memory.
Off – turn off pump
Auto – Dispense a fixed volume (mL) every interval (s) . Volume and Interval set from HMI and saved in the Arduino’s non-volatile memory.
- Dispense if ( error = (setpoint – present value)) < 0 and trend to control on rising
- Dispense if (error = (setpoint – present value)) > 0 and the trend to control on is falling
- Stop dispensing when PV is 5% above or below SP depending on the trend to control. This minimizes unnecessary on/off chatter around the SP.
EC – Desired trend is falling trend. e.g. when below SP control apply control
- SP = 1050, PV = 1020
- error = 1050 – 1020 = 30 > 0
- trend desired: falling
- Result: control pump
- Stop control when PV = 1050 * 1.05 ~ 1100
pH – Desired trend is rising trend. e.g. when above SP control apply control
- SP = 6, PV = 6.2
- error = 6 – 6.2 = -0.2 < 0
- trend desired: rising
- Result: control pump
- Stop control when PV = 6* .95 = 5.7
The following charts illustrates the result. The left side is when I first moved the controller into Auto and was not tuned to the given process. Both pH and EC respond to drastically to the step change. The right side highlights the EC needing control and the bump in process is not as drastic. One day I may revert to implementing the P part of the PID and dispense the volume based magnitude of the error. So far there is no need for that.