PLC/Programming basics

Logic is integral to the programming of PLCs.

Logic gates

 * And gate
 * Or gate
 * Nor gate
 * Nand gate

Programming types

 * Ladder logic - simplified representation of electronic schematics

Inputs

 * I (Inputs) - These bits represent the connection to any external control input device wired to the PLC, including switches, buttons and motion sensors.

Outputs

 * O (Output) - Each output bit can only be used as an output once.

Internal bits
Internal bits make possible almost limitless necessary logical constructs to be made.

Latches
Holds an electrical function on. A momentary push-button, output (from a timer or counter) or an internal bit are capable of triggering a latch. Latches have the same reference as the output on the same rung. Ideally, a latch must be foolproof with an emergency stop from an input. Latches represent virtual relays.

Timers

 * TON (Timer on) - once powered waits until its preset time to turn on the output.
 * TOF (Timer off) - turns on when powered, then turns off when the preset time is reached
 * RTF (Retaining timer) - are potentially dangerous as they keep count even if the PLC is reset.

Counters

 * CTU (Counter up) - Every time this counter gets continuous power, this counter counts up. Once a function is reached it outputs.
 * CTD (Counter down) - Similar to CTU, except this counts down.

Sequencers
Sequencers are capable of using internal (binary) logic bits to shortcut repetitive ladder logic.