Ladder block reference
The virtual controller of Industrial UI has 40 function blocks, and you can write your own. Here is what each of them does, which parameters it takes and where it earns its place in a real project.
How blocks work in a rung
A block sits in a rung like a contact. The power arriving from the left is its enable input, EN. What leaves on the right depends on the kind of block:
- Q blocks — timers, counters, comparisons, BLINK, PWM, HYST, ROC, the clocks — put their Q output on the wire, so the next contact or coil sees it. Q can also be written to a tag.
- Data blocks — math, scaling, filters, PID — calculate while EN is on and write the result to an OUT tag. They pass EN along unchanged (ENO), so several of them can sit in one chain.
Blocks that count or accumulate — counters, TONR, RUNTIME, TOTALIZER, STEP, DAYLEN — have a reset tag R: while that tag is on, the block starts over. Where a block compares or calculates with a second value, that value can be a fixed number or another tag. To make a block run on every scan, feed it from SYS_ALWAYS_ON.
Timers
Times are set in milliseconds: 5000 is five seconds.
- TON — on-delay
- Q turns on when EN has been on for the preset time without interruption, and off as soon as EN drops. Use it for: a motor that starts 5 s after the command, ignoring a float switch that splashes, an alarm that fires only when a fault lasts longer than 10 s.
- TOF — off-delay
- Q follows EN on at once, but stays on for the preset time after EN drops. Use it for: a fan that runs on after the heater stops, staircase lighting, a pump that keeps running a little after the demand ends.
- TP — pulse
- A rising edge of EN gives a pulse of exactly the preset length, however long EN stays on. Use it for: opening a solenoid valve for a measured dose, sounding a horn for 3 s, a one-shot command to a device.
- TONR — retentive on-delay
- Adds up the time EN is on, keeps the sum when EN drops and even across restarts; Q turns on when the sum reaches the preset. Only the R tag clears it. Use it for: “filter needs cleaning after 200 hours of operation”, total burner time, anything that must not start from zero after a power cut.
Counters
Counters react to rising edges of EN, one count per edge. The preset (PV) is set in the block; the current count can be written to a tag.
- CTU — count up
- Counts up; Q is on when the count reaches PV. R sets it back to zero. Use it for: packing 12 items per box, counting cycles of a press, the number of starts of a compressor.
- CTD — count down
- Starts at PV and counts down; Q is on at zero. Use it for: parts remaining in a batch, retries left before a lockout.
- CTUD — counter with reset and count output
- Counts up on EN edges with Q at PV, a reset tag and the count on OUT. Counting down is done with CTD.
Comparisons
CMP_GT (>), CMP_LT (<), CMP_GE (≥), CMP_LE (≤), CMP_EQ (=) and CMP_NE (≠) compare a tag with a fixed threshold or with another tag and pass power only while the condition holds. Use them for: high-temperature and low-level alarms, “start the second pump above 80 % demand”, reacting to a mode tag or to a step of the STEP sequencer (step = 2).
Math and data
While EN is on, these blocks calculate every scan and write the result to OUT.
- ADD, SUB, MUL, DIV, MOD
- OUT = A + B, A − B, A × B, A ÷ B or the remainder of A ÷ B. B is a tag or a number. Dividing by zero keeps the last result instead of producing nonsense. Use them for: power from voltage and current, the difference between supply and return temperature, averaging two sensors.
- MOVE
- Copies one tag into another. Use it for: passing a setpoint from the HMI to a PLC, taking a snapshot of a value at a given moment.
- SEL — selector
- OUT = A while EN is on, otherwise B. Use it for: switching between a day and a night setpoint, manual and automatic value.
- LIMIT
- Clamps a value between Min and Max. Use it for: keeping a setpoint typed by an operator within safe limits.
- SCALE
- Maps a value from an input range to an output range in a straight line and clamps it. Use it for: raw ADC counts 0–4095 into 0–10 bar, an analogue input 0–27648 into 0–100 °C, percent into drive frequency.
- ABS and SQRT
- Absolute value (integer tags are read as signed 16-bit) and square root (a negative input keeps the last result). SQRT gives flow from a differential pressure sensor.
Signal processing
- FILTER — smoothing
- Exponential smoothing: OUT moves towards the input by the fraction Alpha each scan. A smaller Alpha gives a calmer signal. Use it for: a noisy level sensor, a jumping load cell, flow readings that flicker on the screen.
- DEADBAND
- Passes the input to OUT only when it has moved by at least the deadband since the last passed value. Use it for: stopping jitter from filling the history and from triggering logic.
- RAMP
- OUT follows the input no faster than the set rate, in units per second. Use it for: a soft start of a drive speed, slow opening of a valve, avoiding pressure shocks when a setpoint changes.
- ROC — rate of change
- Q turns on when the value changes faster than the threshold, in units per second; the rate itself can go to OUT, with optional smoothing. Use it for: detecting a broken sensor, a burst pipe, a temperature rising too fast.
- HYST — two-point control
- Q turns on when the input falls to the low limit and off when it rises to the high limit, holding its state in between. Use it for: a thermostat, a sump pump between two levels, a compressor between two pressures — any on/off control that must not chatter.
Control: PID, PWM, sequencer
- PID
- Classic PID control: the measured value (PV tag) is pulled towards the setpoint (SP tag); OUT is the output from 0 to Out max. Gains are Kp, Ki (1/s) and Kd (s). When EN goes off, the output holds its value — manual mode. Use it for: temperature of a tank or room, pressure with a drive, flow with a control valve.
- AUTOPID — self-tuning PID
- Wired exactly like PID, but you set only the desired response time: Kp, Ki and Kd are learned while the loop runs. The learned gains survive restarts; learning pauses while the output is saturated or the error is within the noise. Use it when you have no time or data for manual tuning, or the process changes over the seasons.
- PWM
- Turns an analogue value into pulses: Q is on for the percentage given by the duty tag (0–100 %) of each period. Use it for: driving a solid-state relay of a heater from a PID output, dimming, dosing pumps.
- BLINK
- While EN is on, Q flashes with the set ON and OFF times. Use it for: a warning beacon, a status lamp, a heartbeat signal to another system.
- STEP — sequencer
- Each rising edge of EN moves to the next step, 0 to N−1, and then starts over; the step number goes to OUT and is kept across restarts. Combine it with CMP_EQ to switch outputs for each step; R returns to step 0. Use it for: a traffic light, washing and cleaning cycles, alternating duty and standby pumps.
Schedules, calendar and sun
These blocks read the server clock themselves — there is nothing to wire except EN and the output.
- SCHEDULE — weekly timer
- Q is on between the ON and OFF time on the selected days of the week. An ON time later than the OFF time makes an overnight window, such as 22:00 to 06:00. Use it for: office ventilation and heating hours, a night tariff, weekend modes.
- CALENDAR — date window
- Q is on inside a window set to the second. Without dates it repeats daily; with day and month only it repeats every year, even across New Year; with full dates it is a one-time period. Use it for: the heating season from October to April, holiday shutdowns, a single maintenance window.
- ASTRO — astronomical clock
- Calculates sunrise and sunset for your latitude and longitude, so no light sensor is needed. Three modes: NIGHT — on from sunset to sunrise; DAY — the reverse; PHOTO — adds light after sunset until the day reaches a target length, for example 14 hours. Sunset can be the official one or civil (−6°) or nautical (−12°) twilight, and ON and OFF can be shifted by minutes. Polar day and night are handled too. Use it for: street, car park and facade lighting, blinds and shutters, supplementary light in greenhouses.
- DAYLEN — photoperiod
- Controls the daily light period for plants that flower on day length. A mode tag selects the vegetative (start) or flowering (target) day length, and the length moves between them gradually over the set number of days. The light window opens at the same hour every day; Q means lights on, and today's length goes to OUT. R jumps straight back to the start length for a new cycle. Use it for: chrysanthemums, poinsettias, strawberries and other short-day crops.
Metering
- RUNTIME — operating hours
- Counts the hours EN is on, to 0.01 h, into OUT; kept across restarts, cleared by R. Use it for: service intervals of pumps, compressors and fans, and for sharing wear between duty and standby units.
- TOTALIZER
- Integrates a rate over time into a running total. The time base says what the rate is per: 3600 for per hour, 60 for per minute, 1 for per second. Kept across restarts, cleared by R. Use it for: cubic metres of water from a flow in m³/h, kWh from kW, fuel used.
Your own function blocks (FB)
When the same logic is needed several times — three pumps, four heating zones, a row of identical valves — write it once as a function block and call it as often as you need. An FB has an interface and a body of ordinary Ladder networks; each call is an instance with its own data, as with the FBs of Siemens PLCs.
- Interface. Members are IN and OUT pins, IN_OUT for a value the block reads and writes, and STAT for what it keeps between scans — a step, a count, a setpoint. In the networks of the FB a member is written
#Name. - Calls and instances. In a program an FB is a block like any other: give the call an instance name, such as
Pump1, and wire its pins to tags. A pin left unwired, and every STAT, lives in the instance itself asPump1.Setpoint. The timers and counters inside belong to the instance too, so three calls are three independent pumps. - EN. With the call's EN off the body is skipped and its outputs keep their last state.
- From networks you already have. Select networks that work and choose Create FB: the interface is suggested from the tags they use — inputs and outputs of devices become pins, values used only inside become STAT.
- Library. FB types are kept in one library for all programs. Saving a changed type updates every call of it; an FB can call other FBs.
- Live view. Pick one instance and watch the FB's networks run with that instance's values.
Putting blocks together
A few rungs that come up again and again. Arrows show the order of elements from left to right.
Pump with dry-run protection
CMP_GT tank_level > 20 → TON 3000 → ( pump_enable )
The pump is allowed only when the level has stayed above 20 % for three seconds, so a wave on the surface does not start and stop it.
Heater with PID and a solid-state relay
SYS_ALWAYS_ON → PID PV tank_temp, SP temp_sp → OUT heat_pct, Out max 100
SYS_ALWAYS_ON → PWM duty heat_pct, period 2000 → ( ssr )
PID calculates the heating power in percent, PWM turns it into on/off time of the relay every two seconds. Replace PID with AUTOPID if you do not want to tune the gains.
Street lights
ASTRO NIGHT, civil twilight, 48.14 N, 11.58 E → ( street_lights )
The lights follow the dusk every day of the year, with no light sensor to clean.
Service reminder
─┤ pump_run ├─ → RUNTIME → OUT pump_hours
CMP_GE pump_hours ≥ 2000 → ( service_due )
Mark service_due as an alarm with the text “Pump service due”, and it will appear in the Alarm Log after 2000 hours of operation. After the service, clear the counter through the R tag of the RUNTIME block.
Greenhouse lighting
ASTRO PHOTO 14 h, 52.00 N, 4.25 E → ( grow_lights )
In summer the sun provides the 14 hours alone; in winter the lights add exactly the missing time after sunset.
Back to the guide · HMI widget reference · Download Industrial UI · Get a free trial license