Example 11, Bitwise Operation; Example 12, Angle Calculation - CAI Networks WebControl PLC User Manual

Programmable logic controller
Table of Contents

Advertisement

SET OP1 0
END
CHK4LOW:
TSTEQ IP1 0
SET RAM1 0
RET
SET_OP1:
TSTEQ IP1 1 RAM1
SET OP1 1
RET
LIGHTS:
TSTGE CH 19 RAM2
NOP
TSTLE CH 5 RAM3
NOP
OR RAM2 RAM3 OP3
RET
In this logic, SET_OP1 must be subroutine, if "TSTEQ RAM1 0" it will call the
subroutine SET_OP1, but if RAM1 != 0, then it will skip that call. In this way, we can
guarantee OP1 only being turn on once. In the subroutine SET_OP1, it checks if
RFID reader did detected valid RDID card present. If so, it will set the flag RAM1 to
true, so that not being set over and over again. For gate opening device, this will
make sure the gate will not left open all the time.

6.4.11 Example 11, Bitwise Operation

There are ANDB, ORB, and XORB operator operate on the VAR or RAM on the bit
basis. This will allow each RAM or VAR to store up to 31 binary states. When VAR1
stores value 12345, and RAM1 stores value 256, after execute
ANDB VAR1 RAM1 VAR1
VAR1 stores the value 0
After execute:
ORB VAR1 RAM1 VAR1
VAR1 stores the value 123712
XORB VAR1 RAM1 VAR1
First execution will be 123712, if execute next time, VAR1 will be back to 12345. In
another word, XORB can toggle the bit.

6.4.12 Example 12, Angle Calculation

From 3.02.16c firmware, angle calculation is supported. In PLC program, users can:
SIND 91 VAR1
Or
COSD 185 VAR2
Copyright(c) 2008,-2013 CAI Networks, Inc.
TM
WebControl
PLC User Guide Version 3.02.17f
41

Advertisement

Table of Contents
loading

Table of Contents