Adjustment of the IP Adress through TAG`s
iP adress modification through TAG
In this tutorial we described the orientations and procedure to change the IP adress and the subnet mask of your PLC while executing the application. This adjustment is possible through the use of function blocks available by the library SysSocket, from Codesys.
Componentes
Software: MasterTool IEC XE 3.34;
CLP: XP340
Seções do Tutorial
1. ARCHITETURE
2. DEVELOPMENT
2.1. Inserting the library SysSocket_Implementation on MasterTool IEC XE
2.2. Declaring the function blocks SysSockSetIpAddress and SysSockSetSubnetMask
2.3. Example using PLC XP3XXX
2.4. String identification of the Ethernet interface
2.5. Final observations
_____________________________________________________________________________________________
1. ARCHITETURE

In this tutorial is described the steps to change the IP adress when the application is executing. It is necessary to insert the library SysSocket_Implementation from MasterTool, to use the functions SysSockSetIpAddress and SysSockSetSubnetMask.
2.1. Inserting the library SysSocket_Implementation on MasterTool IEC XE
The IP adress and subnet mask alteration can be configured while the application is executing. The library SysSocket from Codesys provides the functions needed (To additional information is possible to acess online help from Codesyse máscara de rede pode ser realizada em tempo de execução pela aplicação do PLC utilizando algumas funções disponíveis na biblioteca SysSocket do CODESYS (maiores informações podem ser consultadas Online Help).
The firs step is to include the library SysSocket Implementation in the project.
Acess the Library Manager, at the treeview.
When opened, select the option "Add library" and the button "Advanced".
Search for the library SysSocket Implementation, on Advanced > System > SysLibs.
2.2. Declaring the function blocks SysSockSetIpAddress and SysSockSetSubnetMask
As mentioned before, both functions SysSockSetIpAddress and SysSockSetSubnetMask, from this librray, will be used.
2.3. Example using PLC XP3XXX
An example of the function in the programming language ST (Structured text) with a controller XP3XX:
In ths example, when bChangeIp isTRUE, the interface ‘eth0’ (that represents NET1 from the Xpress) will receive the IP and subnet mask configurations. The functions will be executed in sequel conditioned by the returns Result and Result2 because when the value is 0, the functions were successfully executed.
2.4. String identification of the Ethernet interface
The string identification of the ethernet interface is particular to every model, as showed in the image below:
2.5. Final observations
It is important to consider that, when the IP adress is modified, the connection with Mastertool will be lost (time out) and the applicattion will be stopped. Will be necessary to scan the gateway on easy connection and select the respective device. The configurations of NET1 don`t need to be updated.
It is also extremely necessary to know that this configuration is not retentive so, if the PLC has a power failure, when connected again the adress tha will return is the one configured on NET1.