cancel
Showing results for 
Search instead for 
Did you mean: 

WebIQ: bit access to DWORD using button

WebIQ: bit access to DWORD using button

Renkowski
Member

Hi.

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)
8 REPLIES 8

CodeShepherd
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"?

HmiGuide
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?

webiq-sk
Frequent Contributor

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):
    Renkowski_0-1700213993307.png

  • Which function do you use to set the variable?
    I use standard button function:
    Renkowski_1-1700214057514.png

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

     



Hi,

I don't use UI Action:

Renkowski_5-1700214749265.png


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

Renkowski_4-1700214646923.png

 

webiq-sk
Frequent Contributor

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

webiqsk_0-1700215981485.png

At least two errors have been logged on the console:

webiqsk_1-1700216031722.png

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:

https://www.smart-hmi.com/user/download/deliver/docs/documentation-webiq-visuals-reference-2.15-ee64... 
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.

HmiGuide
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.

HmiGuide_0-1700472727101.png

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

webiq-sk
Frequent Contributor

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.

 

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist