FA-92222 / PLC ladder logic scan cycles / Member archive
Analog scaling divides by the 0-20 mA span · case 02
Readings are compressed and full scale is never reached at 20 mA.
Case contract
Scale a 4-20 mA analog channel read once per scan. Raw counts are proportional to 0-20 mA with 20 mA = 31208 counts, so 4 mA = 6242. Below 3.6 mA (raw*200 < 36*31208) the channel reports open wire and above 20.5 mA (raw*40 > 41*31208) over-range; in both cases it returns the last good value (None before any). Otherwise the engineering value in tenths is eng_lo*10 + (raw-6242)*(eng_hi-eng_lo)*10 / 24966 rounded half up, clamped to the configured range (reverse-acting ranges allowed). Return [status, tenths] per scan.
Why this case matters
Ladder programs are executed as repeated scans; each defect here changes what a rung, timer, counter or data-table instruction reports on a particular scan, which is how commissioning and field faults are actually observed.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: reverse acting valve | [["ok", 1000], ["ok", 800], ["ok", 200], ["ok", 187], ["ok", 1000]] | [["ok", 1000], ["ok", 750], ["ok", 0], ["ok", 0], ["ok", 1000]] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗