MDrive/MForce – MCode Boolean logic demonstration
The following program uses the Boolean logic operators available in MCode software. The first section starting at PG 1 calls subroutines based on the logical interpretation of general purpose inputs and calls respective subroutines.
The program section starting at PG 200 demonstrates how to assign a logical 1 or 0 to a variable based on an input value. Notice that an input's value can be assigned as a true or false depending on the second operator being a 1 or 0.
S1=0,0 'configure inputs 1 - 4 gen purpose
S2=0,0 'active low, sinking
S3=0,0
S4=0,0
VA zk
VA zl
VA zm
VA zn
PG 1
LB su ' 1 1 1 0 (!=NOT)
CL x1, I1 & I2 & I3 & !I4 = 1
H 200 'or any input
CL x2, I1 | I2 | I3 | I4 = 1
H 200 'exclusive or
CL x3, I1 ^ I2 = 1
BR su
E
LB x1
PR "x1 true"
H 500
RT
LB x2
PR "x2 true"
H 500
RT
LB x3
PR "x3 true"
H 500
RT
PG 200
LB xy
zk = I1 = 0 'makes variable zk not I1
PR "Input I1= "I1
PR "Variable zk= "zk
zl = I2 = 1 'makes variable zl = I2
PR "Input I2= "I2
PR "Variable zl= "zl
E
PG