From Beginner to Pro: A Comprehensive Guide to PLCs with Practical Cases

1. Basic Concepts and Core Principles of PLCs

1.1 What is a PLC?

A PLC (Programmable Logic Controller) is a digital electronic device designed specifically for industrial environments. It implements functions such as logic control, sequential control, timing, counting, and arithmetic operations through programming, and is widely used in the field of industrial automation. Essentially, a PLC is an “industrial computer,” but it has stronger anti-interference capabilities, stability, and reliability compared to ordinary computers.

Core Features of PLCs:

  • Industrial-grade design: High temperature resistance, dustproof, and electromagnetic interference resistance

  • Real-time control: Microsecond-level response speed

  • Modular structure: Flexible expansion based on requirements

  • Simple programming: Supports various engineering programming languages

1.2 Basic Components of a PLC

A complete PLC system typically includes the following hardware modules:

1. Central Processing Unit (CPU): Executes user programs and performs logical operations

2. Memory: Includes ROM (system program) and RAM (user program and data)

3. Input/Output Modules:

  • Input Module: Connects to field devices such as buttons and sensors

  • Output Module: Drives actuators such as relays, solenoids, and motors

4. Power Supply Module: Provides stable operating voltage for all PLC components

5. Communication Interface: Enables communication between the PLC and devices such as HMI, frequency converters, and other PLCs

1.3 Working Principle of PLC: Scanning Cycle

PLCs operate using a cyclic scanning method, where each scanning cycle consists of four stages:

1. Input Sampling Stage: Reads the status of all input terminals and stores it in the input image area

2. Program Execution Stage: Executes user programs sequentially

3. Output Refresh Stage: Sends the computation results to the output latches

4. Self-diagnosis and Communication Processing: Checks hardware status and processes communication requests

Typical scanning cycle time: 1ms-100ms, depending on program complexity and CPU performance

2. Detailed Explanation of PLC Programming Languages

The International Electrotechnical Commission (IEC) has established five standard PLC programming languages:

2.1 Ladder Diagram (LD)

The most commonly used graphical programming language, similar to electrical control circuit diagrams, consisting of contacts, coils, and function blocks. Features:

  • Intuitive and easy to understand, suitable for personnel with an electrical background

  • Suitable for logic control programming

  • Supported by software such as Mitsubishi GX Works and Siemens STEP7

2.2 Instruction List (IL)

A text programming method similar to assembly language, composed of operation codes and operands. Features:

  • Compact code with high execution efficiency

  • Suitable for simple logic and data processing

  • Can be converted to and from ladder diagrams

2.3 Function Block Diagram (FBD)

A graphical programming language based on function blocks, implementing control logic by connecting predefined function blocks. Features:

Suitable for complex algorithms and mathematical operations

High modularity

Commonly used by brands like Schneider and Siemens

2.4 Sequential Function Chart (SFC)

A graphical language specifically for sequential control, dividing control processes into multiple steps and transition conditions. Features:

  • Clear flow, easy to debug

  • Suitable for multi-step sequential control

  • Can reduce program complexity

2.5 Structured Text (ST)

A text programming language similar to high-level languages (e.g., Pascal). Features:

  • Supports complex algorithms and data structures

  • Suitable for mathematical operations and data processing

  • Steeper learning curve

3. Setting Up the PLC Development Environment

3.1 Hardware Selection Guide

Comparison of mainstream PLC brands:

Brand Typical Series Programming Software Features
Siemens S7-1200/1500 TIA Portal Powerful functionality, complete ecosystem
Mitsubishi FX Series GX Works High cost-performance ratio, easy to get started
Omron CP Series CX-Programmer Good stability, Japanese standards
Inovance H5U Series AutoShop High quality, excellent cost-performance ratio

3.2 Software Installation and Configuration

Steps to set up the development environment using Siemens TIA Portal as an example:

1. Install TIA Portal V16/V17

2. Create a new project and select the PLC model (e.g., S7-1200 CPU1214C)

3. Configure hardware setup:

  • Add power supply module

  • Set communication interface (e.g., PROFINET)

  • Add I/O modules

4. Establish connection between PLC and PC:

  • Connect via Ethernet/IP address

  • Or use PG/PC interface adapter

3.3 Basic Programming Operations

Basic operations in Mitsubishi GX Works2:

  • Create a new project: Select PLC model (e.g., FX3U)

  • Write ladder diagram: Use F5-F8 shortcut keys to insert contacts/coils

  • Convert program: Press F4 to convert ladder diagram to machine code

  • Write to PLC: Download program via USB/RS232 connection

  • Online monitoring: View I/O status and register values in real-time

4. Classic PLC Case Studies

4.1 Case 1: Motor Forward and Reverse Control

Control Requirements:

  • Press the forward button SB2 to run the motor forward

  • Press the reverse button SB3 to run the motor in reverse

  • Press the stop button SB1 to stop the motor

  • Forward and reverse must be interlocked to prevent simultaneous activation

I/O Allocation Table:

Device PLC Address Description
SB1 X0 Stop button
SB2 X1 Forward button
SB3 X2 Reverse button
KM1 Y0 Forward contactor
KM2 Y1 Reverse contactor

Ladder Diagram Program:

X1 X2 Y1 Y0

|—| |—-|/|—-|/|—-( )—|

X2 X1 Y0 Y1

|—| |—-|/|—-|/|—-( )—|

Debugging Key Points:

  1. Check if the interlock logic is effective
  2. Test button response time
  3. Monitor output point status

4.2 Case 2: Traffic Light Control

Control Requirements:

  • East-West green light on for 25 seconds, yellow light on for 5 seconds, red light on for 30 seconds
  • North-South signals are opposite to East-West signals
  • Night mode: All yellow lights flash

I/O Allocation Table:

Signal PLC Address Device
East-West Green Light Y0 LED Light
East-West Yellow Light Y1 LED Light
East-West Red Light Y2 LED Light
North-South Green Light Y3 LED Light
North-South Yellow Light Y4 LED Light
North-South Red Light Y5 LED Light
Mode Switch X0 Selector Switch

SFC Programming Implementation:

1. Step 0: East-West green light (Y0), North-South red light (Y5) on

2. Step 1: Timer T0 counts for 25 seconds

3. Step 2: East-West yellow light (Y1) flashes, timer T1 counts for 5 seconds

4. Step 3: East-West red light (Y2), North-South green light (Y3) on

5. Loop execution

4.3 Case 3: Automatic Filling Production Line

Control Requirements:

1. Press the start button to run the conveyor belt

2. Stop the conveyor belt when an empty bottle is detected

3. Open the solenoid valve to fill for 5 seconds

4. After filling, the conveyor belt starts again, working in a loop

5. The emergency stop button can immediately stop all devices

Program Design:

1. Use counter C0 to record the number of filled bottles

2. Timer T0 controls the filling time

3. Photoelectric sensor connected to X0 detects bottle position

4. Conveyor belt motor controlled by Y0

5. Filling solenoid valve controlled by Y1

Advanced Function Extensions:

1. Add touch screen monitoring:

  • Display production count

  • Set filling time

  • Manual/automatic mode switching

2. Networking capabilities:

  • Upload data to MES system via PROFINET

  • Receive commands from the upper computer

5. PLC Debugging and Troubleshooting

5.1 Common Debugging Techniques

1. Segmented debugging method:

  • Test input signal acquisition first

  • Then verify basic logic functions

  • Finally, coordinate the complete system

2. Online monitoring tools:

  • Real-time view of variable status

  • Force modification of I/O values

  • Track program execution flow

3. Simulation testing:

  • Use software simulation (e.g., PLCSIM)

  • Set up a test bench to simulate field signals

5.2 Typical Fault Troubleshooting

PLC no output troubleshooting process:

1. Check the power indicator status

2. Confirm that RUN mode is enabled

3. Check if the program has reached the output instruction

4. Measure the output terminal voltage

5. Check the external load circuit

Communication fault troubleshooting steps:

1. Check physical connections (network cable/DP head)

2. Verify IP address/station number settings

3. Confirm that protocol and baud rate match

4. Use diagnostic tools to analyze messages

6. Learning Path and Resource Recommendations

6.1 Phased Learning Plan

Beginner Stage (1-2 months):

  • Master the basics of ladder diagram programming

  • Complete 10 basic experiments (e.g., motor control, running lights)

  • Learn basic operations of GX Works2/TIA Portal

Intermediate Stage (3-6 months):

  • Master function blocks and data processing instructions

  • Implement HMI-PLC coordination projects

  • Learn advanced functions such as PID control

Advanced Stage (6 months and beyond):

  • Master network communication (PROFINET/Modbus)

  • Develop complex motion control systems

  • Master SCADA system integration

6.2 Quality Learning Resources

Recommended Books:

“Practical PLC Programming with 190 Examples (Mitsubishi FX Series)”: A wealth of practical cases

“Siemens S7-200 SMART PLC Practical Guide”: 7 complete engineering cases

“PLC Programming from Zero to Practical (Illustrated, Video, Cases)”: Suitable for beginners

Video Tutorials:

Bilibili “Inovance PLC Practical Case” series: Recipe programs and touch screen simulation

“PLC Programming Introduction Video Tutorial” complete course: From basics to advanced

Development Tools:

Mitsubishi GX Works3 (supports FX/Q series)

Siemens TIA Portal V17 (S7-1200/1500)

Inovance AutoShop (H5U series)

Conclusion: Suggestions for Mastery

Learning PLC technology is a gradual process. It is recommended to follow the path of “basic theory → software operation → simple projects → complex systems” to deepen understanding. The key is to practice more and accumulate experience through actual projects.

Advice for Beginners:

Start learning with ladder diagrams, then master other languages

Use simulation software first to reduce hardware costs

Participate in open-source projects (e.g., S7-1200 example collection)

Join technical communities for exchange (e.g., “Targeting Industrial Control”)

With the development of Industry 4.0, PLC technology is continuously evolving. It is recommended to keep an eye on the integration of new technologies such as Industrial Internet of Things (IIoT) and edge computing with PLC applications.

Leave a Comment