1. Create local variables for subroutines
1. Create local variables for subroutines
The variables used internally in a closed program are called local variables. External access and modification are not authorized.
1.1. format
| Local variable type | Local variable writing format | Initial value |
|---|---|---|
| LBxxx, the xxx part can be a combination of numbers/characters/underscores of any length | OFF | |
| Word | LWxxx, xxx section can be a combination of numbers/characters/underscores of any length | 0 |
| Double character | LDxxx, xxx section can be a combination of numbers/characters/underscores of any length | 0 |
| Floating point | LFxxx, xxx part can be a combination of numbers/characters/underscores of any length | 0.0 |
Local variables can be named arbitrarily, but it is important to ensure that the same variable is given the same name* Local variables are case sensitive, for example, LWa and LWA are treated as different variables, please pay special attention to this*
1.2. Example
Command table:
NETWORK 000
LD M0
OUT LBaa // 以M0为输入,局部变量LBaa作为线圈输出,相当于将M0的值赋给LBaa
MOV K10 LWba // 当M0为ON时,对局部变量LWba赋值为10
MOV K20 LW12 // 当M0为ON时,对局部变量LW12赋值为20
POP
NETWORK 001
LD LBaa
AW< LWba LW12
SET Y0 K1 // 当LBaa为ON,并且LWba<LW12时,将Y0置位。只有M0为ON时条件才会成立,否则LBaa的初始值为OFF,LWba和LW12的初始值均为0.
POP