How the PLC operates
The PLC is a machine controller designed to uderstand digital and analog inputs from various sensors, execute a user defined logic program, and also write the resulting digital and analog output values to various output elements like hydraulic and pneumatic actuators, indication lamps, solenoid coils etc.
Scan cycle
Details vary between manufacturers, but most PLCs follow a 'scan-cycle' format.
Overhead
Overhead includes testing I/O module integrity, verifying the user program logic hasn't changed, that the computer itself hasn't locked up (via a watchdog timer), and any necessary communications. Communications may include traffic over the PLC programmer port, remote I/O racks, and other external devices such as HMIs (Human Machine Interfaces).
Input scan
A 'snapshot' of the digital and analog values present at the input cards is saved to an input memory table.
Logic execution
The user program is scanned element by element, then rung by rung until the end of the program, and resulting values written to an output memory table.
Output scan
Values from the resulting output memory table are written to the output modules.
Once the output scan is complete the process repeats itself until the PLC is powered down.
The time it takes to complete a scan cycle is, appropriately enough, the "scan cycle time", and ranges from hundreds of milliseconds (on older PLCs, and/or PLCs with very complex programs) to only a few milliseconds on newer PLCs, and/or PLCs executing short, simple code.
Basic instructions
Be aware that specific nomenclature and operational details vary widely between PLC manufacturers, and often implementation details evolve from generation to generation.
Often the hardest part, especially for a beginning PLC programmer, is practicing the mental ju-jitsu necessary to keep the nomenclature straight from manufacturer to manufacturer.
Positive Logic (most PLCs follow this convention)
True = logic 1 = input energized.
False = logic 0 = input NOT energized.
Negative Logic
True = logic 0 = input NOT energized
False = logic 1 = input energized.
Normally Open
(XIC) - eXamine If Closed.
This instruction is true (logic 1) when the hardware input (or internal relay equivalent) is energized.
Normally Closed
(XIO) - eXamine If Open.
This instruction is true (logic 1) when the hardware input (or internal relay equivalent) is NOT energized.
Output Enable
(OTE) - OuTput Enable.
This instruction mimics the action of a conventional relay coil.
On Timer
(TON) - Timer ON.
Generally, ON timers begin timing when the input (enable) line goes true, and reset if the enable line goes false before setpoint has been reached. If enabled until setpoint is reached then the timer output goes true, and stays true until the input (enable) line goes false.
Off Timer
(TOF) - Timer OFF.
Generally, OFF timers begin timing on a true-to-false transition, and continue timing as long as the preceding logic remains false. When the accumulated time equals setpoint the TOF output goes on, and stays on until the rung goes true.
Retentive Timer
(RTO) - Retentive Timer On.
This type of timer does NOT reset the accumulated time when the input condition goes false.
Rather, it keeps the last accumulated time in memory, and (if/when the input goes true again) continues timing from that point. In the Allen-Bradley construction this instruction goes true once setpoint (preset) time has been reached, and stays true until a RES (RESet) instruction is made true to clear it.
Latching Relays
(OTL) - OuTput Latch.
(OTU) - OuTput Unlatch.
Generally, the unlatch operator takes precedence. That is, if the unlatch instruction is true then the relay output is false even though the latch instruction may also be true. In Allen-Bradley ladder logic (and others) latch and unlatch relays are separate operators.
However, other ladder dialects opt for a single operator modeled after RS (Reset-Set) flip-flop integrated circuit chip logic.
Jump to Subroutine
(JSR) - Jump to SubRoutine
For jumping from one rung to another the JSR (Jump to Subroutine) command is used.
Programming
Early PLCs, up to the mid-1980s, were programmed using proprietary programming panels or special-purpose programming terminals, which often had dedicated function keys representing the various logical elements of PLC programs. [2] Programs were stored on cassette tape cartridges. Facilities for printing and documentation were very minimal due to lack of memory capacity. The very oldest PLCs used non-volatile magnetic core memory.
More recently, PLCs are programmed using application software on personal computers. The computer is connected to the PLC through Ethernet, RS-232, RS-485 or RS-422 cabling. The programming software allows entry and editing of the ladder-style logic. Generally the software provides functions for debugging and troubleshooting the PLC software, for example, by highlighting portions of the logic to show current status during operation or via simulation. The software will upload and download the PLC program, for backup and restoration purposes. In some models of programmable controller, the program is transferred from a personal computer to the PLC though a programming board which writes the program into a removable chip such as an EEPROM or EPROM.
Programming
PLC programs are typically written in a special application on a personal computer, then downloaded by a direct-connection cable or over a network to the PLC. The program is stored in the PLC either in battery-backed-up RAM or some other non-volatile flash memory. Often, a single PLC can be programmed to replace thousands of relays. [3]
Under the IEC 61131-3 standard, PLCs can be programmed using standards-based programming languages. A graphical programming notation called Sequential Function Charts is available on certain programmable controllers. Initially most PLCs utilized Ladder Logic Diagram Programming, a model which emulated electromechanical control panel devices (such as the contact and coils of relays) which PLCs replaced. This model remains common today.
IEC 61131-3 currently defines five programming languages for programmable control systems: FBD (Function block diagram), LD (Ladder diagram), ST (Structured text, similar to the Pascal programming language), IL (Instruction list, similar to assembly language) and SFC (Sequential function chart). These techniques emphasize logical organization of operations.[3]
While the fundamental concepts of PLC programming are common to all manufacturers, differences in I/O addressing, memory organization and instruction sets mean that PLC programs are never perfectly interchangeable between different makers. Even within the same product line of a single manufacturer, different models may not be directly compatible.
More about PLC Programming soon!
Articlea from wikibooks.org and wikipedia.org