ModBus RTU in CODESYS

Topics about the Software of Revolution Pi
Post Reply
schoebenji
Posts: 3
Joined: 04 May 2022, 09:30
Answers: 0

ModBus RTU in CODESYS

Post 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!
Attachments
Screenshot.PNG
Screenshot.PNG (3.8 KiB) Viewed 3060 times
u.biakoup
KUNBUS
Posts: 182
Joined: 14 Apr 2022, 13:04
Answers: 2

Re: ModBus RTU in CODESYS

Post 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
Amar
KUNBUS
Posts: 158
Joined: 15 Jul 2019, 12:58
Answers: 4

Re: ModBus RTU in CODESYS

Post by Amar »

You could initally try to get the provided codesys example ModbusTCP-RTU-Slave running with QModbus Master using USB RS 485 convertor.
KUNBUS
schoebenji
Posts: 3
Joined: 04 May 2022, 09:30
Answers: 0

Re: ModBus RTU in CODESYS

Post 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.
Attachments
Master_COM.PNG
Master_COM.PNG (58 KiB) Viewed 2852 times
COM-Port.PNG
COM-Port.PNG (50.6 KiB) Viewed 2852 times
System-Info.PNG
System-Info.PNG (24.47 KiB) Viewed 2852 times
Amar
KUNBUS
Posts: 158
Joined: 15 Jul 2019, 12:58
Answers: 4

Re: ModBus RTU in CODESYS

Post 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.
KUNBUS
schoebenji
Posts: 3
Joined: 04 May 2022, 09:30
Answers: 0

Re: ModBus RTU in CODESYS

Post by schoebenji »

That was the problem! I didn't add the command to the CODESYSControl_User.cfg, only CODESYSControl.cfg.
Thank you!
Post Reply