MODBUS TCP on CODESYS

boneless

Lifetime Supporting Member + Moderator
Join Date
Feb 2008
Location
OKC
Posts
1,628
Hi all,
A couple of years ago, I ran some tests with MODBUS TCP communication between rPi running CodeSYS and a couple of Arduino's.
I remember that I could set all the parameters under the MODBUS devices.
I am now trying to run another test, and I can't seem to find where to set the IP address for my SLAVE/SERVER. Am I correct to assume that this is set through a FB now?
Nor am I able to find any free libraries on the CodeSYS site. Am I looking in the wrong place?
Any help would be greatly appreciated!
 
Hi all,
A couple of years ago, I ran some tests with MODBUS TCP communication between rPi running CodeSYS and a couple of Arduino's.
I remember that I could set all the parameters under the MODBUS devices.
I am now trying to run another test, and I can't seem to find where to set the IP address for my SLAVE/SERVER. Am I correct to assume that this is set through a FB now?
Nor am I able to find any free libraries on the CodeSYS site. Am I looking in the wrong place?
Any help would be greatly appreciated!

Normally you set slave's IP address in the General Tab of the Modbus_TCP_Slave but I can set it code as well. I do it when I want to let the user changer slave IP from the HMI.

Look at part 3 of my old blog:

http://automationofthings.blogspot.com/2015/10/turn-your-raspberry-pi-into-plc-part-3.html
 
Last edited:
ahhhh, ffs, I forgot one level :).


I added the ethernet interface, then added the slave.
But I need to add the ethernet interface, then add the master (me) and finally add the slave that connects to the master.


Thank you so much, your blog gave me the hint I needed! :).


Do you happen to have any examples of setting the IP with code through the HMI tho?
 
Hello again,


Did some more testing, your tutorial has been very helpful, thank you Kallileo.


I have one follow-up. Do you know if it is possible to read the status of analog output signals? I can read digital in and outputs, as well as analog inputs and holding registers. But can't seem to find a way to read output registers, only individual coils.
 
In Modbus, analog outputs are usually mapped to Holding Registers (16bit integers) because only HR can be both readable and writable using the respective HR function code.

It also possible that in order to write to analog output you need write to a HR but in order to read the same output you need to read an Input registers.
There are also devices that don't have discrete inputs and input registers at all but only coils and HRs for both read-only and read/write memory supporting only few Modbus function codes.
Always check the manual of the device as Modbus be could a real mess.

https://blog.softwaretoolbox.com/opc-modbus-function-codes
 
Last edited:

Similar Topics

I have a program for a PLC, but I don't have the PLC now. I am running the PLC program in the Codesys simulation mode. Can I connect SCADA to...
Replies
2
Views
1,754
I'm going to be adding Modbus TCP communications to a Turck Codesys system. There will be more than one HMI hitting the Turck hardware, hopefully...
Replies
0
Views
1,051
Hi folks, I'm running eCockpit version 1.3.1.4 I have set up a Modbus client function using the standard library module: FbMbMasterTcp. My...
Replies
4
Views
3,858
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...
Replies
15
Views
11,110
I havent been able to connect each other. looking for some help i got the addresing but i cant figure it out.
Replies
2
Views
2,006
Back
Top Bottom