How to improve the running speed of the plc program, you can use the following programming methods, for reference only:
1. According to the actual needs of the project, the function block planning is carried out, and the subroutine is written in the PLC. The subroutine is a relatively independent program compiled for some specific control purposes. Execute the subroutine call instruction CALL, etc. If the condition does not satisfy the subroutine call, the scan of the program is only performed in the main program, and the subroutine is not scanned again, thus reducing unnecessary scan time.
2, using word or double word data to the DO point method to control the output in the application of the PLC usually has a large number of output control, using word or double word data to the DO point method to control the output can increase the speed, as long as the actual Application requirements, reasonable allocation of output addresses, conversion control output control words, can greatly reduce the number of steps executed by the PLC program, thereby speeding up the PLC program running speed.
3, pulse trigger SET, RESET
In the PLC, the SET instruction can be executed only once, and it is not necessary to execute this instruction every scan. It is suitable for use with the pulse output (PLS/PLF) instruction. Some engineers have ignored this problem and used the usual method to drive the SET command, inadvertently increasing the PLC program scan run time.
4, to avoid type conversion S7-200 as an example, its memory format is exactly the opposite of our commonly used PC, it is high word in front, low word in the back. So we can put the word variable in the last two bytes and clear the first two bytes when the program is initialized (the two bytes must not be used elsewhere in the program).
When we define a symbol, we define the word variable at VW2 while keeping the value of VW0 to zero. In the program, VW2 can be used to access the variable in font form. At the same time, VD0 can be accessed in double font, which avoids type conversion.
To avoid confusion at the time of use, it is best to distinguish between word types and double word types with explicit symbol definitions. It is strongly recommended that the Hungarian nomenclature be used to indicate the variable type with a prefix, and the name of the group cooperation variable of the meaningful English word capitalized with the first letter. I am used to the following suffixes:
b - byte type variable (byte)
W——word variable (word)
d - double word variable (double)
r - real variable (real)
F——bit variable (flag)
Btn - self-reset button input (button)
Sw - switch or self-locking button input (switch)
Sig - sensor, coding and other level signal input (signal)
Rly - output relay bit (relay)
......
Of course, this is based on personal habits, there is no rule, mainly to facilitate their own distinction.
If there is a word type variable named VarName, in order to use the previous conversion technique, we can define it like this:
wVarName - VW2
dVarName - VD0
Clear VW0 to zero when the program is initialized (if it is a variable that does not need to be memorized, clear dVarName directly) or set VW0 to zero in the data block. Then you need to use wVarName when you need to access variables in word type. You need to use dVarName when you need to access variables in double word type. No type conversion is needed at all.
This method can greatly reduce the number of program statements, making the program more concise and readable, and the program running efficiency is also improved because no time-consuming type conversion is required. And the greater the amount of mathematical operations, the more obvious the efficiency improvement.
The disadvantage is that it takes up two more bytes of memory, and VW0 cannot be used in future programs. However, the RAM space of the S7-200 is very large, and it is generally inexhaustible. Taking 226 as an example, there is up to 10K of RAM, and even never exceeds 1K. These RAMs are all bought for money. They don't have to be used, and they are not wasted.
Similarly, if a byte type variable often needs to be converted to and from a word type variable, letting the byte variable occupy one byte of memory is wasted one byte, avoiding type conversion.
The above is the programming method to improve the running speed of the PLC.
Laptop With Touch Screen,2-In-1 Laptop,Laptop For Education,2 In1 Windows Tablet
C&Q Technology (Guangzhou) Co.,Ltd. , https://www.gzcqteq.com