Help in VB to PG code
Hi,
The interlock signal (boolean) are converted to Integer at PLC program and the individual Bit status (boolean) are display at HMI using the following VB code,
"BitStatus = 2^bitno AND Input"
whereas,
BitStatus = boolean data type - to indicate the bit status of the input "bitno"
bitno = Integer data type - which points the bitno of the packed integer input
Input = Integer data type - (boolean) packed integer input
The same code can't be used and I couldn't get an equivalent function code in PG.
Can anyone help ?
Voted best answer
Hello,
does this work? :
BitStatus: (2^bitno & Input) != 0
/Ronny
Answers
Hello,
Are u assigning r comparing the status with bit no and input.
In ur eqn bitstatus=bool and where as others are int type so its not taking since u r using assignment operator
Please check ur reqt
If you want to use a specific bit from an integer to evaluate to a boolean in a PG2 expression you could simply do this
MyPackedInteger[n]
where MyPackedInteger= an integer value
n= the bit number you want to evaluate to a boolean. 0 = the least significant bit.
Actually much simpler than the VB code
Hope this helps
Add new comment