The optimization of this method can greatly reduce the number of program statements, making the plc program more concise and more 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. For example, 226 has up to 10K of RAM, and even never exceeds 1K. These RAMs are all bought for money. They don't need to be used, 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. Specific steps are as follows:
1: According to the actual needs of the project, perform function block planning and write subroutines
Subroutines in PLC are relatively independent programs that are programmed for 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: Use word or double word data to transfer to DO point method to control output
In the application of PLC, there is usually a large number of output control. The method of transmitting the word or double word data to the DO point to control the output can improve the speed. As long as the output address is properly allocated according to the requirements of the actual application, the control output control word can be changed. The number of steps of the PLC program execution is greatly reduced, thereby speeding up the running speed of the PLC program.
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: Avoid type conversion, the method is as follows:
Take the S7-200 as an example. Its memory format is exactly the opposite of our usual PC. It is high in the front and low 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 suffix: b --- byte type variable (byte)
w———— font 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. For example, 226 has up to 10K of RAM, and even never exceeds 1K. These RAMs are all bought for money. They don't need to be used, 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.
Pharmaceuticals,2-Methyl- Propanoic Acid Monohydrate Price,2-Methyl- Propanoic Acid Monohydrate Free Sample,Pure 2-Methyl- Propanoic Acid Monohydrate
Zhejiang Wild Wind Pharmaceutical Co., Ltd. , https://www.wild-windchem.com