Not understanding ZEROBIT

rfeyer

Active Member
My first assumption is that ZEROBIT is designated by BNZ, hope that is correct.
 
Please correct me here if I am wrong:
 
- ZeroBit can be designated to any variable
- If T1 is 80 degrees, and I ask TSTNE T1  79    then BNZ T1 should be 1?
- If BNZ can be used WITHOUT a designator, what is it actually testing?
 
Rainer
 
No.  Zerobit is NOT designated to any variable.  It is indicator for the last operator result TRUE or FALSE, or value is zero or non-zero.
It will change once next operator finish operation that related to assign any value to any variable, or any comparison.
 
If you want to use zerobit from a particular operator for later use, you must save it after that particular operation.  If you have any doubt, save its value and assign it to a VAR, so that you can see it after operation, by insert a long DELAY like 10-15 seconds.
 
Think of the ZERO BIT as it's own one bit (semi-hidden) variable automatically set by every arithmetic operation.
 
BNZ, BZ and others use it for their decisions.
 
Here is a copy of the CAI WebControl User Guide.(hopefully with CAI's permission)  It helps to return to it as things get less muddy and look again sometimes.
Code:
From WebControlTM PLC User Guide Version 3.02.18a
Copyright(c) 2008-2014 CAI Networks, Inc. 24

The program control block has a zero bit that is updated implicitly on TEST instructions. This zero bit is set by any one of these TEST instructions:

 TSTEQ, TSTNE, TSTGT, TSTLT, TSTGE, TSTLE, ANDT, ORT, XORT, ANDBT, ORBT, XORBT, TSTB.

Zero bit flag can be accessed by IO name ZBIT. This zero bit can
also be used implicitly when using branch and call instructions, like BZ, BNZ, CZ, CNZ.

E.g. the following test instruction yields a Boolean result which will implicitly set thestate of the zero bit. Next a branch instruction is used which branches on the state of the zero bit.

  TSTEQ IP1 1 # sets zero bit based on the result of the test instruction
  BNZ label # branches to label if zero bit is non-zero
 
That makes sense - so it is more of a global and singular variable.
LarrylLix, I do not see the above quote in my webcontrol guide nor do I remember reading it on the CIA page - where is it excerpted from? This guid would probably answer a bunch more questions I am researching, including use of/ reading cgi scripts
 
Rainer
 
Back
Top