Mold costs depe…
Siemens PLC learning skills
Classification of Siemens PLC: Siemens PLC in Germany is widely used in China, such as in metallurgy, chemical industry, printing production line and other fields. Siemens PLC products include logo, S7-200, s7-1200, S7-300, S7-400, etc. Siemens S7 Series PLC is small in size, fast in speed, standardized, has network communication capability, stronger in function and high in reliability. S7 Series PLC products can be divided into micro PLC (such as S7-200), PLC with small-scale performance requirements (such as S7-300) and PLC with medium and high performance requirements (such as S7-400).
Working principle of Siemens PLC programming: after the PLC is put into operation, its working process is generally divided into three stages, namely input sampling, user program execution and output refresh. The completion of the above three stages is called a scanning cycle. During the whole operation, the CPU of the PLC repeatedly executes the above three stages at a certain scanning speed.
Input sampling
In the input sampling phase, the PLC sequentially reads all input states and data in a scanning manner, and stores them in the corresponding cells in the I / O image area. After the input sampling is completed, it will be transferred to the user program execution and output refresh stage. In these two stages, even if the input state and data change, the state and data of the corresponding unit in the I / O map area will not change. Therefore, if the input is a pulse signal, the width of the pulse signal must be greater than one scanning period to ensure that the input can be read in in any case.
User program execution
In the execution stage of the user program, the PLC always scans the user program (ladder diagram) in order from top to bottom. When scanning each ladder diagram, the control circuit composed of each contact on the left of the ladder diagram is always scanned first, and the control circuit composed of the contact is logically operated in the order of left to right and up to down, and then the status of the corresponding bit of the logic coil in the system RAM storage area is refreshed according to the result of the logic operation; Or refresh the output coil to correspond in the I / O mapping area.
That is, during the execution of the user program, only the state and data of the input point in the I / O image area will not change, while the state and data of other output points and software devices in the I / O image area or the RAM storage area of the system may change. Moreover, the program execution result of the ladder diagram arranged above will affect the ladder diagram arranged below which these coils or data are used; On the contrary, the state or data of the logic coil that is refreshed in the ladder diagram below can only be used for the program above it in the next scanning cycle.
Output refresh
When the scanning user program is finished, the PLC enters the output refresh stage. During this period, the CPU refreshes all the output latch circuits according to the corresponding states and data in the I / O mapping area, and then drives the corresponding peripherals through the output circuits. This is the real output of PLC.
For the same several ladder diagrams, the arrangement order is different, and the execution result is also different. In addition, the operation result of the scanning user program is different from that of the hard logic parallel operation of the relay control device. Of course, if the time taken by the scanning cycle is negligible for the whole operation, there is no difference between the two.
Problems needing attention in Siemens PLC programming:
1. Subroutines can be called in the interrupt program
Accumulator and logical stack storage are common in interrupt program and called subroutine
2. Data under interrupt program and main program can be shared
Although interrupt programs can be shared, we should pay attention to the factor influence of Asynchronous Characteristics of events in interrupt events to solve the consistency problem of shared data. It may occur anywhere the main program executes in an interrupt event.
3. Interruption of communication interface
The serial communication port of PLC can be controlled by ladder diagram or statement table program. This operation mode of the communication port is called the own port mode. In the case of freedom, the baud rate and the number of bits of each byte can be defined by the program. In the process of executing the main program, the free port mode can be defined only when an interrupt is applied. The control of communication by the program can be simplified by receiving and sending interrupts.
4. I / O interrupt
I / O interrupts include rising or falling edge interrupts, tell counter interrupts and burst output interrupts.
S7-200 if the CPU interrupts the rise or fall of the input i0.0 ~ i0.3, the event occurring is captured by the input terminal. Such rising edge or falling edge can be used to indicate the conditions that must be paid attention to when an event occurs.
5. Time base interruption
6. Interrupt priority and queuing
7. Limitation of interruption
8. Interrupt program programming steps