Service and Support: 913-303-9700

What is PLC Programming? A Comprehensive Guide to Understanding and Implementing PLC Systems

Introduction to PLCs

Today’s industrial automation systems are more advanced and tech-savvy than ever before. However, they didn’t reach this level on their own!

Programmable Logic Controllers, or PLCs, form the backbone of these systems, enabling internal components to function together seamlessly. Versatile and adaptable, these digital computers are crucial to many of the systems and devices we rely on today.

What is a PLC?

It’s a specialized, rugged computer device designed to control industrial systems. It works by connecting different units and allowing them to work in a coordinated manner.

What gives it this power? Every PLC is a basic computer processor that gathers various inputs and evaluates them to achieve the desired output. The inputs can be digital or analog. Users can program the system in multiple ways to fit a certain scenario, making PLCs essential in many applications across various industries, including conveyor systems, oil refineries, manufacturing lines, and more.

Example: a simple light switch and a light bulb. By flipping a switch, the light turns on or off. There is little versatility or flexibility in this application. When a PLC gets involved, the user can create more complex controls. The light can be programmed to blink on and off or to turn off one minute after it turns on. Now think of thousands or even tens of thousands of circuits all being controlled in coordination with each other. This is essentially what a PLC does.

How Does It Work?

A PLC relies on a computer processor to turn multiple inputs into logic to control their outputs. As a PLC scans inputs from different sources, it internalizes and processes them. It then executes user programming to achieve the desired outputs and communicates relevant information to a control network like Modbus or Ethernet IP. Due to their responsibility for mission-critical systems and proximity to operators, PLCs undergo a series of diagnostics to ensure everything is functioning correctly before scanning inputs again. This entire sequence is known as the “scan cycle.” The size of the PLC program and the number of inputs directly influence the length of the scan cycle, which is measured in milliseconds—a term commonly referred to as “fast.” However, in applications where speed is most important, a Programmable Automation Controller (PAC) may be necessary. A PAC employs multiple CPUs within a single system or chassis to enable parallel processing or specialized handling of various aspects of the application.

PLCs are crucial to user programming because they dictate the actions to achieve desired outcomes. Without this programming, a PLC would just be an expensive paperweight.

In essence, a PLC is often likened to a compact, specialized computer. It shares terminology with traditional computing systems, such as memory, software, CPU, and I/O systems. However, a PLC is specifically designed for industrial environments, managing tangible inputs and outputs from devices, machines, and operators, whereas a personal computer is tailored for use in homes or offices.

Basic PLC Components

PLCs are available in various sizes and with different capabilities, classified into several main categories: smart programmable relays, compact PLCs, modular PLCs, and small-medium-large PLCs.

Compact PLCs

Also known as integrated PLCs or smart programmable relays, these systems feature a complete unit housed in a single compact case. Due to this design, the manufacturer determines the number and types of inputs and outputs, rather than the user.

Modular PLCs

These PLCs consist of multiple modules plugged into a single rack. They come in various sizes and offer different levels of power and functionality.

Small, Medium, and Large PLCs

These PLCs vary in size based on specific application requirements.

Although these PLCs are tailored to diverse needs and applications within their respective categories, each typically includes the following four components:

  • Power Supply: This component ensures the PLC remains operational by providing 24VDC or 120VAC line voltage, often with a built-in battery backup to prevent data loss during power outages.
  • CPU (Central Processing Unit): The CPU executes the PLC program and interfaces with other components. It contains the microprocessor responsible for coding, decoding, and computing data.
  • ROM (Read Only Memory): ROM stores programs and parameters that cannot be altered. It holds the PLC operating program.
  • RAM (Random Access Memory): RAM stores the user program and allows data to be written and read. Information in RAM can be lost during power outages unless protected by a battery backup.

In addition to these components, some PLCs may also feature EAPROM (Electronically Alterable Programmable Read Only Memory) for storing user data persistently without external power.

Understanding these components provides insight into how PLCs function and how they are integrated into industrial systems.

Operating Systems vs. User Programs

In PLC programming, you often encounter two types of programs executed by the CPU: the operating system and the user program. Let’s explore the key distinctions between these two components.

Operating System

The operating system (OS) of a PLC encompasses tasks and programs designed to run automatically, functioning without direct user commands. It manages all CPU functions, sequences, and operations not specific to a particular control task. Key tasks of the OS include:

  • Initiating warm and hot restarts
  • Updating and outputting I/O process image tables
  • Executing the user program
  • Managing memory areas
  • Detecting and handling interrupts
  • Establishing connections with programmable devices

User Program

The user program comprises the various functions necessary for the PLC to perform a specific automated task. It represents the part of the PLC where operators define desired outputs, which are stored in the PLC’s internal memory.

While responsible for visible functions, the user program operates in conjunction with the PLC operating system.

Programming a PLC

One common method to program, modify, or troubleshoot a PLC is using a PC-based device in conjunction with the manufacturer’s software. Alternatively, proprietary handheld devices connected to the PLC via a cable are also used.

While a handheld device is often preferred for its portability and convenience, it may lack a traditional keyboard and have limited capabilities. Conversely, a PC device, despite being bulkier, typically offers more robust processing power. For example, it allows users to run programs in online or offline mode, as well as edit, monitor, diagnose, and troubleshoot the program.

Regardless of the system used, you can use your laptop or handheld device to input the PLC program. From there, you can edit the code and transfer it to the CPU.

Once the programming is complete, disconnect your device, as the code is now stored within the CPU, where it directs and manages the operations of the entire unit.

An Intro To Ladder Programming

When discussing PLC programming basics, you may often encounter the term “ladder programming.” What does this entail?

PLC programming languages generally fall into two main categories, which vary depending on the manufacturer. While some use their own specialized languages, standard options fit into either textual or graphical categories.

Textual languages include:

  • Instruction Lists (IL)
  • Structured Text (ST)

Graphical languages include:

  • Ladder Diagrams (LD)
  • Sequential Function Chart (SFC)
  • Function Block Diagram (FBD)

Graphical languages are typically preferred over text-based ones for their simplicity and convenience. Among these, ladder diagrams are particularly favored for their ease of use.

Structure of Ladder Logic

Ladder logic, a graphical language dating back to the early 1970s when modern PLCs emerged, mimics relay diagrams familiar to plant electricians. Over time, the number of available symbols has expanded, enabling more advanced functionalities. PLCs use these symbols to simulate real-world relay logic controls, connecting them through rungs of circuitry to direct electrical current flow.

The term “ladder programming” originates from the resulting ladder-like arrangement of symbols:

  • A left power rail
  • A right power rail
  • Individual circuits (“rungs”) connecting the left and right rails

Common Logic Symbols

Within ladder logic, several symbols are frequently used, including:

  • Contact symbols (Normally Open (NO) and Normally Closed (NC))
  • Output symbols for warning lights and motor contactors
  • One-shot positive Edge connections for specific conditions changing from false to true
  • Timer Delay instructions for delaying on or off events
  • Comparison instructions for determining values
  • Math instructions for performing calculations
  • Special instructions like communication directions, PID loops, and more

Function Blocks

Function blocks allow users to incorporate complex instructions within PLC ladder programming. These blocks can replace physical components such as mechanical timers and improve scan times. Examples include:

  • AND/OR logic for combining inputs to trigger outputs
  • Use of OR logic for parallel circuit requirements, where one input or another can activate an output

Understanding these aspects of ladder programming provides insight into how PLCs are programmed and operated in industrial settings.

Creating a PLC Program

If you’re looking to create a PLC program using ladder logic, let’s walk through the steps involved:

  1. Define Program Functions: Firstly, clearly define what you want your program to accomplish. Do you need to control a light switch? Stop a conveyor belt? Or perhaps introduce a pause cycle for a machine every three minutes? Having a clear understanding of the desired output function is essential before starting.
  2. List Program Conditions: Next, enumerate all the conditions that will influence your program’s behavior. For instance, in the case of a light switch, one condition might be that flipping the switch up turns the light on, while flipping it down turns it off. Consider creating a flowchart to visually map out these conditions.
  3. Configure Your Software: Now, open your programming software on either your handheld device or PC. Configure the software settings accordingly, ensuring you select the “ladder logic language” as your programming language. Specify the hardware processor and assign a name to your new program.
  4. Create Your Rungs: Begin building your ladder logic program by adding the necessary rungs. Start with setting up your power rails and then proceed to program each rung carefully, defining inputs and outputs as needed.
  5. Check for Errors: It’s crucial to perform a thorough error check at this stage. Identifying and correcting errors now can save time and effort later on.
  6. Download the Program: Finally, download your completed program to the PLC’s memory. Once the transfer is complete, disconnect your programming device.

Following these steps will help you effectively develop and deploy a ladder logic-based PLC program for your application.