CCST 41 — 4-20 mA Scaling with a Live-Zero Check
Ready to build this?
Sign up free — no credit card required. This scenario requires the Pro plan.
Sign up to play this scenario →Already have an account? Log in
Not ready for Pro? Try a free scenario like this →
Briefing
A pressure transmitter sends a 4-20 mA signal. The analog card gives LOOP_MA_X10, the current in tenths of a milliamp, so 4.0 mA reads 40 and 20.0 mA reads 200. Two jobs: 1. PV_PCT is the process variable as a percentage of range: 4 mA is 0 percent and 20 mA is 100 percent. A result within 1 of the true value is accepted. 2. SIGNAL_FAULT is on when the current falls outside the live-zero window: below 3.6 mA (36) or above 21.0 mA (210). The signal never goes below 4 mA when the loop is healthy, so a reading near 0 is a broken wire, not a zero process value. Whole-number maths keeps no fraction, so multiply before you divide. The in-between product is bigger than a small integer; use a DINT for it. Maths is built with Math boxes (ADD, SUB, MUL and DIV), or in the Code tab one assignment per line. Comparisons are built with Compare boxes, or in the Code tab as contacts, for example | (A > B) | := LAMP ;
Objectives
- 4.0 mA (40) gives 0 percent, 12.0 mA (120) gives 50 and 20.0 mA (200) gives 100
- A current between the edges of the window leaves SIGNAL_FAULT off
- Below 3.6 mA (36) or above 21.0 mA (210) turns SIGNAL_FAULT on
Hints
- The signal does not start at zero. Which part of the current is the real process span, and which part is just the live-zero offset?
- Think of the scaling as a fraction of the span: how far above the bottom of the signal is the reading, out of the full distance from bottom to top?
- Whole-number division throws the fraction away, so a small number divided by a larger one becomes 0. Decide which operation must come first, and where the bigger in-between value is held.
- Check 40, 80, 120 and 200 in the input panel: they should read about 0, 25, 50 and 100. Then try 20 and 230: the fault should come on for both.
I/O Table
Inputs
LOOP_MA_X10Loop current in tenths of a milliamp (40 = 4.0 mA)
INT · %IW0
Outputs
PV_PCTProcess variable, 0-100 percent of range
INT · %QW0
SIGNAL_FAULTLoop current outside the 3.6-21.0 mA live-zero window
BOOL · %Q0.0
Your program will be tested against:
All test cases run automatically when you submit. Assertions are hidden until you pass.
- #14.0 mA → 0 percent
The bottom of the signal is 0 percent
- #28.0 mA → 25 percent
A quarter of the 16 mA span
- #312.0 mA → 50 percent
Mid-scale
- #420.0 mA → 100 percent
Top of the signal
- #5Healthy signal → no fault
No fault anywhere inside the window
- #60.0 and 2.0 mA → fault
A dead or broken loop is flagged
- #723.0 mA → fault
A shorted loop or saturated transmitter is flagged
- #810.0 mA → about 37.5 percent
A reading that does not divide evenly
- #9Window edges: 3.6 and 21.0 mA are healthy
Exactly on the edge is not a fault; one tenth outside is
Related scenarios
Ready to build this?
Sign up free — no credit card required. This scenario requires the Pro plan.
Sign up to play this scenario →Already have an account? Log in
Not ready for Pro? Try a free scenario like this →