Set Bit in Word on Pushbutton Press
Hello, I have a word in an AC 800M controller that contains bits for a number of HMI pushbuttons. Ideally I'd like to implement a "set while pressed" or "toggle to 1 when pressed" action with HMI pushbuttons, where the specified bit in the word is set to 1. The word bits are assigned to pushbutton bits in the controller, and the word bit is reset once the controller reads it. I'm not exactly sure what to enter into the "target" expression for the pushbutton to achieve this. Would appreciate any help. Thanks!
Voted best answer
I have not tried this in HMI yet but I have in the controller. You can try the following in HMI:
For this you i need to know the bit you are trying to set. In this case im setting Bit 0. So the value after || is 2 ^ 0 = 1
PropertyRef -> PushbuttonWord
Value -> PushbuttonWord || 1
The way this works is the following:
The PushbuttonWord value is 120
So in bits:
01111000
Then you use the or operator with the value 1
So in bits:
00000001
You need to see this as the following:
01111000
00000001
------------- ||
Result value
The result value will contain the following value in bits
01111001
Because it will compare each bit position.
So it starts at position of bit 0. It will see a 0 in the PushbuttonWord and a 1 in the value of 1. Because the or operator is used and one of the values is a 1 the bit is set.
So bit at position 1 it will be a 0 because PushbuttonWord and the value 1 have a zero at position 1
I hope I explained it properly and it will work. Let me know your experience.
For this you i need to know the bit you are trying to set. In this case im setting Bit 0. So the value after || is 2 ^ 0 = 1
PropertyRef -> PushbuttonWord
Value -> PushbuttonWord || 1
The way this works is the following:
The PushbuttonWord value is 120
So in bits:
01111000
Then you use the or operator with the value 1
So in bits:
00000001
You need to see this as the following:
01111000
00000001
------------- ||
Result value
The result value will contain the following value in bits
01111001
Because it will compare each bit position.
So it starts at position of bit 0. It will see a 0 in the PushbuttonWord and a 1 in the value of 1. Because the or operator is used and one of the values is a 1 the bit is set.
So bit at position 1 it will be a 0 because PushbuttonWord and the value 1 have a zero at position 1
I hope I explained it properly and it will work. Let me know your experience.
Answers
- Set the Bit from the HMI using a "push button". OPC Writes are "events" - they happen once. To set a bit on a word append #Bit<num> to the OPC property in graphics builder.
- Clear the Bit in the PLC *after* the PLC has finished processing it. The HMI will "see" that the bit has been cleared and the PLC is done. ( Never "Clear" the Bits from the HMI, because the HMI cannot know when the PLC has finished reading the bit )
A note on style ... Using "push buttons" directly on operator displays is bad practice. The push button default style looks identical to the Page Link default style. Operators have no clue if they are pressing a page link or stopping the plant. Always use confirmation dialogs - a "BooleanDEW" ( Data Entry Window ) graphic sub element will do this quite well.
-
by User72619 Rank: 1241 on 2/17/2021 5:46:07 PM | Like (0) | Report
Having gotten this to work using the answer below, I am now trying to do the same thing using a faceplate button. Is it possible to enter an expression in the "Property value" field? Everything I have tried to logical OR an int with the word value has failed.
Add new comment