2, PLC's basic structure
b, memory C, power 3, PLC works One. Scanning technology When the PLC put into operation, its work process is generally divided into three stages, namely the input sample, the user program execution and output refresh three stages. Completion of the three phases is called a scan cycle. During the entire operation, PLC's CPU scan speed of a certain repeat the above three stages.
The input sampling stage, PLC to scan the input in order to read all the states and data, and deposit them with the I / O image area in the corresponding the cell. After the input sample, transferred to the user program execution and output refresh stage. In both phases, even if the input state and data changes, I / O image area in the state and the corresponding data elements will not change. Therefore, if the input is a pulse signal, the pulse width must be greater than a scan cycle, to ensure that in any case, the input can be read. (B) the user program execution stage Stage in the user program execution, PLC is always in the order by top-down scan the user program (ladder). When the scan each ladder, the ladder is always the first scan by the contact form on the left of the control line, according to the first left and right, the first following the order of the control circuit by the contact form logical operations , then the logical result of the operation, refresh the logic of the coil in the system RAM memory state of the corresponding bit; or refresh the output coil in the I / O image area in the state of the corresponding bit; or to determine whether the implementation of the ladder instructions provided for special functions. That is, the user program execution, only the entry point in the I / O image area of the state and the data will not change, while the other output point and the soft device I / O image area or system RAM storage area state and data are likely to change, and ranked in the top of the ladder, the program execution results came in below those who will use these coils work or data of the ladder; the contrary, the ladder came in below its be refreshed or data logic state of the coil to the next scan cycle can only be on the top row of the procedures in their work. <> (C) Output refresh period When the scan after the end of user program, PLC to enter the output refresh stage. During this time, CPU in accordance with the I / O image area corresponding to the state and refresh all of the output data latch circuit, and then the output circuit driving the corresponding peripherals. At this time, is the PLC's real output. Compare the similarities and differences under the two programs: Program 1:
※ The use of a single scan cycle, you can complete refresh of% M4; ※ The two use four scan cycles to complete the refresh of% M4.
In general, PLC scan cycle, including self-diagnosis and communication, as shown below, that is, a scan is equal to self-diagnosis, communication, input sample, the user program execution, the output refresh so the sum of all time. <>
PLC in order to enhance anti-interference ability, enhancing their * sexual, PLC input terminal of each switch optical isolation techniques are used. <> In order to achieve the hard logic of the relay control circuit parallel control, PLC using micro-computer is different from the normal operating mode (scanning technology). These two main reasons, making the PLC have I / O response than the average industrial microcomputer control system consisting of more than full, and its response time is at least equal to one scan cycle, generally more than one scan cycle or even longer.
Scan
Maximum I / O response time S7-200 Performance requirements for low-touch block of small control systems, which can have up to 7 expansion modules ability to integrate the module backplane bus, its network connection with RS-485 communication interface and PROFIBUS two kinds of devices can be programmed PG access to all modules, with a power supply, CPU and I / O device integration unit. One of the expansion module (EM) are the following: Digital Input Module (DI) - 24VDC and 120/230VAC; digital outputs (DO) - 24VDC and relays; analog input module (AI) - Voltage , current, resistance and thermocouple; Analog Output Module - Voltage and current. There is also a rather special module - Communications Processor (CP) - The function is able to block S7-200 as the master station connected to the AS-interface (sensor and actuator interface), through the AS-Interface slaves can be control up to 248 devices, so that you can significantly extend S7-200 input and output points. CPU design <> There are 3 modes of operation manually selected: STOP - Stop mode, not executed; TERM - run the program, the programmer can read / write access; RUN - run the program, through the programming can only be read. Status indicator (LED): SF - system error or (and) CPU internal error; RUN - run mode, the green light; STOP - Stop mode, yellow; DP - Distributed I / O (CPU-only 215). <> Memory Card - used in case of no power without the battery can save the user program. PPI port used to connect programming devices, text displays, or other CPU. S7-300 Compared with S7-200, S7-300 for the small system, he can extend the module up to 32 modules, backplane bus module also integrates its network connection is more mature and popular, with MPI (multi-point Interface), PROFIBUS and Industrial Ethernet, the communication and to program simple and multiple selection of, and can be configured by means of HWConfig tool and set parameters. <> S7-300 module a little more, in addition to the signal modules (SM) and 200 of the EM module outside of the same type, it has interface modules (IM) - used for multi-layer configuration, the bus reached from the floor another level; placeholder module (DM) - set the parameters that do not reserve a slot or signal modules installed interface module for future reserves one slot; function module (FM) - perform special functions, such as counting, positioning , closed-loop control of the CPU functional equivalent of an extension or supplement; communications processor (CP) - provides point to point connection, PROFIBUS and Industrial Ethernet. CPU design Mode selector are: MRES = module reset; STOP = Stop mode, the program does not perform; RUN = program execution, the programmer read-only operations; RUN-P = program execution, the programmer can read and write operations. Status indicators: SF, BATF = battery failure; DC5V = internal 5 V DC voltage indication; FRCE = said at least one input or output is forced; RUN = When the CPU starts flashing, the running mode, Always; STOP = in Always stop mode, a slow flash memory reset request, is running reset flash quickly. MPI interface is used to connect to the programming device or other equipment, DP interface is used to directly connect to the distributed I / O. <>
The main difference with the 300 is more powerful on the scale and performance, the startup type of cold start (CRST) and hot start (WRST) of the points, the other basically the same. Oh, it also has an external battery power interface, replace the battery when the line can provide backup power to the RAM. Programming device There are programming device PG720 PG740 PG760 - can be understood as a laptop computer with programming software; also be directly installed STEP7 (SIEMENS programming software) PC to complete. The realization of communication (to be programmed first and communication on the PLC's CPU) requirements mainly due to the interface: 1. You can upload CP5611 PC card - top with MPI port can connect the cable directly. 2. Plus a PC adapter, the MPI port into RS-232 口 received after the PC. 3.PLC plus CP343 card, it has an Ethernet port.
Each automated process is composed of many smaller parts and sub-process components, so the project to establish the first task is to break down sub-tasks. The definition of each sub-task to complete the automation system hardware and software requirements. The hardware, including input / output number and type of the corresponding serial number and types of modules, the use of rack number, CPU type and capacity, HMI (Human Machine Interface) system, the network system. Program structure is mainly software, automated data management process, configuration data, communication data and procedures and project documentation. SIEMENS S7-in, the above work in project management (SIMATIC Manager), including the necessary hardware (+ configuration), network (+ configuration), all procedures and automated data management solutions. F1 online help. SIMATIC Manager STEP 7 project, the preparation of the tools STEP 7 user program, a ladder LAD, statement table STL, and function block diagram FBD, the programming language. Using an external programmer programmer or the user program can be saved to the EPROM card. SIMATIC Manager is an online / offline editing S7 graphical user interface objects, these objects, including items, the user program, fast, hardware stations and tools. The manager's user interface is almost in the toolbar and WINDOWS is a few more PLC menu - show access nodes, memory card, download, simulation module. Note:: Due to the current mainstream system is S7-300, so the following fundamental to the operation of S7-300 based, while the actual process due to the different configuration may be different.
First tier: contains the project chart, on behalf of each project and the project stored on a data structure. <> Level: stop (such as the S7-300) for storing the hardware configuration and module parameters and other information, station is the starting point of the hardware configuration. S7 program folder is the starting point for writing programs, all of the software are on the S7 S7 Series program folder, which contains the block files and source folder. <> SIMATIC network diagram (MPI, PROFIBUS, Industrial Ethernet) Third level and other levels: and the higher level object type. <>
Create a project: FILE NEW NEW PROJECT Insert S7 block: INSERT PROGRAM S7 PROGRAM Into the S7 blocks: INSERT S7 BLOCK then Optional: 1: organization blocks (OB) by the operating system calls, they are the operating system and user program interface. 2: function and function block FB FC is the actual user program to use their complex programs can be broken down into small, easy to debug the unit. 3: data blocks storing user data. Select the block type, it will open a Properties dialog box, which may enter the block number and the programming language to use, and other settings. Add: <> 1, the total memory clear - MRES = MEMORY RESET, after MRES module is equivalent to a new module, so please be careful. Is: on the MRES enough time to STOP LED flash 2; STOP then quickly bounced back into the MRES, this time under the STOP quick flash 6 - Memory Empty will delete all user application data, hardware testing and initialization, if the EPROM card with at this time, the contents of the card to the internal RAM area COPY 2, SIEMENS signal modules (SM) design, the wiring is very easy to replace Moban without wiring (which can be pulled down.) A spring and screw fixation connecting the two. 3, for the software license: CD-ROM after installation, be sure to use a floppy disk (right panel) authorization, or software to reinstall the system, be sure to "take back" the right to a floppy disk only after the order to reload again later authorization is only to contact Siemens had. The concept of hardware configuration and memory S7-300 memory concept: <> Load memory is a programmable module, which includes the establishment of the programming object loaded on the device (logic blocks, data blocks, and other information), it can be integrated memory card or internal RAM. There are two kinds memory card, which, when using RAM memory card, the system must be equipped with battery, when using Flash EPROM memory card, then power is not lost, but the internal data RAM, the battery needed to keep. Working memory and run time use only contains the programs and data, RAM working memory integrated in the CPU, through the back-up battery to maintain. System memory consists of the process input and output image table (PII, PIQ), bit memory, timers, counters and local heap practice. Maintain the non-volatile memory RAM, if not install back-up battery can also be used to keep some data, set the CPU parameters to specify to keep the region. <> We can see from the above concept, if we modify the program online, be modified in the block stored in working memory, when the programmer to upload programs to spread from the working memory programmer. The power will lead to the loss of data RAM, so if we want to save the modified security procedures must be kept in FEPROM or hard disk.
<>
Configuration process: Start the hardware configuration: a new project (PROJECT), select the item, and insert (INSERT) a station (STATION), in the SIMATIC Manager, select the hardware station (HARDWARE) can double-click OPEN, and we also can open the hardware catalog - -VIEW-CATALOG, if you choose standard hardware catalog, it will provide all of the rack, modules and interface modules. Generate a hardware configuration: the main choice of rack, specifying the module to be placed in the rack. Specifically: 1, in the hardware catalog to open a SIMATIC300 station RACK-300 (for example, 300), double-click or drag the left of the window. In the left window so that there are two racks on the table: the top part shows a summary table, the following part of the show with order number, MPI address and I / O address details. 2, Power: double-click or drag the directory "PS-300" module into the slot on the table number one. 3, CPU: CPU-300 from the directory of your choice that you configure CPU, included in the 2nd slot. 4, No. 3 slot - General interface module to retain (for multi-layer configuration), in the actual configuration, if you want to keep this position after the installation interface module, when installed must insert a placeholder module. 5, the signal module: start from the 4th slot can be inserted up to eight signal modules (SM Card), including communications processors (CP) and the function module (FM). 6, CP card (communication processing card): If the Ethernet card CP-343, PROFIBUS CP-341, 342 and so on. Of course, we can directly use the MPI port on the CPU, to save money but the speed is relatively slow. Distribution of parameters: module parameters required for a variety of settings. Double-click the module to open the Properties dialog box (Properties) CPU - properties include the common attributes General (the main provider of the module type, location and MPI address - if we are composed of several PLC via MPI interface to the network, each assigned a different MPI address of CPU); startup items START.UP (the main choice three kinds of startup mode, HOT-statements from the power outage, which is the program off at the beginning, WARM-from scratch, which is the first program started, COLD-cold start; monitoring time including reading from the module time to prepare and transmit the information parameters to the module's time; to save the number of Retentive Memory: used to specify when there is power failure or when switching from STOP to RUN the need to maintain the memory area; cycle / clock memory; protection (of various levels of permissions and set the key and password ); diagnosis / clock. <> Save to download and upload: After the above settings then we can save, compile, consistency check, the settings in the configuration downloaded to the PLC. Of course, the actual operation of the PLC, we can also upload (Upload Station) to read the actual configuration of the programmer. <>
1, S7-300, the configuration in the free position, then the configuration can not compile; 2, incorrect CPU (for example: a CPU 315-2DP, not the CPU 314) can not download the configuration at this time; <> 3, analog module slot allocated to the incorrect location, this time because the CPU will enter the STOP mode parameter assignment error; 4 Analog measuring range module is not correct, leading to analog module configuration error. STEP 7 programming language: LAD Ladder / FBD Function Block Diagram / STL statement list, richer, more flexible, but more difficult for beginners to understand, of course, some languages can not express LAD. Start editing the block: Select the desired programming language, double-click to open the block to be edited, such as OB1 or FC1 and so on. When using the LAD or FBD programming language, used the toolbar to insert a simple program file, when using the STL, you can get online help on the syntax and language features - HELP-Help on STL. Programmer consists of: statement table: is the block, declare variables and parameters for the block; code area: contains the program itself; program components: the optional open or closed, depending on the content of the programming language of choice, double-click or drag into the insert. VIEW menu: to switch to another language, and to achieve LAD / FBD / STL conversion between, you know, LAD / FBD converted into STL, in the statement, the table may not be the most effective procedures. The STL is not converted into other lines, the conversion can not still use the statement that the conversion process will not be lost. <> The larger the space the other menu, or the best combination of materials and software they are familiar.
CPU cycle of operation consists of three main parts: CPU checks the status of the input signal and the refresh image input table (PII..); The user program, which is in the process OB1 and some events (interrupts, etc.); the process output image output table (PIQ) written to the output module. Mentioned above PII / PIQ is the CPU in a particular memory module is used to save the input / output module of the signal, checks the user program, you can guarantee that a scanning cycle for the same signal state. <> Program structure: The above mentioned before, a relatively simple procedure, we can not block a variety of routines (such as FC.FB), but directly to the program directly written in a block (usually the main block OB1), CPU processing instruction one by one, we call this is called linear programming; while slightly more complex procedures, we can divide it into several blocks, each block contains part of the task processing program, in each block can be further decomposed into several segments, the segment can be generated for the same section of the module type, tissue block OB1 call other blocks by the inclusion in the order of the instruction, we call this method is called block programming; addition, reusable functionality into a single block, OB1 (or block) call these blocks and pass the relevant parameters, this method is called structured programming. The user block (block) includes program code and user data in a structured program, some call processing block cycle, some blocks calls when needed. Block total organization blocks (OB), function block (FB), function (FC), the system function block (SFB) and system functions (FC) 5 species, of which the system block is the CPU operating system pre-defined functions and function blocks, these blocks do not take the user program space. The next section discusses the place to discuss SIEMENS instructions before the module address: port in non-DP S7-300 and S7-400 is not configured with a fixed slot addressing, the use of port with DP S7-300 and S7-400 , you can assign the module start address. But we know that the CPU memory reset, the parameters and addresses will be lost, which means that all addresses are returned and the slot on the address or the default address. We were still S7-300, for example, in the S7-300, the chassis slot number on the simplified module address, module address of the first module from the rack address of the decision. Slot 1 to the general power supply, slot 2 is the CPU, slot 3 for IM (Interface templates) used, 4 to 11 for the I / O cards, CP card and FM card. Their permanent address is reserved for each slot 4 bytes - that is, slot 4 (the first one I / O cards), the address is 0.0 ~ 3.7 (32 bit), slot 5 (the second block I / O card) address for the 4.0 ~ 7.7, assuming the first card is a DI, then their address is I0.0, I0.1,,, I3.7, if the second card for the DO card, the address is Q4.0, Q4 .1,,,, Q7.7, please note that when using 16-channel DI / DO module, each slot will lose two bytes (16 bits). <>
Or> = 1 (FBD) O (STL) (OR instruction) XOR XOR (FBD) X (STL) (XOR instructions) NOTE: The XOR operation is: When the two signals in only one meet, the output state is "1", this command can not be used in a variety of different addresses or logical operations (N a, there is a 1 is 1), so three and three or more different or instructions, the old RLO (result of logic operation) and another input for XOR. = Assignment Set S just set, it remains to be another command reset. <> Reset Reset R alone, has maintained that it was another command set up. <> Set the trigger reset: input simultaneously set and reset inputs, two inputs simultaneously if RLO = 1, according to priority. In the LAD / FBD of the respective set and reset priorities priority different symbols in the STL, the last written instructions with a high priority. Note: If the command to set the output set, when the CPU is reset when it all started, but if the declaration to maintain, when the CPU starts the whole, it has remain set. Connector: M0.0 (#), assigned to the middle element, the current RLO is saved to the specified address, when it and other components in series, the connector into the same instructions and contacts. Note that the connector can not: Directly connected to the power bus Directly with a branch; By the end of the branch. <> However, the connector can be used "NOT" elements to it to take anti-operation. Of RLO command: <> NOT = negated; CLR = reset (only in STL in); SET = set (only in STL in); SAVE = Save the RLO to the status register in the "BR"; BR = saved for re-inspection RLO. <> Master Control Relay function MCR: a current to turn on or off the main switch logic. If the MCR does not satisfy the conditions: 0 assigned to the output coil, a set coil and reset coil does not change the current value of the instruction, MOVE command to spread to the destination address 0. Start the Master Control Relay function MCRA instruction / MCRD instructions to cancel MCR functions, until another MCRA instruction work. Unconditional transfer (not dependent on RLO) JMP <> In the LAD / FBD, in the coil symbol as indicated above, the input label or symbol, such as NEW1, NEW2 etc., label up to 4 characters, first character must use a letter or "_." <> Jump rules: You can jump forward or backward, the purpose of the jump instruction and the jump must be in the same block (the maximum length of 64K bytes to jump); jump purpose in a block can only occur once; jump switch command can be used in FB, FC, and OB in the. <> Jump conditions: There are two: JC - when RLO = 1 时, JC before it is implemented, when RLO = 0, do not jump, continue with the following procedure, but set RLO = 1. JCN - When the RLO = 0 时, JCN was performed when RLO = 1, do not jump. Edge detection: RLO-edge detection and signal - edge detection. <> RLO-edge detection: When the logical result of the operation changes, resulting in RLO edge. Edge detection is FP - RLO from "0" change to "1", "FP" check the instructions to generate a "scan" signal "1"; test negative edge of the FN, the RLO from "1" change to "0" , "FN" Check the instructions to generate a "scan" signal "1." These two results are saved in the "FP (FN)" bit in memory or data bits, such as M 1.0 ..., at the same time, you can output in the other coil. Signal - edge detection: RLO with the above instructions Similarly, when the signal changes, a signal edge, there are positive / negative edge of the points: POS / NEG. The above instruction, the best combination of the actual software you master the method, characteristics and differences, please refer to a variety of other complex high-level programming instruction manual. <>
Number of instruction in the discussion before the first look at a variety of data formats, on the binary, decimal, and several other representation, are introduced in other places, not repeat it here. First, the data format (16 bit): Data type INT is the integer (16 bits), where sign (bit 15) that is positive or negative ("0" = positive, "1" = negative), 16-bit integer Value range is -32768 ~ +32767. In binary format, the form of negative integers with positive binary complement. (Complement obtained by inversion plus 1) a negative-bit format, the location of the weighted sum of zero, plus one, and then put a minus sign in front. BCD Code: decimal binary number with four each, said because the maximum is 9, so it is necessary in order that out of four Er Jinzhi (9 decimal = 1001 binary), note that the decimal from 0 to 9, the number of BCD code binary number that represents the same, but the BCD code is usually used as a display, not binary. The above INT (integer) is primarily used operations. Such as the BCD code W # 16 # 296, in the performance of CPU, 0000,0010,1001,0110 (direct +, 2,9,6 = +296); the integer is represented as +296 0000,0001,0010,1000 (28 +25 +23 = 296), then such an integer is expressed as 1111,1110,0110,0011 -413 (because it is negative, so the use of complement, take anti-plus 1, so the above binary number =- (28 + 27 +24 +23 +22 +1) = "-413", while the number in BCD code (W # 16 # F413) can be simply expressed as 1111,0100,0001,0011. Second, the data format (32 bit): DINT types of data - with the sign bit of the 32 - bit integer, defined as a "double integral" or "long integer", method and scope of its representation is: L # -2147483648 ~ L # +2147483647; there is a real number is the REAL type (also called floating point), is 1.175495 * 10-38 ~ 3402823 * 1038 between the general format of real numbers (Sign) * (1.f) * (2e- 127), where Sign is the sign bit 31-bit (ie the highest bit), low of 0 to f = 22-bit base, 23 to 30 for the e = index. STEP 7 in the real numbers are represented according to IEEE standards. <> Data loading and transfer: MOVE (LAD / FBD) or the L and T (STL): If the input EN valid input "IN" at the value of the copied to the output "OUT". Loading and execution of delivery instruction has nothing to do with the RLO, the data exchange through the accumulator, and loading instructions to write the right side of the source address of the value of accumulator 1 (not 32-bit padded with 0), passing command copies some or all of the contents of accumulator to specified destination address. If the first load L +5 / LL # 523312 / LB # 16 # EF (+5 were loading an integer / integer 523,312 a dual / a hexadecimal number EF) to the first accumulator (ACCU1), and then transfer to the destination, such as T MB5 and so on. Accumulator is the CPU in the auxiliary storage, they are used for data exchange between different address, comparison and math operations. S7-300 has two 32-bit accumulator, S7-400 has four 32-bit accumulator. In the loading process, ACCU 1 in the value of the first into ACCU 2, before the new value is written to be cleared, and then write the value to be loaded into ACCU 1, pass the time is read from ACCU 1. Loading and delivery instructions can specify 32-bit in a byte or word and double word, if only to pass a byte, only the right 8. In the LAD / FBD, we can use the MOVE to allow input (EN) to load and transfer operations and RLO link in the STL, you always perform loading and delivery operations, while and the RLO has nothing to do, but we can take advantage of conditions RLO jump instruction to execute and functions related to loading and delivery. <> Timer: STEP 7 in, CPU reservations for the timer, a special memory, the area reserved specifically for each timer is a 16-bit word address. Timer bit 0 to 9 contain the time value in binary, 12,13 bit of time benchmarks - 0 10ms, 1 that 100ms, 2 = 1 sec, 3 = 10 seconds, the time base is defined by a unit on behalf of time interval. Constant time value can be directly used to represent (in this case time basis automatically assigned automatically by the system), such as S5T # 100ms, S5T # 2h2m2s20ms. S5 timer format: the specified time as mentioned above can be fixed directly to the input time constant, or by the operator with a trackwheel or buttons to change the word or data word and memory in the time value of the process and formula. L can be used in the use of command (read) the address of the output of the timer BI (including 10-bit binary representation of the time value, with no time reference), such as L T5; can also use the LC command to read out the address side of the timer BCD (3 BCD number representation of the time value and 12,13-bit time base.) Detailed description of several commonly used timers: The following describes only the function of specific symbols can be found in the components list. ON delay (SD) Timer: When the timer "S" input of the RLO changes from 0 to 1, the timer starts. Just enter the S = 1, the timer works, when the TV reaches the specified value (the default) when the timer starts (output Q = 1), while the locator and a reset terminal R side, when equal to 1, to clear and reset the timer value of the Q output. The current time can be output in the BI to read binary, BCD code in the form of BCD client to read out the current time value is the initial value less TV since the elapsed time the timer starts. Maintain the on-delay timer with (SS): SD timer consistent with the above, the only difference is that with a hold function, ie: if S input RLO changes from 0 to 1, the timer will start, even though occurred during regular client input S = 0, when the timer will continue to write. But one thing, while maintaining the process, if the S input again from 0 to 1, the timer is restarted. <> Off delay timer (SF): In some ways, and the above-mentioned SD Delay Timer state just the opposite. When the timer from the S input RLO "1" change to "0", the timer starts, the output signal Q = 0, other features and output as SD. Understand, and whether the SD-delay timer, more for positive logic, and SF more safe for the accident (sometimes also called anti-logic, that is, in normal conditions, the input and output are 1 or charged case). <> Pulse (SP): This is better understood, when the "S" input changes from 0 to 1, start the timer, the output Q = 1 (up to a pulse. Q reset output is: time or start the timer signal from 1 to 0 or reset input R signal = 1. Extended Pulse (SE): When the input RLO from 0 to 1, the timer starts, the output Q is set to 1, even among the S end of the input variable to 0, output Q remains 1. When the timer is running, if the start signal from 0 to 1, the timer will be restarted. It is the timer reset time or reset signal terminal R 1. <> Bit instruction timer: the timer can also be used for all simple bit instruction starts, the method and timer function previously discussed the similarities are: the S end of launch conditions, the specified time value, reset the R-ended input conditions, signal response in the Q-side. The difference is (to LAD / FBD) can not check the current time value (no BI / BCD output). (Editor:admin) |