Showing results for 
Search instead for 
Did you mean: 

WebIQ: bit access to DWORD using button

WebIQ: bit access to DWORD using button

New Poster


To limit tags used by VIUS, I want to use DWORD for bit actions like JOG, ENABLE, STOP etc.
It is possible but works strange.
If I connect button action to bit of DWORD and pressing/releasing long bit is set and reset correctly.
But if I pressed it only for short time bit is set but not reset.
I've attached short video presenting this problem.
Do you know solution to this???

WebIQ Server Version
2.14.3 release/2.14.3 (31c8a976)
WebIQ Designer Version
2.14.3 v2.14.3 (9be57450)

Community Moderator
Community Moderator

Moved to corresponding forum "Smart HMI - WebIQ Designer and Server".

Could you have a look to topic "Bit access read/write from button"?

Community Moderator
Community Moderator

Can you please provide the following information:

  • Update rate of variable
  • Which function do you use to set the variable?
  • What is the PLC cycle time where the variable is used?


Can you please explain how you are writing the value when clicking on a button? Are you using a UI Action for that? A standard one or a custom one?

Please also open the browser console by pressing F12 - is there an error shown in that case?

Hi, here are answers:

  • Update rate of variable
    I use standard definition of variable (OPC_UA is runing on CtrlX_X3M):

  • Which function do you use to set the variable?
    I use standard button function:

  • What is the PLC cycle time where the variable is used?
    That's simple test program with only one task cycle=10ms:



I don't use UI Action:


After pressing F12, I don't see any error regarding OPC_UA read/write:



Please check the console tab, "issues" are browser recommendations only, not JavaScript console output:


At least two errors have been logged on the console:


OPC UA does not allow the user to access a bit of a word directly. The OPC UA specification (OPC 10000-3 - UA Specification Part 3 - Address Space Model 1.05.01) does not specify this as a standard data type.

As such you can only write bytes, not bits, with OPC UA. This also means that you might inadvertently overwrite other bits as well as you can only write bytes. As such for this specific purpose a method is available that will try to set the value correctly by verifying if the local value might have been changed on the server before writing it: 
This might not be the cause of the issue here, but in general you should always use this function when writing bits if you want to ensure data integrity through a custom UI Action for example.

In this case the simple reason might be that if the "mouseup" event is fired, the answer from your PLC regarding the previous write for the "mousedown" action has not yet been received. OPC-UA is a networked system and things happen asynchronously.

The easiest solution here would be to simply use standard data types (i.e. bytes) and not bits as this can always cause issues because if the OPC-UA client can only send bytes and not bits other bits that might have changed between the client reading the byte, manipulating it and then sending it back might have been changed on the server already. If you really need this you can use the compareExchange function. If it is possible to use bytes you should use bytes.

This is not a limitation of WebIQ, but how OPC UA works as it does not provide direct access to bits.

Community Moderator
Community Moderator

I can reproduce the problem with an new project (independet if the item is connected to a PLC variable or not). In my option it is a different implementation for the option "Write on/off values when pressed/released" for bit and non bit access.


I have the same behaviour in the attached workaround when the function writeValue() is call without { skipSameValueCheck: true }

The attached project contains

  • one button which uses "Write on/off values..."
  • one button which uses UI-Actions to write values (workaround)

@webiq-sk Please check the implementation for bit access in this function

This issue cannot be fixed with any JavaScript code as it is a frontend-agnostic issue. As pointed out is is because OPC-UA does not provide bit access so you can only set bytes. However, certain bits can have changed after you read them before sending it back so you potentially overwrite bits you don't want to set.

For this, the compareExchange method has been created which aims to workaround this.

The UI actions won't help, because they cannot prevent a data package on the way from the OPC-UA server to WebIQ to the browser from being sped up.

Also, the UI Actions use im.setValue which you can only use for virtual items as it will only change the value locally, not on the server. For that, you always have to use writeDirect and readDirect.