🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Manufacturing & Marine › Industrial Maintenance › Programmable Logic Controllers for Industrial Maintenance › Lesson 7
MFG-INDU16-06 · Lesson 7 · 13 clock hours · lab

Comparison, Data Move, and Math Instructions

Objective. Students write ladder logic using GRT, LES, EQU, MOV, and ADD/SUB/MUL instructions to implement a temperature setpoint comparison and a totalizer that displays accumulated flow on a simulated HMI tag.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by a licensed engineer or certified journey-level tradesperson or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Comparison, Data Move, and Math Instructions in Ladder Logic

Modern PLCs do far more than switch outputs on and off. They compare numbers, move data between registers, and perform arithmetic — all inside ladder logic rungs. This lesson covers the instructions you will use most in industrial maintenance: GRT, LES, EQU, MOV, ADD, SUB, and MUL. Mastering these lets you read, write, and troubleshoot the control programs running the machinery you maintain.

How Comparison Instructions Work

A comparison instruction sits on a rung like a normally open contact — it passes power (evaluates TRUE) when its condition is met, and blocks power (evaluates FALSE) when it is not. The PLC re-evaluates every rung every scan, so a comparison updates continuously while the program runs.

GRT (Greater Than): Passes power when the Source A value is greater than the Source B value. Example: if the process temperature tag reads 215 and the setpoint tag holds 200, GRT is TRUE and any output on that rung energizes.

LES (Less Than): Passes power when Source A is less than Source B — the logical opposite of GRT.

EQU (Equal): Passes power only when Source A exactly equals Source B. EQU is used most often with integer counters and timers, where exact equality is realistic. On analog values that change continuously, EQU can be difficult to trigger reliably; use a deadband or a combination of GRT and LES instead.

In Allen-Bradley ControlLogix / CompactLogix notation, you specify a tag (a named memory location) for each source rather than a raw address. Other manufacturers use similar function blocks under slightly different names, but the logic is the same.

The MOV (Move) Instruction

MOV copies a value from a Source to a Destination. It is an output instruction — it executes when the rung is TRUE. A common use is loading a setpoint at startup:

Because MOV executes every scan the rung is TRUE, you typically control it with a one-shot contact so it fires once, or you leave it always TRUE if you want the destination to track the source continuously.

Math Instructions: ADD, SUB, MUL

Math instructions are also output instructions — they execute when the rung is energized.

ADD: Adds Source A and Source B and stores the result in the Destination tag. In this lesson you will use ADD to accumulate flow: each time a flow pulse counter increments, ADD adds the new count to a running total stored in a DINT (32-bit signed integer) tag.

SUB (Subtract): Subtracts Source B from Source A and writes the result to Destination.

MUL (Multiply): Multiplies Source A by Source B and writes the result to Destination. Useful for unit conversions — for example, converting pulse counts to engineering units.

Integer vs. Floating-Point Data Types

Choosing the right data type prevents subtle errors.

In this lab the accumulated flow tag is a DINT because pulses are whole numbers. If you later convert to gallons with a decimal factor, move the result to a REAL tag.

Analog Scaling and the Temperature Input

The temperature transmitter in this lab produces a 4–20 mA signal representing 0–250 °F. The PLC analog input module converts this to a raw integer count. A scaling function (often a built-in SCL or CPT instruction, or a manual formula) maps that count to engineering units stored in a REAL or INT tag. In this lab the scaling is already configured; your comparison reads the scaled tag directly. Always verify the scaled value against a known reference before relying on a comparison for process control.

Safety Rules for This Lab

Lockout/Tagout: The PLC trainer is low-voltage, but the principles you practice here apply directly to live equipment. Never modify a program on live production equipment without following your facility's Management of Change and LOTO procedures per OSHA lockout/tagout requirements.

Online Edits: When monitoring a running program, changes take effect immediately. Confirm with your instructor before going online. Never make online edits to unfamiliar programs on actual machinery — an unintended output could move actuators and cause injury.

PPE: Safety glasses are required in the lab at all times. Closed-toe shoes are required.

Static Sensitive Devices: Handle PLC modules by the edges; ground yourself before touching terminals.

Connecting It to the HMI

An HMI (Human-Machine Interface) reads tag values directly from the PLC data table. When you write the accumulated gallons to a DINT tag and the setpoint to an INT tag, the HMI display updates automatically each scan. This is why naming tags clearly and choosing the correct data type matter — the HMI inherits whatever the PLC tag holds.

Key terms10

GRT (Greater Than)A comparison instruction that evaluates TRUE — and passes power on a rung — when the value of Source A is greater than the value of Source B.
LES (Less Than)A comparison instruction that evaluates TRUE when Source A is less than Source B; used to detect when a process value drops below a threshold.
EQU (Equal)A comparison instruction that evaluates TRUE only when Source A exactly equals Source B; most reliable with integer counters rather than continuously varying analog values.
MOV (Move)An output instruction that copies the value in the Source location to the Destination tag each scan the rung is energized; commonly used to load or update setpoint values.
ADDA math output instruction that adds Source A and Source B and stores the result in the Destination tag; used to accumulate totals such as flow pulse counts.
DINT (Double Integer)A 32-bit signed integer data type capable of storing whole numbers up to approximately ±2.1 billion; the preferred type for large accumulating totalizers.
REALA 32-bit floating-point data type that can store decimal values; used when fractional precision is needed, but should not be compared with EQU due to rounding.
Scan CycleThe repeating sequence in which the PLC reads all inputs, executes all logic rungs in order, then updates all outputs; comparison instructions re-evaluate every scan.
TagA named memory location in a modern PLC (such as Allen-Bradley ControlLogix) used in place of a raw numeric address; tags have a name, data type, and current value.
SetpointA target or threshold value stored in a data register that a comparison instruction uses to determine whether a process condition requires a control action.

Worked examples4

1. A DINT totalizer tag currently holds 1,250 gallons. The flow counter has just incremented by 15 pulses, and each pulse equals 1 gallon. Write the ADD instruction values and calculate the new Destination value.
  1. Identify Source A: the current totalizer tag value = 1,250.
  2. Identify Source B: the new pulse count to add = 15.
  3. Apply the ADD formula: Destination = Source A + Source B = 1,250 + 15.
  4. Calculate: 1,250 + 15 = 1,265.
Answer: The Destination (DINT totalizer tag) will be written as 1,265 gallons after this scan.
2. The analog input module scales the 4–20 mA temperature signal linearly to 0–250 °F. The raw count from the module ranges 0–32,767. If the raw count currently reads 13,107, what is the scaled temperature in °F? (Use linear interpolation: Temp = (raw / 32,767) × 250.)
  1. Write the scaling formula: Temp = (raw count / 32,767) × 250.
  2. Substitute the known raw count: Temp = (13,107 / 32,767) × 250.
  3. Divide: 13,107 ÷ 32,767 ≈ 0.4000.
  4. Multiply: 0.4000 × 250 = 100.0.
Answer: The scaled process temperature is 100 °F.
3. A GRT comparison rung uses Source A = the process temperature tag and Source B = the setpoint tag. The setpoint tag is loaded by a MOV instruction with a constant of 175. The current temperature is 182 °F. Determine whether the cooling fan output is energized.
  1. Identify Source A (process temp) = 182 and Source B (setpoint) = 175.
  2. Evaluate the GRT condition: Is 182 > 175? Yes.
  3. Because GRT evaluates TRUE, the rung passes power.
  4. The cooling fan output coil on that rung is energized (ON).
Answer: The cooling fan output is ON because 182 > 175, making GRT TRUE.
4. You need to use a MUL instruction to convert a pulse totalizer (DINT, 4,000 pulses) to gallons, given a K-factor of 10 pulses per gallon. Calculate the result and identify the correct destination data type.
  1. Identify Source A (pulse count) = 4,000 and Source B (K-factor denominator as integer division): since 10 pulses = 1 gallon, gallons = 4,000 ÷ 10.
  2. Note: for division use DIV — MUL multiplies. Reframe: to convert 4,000 pulses to gallons, divide by 10, giving 400 gallons. If instead using MUL with a fractional factor (0.1 gallon/pulse), Source A = 4,000 DINT and Source B = 0.1 REAL, which requires a REAL destination.
  3. Using integer DIV: 4,000 ÷ 10 = 400. Destination data type: DINT (whole number result).
  4. Using MUL with REAL factor: 4,000 × 0.1 = 400.0. Destination data type: REAL (to preserve decimal capability).
Answer: 400 gallons. Use DINT if dividing by the integer K-factor; use REAL if multiplying by a decimal conversion factor so fractional gallons can be stored.

The math in this lesson2

Learners set up ADD, MUL and DIV instruction operands that compute totals and unit conversions.
A-SSE.1F-LE.1
Brush up in the math halls at newSchoolWorks.com:
In class: Students receive a written control narrative describing a heating system: if process temperature (analog input, scaled 0–250°F) exceeds a setpoint stored in a data register, a cooling fan output turns on; they translate the narrative into a ladder program using GRT and a MOV-loaded setpoint. · Students add an ADD instruction that accumulates flow pulses from a counter into a 32-bit DINT tag representing total gallons, demonstrating the difference between integer and floating-point data types. · Students modify the setpoint value in the data table while the program runs online and observe the fan output switching — confirming the comparison updates each scan — and document setpoint, actual value, and output state in three test scenarios in their lab log.
Materials: PLC trainer, programming laptop, temperature transmitter simulator (potentiometer scaled to 4–20 mA), lab log, NCCER controls reference, manufacturer instruction set reference manual (PDF)
Check: Fan output must switch ON within one scan of temperature crossing setpoint in online monitor; student lab log must show correct data values for all three setpoint test scenarios — instructor initials log.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

PLC Programming and Troubleshooting
1. A GRT instruction has Source A = process temperature tag (current value 198 °F) and Source B = setpoint tag (current value 200 °F). What is the state of the GRT instruction this scan?
PLC Programming and Troubleshooting
2. Which instruction would you use to load a constant value of 200 into a setpoint tag when a one-shot contact fires at program startup?
PLC Programming and Troubleshooting
3. A technician uses an EQU instruction to compare a REAL-type process pressure tag to a REAL-type setpoint tag. The setpoint is 75.0 and the process reads 74.99998 due to floating-point rounding. What will happen?
PLC Programming and Troubleshooting
4. A flow totalizer DINT tag holds 2,000,000 gallons. The next ADD instruction will add 500 gallons. What will the DINT tag hold after execution?
PLC Programming and Troubleshooting
5. While monitoring a running PLC program online, you change the setpoint tag from 200 to 180 in the data table. The process temperature is currently 185 °F. How quickly does the GRT rung respond?
PLC Programming and Troubleshooting
6. A ladder rung contains only an ADD instruction with no enabling contact. What is the result?
Safety and Health
7. Which OSHA requirement governs the practice of controlling hazardous energy when performing maintenance on equipment controlled by a PLC?
PLC Programming and Troubleshooting
8. A student stores accumulated flow as an INT (16-bit integer) tag instead of a DINT. The totalizer reaches 32,767 gallons and the ADD instruction fires again. What most likely happens?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.