much delay in 10ms

Questions regarding the use of the ANSI C SDK for Server or Client development or integration into customer products ...

Moderator: uasdkc

Post Reply
qingmeng
Full Member
Full Member
Posts: 8
Joined: 21 Nov 2018, 11:05

much delay in 10ms

Post by qingmeng »

Hi team,

I am now using this SDK(ANSI C 1.7) to develop the software, and I have two question.

Firstly, I found that I cannot call the "UaBase_DoCom()" by multi-thread, can this support this?

Secondly, I use this in one loop "UaClient_Session_BeginRead() -> UaBase_DoCom() -> UaClient_Session_BeginWrite() -> UaBase_DoCom() " to read and write value to an OPC UA server. And it is ok to use the PLCSIMAdv within call this per 100ms and 10ms, but if use this loop to exchange value with the real PLC and the update time is 10ms, then there will be much delay and the read call back/write call back may get the error code "OpcUa_BadTimeout".

User avatar
Support Team
Hero Member
Hero Member
Posts: 2533
Joined: 18 Mar 2011, 15:09

Re: much delay in 10ms

Post by Support Team »

Hello qingmeng,

the AnsiC SDK main loop (UaBase_DoCom()) has to be driven by one single thread. All client SDK functionality is intended for single-threaded use only and can not be used from different threads, see http://documentation.unified-automation ... ssion.html. Some of the server SDK functionality may be used from different threads, see http://documentation.unified-automation ... ation.html.

On the client side, all service call functions are asynchronous. After issuing a service call, e.g. by UaClient_Session_BeginRead(), you need to call UaBase_DoCom() until you receive the callback for the call. Of course you can issue multiple calls in parallel, but it is important to regularly call UaBase_DoCom() for the SDK to handle the session watchdog read and react to incoming data from the server.
Best regards
Unified Automation Support Team

qingmeng
Full Member
Full Member
Posts: 8
Joined: 21 Nov 2018, 11:05

Re: much delay in 10ms

Post by qingmeng »

Hi team,

see »http://documentation.unified-automation ... ation.html, it seems that the multi-thread is supportted after version 1.40, but my version is 1.70, and if want to use multi-thread should trun on OPCUA_USE_SYNCHRONISATION, which is supportted by OPCUA_MULTITHREADED, and for this, need a file “opcua_p_thread.h>”, which is not included in my source.

I had konwn that the UaBase_DoCom() must be called until receive the callback for the call, and then you can see the below table, I want to konw why when I read/write more tags (10 inputs and 10 outputs) whitin little update time (10ms) for real PLC, there will be large delay time.

Update time The numbers of tags PLCSIM Real PLC
100 ms 3 outputs, 3 inputs √ √
10 outputs, 10 inputs √ √
10ms 3 outputs, 3 inputs √ √
4 outputs, 4 inputs √ delay
10 outputs, 10 inputs √ ×

thanks a lot

User avatar
Support Team
Hero Member
Hero Member
Posts: 2533
Joined: 18 Mar 2011, 15:09

Re: much delay in 10ms

Post by Support Team »

Hello qingmeng,

the AnsiC client SDK is intended for single-threaded use only and can *not* be used from different threads than the main thread running the UaBase_DoCom() loop. Using client SDK functionality from different threads is not supported.

It depends on the server you are using and on the hardware the server is running on how long the service calls take for completing. You might want to use Wireshark for tracing the UA service calls in order to check how fast the server is handling the requests: http://documentation.unified-automation ... eWireshark
Best regards
Unified Automation Support Team

Post Reply