The basic composition and principle of PLC learning

Programmable Controller (PC) should be originally referred to as PC. In order to distinguish it from personal computer PC, the programmable controller is abbreviated as PLC (Programmable Logic Controller), but it does not mean PLC can only control logic signals. PLC is designed for industrial environment applications. It comes with an intuitive, simple and easy to grasp the programming language environment of industrial field control devices.

First, the basic composition of PLC

The basic composition of the PLC includes a central processing unit (CPU), a memory, an input/output interface (abbreviated as I/O, including an input interface, an output interface, an external device interface, an expansion interface, etc.), an external device programmer, and a power supply module. figure 1. Each internal unit of the PLC is connected through a power bus, a control bus, an address bus, and a data bus. Externally, corresponding equipment and control devices are configured according to actual control objects to constitute a PLC control system.

Figure 1 The basic composition of PLC

Central processor

The central processing unit (CPU) consists of controllers, operators, and registers and is integrated in one chip. The CPU is connected to the memory, input/output interface, programmer, and power supply through the data bus, address bus, control bus, and power bus.
The CPU of the small PLC adopts 8-bit or 16-bit microprocessor or single-chip microcomputer, such as 8031, M68000, etc. The price of this type of chip is very low; the PLC of medium-sized PLC adopts 16-bit or 32-bit microprocessor or single-chip microcomputer, such as 8086 and 96 series. SCM, etc., The main characteristics of this type of chip is the high degree of integration, fast operation and high reliability; while the large-scale PLC requires the use of high-speed chip microcomputer.
The CPU commands the PLC control system to perform various tasks in accordance with the functions assigned to the system programs in the PLC.

2. Memory

The memory in the PLC is mainly used to store system programs, user programs and data.
1) System Program Memory The PLC system program determines the basic functions of the PLC. This part of the program is written by the PLC manufacturer and solidified in the system program memory, mainly including the system management program, the user instruction interpreter, and the function program and system program call. .
The system management program mainly controls the PLC operation and makes the PLC work in the correct order. The user instruction interpreter program converts the PLC user instructions into machine language instructions and transfers them to the CPU for execution. The function program and system program calls are responsible for invoking different functions. Subroutines and their management programs.
The system program belongs to important data that needs to be stored for a long period of time, so its memory is ROM or EPROM. The ROM is a read-only memory. The memory can only read the content and cannot write the content. The ROM has a non-volatile function, that is, the stored content can still be saved after the power is turned off.
EPEROM is an electrically erasable and read-only memory, and it needs to irradiate the lens window on the chip with ultraviolet light to erase the written content, and it can electrically erase the programmable read-only memory as well as E2PROM and FLASH.
2) User program memory The user program memory is used to store user loaded PLC application programs. Since the initial user program needs to be modified and debugged, it is called a user debugging program and is stored in a random access memory that can be randomly read and written. RAM to facilitate user modification and debugging.
Since the program after modification and debugging is called a user execution program, since the user does not need to perform modification and debugging, the user execution program is solidified into the EPROM for long-term use.
3) Data memory PLC needs to generate or call intermediate result data (such as input/output element status data, timers, counter preset values ​​and current values, etc.) and configuration data (such as input and output configuration, settings) Input filtering, pulse capture, output table configuration, storage area retention, analog potentiometer settings, high-speed counter configuration, high-speed pulse output configuration, communication configuration, etc.). This type of data is stored in the working data memory due to the working data and Configuration data is constantly changing and does not require long-term storage, so random access memory RAM is used.
RAM is a kind of high-density, low-power semiconductor memory that can be used as a standby power supply for lithium batteries. Once it is powered off, it can be powered by a lithium battery to maintain the contents of RAM.

3. Interface

The input/output interface is the interface circuit between the PLC and industrial field control or detection elements and actuators. PLC input interface has DC input, AC input, AC and DC input and other types; output interface has transistor output, thyristor output and relay output and other types. Transistors and thyristor outputs are non-contact output type circuits, transistor output types are used for high-frequency low-power loads, thyristor output types are used for high-frequency high-power loads, and relay outputs are contact-output type circuits for low-frequency loads.
The on-site control or detection element inputs various control signals to the PLC, such as limit switches, operation buttons, selector switches, and some other sensor output switches or analogs, etc., and these signals are converted into CPUs to receive and process through the input interface circuit. signal of. The output interface circuit converts the weak control signal sent from the CPU into a strong electrical signal output required on the spot to drive actuators of controlled devices such as solenoid valves and contactors.
1) Input interface The input interface is used to receive and collect two types of input signals, one is a switch input signal such as a button, a switch, a trip switch, and a relay contact; the other is a potentiometer, a tachometer generator Continuously variable analog input signals provided by various inverters.
Take the DC input interface circuit shown in Figure 2 as an example. R1 is a current-limiting and voltage-dividing resistor. R2 and C form a filter circuit. The filtered input signal is coupled to the internal circuit through the optocoupler T. When the input button SB is turned on, the photocoupler T is turned on, and the DC input signal is converted into a 5V standard signal level (TTL for short) that the PLC can process. At the same time, the LED input indicator is on, indicating that the signal is ON. Microcomputer input interface circuits generally consist of registers, gating circuits, and interrupt request logic circuits that are integrated on a single chip. AC input and AC/DC input interface circuits are similar to DC input interface circuits.

Figure 2 DC input interface circuit

The filter circuit is used to eliminate the jitter of the input contact, and the optocoupler circuit can prevent the strong electric interference in the field from entering the PLC. Because the input electrical signal is coupled with the internal circuit of the PLC using optical signals, the two are electrically isolated from each other, so that the input interface has anti-interference ability. The on-site input signal is converted into a 5V TTL input data register through optocoupler and transmitted to the CPU via the data bus.
2) Output Interface The output interface circuit outputs control signals to various actuators of the controlled object. Commonly used actuators include contactors, solenoid valves, control valves (analogues), speed controllers (analogues), indicator lights, digital display devices, and alarm devices. The output interface circuit is generally composed of a microcomputer output interface circuit and a power amplifier circuit. Similar to the input interface circuit, an opto-electric coupler is used to perform anti-interference electrical isolation between the internal circuit and the output interface circuit.
The microcomputer output interface circuit is generally integrated on the chip by the output data register, the gating circuit and the interrupt request logic circuit. The CPU sends the output signal to the output data register through the data bus. The power amplifier circuit is to meet the industrial control requirements, and the microcomputer is Output signal amplification.
3) Other interfaces If the number of I/Os of the host unit is insufficient, expansion can be performed by connecting the I/O expansion interface cable to the I/O expansion unit (without the CPU). PLCs are also often configured to interface with various peripheral devices. Serial communication and EPROM writing functions can be implemented through cables.

4. Programmer

The role of the programmer is to download the user-written program to the user program memory of the PLC, and use the programmer to check, modify, and debug the user program, monitor the execution of the user program, and display PLC status, internal devices, and system parameters.
The programmer has two kinds of simple programmer and graphic programmer. The simple programmer is small in size and easy to carry, but it can only be programmed on-line in a statement format, which is suitable for programming and on-site debugging of small PLCs. The graphics programmer can be programmed both in the form of sentences and in ladders, while also allowing offline programming.
At present, most PLC manufacturers have developed computer-aided PLC programming support software. When a personal computer is installed with PLC programming support software, it can be used as a graphic programmer to edit and modify the user program and communicate with the personal computer and the PLC. The interface implements two-way transmission of the user program and monitors the PLC operating status.

5. Power supply

The PLC's power supply converts externally supplied AC power into DC power for the CPU, memory, etc., and is the power supply center for the entire PLC. Most PLCs use high-quality switching power supplies with good working stability and strong anti-interference ability. Many PLC power supplies can also provide external DC 24V power supplies for power supply to the incoming electrical components on the input interface. Peripheral configuration.

Second, the PLC works 1. PLC internal and external circuits

1) External circuit wiring

Figure 3 is the contactor electrical control circuit for motor full voltage start control. The control logic consists of AC contactor KM coil, indicator lamps HL1, HL2, thermal relay normally closed contact FR, stop button SB2, start button SB1 and contactor normally open The auxiliary contact KM is realized by a wire connection.
After closing the QS and pressing the start button SB1, the coil KM is energized and self-locked, the auxiliary contact KM of the branch where the indicator lamp HL1 is located is connected with the main contact in the main circuit, HL1 is on, and the motor M is started; Button SB2, the coil KM power off, indicator light HL1 off, M stalled.
Figure 4 is an external wiring diagram of a full-voltage motor start control using an S7 series PLC from SIEMENS. The main circuit remains unchanged, the thermal relay normally closed contact FR, stop button SB2, start button SB1, etc. are connected as input devices of the PLC to the input interface of the PLC, and the AC contactor KM coil, indicator lamps HL1, HL2, etc. are used as the PLC. The output device is connected to the output interface of the PLC. The system logic is implemented by executing a user program that is programmed according to the full voltage control requirements of the motor and stored in the program memory.

Figure 3 motor full voltage start electrical control circuit
a) Main circuit b) Control line

Figure 4 motor full voltage start PLC control wiring diagram
a) Main circuit b) Actual wiring diagram of I/O

2) Establishing an internal I/O image area Opens an I/O image memory area in the PLC memory for storing the status of I/O signals. These are called the input image register and the output image register. In addition, other PLC programming elements also have a phase. The corresponding image memory is called the component image register.
The size of the I/O image area is determined by the system program of the PLC. For each input point of the system, there is always a corresponding one of the input image areas. For each output point of the system, there is also an output image area. A bit corresponds to this, and the address number of the input/output point of the system also corresponds to the address number of the shadow register of the I/O map area.
When the PLC is working, the collected input signal status is stored in the corresponding bit in the input image area. The operation result is stored in the corresponding position in the output image area. When the PLC executes the user program, it needs to describe the equivalent contact of the input relay or The data of the equivalent contact and equivalent coil status of the output relay is taken in the I/O mapping area without directly relating to the external device.
The creation of the I/O map area causes the PLC to work only in relation to the state data stored in the memory address unit, and the system output only sets a state data for an address unit in the memory. This not only speeds up the execution of the program, but also separates the control system from the outside world, improving the system's ability to resist interference.
3) Internal Equivalent Circuit Figure 5 shows the internal equivalent circuit of the PLC. Taking the start button SB1 as an example, the access interface I0.0 is connected to a trigger I0.0 of the input image area. When SB1 is turned on The trigger I0.0 is triggered to a "1" state, and the "1" state can be directly referenced by the user program as the state of the I0.0 contact. At this time, the I0.0 contact is the same as the SB1 on-off state. , SB1 is connected, I0.0 contact state is “1”, otherwise SB1 is disconnected, I0.0 contact state is “0”, because I0.0 trigger function is the same as the relay coil and does not need hard connection line, Therefore, the I0.0 trigger is equivalent to an I0.0 soft relay coil inside the PLC. The I0.0 contact directly referencing the I0.0 coil state is equivalent to a normally open contact controlled by the I0.0 coil ( Or called moving contact).

Figure 5 PLC internal equivalent circuit

Similarly, the stop button SB2 is connected with a soft relay coil I0.1 inside the PLC, SB2 is closed, the state of the I0.1 coil is "1", otherwise it is "0", and the status of the relay coil I0.1 is used by the user. After the program is reversed, it is referenced to the state of I0.1 contact, so I0.1 is equivalent to a normally closed contact (or a break contact) controlled by the I0.1 coil. The output contacts Q0.0 and Q0.1 are the physical normally open contacts of the PLC internal relay. Once closed, the external corresponding KM coil and indicator light HL1 will turn on. The PLC output has a common interface COM for output power.

2. PLC control system

Using PLC to realize the electric motor full-voltage starting electrical control system, its main circuit basically remains unchanged, and uses PLC to replace the electric control circuit.
1) PLC control system structure Figure 6 is the basic composition diagram of the PLC control system for motor full voltage starting, which can be divided into three parts: input circuit, internal control circuit and output circuit.
Input circuit

Fig. 6 The basic block diagram of PLC control system

The role of the input circuit is to send the input control signal to the PLC. The input device is the normally closed contacts of the buttons SB1, SB2, and FR. The externally input control signal is input to the corresponding one input relay via the PLC. The input relay can provide any number of normally open contacts and normally closed contacts for programming and use of the PLC content control circuit.
The function of the output circuit output circuit is to convert the PLC output control signal into a signal that can drive the KM coil and the HL1 indicator light. There are many output relays in the internal control circuit of the PLC. Each output relay provides a normally open contact and an output port for the output circuit in addition to the normally open contacts and the normally closed contacts for programming in the PLC internal control circuit. The contact is called internal hard contact and is an internal physical normally open contact. Through this contact, the load of the external KM coil and HL1 indicator is driven, and the KM coil controls the start and stop of the motor M through the KM main contact in the main circuit. The power for driving the load is provided by the power supply of the external power unit. The output port of the PLC also has a COM common terminal for output power.
The internal control circuit of the internal control circuit is formed by a user program written in accordance with the actual control requirements of the controlled motor. Its role is to calculate, process, and judge the status of the input and output signals according to the logic relationship specified by the user program, and then obtain the corresponding output. The control signal drives the output device through the control signal: motor M, indicator light HL1, and the like.
The user program writes all program statements to the user program memory of the PLC through personal computer communication or programmer input. The user program modification only needs to change some of the statements in the memory through the device such as a programmer, and does not change the internal wiring of the controller, thereby realizing the flexibility of control.
2) PLC Control Ladder Diagram A ladder diagram is an equivalent control circuit in which the PLC internal is equivalent to a coil consisting of many internal relays, normally open contacts, normally closed contacts or functional blocks. Figure 7 shows the equivalent control element symbols commonly used in PLC ladder diagrams.

Figure 7 Ladder Diagram Common Equivalent Control Symbols
a) coil b) normally open contact c) normally closed contact

Fig. 8 is the PLC control ladder diagram of the motor full-voltage starter, equivalent control elements corresponding to parts such as FR normally closed contact, SB2 normally closed button, KM normally open auxiliary contact and SB1 normally open button parallel unit, KM coil, etc. Symbols are made in tandem. The motor full-voltage start control trapezoid is similar in form to the contactor electrical control circuit diagram, but there are also many differences from the electrical control circuit diagram.

Figure 8 motor full-voltage start control ladder

The physical structure of the relay element in the ladder diagram is different from that of the coil and the contact element in the PLC ladder diagram of the electrical element. It is only functionally equivalent to the coil and contact of the electrical element. Ladder diagram coils, contacts in the physical sense of the input, output memory, a storage bit, and electrical components of the physical structure is different.
The on-off state of the relay element in the ladder diagram is different from the on-off state of the relay element in the ladder diagram of the electrical element and is related to the stored data on the corresponding storage location. If the data of the storage location is "1", the element is in the "pass." "State, if the bit data is "0", it means "off" state. The actual on-off state of the electrical component is different.
The relay element state switching process in the ladder diagram is different from that of the relay element in the ladder diagram of the electrical component. The PLC only operates the status data of the storage bit. If the PLC assigns “1” to the equivalent storage bit data of the normally open contact, To complete the dynamic closing operation process, if the equivalent storage position data of the normally closed contact is assigned "0", the operation process of the cut-off operation can be completed, and there is no time delay in the switching operation. When the electrical element coils and contacts are moved or disconnected, there must be a time delay, and the operation process of closing and closing is generally required.
The number of contacts in the ladder diagram is different from that of the electrical components. If the PLC takes the bit data “0” from the corresponding storage bit of the input relay I0.0 and stores it in a memory bit in another memory, it is stored. The memory bit becomes a normally open contact controlled by the I0.0 relay and the stored data is "0"; if the bit data is taken after "0", the negation operation is performed first, and then stored in a memory. When storing a bit, the data stored in this bit is "1", and this storage bit becomes a normally closed contact controlled by the relay I0.0.
As long as the PLC has enough internal memory, this bit data transfer operation can be performed indefinitely, and each time an operation is performed, a relay contact in a ladder diagram can be generated. Therefore, it can be seen that the relay contacts in the ladder diagram can be operated in principle. Unlimited use repeatedly.
However, the coils inside the PLC can only be referenced once. If you need to use the coil with the same address number repeatedly, you should be cautious. Unlike PLCs, the number of contacts in electrical components is limited.
Each line of the ladder diagram starts with the left bus and passes through the contacts and coils (or function blocks) to terminate at the right bus. The general parallel unit is drawn on the left side of each row, the output coil is on the right side, and the rest of the series elements are drawn in the middle.

3. PLC working process

After the PLC is powered on, various tasks within the system are inquired, judged, and executed in a certain order, under the supervision of the system program, as shown in FIG. 9 .

Figure 9 PLC sequential cycle process

1) Power-on initialization After the PLC is powered on, the system is initialized first, including hardware initialization, configuration check of I/O modules, setting of power outage protection range, and clearing of internal relays and resetting of timers.
2) The CPU self-diagnosis must perform self-diagnosis in each scan cycle, and check the power supply, PLC internal circuit, user program syntax, etc. through self-diagnosis. If any abnormality is found, the CPU turns on the abnormal relay, and abnormal indication on the PLC panel. The light LED is on, an error code is stored in the internal special register and the fault display flag is given. If it is not a fatal error, the STOP state of the PLC is entered; if it is a fatal error, the CPU is forcibly stopped, and the STOP state is entered after the error is eliminated.
3) Communication with external devices and external devices During the communication phase, the PLC exchanges information with other intelligent devices, programmers, terminal devices, color graphic displays, and other PLCs, and then makes judgments on the status of PLC operations.
The PLC has two working states, STOP and RUN. If the PLC is in the STOP state, the user program will not be executed. It will exchange information with the programmer and other devices to complete the editing, modification, and debugging of the user program. If the PLC is in the RUN state, Will enter the scanning process and execute the user program.
4) The scanning process saves the state of the external input signal in the input image area by scanning, executes the user program, and stores the execution result output in the output image area until it is transmitted to the external device.
After the PLC is powered on, the above work process is executed periodically until the power is turned off.

4. User program loop scan

PLC cyclic scanning of the user program is divided into three stages of input sampling, program execution and output refresh, see Figure 10.

Figure 10 PLC user program scanning process

1) Input sampling stage The CPU will input all field input signals, such as button, limit switch and speed relay, into the image register through the input interface of PLC. This process is called input sampling. After the input sampling is completed, the program execution phase is entered. Even if the input signal changes, the data in the input shadow register will not change until one scan cycle ends, and the next time the input is sampled, it will be updated. This input work method is called centralized input mode.
2) Program Execution Phase In the program execution phase of the PLC, if there is no interrupt or jump instruction, the execution will be performed one by one from top to bottom and from left to right in accordance with the ladder program. Read the status data “0” or “1” of the programming element from the input image register, output image register, and auxiliary relay, and perform the corresponding operation according to the logic relationship specified by the ladder diagram, and write the operation result to the corresponding component image. Register saved. The signal that needs to be output to the outside is stored in the output image register and saved by the output latch.
3) Output processing stage The CPU transfers the status of the output shadow register to the outside via the output latch and output interface of the PLC to drive loads such as contactors and indicator lights. At this time, the contents saved by the output latch will not be refreshed until the output stage of the next scan cycle. This output work method is called centralized output mode.
4) PLC scan process example The ladder diagram will be stored in the user program memory of the PLC in the form of an instruction statement table. The instruction statement table is another PLC programming language. A table consisting of a series of operation instructions describes the control flow of the PLC. The mnemonics used in different PLC instruction statement tables are not the same. The function program of motor full voltage start ladder diagram written by SIEMENS S7-300 series PLC instruction statement table is as follows:
A (
O I0.0 // Take I0.0 and store it in the operation stack.
O Q0.0 //Q0.0 and the data in the stack are ORed and the result is stored on the stack;
)
AN I0.1 //I0.1 takes the non-AND data in the stack and performs the AND operation, and the result is stored on the stack;
AN I0.2 // I0.2 takes non-lattice and intra-stack data and performs an AND operation, and the result is stored on the stack;
= Q0.0 // Send the data in the stack to the output image register Q0.0;
A Q0.0 // Take out Q0.0 data and store it on the stack;
= Q0.1 // Send the data in the stack to output image register Q0.1;
MEND //The main program ends.
The statement statement table is a program composed of a number of statements, and the statement is the smallest independent unit of the program. Each operation function is executed by one or more statements. The PLC statement consists of two parts: the operation code and the operand. The operation code is represented by a mnemonic (for example, A means "take", O means "or", etc.) to explain the function to be executed, that is, to tell the CPU what to do. The main functions of the operation code include the addition, subtraction, multiplication, and division in arithmetic operations, and the functions of time, count, and shift in time or condition control.
Operands generally consist of identifiers and parameters. Identifiers represent the type of operands, such as input relays, output relays, timers, counters, data registers, etc.; and parameters represent the address of an operand or a preset value.
Take the PLC full-voltage start control system as an example. During the input sampling phase, the CPU reads the contact state of SB1, SB2, and FR into the corresponding input image register. When the external contact is closed, the binary value “1” is stored in the register. , on the contrary, deposit "0". The end of the input sample enters the program execution phase, see Figure 11.
When the first and second instructions are executed, information "1" or "0" is fetched from the corresponding input shadow register of I0.0 and stored in the operator called "stack".
When executing the 3rd instruction, the information "1" or "0" in the output image register corresponding to Q0.0 is fetched, and the content in the stack is "or", and the result is stored in the stack again (the parallel connection of the circuit corresponds to " Or "operation".
When executing the 4th and 5th instructions, the state data of I0.1 is firstly taken out for non-operation, and then it is stored on the stack after being ANDed with the data in the stack, and then the state data of I0.2 is taken out for non-computing operations. , and then "and" with the data in the stack and store it again on the stack (the series in the circuit corresponds to the "and" operation).
When executing clause 6, the binary data in the stack is sent to the corresponding output image register of Q0.0.
When executing the 7th instruction, the binary data in the Q0.0 output image register is taken out and stored on the stack.
When executing the eighth instruction, the binary data in the stack is fetched and sent to the corresponding image register of Q2.0.
Execute the 9th instruction, end a cycle scan process of the user program, and start the next scan process.
In the output processing phase, the CPU transfers the binary number in each output shadow register to the output latch. If the binary number stored in the output image register corresponding to Q0.0 and Q0.1 is “1”, the external KM coil and indicator lamp HL1 will be energized; otherwise, it will be powered off.

Figure 11 Motor Full Voltage Start PLC Control Scanning Process

5) Differences between relay control and PLC control The working principle of the PLC program can be briefly described as top-to-bottom, left-to-right, cycle-by-cycle, and sequential execution. There is a difference in the parallel control method with the relay control circuit, see Figure 12.
Figure 12a) Control diagram, if the relay control circuit, because it is a parallel control method, the first is the coil Q0.0 and coil Q0.1 are energized, and then because the normally closed contact Q0.1 disconnect, resulting in coil Q0. 0 power off.
If it is a ladder control circuit, when I0.0 is turned on, coil Q0.0 is energized, then Q0.1 is energized to complete the first scan; after the second scan, coil Q0.0 is normally closed due to contacts. Q0.1 disconnects and powers off, while Q0.1 powers up.
Fig. 12b) In the control diagram, if the relay is a control circuit, both coil Q0.0 and coil Q0.1 are first energized and then Q0.1 is de-energized.
If it is a ladder diagram control line, the contact I0.0 is turned on, so the coil Q0.1 is energized, and then the second line is scanned. As a result, since the normally closed contact Q0.1 is disconnected, the coil Q0.0 cannot always be energized. .

Fig.12 Analysis of on-off status of control contacts in ladder diagram and relay diagram
a) There is no difference in contact continuity. b) There is a difference in contact continuity.

Three tasks

Describe the role of each component of the PLC; read the PLC peripheral wiring diagram; master the basic drawing rules of PLC ladder diagram.

Information: Organize and summarize the notes of the lecture: Determine the basic circuit of the electrical control As an exercise plan for changing the external wiring after the PLC control Plan: Take the motor full-voltage start as an example, make the peripheral wiring, draw the corresponding PLC ladder plan implementation: After school completion PLC peripheral wiring diagram and PLC control ladder diagram drawing inspection: team mutual investigation evaluation: group evaluation

Zinc Sulfate food grade is different from technical grade, it is produced by Zinc oxide and sulfuric acid, both food grade. It can be used in nutritional supplement medicines or fortifiers.

Zinc Sulfate

Zinc Sulfate Monohydrate, Zinc Sulfate Heptahydrate, Zinc Sulfate Food Additive, Zinc Sulfate Feed Grade

Jiangsu Kolod Food Ingredients Co., Ltd. , https://www.kolodchem.com