PID May Not Be Necessary
For many basic applications, PID may be overkill. Proportional control can be simply proportional without the need of Integral and Derivative calculations. Stick with Proportional and use "Timed Proportional" control commonly used for digital output control of valves, dosing pumps, and other on/off actuators. Therefore, this only requires a few basic math instructions.
For example, if a 4 second timer is used and the Proportional output value is 50%, the digital output is on for 2 seconds and off for 2 seconds. 75% would be on for 3 and off for 1 and so on.
Below is not a specific programming language, but it should be sufficient to get an idea of rudimentary timed proportional control.
Using PH and a dosing pump as as an example, this could be done to keep a solution from being acidic:
- IN = pH Probe Input value
- MAX = 7.5 pH
- PBand = 1pH
- Error = MAX - IN
- LOW = (MAX - PBand)
- Timer_PRE = 4000 Milliseconds
- Timer_ACC = Accumulated time
- Timer_DN = Timer done
- Percent = 0 - 1.00
- Output_Time = Timer_PRE * Percent
- Dig_Out = Dosing Pump on
// First Determine the percentage
If (IN < LOW) Percent = 1.00;
If ((IN > LOW)&&(IN < MAX)) Percent = (Error/PBand);
If (IN > MAX) Percent = 0;
// Compare the timer's accumulated value to the output time to set the digital output. This timer resets continuously. Use a minimum requirement to inhibit the output from chattering. In this case, 1/2 second (500 Milliseconds).
If (
Output_Time <
Timer_ACC)
Turn off Dig_Out;
If (
Timer_DN) {
Reset Timer;
If (Output_Time > 500) Turn on Dig_Out;
}
This can be reversed for adding Acid(downward targeting). There can also be more complex features added such as ramping, variable set points and offsets. No PID instructions are necessary. Different control systems will react exactly the same without having to deal with multiple proprietary configurations. The only "tuning" necessary is the timer preset length and the PBand size.
Cheers!