Abstract
PLC is short for Programmable Logic Controller. At present, PLC has two external forms: integrated (compact) and modular.
You have full access to this open access chapter, Download chapter PDF
PLC is short for Programmable Logic Controller. At present, PLC has two external forms: integrated (compact) and modular. The integrated type is to combine the PLC power supply, CPU processor, memory, and a certain number of I/O together to form a whole, as shown in Fig. 9.1a. This type of PLC has low cost, fixed I/O addresses, and is easy to use, the disadvantage is that the program stock is small and the functions are few. Modular PLC is composed of modules with different functions. The types of modules include: power supply module, CPU module, digital input module, digital output module, analog input module, analog output module, communication module, positioning module, counting module, etc. According to the engineering needs, a certain number of modules are combined on a base plate (or rack) to form a flexible assembled PLC, as shown in Fig. 9.1b. This kind of PLC is more expensive than the integrated PLC, but the functions and scale of control are also more powerful. This chapter will take the modular PLC as an example to explain the basic usage of PLC.
9.1 Simple Way to Get Started with Modular PLC
-
1.
First determine the signal module (SM) you are using, and find out the address arrangement method of the digital input (DI) module, digital output (DO) module, analog input (AI) module and analog output (AO) module.
Take the S7-300 PLC with four input and output modules as an example to illustrate the address assignment of the modules, as shown in Fig. 9.2.
Where PS is a power supply module, CPU is a central processing unit (control module), SM are input and output modules.
-
The address of the first SM module (the left-most) closest to the left CPU;
-
The address of the analog input (AI) module is PIW256, PIW258, PIW260–PIW270;
-
The address of the analog output (AO) module is PQW256, PQW258, PQW260–PQW270;
-
The address of the digital input (DI) module is I0.0, I0.1, I0.2–I3.7 (32 in total), or IB0, IB1, IB2, IB3, or IW0, IW2, or ID0.
-
The address of the digital output (DO) module is Q0.0, Q0.1, Q0.2–Q3.7 (32 in total), or QB0, QB1, QB2, QB3, or QW0, QW2, or QD0.
-
The addresses of SM modules at other locations can be deduced by analogy.
If the 16-way DI module is inserted into the first SM location, the address I0.0 represents the first digital input, IB0 represents upper 8 bits, IB1 represents lower 8 bits, IW0 represents all 16 bits.
If the 32-way DI module is inserted into the first SM location, the address I0.0 represents the first digital input, IW0 represents upper 16 bits, IW2 represents lower 16 bits, ID0 represents all 32 bits.
-
2.
Confirm the address programming method of PLC internal memory and data block;
Take Siemens S7-300 PLC commonly used memory M and data block DB as an example.
-
(1)
When used in bits such as M0.0, M0.1, M127.7, DB1.DBX0.0, DB1.DBX 0.1, DB10.DBX 240.0, etc., DB1 represents data block 1.
-
(2)
When used by byte, such as MB0, MB1, MB64, DB1.DBB0, DB1.DBB1, DB15.DBB7, etc.
-
(3)
When used by word, such as MW0, MW2, MW64, DB1.DBW0, DB1.DBW2, DB3.DBW 64, etc.
-
(4)
When using double words, such as MD0, MD4, MD64, DB1.DBD0, DB1.DBD4, DB3.DBD 88, etc.
-
(5)
MD0 is composed of MW0 and MW2, MW0 is composed of MB0 and MB1, MB0 is composed of M0.0, M0.1, M0.2, M0.3, M0.4, M0.5, M0.6 and M0.7.
-
(6)
DB1.DBD0 is composed of DB1.DBW0 and DB1.DBW2, DB1.DBW0 is composed of DB1.DBB0 and DB1.DBB1, and DB1.DBB0 is composed of DB1.DBX0.0–DB1.DBX0.7.
-
(7)
By analogy, it should be noted that there should be no repetition during use. For example, if M0.0–M0.7 is used, MB0, MB1, MW0 and MD0 should not be used for other purposes.
-
(1)
-
3.
Find and modify the address of the PLC programming port and communication port: plug in the programming cable (RJ45 network port or USB port) between the PLC and the programming PC, open the PLC programming software, find the PLC. Set all the default communication ports on the PLC to the address you arranged. If multiple PLCs are connected through fieldbus or industrial Ethernet, arrange that the communication addresses of each PLC should not overlap.
-
4.
According to the module models and positions in the actual PLC, insert modules of the same model modules in the corresponding position in the programming software, so that the address of the module in the software is determined as mentioned above.
-
5.
Now you can start programming.
-
6.
It should be noted that:
-
(1)
There is a corresponding relationship between the value collected by the analog input module in the PLC and the value of the actual process parameter. For example, the pressure is 0–1 MPa, the corresponding pressure sensor outputs 0–10, and 0–10 V is input to the AI module of PLC. The corresponding value in PLC is 0–27,648, such as the PIW256 analog input value of S7-300. Some PLCs may be corresponding to 0–32,768. Beginners must pay attention to this.
-
(2)
Similarly, there is also a corresponding relationship between the output value of AO module and the actual controlled parameters. For example, frequency converter’s 0–60 Hz, the value corresponding to the AO module is 0–27,648, such as PQW256. Some PLCs may correspond to 0–32,768.
-
(3)
When performing double-word floating-point operations inside the PLC, the PLC value must be converted into the corresponding process value before performing the normal calculation of energy-saving control. For example, if the pressure is 0.5 MPa, the value of the AI module’s PIW256 is 13824. It converts to 0.5 and then performs floating point operations. For analog output, it should also be converted into the corresponding output value of PLC. For example, if the inverter outputs 30 Hz, then the AO module of PLC outputs 27,648/2 = 13,824.
-
(1)
9.2 Getting Started with PLC Programming—Ladder Diagram
The commonly used programming language for PLC is ladder diagram, and the expression method of ladder diagram is similar to that of electrical diagram. In order to let beginners quickly master it, we will use ladder diagram programming method to describe the PLC programming method below. Since the ladder diagram programming methods of most PLCs follow the provisions of the international electrotechnical standards, the programming forms are basically the same.
9.2.1 “AND”
Only if the two conditions “A” and “B” are met, C will have output. The program in the PLC is shown in Fig. 9.3, and the logic relationship of “AND” is shown in Table 9.1. A and B are both normally open contacts.
9.2.2 “OR”
One condition of I1.0 “or” I1.1 is realised, then Q8.0 will output 1 (or closed). The ladder diagram of PLC is shown in Fig. 9.4, and the truth table of “or” is shown in Table 9.2. I1.0 and I1.1 are both normally open contacts. Logic tables and truth tables mean the same thing.
9.2.3 “Output”
() means output, output logic 1 (or high) if the conditions are satisfied, and output logic 0 (or low) if the conditions are not met, the ladder diagram in PLC is shown in Fig. 9.5. The logic relationship of the “output” is shown in Table 9.3.
9.2.4 “Set”
Set bit (S) indicates that it will be set to 1 when the conditions occur; when the conditions do not occur, the original state will be maintained without any action. For example, when A “and” B occur, C is set to 1. The ladder diagram of PLC is shown in Fig. 9.6, and the logic relationship of “set” is shown in Table 9.4.
The difference between the set (S) output and the immediate output () is that the immediate output () outputs low (0) when the previous conditions are not met; for the set output (S), when the previous conditions are not met, the output does not change state.
9.2.5 “Reset”
The reset output (R) resets to low when the previous conditions are met, and does not change state when the conditions are not met. For example, when I128.0 and Q12.0 meet the conditions, Q12.7 is reset to the low position, the PLC ladder diagram is shown in Fig. 9.7, and the “reset” logic table is shown in Table 9.5.
9.2.6 Data Transfer “MOV”
If you want to put the analog quantity AIW256 into the memory MW0, the PLC ladder diagram is shown in Fig. 9.8.
9.2.7 “ADD”
If you want to add the values in memories MW2 and MW4 and put the result into DBW0 of data block DB1, the ladder diagram of the PLC is as shown in Fig. 9.9. If you want to use floating point numbers for addition, you can use MD2 plus MD6. But you cannot add MD4 with MD2, because MD2 occupies 4 words, including MW4.
9.2.8 “SUB”
If MW6 is subtracted from DB1.DBW2 and the result is stored in MW8, the PLC ladder diagram is as shown in Fig. 9.10. If you want to do floating point subtraction, use MD6 to subtract DB1.DBD2.
9.2.9 “MUL”
If the data MW10 is multiplied by MW0 and the result is stored in MW2, the PLC ladder diagram is shown in Fig. 9.11. If you want to perform multiplication with floating point numbers, multiply MD0 by MD10.
9.2.10 “DIV”
If the data DB1.DBW4 is divided by DB2.DBW4, and the result is put into DB3.DBW4, the ladder diagram of PLC is shown in Fig. 9.12. If you want to divide by floating-point numbers, divide DB2.DBD4 by DB1.DBD4.
9.2.11 Counter C (Counter)
If I0.0 has a rising edge pulse, the counter C2 adds 1, the counter is cleared when I0.1 is high, MW0 stores the current counter value, and the counter C2 is an up counter. Then the PLC ladder diagram is shown in Fig. 9.13.
If I0.0 has a rising edge, the counter C2 will be decremented by 1. When I0.1 is high, the counter will be cleared. When I0.2 is high, the number in MW2 will be put into the counter. MW0 will store the current counter value, and counter C2 will be a down counter. The PLC ladder diagram is shown in Fig. 9.14.
9.2.12 Timer T (Timer)
If both M0.0 and DB1.DBX2.0 are high, the timer T4 (3 s) starts, and when T4 (3 s) expires, M0.1 is reset. The ladder diagram of the PLC is shown in Fig. 9.15.
9.2.13 Greater Than or Equal to (≥)
If MW6 is greater than or equal to MW256, set M0.7, and the ladder diagram of PLC is shown in Fig. 9.16.
9.2.14 Equal to (=)
If the number in the internal data area VW128 is equal to VW2, put VW4 into VW100, and the PLC ladder diagram is shown in Fig. 9.17.
9.2.15 Less Than (<)
If the number in MW200 is less than the number in MW240, set Q12.7, and the ladder diagram of PLC is shown in Fig. 9.18.
9.2.16 Greater Than (>)
If MW128 is greater than MW0, subtract 1 from MW128 and put it back into MW128. The ladder diagram of PLC is shown in Fig. 9.19.
9.2.17 Less Than or Equal to (≤)
If MW64 is less than or equal to MW62, then MW8 is output to the analog quantity AQW256, and the ladder diagram of PLC is shown in Fig. 9.20.
9.2.18 Rising Edge Action (P)
If I0.0 changes from low to high (there is a rising edge), set Q0.7 to high, and the ladder diagram of PLC is shown in Fig. 9.21.
9.2.19 Falling Edge Action (N)
If M0.0 and M1.1 change from satisfying conditions to not satisfying conditions (falling edge action), then subtract 1 from MW8 and return to MW8. The ladder diagram of PLC is shown in Fig. 9.22.
9.2.20 Per Second Pulse Program
In some PLC instructions, there is a special per second pulse bit, but there are also no per second pulses in some PLCs. The following is a way to make M127.0 go high once per second, and only execute it once. The length of time can be changed by changing the timer time. The PLC ladder diagram is shown in Fig. 9.23.
The working sequence of the PLC program is executed sequentially from top to bottom. The program is executed to the end, it returns to the top program. In the PLC working cycle from top to bottom, M127.0 becomes low again, and the T0 timer starts counting again; after 1 s, T0 becomes high, M127.0 becomes high, and the program executes downward until the end, and M127.0 is always high state, the program returns to the top and then executes from top to bottom. Since M127.0 is high, T0 stops timing. Then, repeat the above process.
9.2.21 PID Closed-Loop Control
PID closed-loop control can be performed in PLC. The ladder diagram of PLC is shown in Fig. 9.24. When M0.0 in the figure is closed, PID control starts. The number of PIDs varies from PLC to PLC. When applying PID in PLC, define the input address, output address, and set value storage address, and then define the data block address corresponding to the P, I, and D parameters. So that the operator on the man–machine interface or the upper computer can modify the actual situation. Then set the positive and negative effects of PID control (such as heating and cooling control), sampling period, maximum output, minimum output and other parameters (different PLCs will be different).
PID can be programmed by yourself and use the scheduled interrupt program to calculate the PID output value. The method is as follows:
Among them, ui is the current PID output value, ui−1 is the last calculated PID output value, and Δu is the current PID correction value. ei is the error this time, it is equal to the set value SV of the controlled parameter minus the actual value PV, ei = SV − PV, ei−1 is the error last time, ei-2 is the error before ei−1. P is the proportional parameter, I is the integral parameter, and D is the differential parameter. The three parameters P, I, and D need to be adjusted to obtain the best control effect.
9.3 PLC Programming Software
9.3.1 Module Configuration
Take the module configuration in Fig. 9.2 as an example.
In Siemens STEP7 programming software, insert 5A power supply module “PS307 5A”, CPU314 module “CPU314”, 16-way digital input module “DI16 × DC24V”, 16-way relay output module “DO16 × Relay output”, 8-way analog input module “AI8 × 12-bit”, 4-channel analog output module “AO4 × 12-bit”. As shown in Fig. 9.25. The third slot is reserved for the interface module IM, which is used to connect expansion racks to increase the number of SM modules in a larger control system.
After selecting the hardware board, remember the I/O address of each board shown in Fig. 9.25.
The address of the 16-way digital input module SM321 is I0.0–I3.7, IB0–IB1, IW0.
The address of the 16-way digital output module SM322 is Q4.0–Q5.7, QB4–QB5, QW4.
The address of the 8-way analog input module SM331 is PIW288–PIW302.
The address of the 4-way analog output module SM332 is PQW304–PQW310.
The address of default MPI communication port is 2, as shown in Fig. 9.25.
The MPI port is a communication bus defined by Siemens itself. If there are more than one S7-300 stations in the same network, the address of the MPI port of “CPU314” needs to be modified.
After completing this step, the subsequent software program will know how many modules in this PLC system has, what modules they are, and where they are.
9.3.2 Software Programming
Open the instruction tree of STEP software on the left, drag the normally open contact , normally closed contact and set in the “bit logic” into segment 1, and input the corresponding addresses I0.0, I0.1 and Q4.0. As shown in Fig. 9.26. I0.0 is a normally open contact. I0.1 is a normally closed contact.
The meaning of this program is: if the digital input bit I0.0 is closed, and the digital input bit I0.1 has no action, then the digital output bit Q4.0 is set to close.
STEP7 complies with the international standard IEC 61,131-3.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Copyright information
© 2024 The Author(s)
About this chapter
Cite this chapter
Yao, F., Yao, Y. (2024). Controllers Used in Energy-Saving Control Systems—PLC. In: Efficient Energy-Saving Control and Optimization for Multi-Unit Systems. Springer, Singapore. https://doi.org/10.1007/978-981-97-4492-3_9
Download citation
DOI: https://doi.org/10.1007/978-981-97-4492-3_9
Published:
Publisher Name: Springer, Singapore
Print ISBN: 978-981-97-4491-6
Online ISBN: 978-981-97-4492-3
eBook Packages: Intelligent Technologies and RoboticsIntelligent Technologies and Robotics (R0)