You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

The "itfAsyncProperty" must be passed during initialization. Otherwise the FB "ResolveHostname" is executed synchronously, which leads to an increased cycle time

(Compare this also with the screeshot at the end of this article)





  • Create a "Standard project" and select CODESYS Control Win V3 as the device.
  • Define the target system by means of the Network scan.




  • Open the Library Manager and add the following libraries:
    Net Base Services




  • Edit the PLC_PRG POU as follows:



    Declaration

    VAR
    	fbAsyncProperty		: NBS.AsyncProperty := (tnTaskName := 'itfAsyncTask', usiTaskPrio := 75, udiTaskInterval := 1000);
        fbResolveHostname	: NBS.ResolveHostname := (itfAsyncProperty := fbAsyncProperty);
        xResolve			: BOOL;
        ipAddress			: NBS.IPv4Address;
        itfIpAddress		: NBS.IIPAddress := ipAddress;
    END_VAR




    Implementation

    fbResolveHostname(xExecute:= xResolve, 
    					udiTimeOut:= 10000000, //10sec 
    					sHostname:= 'www.codesys.com', 
    					itfIPAddress:= itfIpAddress);
    
    IF fbResolveHostname.xDone THEN
    	xResolve := FALSE;
    END_IF





  • Load the project to the controller and start it. Set The variable xResolve to TRUE.


  • No labels