output1.png

1. Basics of PLC

Basic concepts and principles of PLC
A programmable logic controller (PLC) is a special-purpose computer that does not have the display, keyboard, printer and other peripherals of a traditional computer and is usually hidden in the equipment control panel. Initially, PLC was a substitute for relay panels and switchgear because the design of relay control circuits became difficult and maintenance costs were high as the equipment control logic became increasingly complex. In contrast, PLC has the advantages of small footprint, fewer faults, short action time and low energy consumption.

PLC working mode

PLC has two basic working modes: RUN and STOP. In the RUN mode, PLC realizes the control function by repeatedly executing the user program that reflects the control requirements. One cycle can be divided into five stages: internal processing, communication service, input processing, program execution and output processing. In the input processing stage, PLC reads the status of all external input circuits into the input image register; in the program execution stage, it performs logical operations and updates the component image register according to the instruction requirements; in the output processing stage, the status of the output image register is transmitted to the output latch to drive the external load to work.

Input and output system

The input interface of the PLC receives the signal of the controlled device and drives the internal circuit to connect or disconnect through the optocoupler and the input circuit. The output interface outputs the execution result of the program through the optocoupler and the output component to control the connection or disconnection of the external load. There are three types of PLC switch output interfaces: thyristor output type, transistor output type and relay output type, each with different characteristics. For example, the thyristor output type can generally only carry AC loads, with fast response speed and high action frequency; the transistor output type can generally only carry DC loads, with fast response speed and high action frequency; the relay output type can carry AC and DC loads, but the response time is long and the action frequency is low.

Logic Control Basics

Start with basic electrical control components, such as common knife switches, combination switches, fuses, circuit breakers, push button switches, AC contactors, thermal overload relays, intermediate relays, travel switches, time relays, etc. Understanding the structure and working principles of these components will help you better understand the logic control of PLC. For example, the letter symbol of the AC contactor is KM, and its contacts are divided into three parts: main contacts, auxiliary contacts, and coils. When the coil is energized, the main contacts and auxiliary contacts act at the same time to achieve control of the main circuit and control circuit.

2. Programming methods and techniques

(I) Collect more examples to increase experience

Among PLC programming methods, empirical methods are highly favored, and data collection is particularly important in empirical design methods. First, we need to collect typical program samples, which should preferably include complete control tasks, I/O allocation, hardware wiring diagrams, complete programs and comments. For example, a program example for motor forward and reverse control clarifies that the control task is to realize the forward, reverse and stop of the motor. Through reasonable I/O allocation, such as connecting the start button to a specific input point and the motor to the corresponding output point, and with a detailed hardware wiring diagram, we can intuitively understand the actual connection method. The complete program contains logical judgment, timer setting, etc., and clear comments to help us understand the role of each step.
After reading the program, decompose it into components that complete different tasks. For subroutines or interrupt programs with specific functions, collect them in the program library in time. For example, in a complex production line control program, there may be a subroutine specifically used to detect faults. When an abnormal situation occurs, the subroutine is called for fault handling. We can collect such subroutines so that we can call them directly when we encounter similar control tasks in the future, saving program design time and improving the success rate of program debugging.
At the same time, record the highlights of the program, such as the programmer's clever ideas, program structure and the use of application instructions. Taking application instructions as an example, it can greatly shorten the program length, reduce memory capacity and reduce system costs. For example, in the data processing process, the use of specific application instructions can quickly implement functions such as data sorting and filtering.
Finally, design and debug the program for functional scalability, and record the whole process in detail and summarize it. Through this process, we can effectively digest these program examples, integrate them into our future programming, and gradually establish a programming method that suits us.

(II) Smart use of software packages

Take Mitsubishi products as an example. Its software package consists of programming software GX Developer Version 8C and simulation software GX Simulator 6C. Programming software provides a programming environment for designers. We should read the programming manual carefully and master the editing skills of the program so that our design can be displayed.
The designed program needs to be debugged. The traditional debugging method is inseparable from the programming controller CPU. If necessary, input and output modules, special function modules and external machines need to be prepared. The simulation software GX Simulator can provide a virtual experimental platform. It is a soft component package running on Windows. By installing GX Simulator in a computer with GX Developer installed, offline debugging can be realized. The offline debugging function includes monitoring and testing of soft components, simulation operation of I/O of external machines, etc.
For personal learning, when there are no experimental conditions, the simulation software can develop and debug sequential control programs on personal computers. Through continuous simulation and debugging, users can gradually understand the program design experience and increase programming experience.

(III) Pay attention to special function modules

During the learning process, many people focus on software programming, but modern industrial control has brought many new issues to PLC. If general I/O modules are used to solve the problem, the hardware cost is high, the software programming is troublesome, and some control tasks cannot even be completed. Therefore, it is particularly important to learn the special function modules of PLC.
These special function modules include analog input and output modules, high-speed counting modules, and motion control modules. Taking analog input and output modules as an example, in industrial production, it is necessary to monitor and control analog quantities such as temperature and pressure. Through this module, analog quantities can be converted into digital quantities and input into PLC, and then the control signal can be output after processing. PLC manufacturers have provided detailed user manuals. We can complete the implementation of special functions by carefully reading the user manuals, simplify software programming, and reduce economic costs. For example, when using a high-speed counting module, parameter settings and programming according to the instructions in the manual can accurately count high-speed moving objects and improve production efficiency and accuracy.

3. Learning Misunderstandings and Suggestions

(I) Get out of the Eight Misunderstandings

  1. Thinking that learning PLC requires a high degree: In fact, PLC originated from the basics of electrical engineering, and can be learned with a junior high school degree. The ladder diagram in PLC is the same as the relay circuit, which is not exclusive to high-tech molecules.
  1. Think that learning PLC requires a deep foundation: If you don't have a foundation, you can make up for it first, starting with the basics of electrical engineering. PLC technology focuses on application. Even if you don't understand the principle, it's enough to achieve the actual process control goal.
  1. Think that learning PLC requires more information: The information is not about quantity but quality. You should find learning resources in a targeted manner and classify and organize them for storage. Avoid having a lot of information but not knowing where to start.
  1. Think that learning PLC requires learning many brands: There are more than 200 PLCs in the world. Currently, it is generally recognized that the better entry-level PLCs are Siemens or Mitsubishi. After getting familiar with one PLC, it is relatively easy to learn other brands.
  1. Think that learning PLC requires memorizing many programming instructions: Just remember the commonly used instructions, and the specific usage can be found in the programming software or manual. Combining actual cases to understand special instructions will be more thorough.
  1. Think that learning PLC requires learning many programming languages: It is best to use the simplest and clearest program to achieve the control goal, starting with the ladder diagram, and then learning other programming languages ​​after having a solid foundation.
  1. Think that learning PLC equipment technology is not important: Learning PLC The ultimate goal of programming is to use programs to control process equipment and processes. If you are not familiar with process control, PLC instructions are useless.
  1. Thinking that you must have many technologies to do a project: Projects can be large or small, and one person does not have to master all the technologies. In the project, you can play to your strengths and work with the team to do a good job of the project.

(II) Seven learning suggestions

  1. Lay a solid foundation: Start learning from the basics of electrical engineering and master the characteristics and basic functions of PLC. For example, PLC has the characteristics of strong versatility, strong functions, high reliability, variable control program, and has functions such as logic control, timing control, and counting control.
  1. Practice more: Start with simple programs, such as basic logic control, the use of timers and counters, etc. Solve problems in a timely manner and deepen your understanding of PLC programming through practice.
  1. Don't worry about brands: Those with a basic knowledge are advised to learn Siemens first, and those without a basic knowledge should learn Mitsubishi first. After mastering these two representative brands, other brands can be self-taught. Adapting to corporate needs, mastering more brands is more advantageous.
  1. Start with simple programming: First write a simple PLC program, such as the start, stop, forward and reverse rotation of the motor, and traffic light control. Gradually increase the complexity and difficulty of the program.
  1. Collect more examples to increase experience: Collect typical program examples, decompose them into different parts after understanding, and collect subroutines with specific functions. Record the highlights of the program, design, debug and summarize the functional extensibility.
  1. Use software packages skillfully: Master the editing skills of programming software and use simulation software for offline debugging. Develop and debug sequential control programs on personal computers to increase programming experience.
  1. Pay attention to special function modules: Learn special function modules such as analog input and output modules, high-speed counting modules and motion control modules. By studying the user manual, complete the implementation of special functions, simplify software programming, and reduce economic costs.

4. Programming Practice and Confidence

(I) Practice Boldly

Many beginners are often afraid of PLCs, and are afraid of damaging the equipment and dare not actually operate it. However, this fear is unreasonable. It is very important to read the manual carefully, but you cannot become an excellent engineer just by reading. The manual content is not comprehensive. When you are exposed to unfamiliar instructions, you can write a small program separately, let the PLC run, and then modify the conditions one by one to observe the running results. Programming software like MicroWin provides users with very good monitoring methods. By observing the monitoring situation and then re-understanding the description in the manual, you can intuitively understand the functions and usage of these instructions.
Don't worry that the program you wrote will have problems and affect the normal operation of the PLC. Whether there is a problem with the program can only be discovered by running the PLC. And discovering and solving problems is to improve your ability. Putting aside the hardware operation, as far as the software is concerned, there are still few cases where the PLC is damaged due to software problems. Therefore, bold practice is the only way to PLC programming. Of course, bold practice is not barbaric operation, but must follow the necessary specifications. Another thing to note is that before the program is proven to be reliable, never connect the load to avoid unnecessary losses. The output of digital quantity is displayed by LED; while analog quantity processing can be solved by some hardware or software simulation methods.

(II) Cultivate logical thinking

Programming itself is a process of logical thinking. In high-level languages, the most commonly used conditional judgment statements are if then else and select, which are the cause-effect relationship in logic. PLC programs are composed of these cause-effect relationships: judging whether the conditions are met, and then deciding to execute the corresponding instructions.
The original PLC was used to replace the relay logic circuit, so it inherited the description method of the relay circuit using contacts as trigger conditions. In PLC, virtual contacts replace the metal contacts of the relay, and the logical relationship expressed by the relay circuit is still completely preserved. Even if the numerical processing process that relay circuits are not competent for is introduced, PLC is still fundamentally executing cause and effect relationships.
Therefore, to sort out the logical relationship between the various events of the object, this is a careful preparation before programming. For example, in a control project of an automated production line, the working order and logical relationship of each device must be clarified first. From the input of raw materials to each processing link, and then to the output of finished products, each link has specific conditions and triggering events. We can sort out a logical relationship diagram, discuss it repeatedly with the user, obtain the user's approval, and then really enter the program writing process.
For example, in an automobile assembly production line, when the sensor detects that the car body has reached a specific position, it triggers the robot arm to perform a grabbing operation, and then installs the parts on the car body. In this process, the sensor signal is the trigger condition, and the action of the robot arm is the execution instruction. Through such analysis and arrangement, the logical relationship of the entire production process can be clearly seen, providing clear ideas and directions for programming.

5. Related knowledge and habits

(I) Master the necessary knowledge

PLC programs are specific process processes that directly act on objects, so understanding the specific process of objects is crucial. Among them, there are two indispensable knowledge.
On the one hand, it is the hardware knowledge of process instruments, including sensors, transmitters (secondary instruments) and PLC itself. Sensors are like the "eyes" and "ears" of the control system, responsible for collecting information on various physical quantities. For example, temperature sensors can convert ambient temperature into electrical signals and transmit them to PLC. Transmitters amplify the weak signals collected by sensors and convert them into standard signal outputs. For example, pressure transmitters can convert signals of different pressure ranges into a unified 4-20mA current signal. As the control core, PLC receives and processes these signals and makes corresponding control decisions. This is the basis for building a control system. For example, in a chemical production process, sensors such as temperature, pressure, and liquid level transmit real-time data to PLC. PLC makes logical judgments and control outputs based on these data, adjusts valve opening, motor speed, etc., to ensure the stable operation of the production process.
On the other hand, there is process control theory, of which the most important are two-position regulation and PID regulation models. PID regulation is currently the most widely used process control method and has many variations. PID stands for proportional, integral, and derivative control. Take temperature control as an example. When there is a deviation between the actual temperature and the set temperature, proportional control makes quick adjustments based on the size of the deviation, but there may be steady-state errors. Integral control accumulates the deviation to eliminate steady-state errors, but it may take too long to adjust. Derivative control makes adjustments based on the rate of temperature change, predicts the temperature change trend in advance, and improves the response speed and stability of the system. The best way to learn PID is to read books. Almost all books on process control have content about PID. Read more related books.This book is very helpful for understanding PID. For example, in a temperature control system of a heating furnace, by reasonably adjusting the PID parameters, the temperature can be accurately controlled so that the temperature is stable near the set value with a very small fluctuation range.

(II) Develop good habits

Developing good programming habits is crucial to improving PLC programming efficiency and program quality.
First, we need to sort out the logical relationship and timing relationship and compile a program flowchart. Before programming, we should first analyze the control task in detail and clarify the logical relationship and time sequence between each input and output signal. For example, in the control program of an automated production line, the start and stop sequence of different devices, signal transmission and feedback, etc. need to be clearly sorted out, and then the flow and logical structure of the entire program can be intuitively displayed by drawing a flowchart. In this way, the code can be written more systematically during the programming process, reducing the occurrence of errors.
Secondly, the main program, subprograms and interrupt programs are reasonably allocated. As the backbone of the program, the main program is responsible for overall process control and coordinating the calls of various subprograms. Subprograms are used to implement specific functional modules, such as data processing, fault diagnosis, etc. Interrupt programs are triggered and executed when specific events occur, such as timer interrupts, external signal interrupts, etc. Reasonable allocation of these programs can make the program structure clearer and easier to maintain and expand. For example, in a motor control system, the forward and reverse control, speed regulation and other functions of the motor can be written into subprograms, which can be called as needed in the main program. When an emergency occurs, the motor can be stopped immediately through the interrupt program to improve the safety of the system.
Finally, allocate registers reasonably and compile register symbol tables. Many operations of PLC are directly for registers. If unreasonable register address overlap occurs in the program, unpredictable consequences will occur. Compiling a register symbol table can not only avoid the above problems, but also make the program more readable. This is just like giving meaningful names to variables in programming, which makes it easier for programmers to understand and maintain programs. For example, in a complex control system, a large number of registers may be used to store various data. If there is no reasonable allocation and symbol table, confusion and errors are likely to occur. By compiling a register symbol table, you can clearly know the purpose of each register and the type of data stored, improving programming efficiency and program reliability.

6. Examples and Summary

(I) Analysis of Motor Control Examples

  1. Single button controls multiple motors: For example, in the case of "Using PLC scanning principle to achieve single button control of N motors", through clever program design, a single button is used to control four motors to start in reverse order and stop in sequence. The I/O address is clearly defined, and a detailed I/O address allocation table is established according to the control requirements. A clear PLC wiring diagram and reference program are also provided. In actual programming, this idea can be used as a reference to flexibly adjust the program according to specific control requirements to achieve precise control of multiple devices.
  1. Motor timing control: In the case of "Motor timing and PLC wiring diagram - Electronic enthusiasts network", a button is used to control a motor, and the control requirements of the motor running forward for 8s, stopping for 8s, reversing for 8s, stopping for 8s, and cycling are achieved when the button is closed. Through detailed IO allocation tables, wiring diagrams and program design, it shows how to use PLC to achieve complex timing control functions. This timing control is widely used in many automated production lines, such as controlling the intermittent operation of equipment on the assembly line to improve production efficiency.
  1. Sequential start control of motors: "PLC control quick start, detailed explanation of sequential start control wiring diagram of motors and ladder diagram program" and other cases all involve sequential start control of motors. This control method is very common in actual production. For example, during the startup of some large equipment, in order to avoid the impact of excessive instantaneous current on the power grid, it is necessary to start each motor in a certain order. By studying these cases, you can master the methods of I/O allocation, wiring diagram drawing and ladder diagram program writing to achieve precise control of sequential start of motors.

(II) Summary of PLC Getting Started

  1. Combining theory with practice: Start by understanding the basic concepts, principles and working methods of PLC, and master theoretical knowledge such as input and output systems and logic control basics. At the same time, through actual programming cases, such as motor control examples, practical operations are carried out to deepen the understanding of theoretical knowledge.
  1. Use programming tools skillfully: Learn to use programming software and simulation software, such as Mitsubishi's GX Developer Version 8C and GX Simulator 6C. Use programming software for program design and simulation software for offline debugging to improve programming efficiency and accuracy.
  1. Pay attention to special function modules: Learn special function modules such as analog input and output modules, high-speed counting modules and motion control modules, and select appropriate modules according to actual control needs to improve system performance and functions.
  1. Develop good programming habits: Sort out the logical relationship and timing relationship, compile a flowchart; reasonably allocate the main program, subroutine and interrupt program; reasonably allocate registers and compile a register symbol table. These good programming habits can improve the quality and maintainability of the program.

(III) Start the journey of automation programming from an international perspective

From an international perspective, PLC technology continues to develop and innovate. The automation production needs of different countries and regions vary, but as a core control device, the basic principles and programming methods of PLC are the same. By learning advanced PLC application cases and technologies in the world, we can broaden our horizons and understand automation solutions in different industries. At the same time, we should actively participate in international exchanges and cooperation, share our own experiences and achievements, and jointly promote the development of PLC technology. In this process, we should continue to learn and master new technologies and methods, adapt to the ever-changing market needs, and start our own automation programming journey.