General Discussions
Setting Bit in Word

Still new to VTScada.

I have an I/O tag of length word in VT scada with an output address to a register in the PLC. I want to set/reset a bit at a desired position in that tag if an alarm status tag is true. What is the best way to do this?

Thanks

Still new to VTScada. I have an I/O tag of length word in VT scada with an output address to a register in the PLC. I want to set/reset a bit at a desired position in that tag if an alarm status tag is true. What is the best way to do this? Thanks

Best way is to use I/O - Digital tags for each bit independently.

If you want to bit pack to registers to save on tag count, it gets a lot messier and you'll need to build expressions to sum the correct values.

Best way is to use I/O - Digital tags for each bit independently. If you want to bit pack to registers to save on tag count, it gets a lot messier and you'll need to build expressions to sum the correct values.

Use a calc tag with the word in an expression with the bitwise functions.

From the docs (you would use the tag value rather that the hardcoded values):

Example:

var1 = XOr(0b1100, 0b1010);

The value of var1 will be 0b0110.

Use a calc tag with the word in an expression with the bitwise functions. From the docs (you would use the tag value rather that the hardcoded values): Example: var1 = XOr(0b1100, 0b1010); The value of var1 will be 0b0110.

Thanks for these responses.

I was able to accomplish the above using the expression ([Alarm Status Tag1]==1)x1 + ([Alarm Status Tag2]==1)x2, etc. to pack individual bits into a word.

However, I'd like to use dan's solution for setting bits of HMI pushbuttons packed into words. In the above example, the Alarm Status Tags are internal tags that can be read and used in an expression.

I've tried creating an I/O tag "HMI Pushbuttons" which writes to the PLC address, with child tags for each button of type "Numeric Calculation". In the first button tag, I tried the expression And([HMI Pushbuttons],0x0001). However, this gives me an invalid as the response.

Can you walk me through the steps on how to set this up properly, including which tag types to create and which to link to the pushbuttons?

Thanks.

Thanks for these responses. I was able to accomplish the above using the expression ([Alarm Status Tag1]==1)x1 + ([Alarm Status Tag2]==1)x2, etc. to pack individual bits into a word. However, I'd like to use dan's solution for setting bits of HMI pushbuttons packed into words. In the above example, the Alarm Status Tags are internal tags that can be read and used in an expression. I've tried creating an I/O tag "HMI Pushbuttons" which writes to the PLC address, with child tags for each button of type "Numeric Calculation". In the first button tag, I tried the expression And([HMI Pushbuttons],0x0001). However, this gives me an invalid as the response. Can you walk me through the steps on how to set this up properly, including which tag types to create and which to link to the pushbuttons? Thanks.
16
3
3
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft