Skip to content

SCP — Scale with Parameters

Category
Compute
Type
Output
Availability
All platforms

SCP instruction block: Input Valve_Pct, In Min 0, In Max 100, Sc Min 4, Sc Max 20, Output mA_Out


SCP (Scale with Parameters) maps Input from one range onto another and writes the result to Output every scan its rung is true. It is the straight-line conversion y = mx + b with the line given by two points: In Min maps to Scaled Min, In Max maps to Scaled Max. Use SCP to turn analog counts into engineering units, engineering units into a PWM or DAC value, or percent into a 4 to 20 mA command. Do not rely on SCP to limit the result; an Input outside the input range produces an Output outside the scaled range. Clamp afterwards with LIM and MOV, or in an MBS block.


Operand Type Format Valid Range Required Description
Input Any numeric tag, member, element or bit, or a literal Tag, Tag.Member, Tag[n], Tag.bit, or a literal Any resolvable numeric reference Yes The value to scale.
In Min Numeric tag or literal Same Any; must differ from In Max Yes Input value that maps to Scaled Min.
In Max Numeric tag or literal Same Any; must differ from In Min Yes Input value that maps to Scaled Max.
Sc Min Numeric tag or literal Same Any Yes Output at In Min.
Sc Max Numeric tag or literal Same Any Yes Output at In Max.
Output A writable numeric tag, member or element Tag, Tag.Member, Tag[n] SINT, INT, DINT or REAL; not a literal, not an input pin Yes Where the scaled value is written.

The formula is Output = (Input − In Min) × (Sc Max − Sc Min) ÷ (In Max − In Min) + Sc Min, computed in floating point. Any of the four range operands may be a tag, so a calibration can live in the tag database instead of the instruction. LadderIDE does not impose the SLC 500 rule that the limits be constants.

Output type. A REAL Output keeps the fraction. A whole-number Output truncates toward zero, which is usually what a PWM or DAC value wants.

Inverted ranges. Sc Min greater than Sc Max gives a falling line; a 0 to 1023 input becomes 100 to 0. Both are legal.


Nothing. Output keeps its power-up value.

The instruction does nothing. Output holds its last value.

Input and the four range operands are read and the scaled value is written to Output every scan the rung is true. If In Max equals In Min the line is undefined: nothing is written, Output holds, no fault.

Nothing.


Scenario: A valve positioner takes a 4 to 20 mA command. The control logic works in percent open, and a current-loop output device on the Network tree takes milliamps.

Tags:

  • Scale_Out — Drive the output, BOOL
  • Valve_Pct — Valve command, percent open, INT
  • mA_Out — Loop command in milliamps, REAL

Rung 1:

—] [Scale_Out———[SCP Valve_Pct 0 100 4 20 mA_Out]———

Scan 1 — Scale_Out = 0. Valve_Pct reads 25. The rung is false: mA_Out holds 0. Only the two tag operands, Input and Output, show a value line; the four literal limits have none.

Figure 1 — SCP rung false: Input Valve_Pct 25, limits 0 100 4 20, Output mA_Out 0, rung dark

Scan 2 — Scale_Out = 1. (25 − 0) × (20 − 4) ÷ (100 − 0) + 4 is written: mA_Out reads 8.

Figure 2 — SCP rung true: mA_Out reads 8, rung lit

At 0 percent the loop sits at 4 mA, the live zero; at 100 percent, 20 mA. Type 110 into Valve_Pct and mA_Out reads 21.6, beyond the range, which is why a clamp follows an SCP that can be overdriven.


  • CPT — Compute (the same line written as a formula)
  • MUL — Multiply (gain only, no offset)
  • LIM — Limit Test (detect an out-of-range result)
  • Adding Network Devices — the output device that takes the milliamps
  • Compute Instructions — Category index

Analog input to units. SCP Raw 0 1023 0 5000 mV gives millivolts from a 10-bit ADC. Use the ADC’s real full-scale count, 1023 not 1024, or the top of the range is off by one step.

Calibration in tags. Put the limits in REAL tags and the operator can trim a transmitter from the Tag Browser without editing the program.

Clamp. SCP never limits. LIM 4 mA_Out 20 false means overdrive; a following MOV can pin the value.

The block never colours. Watch the rung wire and the Output value line.

Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11