MemSw Function
Returns the status of the specified memory I/O bit.
Syntax
MemSw(bitNumber)
Parameters
- bitNumber
- Specify a numeric value representing a memory I/O bit number.
Return Values
Returns “1” when the specified bit is On and “0” when the specified bit is Off.
Description
MemSw returns the status of one memory I/O bit. Valid entries for MemSw range from bit 0 to bit 511. MemOn turns the specified bit on and MemOff turns the specified bit Off.
See Also
In, MemIn, InBCD, MemOff, MemOn, MemOut, Off, On, OpBCD, Oport, Out, Sw, Wait
MemSw Function Example
The example shown below shows 2 tasks each with the ability to initiate motion instructions. However, a locking mechanism is used between the 2 tasks to ensure that each task gains control of the robot motion instructions only after the other task is finished using them. This allows 2 tasks to each execute motion statements as required and in an orderly predictable fashion.
MemSw is used in combination with the Wait instruction to wait until the memory I/O bit 1 is the proper value before it is safe to move again.
Function main
Integer I
MemOff 1
Xqt 2, task2
For i = 1 to 100
Wait MemSw(1) = Off
Go P(i)
MemOn 1
Next I
Fend
Function task2
Integer I
For i = 101 to 200
Wait MemSw(1) = On
Go P(i)
MemOff 1
Next I
Fend
Other simple examples from the Command window are as follows:
> memon 1
> print memsw(1)
1
> memoff 1
> print memsw(1)
0