File view
| 1 | # PLC-5000 I/O Site Configuration Matrix |
| 2 | |
| 3 | ## Hardware Constraints |
| 4 | |
| 5 | | Resource | Max | Define | |
| 6 | |-------------------|-----|----------------| |
| 7 | | Output Bits | 8 | `N_OUTPUTS` | |
| 8 | | IS Input Bits | 8 | `N_INPUTS` | |
| 9 | | AC Input Bits | 8 | `N_AC_INPUTS` | |
| 10 | | Channels/Turbines | 4 | `N_ISM` | |
| 11 | | Products | 4 | `N_PROD` | |
| 12 | | Piston Switches | 4 | `N_PRES_INPUTS`| |
| 13 | | Auth Inputs | 4 | `N_AUTH_INPUTS` | |
| 14 | |
| 15 | Compile-time flags assumed (current defaults from `PLC.c`): |
| 16 | - `MODBUS_M_ON = 1` (LDN pressure via Modbus master) |
| 17 | - `ALARM_PER_PROD = 1` (one alarm output per product, not per channel) |
| 18 | - `CV_ON = 1` (control valves enabled) |
| 19 | - `RESET_ALL_INPUT = 1` (last free AC input = Reset All) |
| 20 | - `DISABLE_INPUT = 0` (auth inputs are NOT used as disable) |
| 21 | |
| 22 | --- |
| 23 | |
| 24 | ## General Output Mapping Formula (Bits 0-7) |
| 25 | |
| 26 | ``` |
| 27 | Bit Range | Function |
| 28 | ------------------------------------|-------------------------------------------- |
| 29 | 0 to T-1 | Turbine Pump outputs (1 per turbine) |
| 30 | T to 3 | UNUSED (gap if T < 4) |
| 31 | 4 to 4+C-1 | Control Valve outputs (CV_OFFSET = 4) |
| 32 | 4+C to 4+C+P-1 | Alarm outputs (1 per product)* |
| 33 | ``` |
| 34 | |
| 35 | Where: |
| 36 | - **T** = total turbines across all products (`Config.N_Turbines`) |
| 37 | - **C** = total control valves across all products (`Config.N_CVs` = sum of all SCV+PCV+DCV) |
| 38 | - **P** = number of products (`Config.N_Products`) |
| 39 | |
| 40 | ### CV Output Sub-ordering (within the CV range) |
| 41 | |
| 42 | For each product sequentially: |
| 43 | 1. **SCV** (Solenoid Control Valves) first |
| 44 | 2. **PCV** (Pressure Control Valves) next |
| 45 | 3. **DCV** (Demand Control Valves) last |
| 46 | |
| 47 | ``` |
| 48 | Product 0 SCVs → Product 0 PCVs → Product 0 DCVs → Product 1 SCVs → Product 1 PCVs → ... |
| 49 | ``` |
| 50 | |
| 51 | ### Alarm Output Overflow Rules |
| 52 | |
| 53 | | Condition | Behavior | |
| 54 | |----------------------------|-----------------------------------------------| |
| 55 | | `C <= 4 - P` | Individual alarm output per product at bit 4+C+i | |
| 56 | | `4 - P < C < 4` | Combined alarm for all products at bit 7 | |
| 57 | | `C >= 4` | NO alarm output (all output bits consumed by CVs) | |
| 58 | |
| 59 | *Source: `WriteOutputs()` in `plc_outputs.lib`* |
| 60 | |
| 61 | --- |
| 62 | |
| 63 | ## General Input Mapping Formula |
| 64 | |
| 65 | ### IS Inputs (Intrinsically Safe - `Inputs[]` array) |
| 66 | |
| 67 | ``` |
| 68 | Bit Range | Function |
| 69 | ------------------|-------------------------------------------------- |
| 70 | 0 to PS-1 | Sump Sensor + High Pressure Switch (per piston switch) |
| 71 | PS to 7 | UNUSED |
| 72 | ``` |
| 73 | |
| 74 | Where **PS** = total piston switches across all products (`Config.N_PS`). |
| 75 | |
| 76 | Each piston switch gets one IS input. Turbines within a product that exceed the piston switch count share the previous turbine's IS input (via `Channel[j].IOPS`). |
| 77 | |
| 78 | With `MODBUS_M_ON = 1`: |
| 79 | - Primary pressure readings come from LDN sensors via Modbus, NOT from IS inputs |
| 80 | - The IS input serves as: **Sump sensor** (if `NoSumpFlag = 0`) AND **high pressure switch confirmation** |
| 81 | - Both use the same physical input bit (`SUMP_OFFSET = 0`) |
| 82 | |
| 83 | ### AC Inputs (Authorization - `AC_Inputs[]` array) |
| 84 | |
| 85 | ``` |
| 86 | Bit Range | Function |
| 87 | ------------------|-------------------------------------------------- |
| 88 | 0 to T-1 | Authorization input (1 per turbine/channel) |
| 89 | T to 2 | UNUSED (if T < 3) |
| 90 | 3 | Reset All* (if T < 4) |
| 91 | 4 to 7 | UNUSED |
| 92 | ``` |
| 93 | |
| 94 | Where **T** = total turbines. |
| 95 | |
| 96 | *Reset All is only available when `Config.N_Turbines < N_AUTH_INPUTS (4)` and `RESET_ALL_INPUT = 1`. It uses `AC_Inputs[3]` (index `AUTH_OFFSET + N_AUTH_INPUTS - 1`).* |
| 97 | |
| 98 | **DCV Demand Note:** When a product has DCVs, the AC auth inputs for that product's turbines also serve as DCV demand signals. `ACInputs[Product[i].FirstTurbine + j]` controls `DCV[j]`. The same physical signal that authorizes a turbine also opens its corresponding DCV. |
| 99 | |
| 100 | --- |
| 101 | |
| 102 | ## Output Matrix by Site Configuration (Max 2 Products) |
| 103 | |
| 104 | ### Legend |
| 105 | - **P1T1** = Product 1, Turbine 1 Pump output |
| 106 | - **P1-SCV1** = Product 1, Solenoid Control Valve 1 |
| 107 | - **P1-ALM** = Product 1, Alarm output |
| 108 | - **COMBINED-ALM** = Shared alarm output for all products |
| 109 | - `—` = Unused |
| 110 | |
| 111 | ### 1-Product Configurations |
| 112 | |
| 113 | | Output Bit | 1P/1T/0CV | 1P/2T/0CV | 1P/2T/1SCV | 1P/2T/1S+1P | 1P/3T/0CV | 1P/4T/0CV | 1P/4T/1SCV | 1P/4T/2SCV | 1P/4T/3SCV | |
| 114 | |:----------:|:---------:|:---------:|:----------:|:------------:|:---------:|:---------:|:----------:|:----------:|:----------:| |
| 115 | | **0** | P1T1 | P1T1 | P1T1 | P1T1 | P1T1 | P1T1 | P1T1 | P1T1 | P1T1 | |
| 116 | | **1** | — | P1T2 | P1T2 | P1T2 | P1T2 | P1T2 | P1T2 | P1T2 | P1T2 | |
| 117 | | **2** | — | — | — | — | P1T3 | P1T3 | P1T3 | P1T3 | P1T3 | |
| 118 | | **3** | — | — | — | — | — | P1T4 | P1T4 | P1T4 | P1T4 | |
| 119 | | **4** | P1-ALM | P1-ALM | P1-SCV1 | P1-SCV1 | P1-ALM | P1-ALM | P1-SCV1 | P1-SCV1 | P1-SCV1 | |
| 120 | | **5** | — | — | P1-ALM | P1-PCV1 | — | — | P1-ALM | P1-SCV2 | P1-SCV2 | |
| 121 | | **6** | — | — | — | P1-ALM | — | — | — | P1-ALM | P1-SCV3 | |
| 122 | | **7** | — | — | — | — | — | — | — | — | COMB-ALM | |
| 123 | |
| 124 | ### 2-Product Configurations |
| 125 | |
| 126 | | Output Bit | 2P/1+1T/0CV | 2P/1+1T/1+1SCV | 2P/2+1T/0CV | 2P/2+2T/0CV | 2P/2+2T/1+1SCV | |
| 127 | |:----------:|:-----------:|:---------------:|:-----------:|:-----------:|:---------------:| |
| 128 | | **0** | P1T1 | P1T1 | P1T1 | P1T1 | P1T1 | |
| 129 | | **1** | P2T1 | P2T1 | P1T2 | P1T2 | P1T2 | |
| 130 | | **2** | — | — | P2T1 | P2T1 | P2T1 | |
| 131 | | **3** | — | — | — | P2T2 | P2T2 | |
| 132 | | **4** | P1-ALM | P1-SCV1 | P1-ALM | P1-ALM | P1-SCV1 | |
| 133 | | **5** | P2-ALM | P2-SCV1 | P2-ALM | P2-ALM | P2-SCV1 | |
| 134 | | **6** | — | P1-ALM | — | — | P1-ALM | |
| 135 | | **7** | — | P2-ALM | — | — | P2-ALM | |
| 136 | |
| 137 | --- |
| 138 | |
| 139 | ## IS Input Matrix by Site Configuration |
| 140 | |
| 141 | Assumes `N_PistonSwitches = N_Turbines` per product (typical). |
| 142 | |
| 143 | ### 1-Product Configurations |
| 144 | |
| 145 | | IS Input Bit | 1P/1T | 1P/2T | 1P/3T | 1P/4T | |
| 146 | |:------------:|:-----:|:-----:|:-----:|:-----:| |
| 147 | | **0** | Sump/HiPres 1 | Sump/HiPres 1 | Sump/HiPres 1 | Sump/HiPres 1 | |
| 148 | | **1** | — | Sump/HiPres 2 | Sump/HiPres 2 | Sump/HiPres 2 | |
| 149 | | **2** | — | — | Sump/HiPres 3 | Sump/HiPres 3 | |
| 150 | | **3** | — | — | — | Sump/HiPres 4 | |
| 151 | | **4-7** | — | — | — | — | |
| 152 | |
| 153 | ### 2-Product Configurations |
| 154 | |
| 155 | | IS Input Bit | 2P/1+1T | 2P/2+1T | 2P/2+2T | 2P/1+3T | 2P/3+1T | |
| 156 | |:------------:|:-------:|:-------:|:-------:|:-------:|:-------:| |
| 157 | | **0** | P1-Sump/HiPres | P1-Sump/HiPres 1 | P1-Sump/HiPres 1 | P1-Sump/HiPres | P1-Sump/HiPres 1 | |
| 158 | | **1** | P2-Sump/HiPres | P1-Sump/HiPres 2 | P1-Sump/HiPres 2 | P2-Sump/HiPres 1 | P1-Sump/HiPres 2 | |
| 159 | | **2** | — | P2-Sump/HiPres | P2-Sump/HiPres 1 | P2-Sump/HiPres 2 | P1-Sump/HiPres 3 | |
| 160 | | **3** | — | — | P2-Sump/HiPres 2 | P2-Sump/HiPres 3 | P2-Sump/HiPres | |
| 161 | | **4-7** | — | — | — | — | — | |
| 162 | |
| 163 | --- |
| 164 | |
| 165 | ## AC Input Matrix by Site Configuration |
| 166 | |
| 167 | ### 1-Product Configurations |
| 168 | |
| 169 | | AC Input Bit | 1P/1T | 1P/2T | 1P/3T | 1P/4T | |
| 170 | |:------------:|:-----:|:-----:|:-----:|:-----:| |
| 171 | | **0** | Auth T1 | Auth T1 | Auth T1 | Auth T1 | |
| 172 | | **1** | — | Auth T2 | Auth T2 | Auth T2 | |
| 173 | | **2** | — | — | Auth T3 | Auth T3 | |
| 174 | | **3** | **Reset All** | **Reset All** | **Reset All** | Auth T4 | |
| 175 | | **4-7** | — | — | — | — | |
| 176 | |
| 177 | ### 2-Product Configurations |
| 178 | |
| 179 | | AC Input Bit | 2P/1+1T | 2P/2+1T | 2P/2+2T | 2P/1+3T | 2P/3+1T | |
| 180 | |:------------:|:-------:|:-------:|:-------:|:-------:|:-------:| |
| 181 | | **0** | P1-Auth T1 | P1-Auth T1 | P1-Auth T1 | P1-Auth T1 | P1-Auth T1 | |
| 182 | | **1** | P2-Auth T1 | P1-Auth T2 | P1-Auth T2 | P2-Auth T1 | P1-Auth T2 | |
| 183 | | **2** | — | P2-Auth T1 | P2-Auth T1 | P2-Auth T2 | P1-Auth T3 | |
| 184 | | **3** | **Reset All** | **Reset All** | P2-Auth T2 | P2-Auth T3 | P2-Auth T1 | |
| 185 | | **4-7** | — | — | — | — | — | |
| 186 | |
| 187 | **Key observations:** |
| 188 | - **Reset All** is available at AC Input 3 ONLY when total turbines < 4 |
| 189 | - When total turbines = 4, ALL AC inputs are consumed by auth — no Reset All available |
| 190 | - With `DISABLE_INPUT = 1` (not current default), the last turbine's AC input in each product becomes a disable input instead of auth |
| 191 | |
| 192 | --- |
| 193 | |
| 194 | ## How Shifting Works — Walkthrough |
| 195 | |
| 196 | ### Example: Adding a 2nd product to a 1-product / 2-turbine / 1-SCV site |
| 197 | |
| 198 | **Before (1P/2T/1SCV):** |
| 199 | ``` |
| 200 | OUTPUTS: [P1T1][P1T2][ — ][ — ][P1-SCV][ P1-ALM ][ — ][ — ] |
| 201 | Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 |
| 202 | |
| 203 | IS: [Sump1][Sump2][ — ][ — ][ — ][ — ][ — ][ — ] |
| 204 | Bit0 Bit1 ... |
| 205 | |
| 206 | AC: [Auth1][Auth2][ — ][RESET][ — ][ — ][ — ][ — ] |
| 207 | Bit0 Bit1 Bit2 Bit3 ... |
| 208 | ``` |
| 209 | |
| 210 | **After adding Product 2 (1 turbine, 1 SCV) → 2P / 2+1T / 1+1SCV:** |
| 211 | ``` |
| 212 | OUTPUTS: [P1T1][P1T2][P2T1][ — ][P1-SCV][P2-SCV][ P1-ALM ][ P2-ALM ] |
| 213 | Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 |
| 214 | |
| 215 | IS: [P1-Sump1][P1-Sump2][P2-Sump1][ — ][ — ][ — ][ — ][ — ] |
| 216 | Bit0 Bit1 Bit2 ... |
| 217 | |
| 218 | AC: [P1-Auth1][P1-Auth2][P2-Auth1][RESET][ — ][ — ][ — ][ — ] |
| 219 | Bit0 Bit1 Bit2 Bit3 ... |
| 220 | ``` |
| 221 | |
| 222 | **What shifted:** |
| 223 | - Output Bit 2: `—` → **P2 Turbine 1 Pump** |
| 224 | - Output Bit 5: `P1 Alarm` → **P2 SCV** (P1 Alarm pushed to Bit 6) |
| 225 | - Output Bit 6: `—` → **P1 Alarm** (shifted right by 1 due to new CV) |
| 226 | - Output Bit 7: `—` → **P2 Alarm** (new) |
| 227 | - IS Input Bit 2: `—` → **P2 Sump/HiPres** |
| 228 | - AC Input Bit 2: `—` → **P2 Auth T1** |
| 229 | |
| 230 | ### Example: Adding a CV to an existing product |
| 231 | |
| 232 | **Before (1P/2T/0CV):** |
| 233 | ``` |
| 234 | OUTPUTS: [P1T1][P1T2][ — ][ — ][ P1-ALM ][ — ][ — ][ — ] |
| 235 | Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 |
| 236 | ``` |
| 237 | |
| 238 | **After adding 1 SCV → 1P/2T/1SCV:** |
| 239 | ``` |
| 240 | OUTPUTS: [P1T1][P1T2][ — ][ — ][ P1-SCV ][ P1-ALM ][ — ][ — ] |
| 241 | Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 |
| 242 | ``` |
| 243 | |
| 244 | **What shifted:** |
| 245 | - Output Bit 4: `P1 Alarm` → **P1 SCV** (alarm pushed to Bit 5) |
| 246 | - Output Bit 5: `—` → **P1 Alarm** (shifted right by 1) |
| 247 | - IS and AC inputs: unchanged (CVs don't affect input mapping) |
| 248 | |
| 249 | --- |
| 250 | |
| 251 | ## Maximum Configurations Before Overflow |
| 252 | |
| 253 | | Products | Max Turbines | Max CVs (with per-product alarm) | Max CVs (with combined alarm) | Max CVs (no alarm) | |
| 254 | |:--------:|:------------:|:--------------------------------:|:-----------------------------:|:-------------------:| |
| 255 | | 1 | 4 | 3 | 3* | 4 | |
| 256 | | 2 | 4 | 2 | 3 | 4 | |
| 257 | |
| 258 | *With 1 product, "combined" is the same as "individual" since there's only 1 alarm output needed. |
| 259 | |
| 260 | **Hard limits:** |
| 261 | - Total turbines: 4 (limited by `N_ISM`) |
| 262 | - Total turbines + total CVs + alarm outputs must fit in 4 bits (bits 4-7) |
| 263 | - Total piston switches must be <= 8 (limited by `N_INPUTS`, typically = total turbines) |
| 264 | - Total turbines must be <= 4 for auth inputs (limited by `N_AUTH_INPUTS`); at 4, Reset All is lost |
| 265 | |
| 266 | --- |
| 267 | |
| 268 | ## Configuration Variables That Drive I/O Shifts |
| 269 | |
| 270 | | Variable (per product) | Affects Outputs | Affects IS Inputs | Affects AC Inputs | |
| 271 | |---------------------------|---------------------------|----------------------|------------------------| |
| 272 | | `N_Turbines` | Turbine bits 0 to T-1 | — | Auth bits 0 to T-1 | |
| 273 | | `N_PistonSwitches` | — | IS bits 0 to PS-1 | — | |
| 274 | | `CV.SCV` (count) | CV bits, shifts alarms | — | — | |
| 275 | | `CV.PCV` (count) | CV bits, shifts alarms | — | — | |
| 276 | | `CV.DCV` (count) | CV bits, shifts alarms | — | DCV demand shares auth | |
| 277 | | `N_Products` (global) | Alarm bit count | — | Reset All availability | |
| 278 | |
| 279 | --- |
| 280 | |
| 281 | ## Source Code References |
| 282 | |
| 283 | | Function / File | What it controls | |
| 284 | |------------------------------|------------------------------------------| |
| 285 | | `ChannelSetup()` in `PLC.c` | IOPS assignment, CV IO channel positions | |
| 286 | | `WriteOutputs()` in `plc_outputs.lib` | Output bit writing logic | |
| 287 | | `InputHandler()` in `plc_inputs.lib` | Input scanning and flag setting | |
| 288 | | `InitChannel()` in `plc_configuration.lib` | Default IOChannel = channel index | |
| 289 | | Constants in `plc_constants.lib` | `CV_OFFSET=4`, `N_OUTPUTS=8`, `SUMP_OFFSET=0`, etc. | |