The PLC is an acronym for Programmable Logic Controller. It is a microcomputer system for industrial control.
The hardware system of the PLC must have controller (single chip, CPU, FPGA, etc.), actuator (relay, optocoupler input, etc.), main board (circuit board), all of which are indispensable. Since the current 8-bit MCU has an on-chip memory capacity of up to 64kB of program memory or 4kB of data memory, the 32-bit MCU also has 512kB of program memory and 128kB of data memory, so a simple PLC does not require off-chip memory (memory chip) , memory stick) can also run. A more powerful PLC requires additional devices such as off-chip memory and auxiliary memory (hard disk, SD card).
The software system of PLC is divided into three parts:
1. The lower computer program running on the PLC host. Used to control the output, detect the input, and communicate with the host computer. The program is a ladder diagram to C language or assembly language, and then compiled and programmed into the program memory of the PLC. Although the compilation process must pass C language or assembly language, PLC manufacturers generally do not allow users to directly write the PLC host's lower computer program using C language or assembly language.
2, PLC programming software. Used to write the user's control method to the lower computer. It converts the user's ladder diagram into a C language program or an assembly language program, which is compiled and programmed into the program memory of the PLC. The programming software itself can be developed by high-level languages ​​such as C language and C++ language. The specific development language needs to be understood by the corresponding PLC manufacturer.
3. PC software. It is used to coordinately control the running state of the PLC on a macroscopic basis, instead of performing complex calculations on the PLC, storing the operation records of the equipment, and feeding back the system information to the administrator in a visual manner. The common upper computer software is “configuration softwareâ€, which is a host computer control platform developed by PLC manufacturers or software companies. Users can use the specified scripting language for secondary development. For example, the "Kingview" software specifies the secondary development using the BASIC language. If you do not use the configuration software, users can also use the assembly language, C language, C++, JAVA, BASIC and other programming languages ​​to write code on their respective compilers to develop their own PC software.
C language is a general-purpose computer programming language oriented to the process. As a programming language in the number of programming languages, it is widely used in industrial control (*PLC driver, *embedded system, PC software), games. Development (â–² DirectX, â–² PhysicX, large game development), operating system development (*Windows core, *Linux core, *Android core), driver development (*USB driver, *serial driver, *network card driver, *hard disk drive) Software platform build (JAVA virtual machine, Oracle database), large application software development (OFFICE, VM WorkStation, CAD, PhotoShop, SolidWorks, Matlab).
In the above example, if the example with "*" on the left side, if you do not use C language, you can only select assembly language. There is no room for other choices. Any example with "▲" on the left must be transitioned through C language to use other. Language, without a logo on the left, can use languages ​​other than C, but using C will greatly simplify software development (mainly software performance is easy to improve). In addition, the C language is called the "C" language because it is the programming language that appears after the "B language". This C represents only a sequence.
After comparison, PLC is an industrial control system, including the concept of hardware and software. The C language is one of the tools for building industrial control systems and other software. Between them is the relationship between houses and symbols. PLC is a house, and C language is a symbol. Symbols, along with other pixels, are drawn into a blueprint on paper, and the various materials are assembled in blueprints to form a house. However, the existence of symbols is not visible on the built houses, and the symbols can be used not only to design houses, but also to do more and more great things.
PLC has its own programming language and cannot be programmed in C language. Each manufacturer has its own programming software, Windows programming software for several major companies such as Mitsubishi's GPP For Windows programming software, HMI human-machine interface screen design software, and MELSEC-MEDOC programming software.
The world's most famous PLC manufacturers are, General Electric Company of the United States, Allen-Bradley Company of the United States, Mitsubishi Corporation of Japan, Fuji Electric Corporation of Japan, Omron Corporation of Japan, Siemens of Germany, General Electric Company of France, TE Company of France Different manufacturers' products are far apart in use, and even different series of products from the same manufacturer have great differences in programming languages ​​and programming methods!
Plc's C language programmingThis chapter focuses on the features of the C language editing function block, editing, instruction calls, function storage, application points, etc., with a list of commonly used functions.
1, function overview
XCP adds new functions to support users to write function blocks in C language in XCP Pro programming software, and to call them where needed. The biggest advantage is that it supports almost all C language functions and enhances the confidentiality of the program. Multiple calls and calls to different files greatly increase the efficiency of the programmer.
2. Instruction form
Applicable to XC series PLC V3.0C and above, XC1, XC3, XC5 are supported.
The name consists of numbers, English, and underscores. The first character cannot be a number. The length of the name must be "=9 characters. ï¬
The name cannot conflict with the PLC built-in instruction name, such as LD, ADD, SUB, PLSR, etc. ï¬
The name cannot be the same as the function block of the current PLC.
3, the operation steps
1. Open the PLC editing software, select “Function Function Block†in the “Project†toolbar on the left, right click and select “Add New Function Blockâ€.
2. The following dialog box appears, filling in the information of the function to be edited.
3. After the new build is completed, the following edit screen will appear.
Parameter transfer mode: When the ladder is called, the incoming D and M are the starting addresses of W and B. As shown in the above figure D0, M0, W[0] is D0, W[10] is D10, B[0] is M0, and B[10] is M10. If the parameters used in the ladder diagram are D100, M100, then W[0] is D100 and B[0] is M100. Therefore, the first address of the word and bit device is set by the user in the PLC program.
Parameter W: Indicates the word device. It is used as an array when used, such as W[0]=1; W[1]=W[2]+W[3]; it can be used in the program according to the standard C specification.
Parameter B: indicates the bit device, which is also used as an array when used. Supports position 1 and bit clear, such as B[0]=1; B[1]=0; and assignment, such as B[0]=B[1 ].
Double word operation: Add a D before W, such as DW[10]=100000, which means assigning a double word to W[10]W[11].
Floating point arithmetic: Supports defining floating point variables in functions and performing floating point operations.
Function library: User function blocks can directly use the functions and constants defined in the function library. The functions and constants contained in the function library are shown in the attached section. ï¬
Other data types supported:
Predefined macros:
Fourth, the function of importing and exporting
1, export
(1) Function: Export the function as a file for import by other PLC programs.
(2) Export method
a) Editable: Export the source code and save it as a file. Once imported again, you can edit again
b) Not editable: source code is not exported. Can only be used after importing again, can't edit
2, import
Function: Import an existing function function block file for use by the PLC program.
Select the function block, right click on the menu "Import function block file from hard disk", select the corresponding file, press OK.
Fifth, the editing of the function block
Example: Add the registers D0, D1 in the PLC, and then assign the value to D2;
(1) First create a function function block in the "Project" toolbar, here we will name it ADD_2, and
Edit the C language program.
(2) After editing, click compile;
Based on the information displayed in the compilation information list, we can find the syntax violations in the C language program. It is easier to find in the program that the symbol ";" is missing after W[2]=W[0]+W[1].
When we modify the program, compile again. It can be confirmed from the list information that there is no syntax error in the program.
(3) Then write the PLC program, assign the decimal number 10, 20 to the registers D0, D1, respectively, and call the function block ADD_2. As follows:
(4) Then download the program to the PLC, run the PLC, and set M0.
(5) We can observe that the value of D2 becomes 30 through the free monitoring on the toolbar, indicating that the assignment is successful.
Six, program examples
Function: Calculate the CRC check value using the function block. ï¬
The CRC check algorithm is as follows:
(1) Let the 16-bit register (CRC register) = FFFFH.
(2) Exclude the first 8-bit byte message from the lower-order 16-bit CRC register (Exclusive OR).
(3) Shift one bit of the CRC register right and fill 0 with the high bit.
(4) Check the value of the right shift. If it is 0, the new value of the third step is stored in the CRC register. If it is non-zero, then
The value of the CRC register is XORed with A001H and the result is stored in the CRC register. (5) Repeat (3) to (4) to complete the 8-bit calculation. (6) Repeat (2) to (5) and take an 8-bit message command until all message instruction operations are completed. At last,
The value of the obtained CRC register is the check code of the CRC. It is worth noting that the CRC check code must be exchanged.
Set in the check code of the message command.
Edit the C language function block program as follows:
Write PLC ladder program, D0: check the number of bytes of data, D1 ~ D5: check the contents of the data. as follows:
Download to the PLC, then run, make M0 turn ON, through free monitoring, you will find the high and bottom bits of the CRC check value in registers D6 and D7 respectively.
Seven, application points
PLC program using function function block, after uploading. The function block cannot be uploaded and an unknown command error will occur.
Inside a function function block file, you can write multiple sub-functions and call each other.
Multiple function function block files are independent of each other and cannot call each other's own functions. ï¬
The function block file can call floating point, arithmetic and other C language library functions, such as sin, cos, tan
Eight, attached function table
ZGAR Aurora 500 Puffs
ZGAR electronic cigarette uses high-tech R&D, food grade disposable pod device and high-quality raw material. All package designs are Original IP. Our designer team is from Hong Kong. We have very high requirements for product quality, flavors taste and packaging design. The E-liquid is imported, materials are food grade, and assembly plant is medical-grade dust-free workshops.
Our products include disposable e-cigarettes, rechargeable e-cigarettes, rechargreable disposable vape pen, and various of flavors of cigarette cartridges. From 600puffs to 5000puffs, ZGAR bar Disposable offer high-tech R&D, E-cigarette improves battery capacity, We offer various of flavors and support customization. And printing designs can be customized. We have our own professional team and competitive quotations for any OEM or ODM works.
We supply OEM rechargeable disposable vape pen,OEM disposable electronic cigarette,ODM disposable vape pen,ODM disposable electronic cigarette,OEM/ODM vape pen e-cigarette,OEM/ODM atomizer device.
Aurora 500 Puffs,Pod System Vape,Pos Systems Touch Screen,Empty Disposable Vape Pod System,500Puffs Pod Vape System
ZGAR INTERNATIONAL(HK)CO., LIMITED , https://www.zgarecigarette.com