Modbus TCP Library Codesys 3.5

swedeleaner

Member
Join Date
Dec 2013
Location
Göteborg
Posts
143
Hello!

Is there any readily avalaible function blocks for this?!
Found heaps of Codesys 2.3 stuff, but the libraries have changed and can´t be installed in Codesys 3.5

I´m looking for Modbus TCP Client (Master) and Modbus TCP Server (Slave).

OSCAT have some FB:s for this but in codesys 2.3
Is it possible to open function blocks from libraries in Coesys 2.3?

Guess I could try to do a copy-paste with the code, but can´t open the FB:s in Codesys 2.3 (Nothing happens when i double click on them.

If someone knows where i can find FB´s developed for Codesys 3.5 i would really appreciate it.

(I´m building a Raspberry Pi Soft-PLC with Crevis-nodes for my home)
(y)
 
If I may make a recommendation. If you're using the Raspberry PI I recommend you look into doing all of this with Node Red.

Good Luck!

Yosi
(8{)} :) .)
 
Hi swedeleaner,
How did you solved this with Codesys native functions?
I was able do do this with ModbusServer FB (ModbusTCP slave lib) but I did not find anything for Client?
 
It wasn’t that obvious.

You assign the Network adapter as a Modbus Client if I’m not misstaken. I could email my project to you, send me your e-mail as a message!
 
I know it's an old thread but... the issue is still alive for many

I managed to make a Modbus RTU client via the ModbusRequest2 FB inside the IoDrvModbus library, it's pretty straightforward:
- you open the com port
- execute the request passing the port handle to the FB

Now I'm trying to make a Modbus TCP client without doing it via the Device, because it pretty much sucks.

I found the ModbusRequest inside the IoDrvModbusTCP and understood I have to use ModbusTCPSlave to connect to the slave/server before handling the request. Still, I'm not able to understand how to connect to the slave.

If any of you managed to do it and could give me some hints, that would be great. Thanks
 
Please check the following link. You need to establish connection first using IoDrvModbusTCPSlave.
I have used this library once on SoMachine. I created a state machine with IoDrvModbusTCPSlave being in the first step and then I would use ModbusRequest to execute various Modbus commands in the following steps or something like that.

https://product-help.schneider-elec...guration_editor/modules/_mod_f_libraries.html
 
@kallileo are you sure about that?
I think 'IoDrvModbusTCPSlave' is for creating a Modbus TCP Slave (server) on your device.

Maybe you meant 'ModbusTCPSlave': in fact I created the instance but I have no idea how to start the connection... :confused: following you link: https://product-help.schneider-elec..._modbustcpslave_function_block_modbustcpslave
it tels that you start it wiht the property 'xEnable', which doesn't exist.
I used the method 'UpdateCommunicationSettings' to set the ip and port, and now...? I attached a picture to show both my instance and the instance created in the device tree

I really appreciate your help

CONFIG.png
 
the ModbusRequest FB works if I use the POINTER TO ModbusTCPSlave in my device tree, because it is connected.

But I cannot use the ModbusRequest FB with my ModbusTCPSlave created locally, because the connection state is OFF even if I configured the ip and port, because there seems to be no method to start the connection
 

Similar Topics

Hi There. I have PC to get few tags from PLC into C# windows forms application. What is the best and fastest way? I could not find Omron in...
Replies
3
Views
230
Hi, I have a project coming up where I need to communicate a Gem500 with a Siemens S7-300 over ethernet. The Gem500 uses the Modbus TCP protocol...
Replies
1
Views
4,876
Hello Does anyone know where to get a MODBUS TCP c/c++ library. I want to connect my c/c++ programm with a remote PLC (Beckhoff/Twincat). I...
Replies
2
Views
6,727
Hello gentlemen, Im working on a small project on TIA Portal, about establishing a Modbus TCP connection between my ET200SP plc and a socomec...
Replies
11
Views
240
If a device has Modbus RTU over serial and Modbus RTO over TCP and Modbus TCP then there is a difference between Modbus RTU over TCP vs Modbus TCP...
Replies
7
Views
436
Back
Top Bottom