A little code help please....

TRLcam

New Member
I will admit, I am not a programmer just a user of the webcontrol hardware.  I am using a PLC board to turn on and off a remote camera.  I found this example in the CAI literature.
 
START    
    CALLSUB PERIOD   
    END    

PERIOD:
    TSTGE CH 23 RAM2
    NOP    
    TSTLE CH 5 RAM3
    NOP    
    OR RAM2 RAM3 OP1
    RET  
 
It works great but I really want it to do the opposite.  On at 5 and off at 23.  I have rearranged the values and tried about everything I can think of.  It just can't be that hard.
 
Can somebody help me please?
 
TRLcam said:
I will admit, I am not a programmer just a user of the webcontrol hardware.  I am using a PLC board to turn on and off a remote camera.  I found this example in the CAI literature.
 
START    
    CALLSUB PERIOD   
    END    

PERIOD:
    TSTGE CH 23 RAM2
    NOP    
    TSTLE CH 5 RAM3
    NOP    
    OR RAM2 RAM3 OP1
    RET  
 
It works great but I really want it to do the opposite.  On at 5 and off at 23.  I have rearranged the values and tried about everything I can think of.  It just can't be that hard.
 
Can somebody help me please?
I am sure this little piece of code does nothing by itself but here goes, reversing the logic. I've forgotten the exact opcode but you should get the idea.
 
PERIOD:
    TSTLT CH 23 RAM2
    NOP    
    TSTGT CH 5 RAM3
    NOP    
    AND RAM2 RAM3 OP1
    RET  
 
We change (CH >= 23) OR (CH <= 5) into  (CH < 23) AND (CH > 5)
 
DeMorgan's theorum. You have to invert everything including the operators.
 
 
NOT( A or B ) = NOT( A ) NOT( or ) NOT( B )  = NOT( A ) AND NOT( B )
 
In this case your A and B were logic formulae, 'CH <= 5'
 
Heavy enough for you yet?  :)
 
Back
Top