The ladder language
Ladder logic (LD) is the most used language to program PLCs: it reads like an electrical diagram.
A ladder program is made of rungs placed between two vertical rails. On the left of each rung, the conditions (contacts, comparisons); on the right, the actions (coils, timers, math). When the conditions let power flow all the way to the right, the action is done.
The PLC reads its inputs, runs the rungs from top to bottom, writes its outputs, then starts again. This is the PLC scan, repeated tens of times per second.
Instructions by category
Contacts
Contacts read a BOOL variable and let power flow through the rung, or not.
Coils
Coils write the rung's result into a BOOL variable.
Timers
Timers add time to the logic: wait, delay, make a pulse.
Counters
Counters count events: parts, cycles, button presses.
Edges
Edge detectors give a one-scan pulse when a signal changes.
Compare
Comparisons test two values and let power flow when the test is true.
Math
Math instructions copy values and compute: add, subtract, multiply, divide.
Control
Control keeps a measurement close to a set point by adjusting an output continuously.
Program
Program instructions organise the code: call a routine or a reusable block.
Data types
Data types say what a variable holds: a bit, an integer, a real, a duration, or the memory of a timer or a counter.