The original design purpose of the MIRTOS Operating System is to control an inexpensive, low-powered, dual output device, either with two pumps, or with a single pump and a flow-reversing control valve for filter media backwash. Either one or two Process Variables, i.e., Analog Input(s), such as a water tank level, obtained from local input(s) or received from a remote site via telemetry, is expected.
There is an independant and changeable Run Setpoint and a Stop Setpoint for each Discrete Output.
If the Run Setpoint and Stop Setpoint are the same, then the automatic control for that Discrete Output is disabled. This is the default state of each channel or control loop until a configuration is entered.
If the Run (or Start) Setpoint is less than the Stop Setpoint, then a "Pump In", or "Pump Up" or "Reservoir Fill" type of control is desired. A Discrete Output will turned ON when the associated Process Variable is below the Run Setpoint (i.e., run the pump to fill the tank.) It will be stopped when the Process Variable is above the Stop Setpoint (i.e., the tank is sufficiently full.) When the Process Variable is its Deadband, the Discrete Outputs will be left unchanged, either continuing to run, or continuing to stop (as odd as that phrase sounds.)
Conversely, if the Run (or Start) Setpoint is greater than the Stop Setpoint, then it is a "Pump Down" or "Pump Out" or "Sump Pump" type of control. The output will be energized, or called to run, above the Run Setpoint and deenergized, or called to Stop, below the Stop setpoint, and left alone within the Deadband.
This System Application is mostly configuration of one System Variable and the 16-byte Control Structure which it specifies. First, set EEbPumpCtrl_UVIndex in EEPROM to be the index of the first of sixteen (16) uVars.B[##] BYTEs to use. Then fill in the Control Structure starting at that uVars.B[ EEbPumpCtrl_UVIndex ] value in SRAM. For example, assuming that EEbPumpCtrl_UVIndex, at EEPROM address 0x2B is set to 32, and noting that value specifies SRAM address 0x2A0, the following Control Structure could be configured:
Offset | Variable name | SRAM Address | Value | Description, usage, notes |
---|---|---|---|---|
0 | wControlInterval | 0x2A0 | 250 | Interval between process updates |
2 | wLastUpdateTime | 0x2A2 | mSec | Timer starting millisecond value |
4 | bPump1PVIndex | 0x2A4 | 7 | Pump #1 Process Variable Analog Input index = ADC7 |
5 | bPump1DiscOut | 0x2A5 | 0 | Pump #1 Discrete Output index = 0 |
6 | wPump1RunSP | 0x2A6 | 0x100 | Pump #1 Run Setpoint = 256 |
8 | wPump1StopSP | 0x2A8 | 0x170 | Pump #1 Stop Setpoint = 368 |
10 | bPump2PVIndex | 0x2AA | 7 | Pump #2 Process Variable Analog Input index (same) |
11 | bPump2DiscOut | 0x2AB | 1 | Pump #2 Discrete Output index = 1 |
12 | wPump2RunSP | 0x2AC | 0x0A0 | Pump #2 Run Setpoint = 160 |
14 | wPump2StopSP | 0x2AE | 0x140 | Pump #2 Stop Setpoint = 320 |
A script can be used to do this:
This can be expressed a little more compactly:> E 0x2B = 32 ; Config starts at uVars.B[ 32 ] = 0x2A0 >ESW 0x2A0 = 250 mSec ; Interval: 250 mSec >ES 0x2A4 = 7 0 ; Pump #1: use AIn(7) and DOut(0) >ESW 0x2A6 = 0x100 0x170 ; Pump #1: run and stop setpoints >ES 0x2AA = 7 1 ; Pump #2: use AIn(7) and DOut(1) >ESW 0x2AC = 0x0A0 0x140 ; Pump #2: run and stop setpoints >E 1 |= 0x11 ; Enable both Pump Control and Auto A2D >
Or, this way, which is even more compact, but more cryptic and a little harder to understand what is being done:> E 0x2B = 32 >ESW 0x2A0 = 250 mSec 7 0x100 0x170 0x107 0xA0 0x140 >E 1 |= 0x11 >
> E 43 = 32 >ESW 672 = 250 M 7 256 368 263 160 320 >E 1 |= 17 >DV+ ; And the result is something like this: SRAM contents: 0280: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0290: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 02A0: FA 00 9B EE 07 00 00 01-70 01 07 01 A0 00 40 01 ........p.....@. 02B0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ >
Of course, the script lines above could be added to the startup script to automatically initialize the Pump Control Configuration structure when the device reboots.
To actually test this configuration, feed a variable signal into Analog Input 7, which are the pins immediately to the left of the power input on the SSG dual relay board. One way to do that is to use a trim pot. Connect Vcc on one side and ground on the other side. Then connect the center tap to the "+" (right) connection of AI7. Notice what happens to the Discrete Outputs as the trim pot is turned.
A great Analog Input for a tank level sensing application is one of the MaxSonar® units from MaxBotix®.
Notes: | |
When the Process Variable is in the Deadband, the pump output can be manually controlled to run or stop the pump. The control logic will leave the Discrete Output alone until the Process Variable crosses a Setpoint boundary then deenergize or energize the Discrete Output, as appropriate. This allows a tank to be "topped off", for example. | |
The range of Analog Input values is 0 to 0x3FF = 1,023. | |
An Analog Input value above 10 could be used to specify a scaled value or value received from a remote device. | |
Although the design is for pump control, this System Function can also be used to control temperature, flow, position, temperature, or chemical dosing, for example. |
See also: | |
The ReadAtoDValue System Function. |