2-875
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Other Instructions
2
Lock and Unlock
Lock and Unlock
The Lock and Unlock instructions create lock regions. If a lock region in one task is being executed, the
lock regions with the same lock number in other tasks are not executed. Specify the lock number with
Index.
The following figure shows a programming example.
Both task T1 and task T2 contain a lock region with Index set to 1. If the Lock instruction in T2 is exe-
cuted first, the lock region in T1 is not executed until the Unlock instruction is executed in T2.
Lock: Starts an exclusive lock between tasks. Execution of any other task with a lock region
with the same lock number is disabled.
Unlock: Stops an exclusive lock between tasks.
Instruction Name FB/FUN Graphic expression ST expression
Lock Lock Tasks FUN Lock(Index);
Unlock Unlock Tasks FUN Unlock(Index);
Variables
Name Meaning I/O Description Valid range Unit Default
Index Lock num-
ber
Input Lock number Depends on data type.
--- 0
Out Return
value
Output Always TRUE TRUE only
--- ---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
Index OK
Out OK
Function
(@)Lock
EN ENO
Index Out
(@)Unlock
EN ENO
Index Out