...
- Create a "Standard project" and select CODESYS Control Win V3 as the device.
- Define the target system by means of the Netzwork Network scan.
Insert an Ethernet adapter in the device tree and specify the interface to be used.
Note If a target system is not defined yet, then the error message "Gateway not configured" is displayed.
- Insert a Modbus TCP Master below the Ethernet adapter in the device tree.
Insert a Modbus TCP Slave below the Modbus TCP Master in the device tree.
Info Pay attention that the address is the the same as for the Modbus Slave Device.
Adapt the POU PLC_PRG as follows:
Section Column width 7 Declaration
Column width 93 Code Block theme Confluence VAR xUpdate : BOOL; sIp : STRING; udiResult : UDINT; abyNewIp : ARRAY [0..3] OF BYTE := [192,168,99,198]; // Insert here the correct IP-Address of the Modbus_Slave_Device END_VAR
Section Column width 7 Implementation
Column width 93 Code Block theme Confluence sIp := IoDrvEthernet.IPARRAY_TO_IPSTRING(Modbus_TCP_Slave.ComSettings.ipAddress); Modbus_TCP_Slave.xConfirmError := FALSE; IF xUpdate THEN xUpdate := FALSE; udiResult := Modbus_TCP_Slave.UpdateCommunicationSettings(ipAddress := abyNewIp, uiPort := 502); Modbus_TCP_Slave.xConfirmError := TRUE; END_IF
...