Connecting to discreet devices using TCP/IP in Codesys
Hello and thank you for viewing my question. I am trying to read/write to some remote temperature controllers using TCP/IP. I am completely lost when it comes to programming Modbus.
I am using AutomationBuilder2.3 w/ Codesys
The information I have is as follows:
IP address: 172.23.7.81
Process variable address: 30360 This is to be read only
Process setpoint variabe address: 42160 This is to be R/W
Do I need additional information? What would be the easiest and most effective way to set this up please?
Thank you so much.
I am using AutomationBuilder2.3 w/ Codesys
The information I have is as follows:
IP address: 172.23.7.81
Process variable address: 30360 This is to be read only
Process setpoint variabe address: 42160 This is to be R/W
Do I need additional information? What would be the easiest and most effective way to set this up please?
Thank you so much.
Voted best answer
Hi,
Here is some simple example. Read the help for ETH_MOD_MAST.
You have to try with start address and FCT until you get the right result.

Mod_IP_Address: STRING:='172.23.7.81';
Mod_IP_Address_DW: DWORD;
ModMast_SLOT: BYTE := 0;
Mod_Unit_ID: BYTE := 0; (*Slave No. Val=0*)
Mod_FCT_4: BYTE := 4; (*for read register 40xxx*) Mod_FCT_6: BYTE := 6; (*for write register 40xxx*) Mod_FCT_3: BYTE := 3; (*for read register 30xxx*)
Mod_Address_Sensors_2: WORD :=360; (* or 361 or 359 for your address 30360 *)
Mod_NB_Sensors_2: INT := 1; (*for reading of 1 register *)
SENSORS_ARRAY: ARRAY [1..2] OF WORD;
Here is some simple example. Read the help for ETH_MOD_MAST.
You have to try with start address and FCT until you get the right result.
Mod_IP_Address: STRING:='172.23.7.81';
Mod_IP_Address_DW: DWORD;
ModMast_SLOT: BYTE := 0;
Mod_Unit_ID: BYTE := 0; (*Slave No. Val=0*)
Mod_FCT_4: BYTE := 4; (*for read register 40xxx*) Mod_FCT_6: BYTE := 6; (*for write register 40xxx*) Mod_FCT_3: BYTE := 3; (*for read register 30xxx*)
Mod_Address_Sensors_2: WORD :=360; (* or 361 or 359 for your address 30360 *)
Mod_NB_Sensors_2: INT := 1; (*for reading of 1 register *)
SENSORS_ARRAY: ARRAY [1..2] OF WORD;
Add new comment