Page 1 of 1

ModBus RTU in CODESYS

Posted: 04 May 2022, 12:33
by schoebenji
Hello!

I'm trying to set up a connection between a pyrometer and my RevPi Connect via ModBus RTU in Codesys. I followed this tutorial https://revolutionpi.de/tutorials/beisp ... -master-2/.
I would like to use the RS-485 port if possible.
My problem is when starting the application the ModBus_Master_COM_Port and the ModBus_Slave_COM_Port aren't running (Screenshot in the attachments).

I'm still inexperienced in this field, so I would really appreciate some help.
Thank you!

Re: ModBus RTU in CODESYS

Posted: 05 May 2022, 15:49
by u.biakoup
Hello,
My first question is: were the COM_Master_ModBus port and the COM_ModBus_Slave port already working?
Check your configuration in pictory again. If possible, delete it and redo it. Save it as a starting configuration (in the File menu) and then reset the driver (in the Tools menu). Please, can you take a screenshot of the system information in codesys and post it here----> Steps: open Tools/Update Raspberry pi/enter your password and click on system-info. This is to see what version of all packages you are using. Maybe there is an incompatibility.

Best regards

Ulrich

Re: ModBus RTU in CODESYS

Posted: 06 May 2022, 15:26
by Amar
You could initally try to get the provided codesys example ModbusTCP-RTU-Slave running with QModbus Master using USB RS 485 convertor.

Re: ModBus RTU in CODESYS

Posted: 10 May 2022, 09:58
by schoebenji
Hello and thank you for your quick responses!

"were the COM_Master_ModBus port and the COM_ModBus_Slave port already working?" ---- No they were not.
I've attached the system info and some other screenshot, maybe they help.


If someone else reads this and also has troubles finding the "Update Raspberry Pi" button:
First you have to customize the Tools deploy, explained here: https://forge.codesys.com/forge/talk/Ru ... d8391340a/
I needed the permission of an admin to install packages and for some reason Codesys installed those in the folder of the admin.
So I just copied the folder "C:\User\<AdminsUser>\CODESYS Control for Raspberry Pi" into my user.
I hope this helps.

Re: ModBus RTU in CODESYS

Posted: 10 May 2022, 11:44
by Amar
Can you verify if following settings have been configured?

/etc/CODESYSControl_User.cfg

[SysCom]
Linux.Devicefile=/dev/ttyUSB


Check if some error related to com port is present the codesys log
https://help.codesys.com/api-content/2/ ... 0e0137e2e5


Next troubleshooting step would be to check if the RS485 port on Connect is not damaged.
For that remove the codesys application running on the RevPi Device.

Connect the RS 485 port on Connect to some USB serial port on Linux/Windows PC
Access the RS 485 port directly from shell and check if TX-RX is essentially working.
Eg:
Communication settings: 19200 8 E None

sudo stty -F /dev/ttyUSB0 19200 cs8 -cstopb -parenb

sudo echo "HELLO" > /dev/ttyUSB0

Use hyperterminal or some USB serial port in Windows/Linux to check if data is trasnmitted/received.

Re: ModBus RTU in CODESYS

Posted: 23 May 2022, 14:23
by schoebenji
That was the problem! I didn't add the command to the CODESYSControl_User.cfg, only CODESYSControl.cfg.
Thank you!