Reference
Ladder Logic Instructions
All 53 instructions in the browser PLC, explained in plain English, with what each one is called on Rockwell, Siemens, Mitsubishi and CODESYS, the mistake people reliably make with it, and a worked rung you can open and run on a real scan cycle.
Contacts
The input side of a rung. Contacts in series are AND; contacts in parallel are OR.
- XICExamine If ClosedPasses power when the bit it is examining is 1.
- XIOExamine If OpenPasses power when the bit it is examining is 0.
- ONSOne Shot (rising edge)True for exactly one scan, on the scan where the conditions before it go from false to true.
- OSFOne Shot Falling (falling edge)True for exactly one scan, on the scan where the conditions before it go from true to false.
- AFIAlways False InstructionNever passes power. Disables the rest of the rung without deleting it.
- NOPDoes nothing and passes power through. A placeholder for a rung that is deliberately empty.
Compare
Contacts that test a number instead of a bit. This is how an analog value becomes logic.
- GRTGreater ThanPasses power while A is greater than B.
- GEQPasses power while A is greater than or equal to B.
- LESPasses power while A is less than B.
- LEQPasses power while A is less than or equal to B.
- EQUPasses power while A equals B.
- NEQPasses power while A does not equal B.
- LIMLimit TestPasses power while the test value sits between the low and high limits, inclusive.
- MEQCompares two values through a mask, so only the bits you care about are tested.
- EXPRA whole boolean expression in one contact, for conditions that would otherwise take a row of instructions.
Coils
The output side. OTE follows the rung; OTL and OTU remember.
Timers
Time in milliseconds. The difference between these three is what happens when the rung goes false.
- TONTimer On-DelayStarts timing when the rung goes true, and sets its done bit once the preset has elapsed.
- TOFTimer Off-DelayIts done bit goes true immediately when the rung goes true, and stays true for the preset after the rung goes false.
- RTORetentive Timer OnAccumulates time while the rung is true, and keeps the accumulated value when it goes false.
Counters
These count edges, not scans, which is why they usually need a one shot in front of them.
- CTUCount UpAdds one to its accumulator on every false-to-true transition of the rung, and sets its done bit at the preset.
- CTDCount DownSubtracts one from its accumulator on every false-to-true transition of the rung.
- CTUDCounts up on its own rung and down on a second bit, for a running total that can go both ways.
Move
Getting values into and out of registers: recipes, setpoints, preloads.
- MOVMoveCopies a value into a register while the rung has power.
- MVMMoves only the bits selected by a mask, leaving the rest of the destination untouched.
- CLRSets a register to zero.
- TODConverts an integer to binary coded decimal, for thumbwheels and legacy displays.
- FRDConverts binary coded decimal back to an integer.
- BTDCopies a run of bits from one place in a register to another.
Math
Arithmetic on 32-bit integers, or on floating point where the instruction offers it.
- ADDAddWrites A plus B into the destination while the rung has power.
- SUBWrites A minus B into the destination.
- MULWrites A times B into the destination.
- DIVWrites A divided by B into the destination.
- MODWrites the remainder of A divided by B.
- SQRWrites the square root of A.
- ABSWrites the absolute value of A.
- NEGWrites A with its sign flipped.
- CPTEvaluates a whole arithmetic expression in one instruction.
Bitwise
Bit-level operations on a whole register at once, for masks and packed status words.
Sequencer
Stepping through a table of values, one step per transition.
Process
Closed-loop control, and a simulated plant to control so you can see it work.
Reset
Clearing a timer or counter back to zero.
Program control
Deciding what runs, and what does not, on this scan.
- JSRJump To SubroutineRuns another routine, then continues from the next rung.
- RETEnds the current routine early and returns to the caller.
- TNDEnds the scan early. Everything after it is skipped until the next scan.
- JMPJumpSkips forward to the matching LBL, so the rungs in between do not execute this scan.
- LBLThe target a JMP jumps to.
- MCROpens a zone whose non-retentive outputs are driven false when the zone is off.
