Difference between logical and bitwise AND/OR for conditional visibility

S

Thread Starter

Scott M.

Suppose I have two conditional expressions.

The first expression is:
[PLC5,0001-15]&~[PLC5,0001-14]|[PLC5,0050-11]

The second expression is:
[PLC5,0001-15]&&~[PLC5,0001-14]||[PLC5,0050-11]

Incidentally, expressions very similar to these are being used in a PanelMate HMI for conditional visibility.

My question is will the above-mentioned expressions be evaluated any different because the first expression has a bit-wise AND and bit-wise OR, while the second expression has the Logical AND and Logical OR operators? Is there any instance where the two conditional expressions are not always both true or both false? I contend that the two expressions evaluate identically every time. Analogously, the expressions are two different paths that lead to the same destination.

Please contact me if clarification is needed. Thanks.
 
K

Kerry Sparks

Because the PanelMate AB driver set (serial/DH+/RIO) "knows" the datatype of the reference to be Boolean, the expression will evaluate the same whether you use the logical AND/OR or the bitwise logical AND/OR functions. The only time I've seen PanelMate evaluate it differently was when connecting to an AB PLC
using the RSLinx OPC server. Since an OPC server provides the datatype of the value it returns RSLinx was sending back B (Boolean/Binary) file data as an unsigned word datatype and normal logical expressions using the bitwise AND, OR, or NOT would behave differently. For instance, a NOT (bitwise)of an unsigned 16 bit 1 evaluates to 65534, where the same NOT (bitwise) of a Boolean
returns a zero. I only saw this in an older Version (2.1) of RSLinx so the problem may be addressed now. The point is that not all OPC servers act the same and you should use the proper logic operators for forward compatibility
since most operator interfaces, including PanelMate, are moving toward OPC connectivity for their data.

Kerry Sparks
 
Top