Programming method to increase PLC operating speed

How to improve the speed of the PLC program, you can use the following programming methods, for reference only:

1: According to the actual needs of the project, carry out functional block planning, write subroutines

In PLCs, subroutines are relatively independent programs that are programmed for specific control purposes. The execution of the subroutine call instruction CALL etc. If the condition does not satisfy the subroutine call, the program scan is performed only in the main program, and the subroutine is no longer scanned, thus reducing the unnecessary scan time.

2: Use word or double word data to send to DO point method to control output

In the application of PLC, there will usually be a large number of output controls. Using word or double word data to transfer to the DO point method to control the output can increase the speed, as long as the output address is reasonably allocated according to the requirements of practical applications, and the control output control word can be changed. Greatly reduce the number of steps in the PLC program execution, thereby speeding up the PLC program running speed.

3: Pulse trigger SET, RESET

In the PLC, the SET instruction can be used only once. It is not necessary to execute this instruction every scan. It is suitable for use with pulse output (PLS/PLF) instructions. Some engineers neglected this problem and used routine methods to drive the SET instructions, unintentionally increasing the scan time of the PLC program.

4: Avoid type conversion, as follows

Taking the S7-200 as an example, its memory format is the opposite of what we commonly use on a PC. It is a high word first and a low word second. So we can put the word variable in the last two bytes and clear the first two bytes when the program is initialized (these two bytes must not be used elsewhere in the program).

If we define a symbol, we define the word variable at VW2 while keeping the value of VW0 at zero. The program can use VW2 to access the variable in a font, and it can also access VD0 with a double word to avoid the type conversion.

In order to avoid confusion during use, it is better to distinguish word types and double word types with explicit symbol definitions. The Hungarian nomenclature is strongly recommended here: the prefix variable type is indicated by the prefix, and the group cooperation variable name with the first letter capitalized meaningful English word. I am used to using the following suffixes:

b----byte variable (byte)

w----word variable (word)

d---- double word variable (double)

r----Real variable (real)

f----bit variable (flag)

Btn---self-resetting button type input (button)

Sw---- switch or self-locking button switch

Sig---sensor, code, etc. level signal input

Rly---output relay bit (relay)

......

Of course, according to personal habits, there is no rule, mainly to facilitate their own distinction.

If you have a word type variable named VarName, to use the previous conversion technique, we can define it like this:

wVarName----VW2

dVarName----VD0

VW0 is cleared at program initialization (if it is a variable that does not need to be memorized, dVarName can be cleared directly) or VW0 can be set to zero in the data block. You need to use wVarName when you need to access variables in word type. You need to use dVarName to access variables in double word type. No type conversion is required at all.

This method can greatly reduce the number of program statements and make the program more concise and readable. As no time-consuming type conversion is needed, the program operation efficiency is also improved. And the greater the amount of mathematical operations, the more significant increase in efficiency.

The disadvantage is that it takes up two bytes of memory, and VW0 cannot be used later in the program. However, the S7-200 has a large amount of RAM, which is generally used up. Take 226 as an example, there are as many as 10K of RAM, and the couple never exceeds 1K. These RAMs are all bought for money. They are not used and they are not wasted.

Similarly, if there are byte-type variables often need to convert with word-type variables, let the byte variables occupy a byte of memory width and avoid a type conversion.

Regarding the third point "you can use the SET instruction to execute only once. You do not need to execute this instruction every scan. Some engineers neglected this problem and used the conventional method to drive the SET instruction, and inadvertently increased the PLC program scan execution time. ""

Finally: It is not very understandable, can you speak more

1: If you write a subroutine in ob, it is scanned, but if you write it as an FC call, the program in FC will not be executed temporarily if the call condition of FC is not satisfied. This is what I mean by saving time.

2: PLC execution steps according to the length of the program will be different, the scanning time will be different according to the number of execution steps, if a mov instruction to complete the control of the 8 digital output, of course, than 8 mov instructions to complete 8 numbers The number of program steps required for the control of the quantity output is small.

add one:

The above is a programming method to increase the speed of the PLC.

RAM/RFM Induction Heating Capacitors

RAM/RFM induction heating capacitors


RAM/RFM Induction Heating Capacitors,Water Pump Capacitor,Water Cooled Condense,Tank Capacitor,RAM/RFM Induction Heating Capacitors

YANGZHOU POSITIONING TECH CO., LTD. , https://www.cndingweitech.com

This entry was posted in on