Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

Bitwise Functions

I need to check a bit-packed status word for various combinations of
conditions that may or may not be On at the same time. Doing it in
decimal, checking every possible combination, is not practical.

Are there any functions to allow logical ANDing of signals to bit
patterns?

E.g., in VB I'd write
If Input_A And &H4 Then msg = "VideoIn Failure"
to see if the third bit of byte Input_A is On (= binary x1xx).

Anyway to do that besides checking a single bit at a time using
getbit()? One odd note about this device's status word, a decimal 63
(binary 0011 1111) means Boards Nominal, else each bit 0 through 5 means
a specific error which may or may not be happening at the same time. So
a nested IF is not practical with 62 bit combinatio
ns.

Thanks,
Alan Richard
NASA Glenn Research Center
Cleveland, Ohio

<><><><><><><><><><><><><><><><><><><><><>

Historical, though non-PC, quote of the day:

"We have staked the whole future of America's civilization,
not upon the power of government, far from it.
We have staked the future of all our political institutions
....upon the capacity of each and all of us to govern ourselves
according to the Ten Commandments of God." - James Madison
0 Kudos
Message 1 of 3
(3,485 Views)
Alan,

as far I know there is no boolean math implemented in Lookout (God knows I
need it a lot...), but the only solution I have used is to connect the value
expression of n switches with the function getbit() to the word I'm reading.
With every switch changing states when the bits change I can use the switch
events to test the conditions... Maybe it's a lot of work, but is the only
way I've found to do this... The problem is worse if you have to assemble a
word from these switches and the switches must be manipulated by the user.

Maybe NI can implement some boolean objects and/or include boolean math to
the next Lookout version. I hope they do so ASAP.


Joaquin Villanueva
T-Systems
0 Kudos
Message 2 of 3
(3,485 Views)
Hi,

I needed to do the same thing myself for decoding a barcode in Lookout and
could never find a way of doing it other than these:

Use a PLC for the basic math then communicate the result.
Use LabVIEW or similar "other" software and share the info.
Write a lot of expressions.

In order to get around an IO limitation (shhhh!) I created a load of expressions
in Lookout to decode PLC registers into bits. It works ok but for a 16 bit
word you need 31 expressions so it may not be worth it.

John
0 Kudos
Message 3 of 3
(3,485 Views)