72
A N D - O R
This program shows how to read the state of two inputs and perform logical
AND and OR on them. For this example there is program code only.
A N D - O R P r o g r a m C o d e
‘******** Parameter Setup ********
IOS 21 = 0,0,0 ‘Distance Bit0, low true
IOS 22 = 0,0,0 ‘Distance Bit1, low true
IOS 23 = 9,0,0 ‘Start input, low true
FLG B0
‘This flag stores Bit0
FLG NB0 ‘This flag stores NOT(Bit0)
FLG B1 ‘This flag stores Bit1
FLG NB1 ‘This flag stores NOT(Bit1)
FLG AND0 ‘This flag stores the result of NOT(Bit1) AND NOT(Bit0)
FLG AND1 ‘This flag stores the result of NOT(Bit1) AND Bit0
FLG AND2 ‘This flag stores the result of Bit1 AND NOT(Bit0)
FLG AND3 ‘This flag stores the result of Bit1 AND Bit0
FLG OR0 ‘This flag stores the result of NOT(Bit1) OR NOT(Bit0)
FLG OR1 ‘This flag stores the result of NOT(Bit1) OR Bit0
FLG OR2 ‘This flag stores the result of Bit1 AND NOT(Bit0)
FLG OR3 ‘This flag stores the result of Bit1 OR Bit0
VAR BIT0 = 21 ‘IO 21 is read into Bit0
VAR BIT1 = 22 ‘IO 22 is read into Bit1
‘******** Program ********
PGM 1
LBL ANDOR
‘The next four lines read the IO states, write
‘them into flags, and write the negatives into
‘flags.
B0 = IO BIT0
NB0 = !B0
B1 = IO BIT1
NB1 = !B1
‘The next four lines perform logical AND.
AND0 = NB1 & NB0
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from