USB-RS232 and onboard RS485 in parallel

Topics about the Hardware of Revolution Pi
Post Reply
MDaxboec
Posts: 2
Joined: 14 Sep 2021, 13:10

USB-RS232 and onboard RS485 in parallel

Post by MDaxboec »

Is it possible to use the two USB ports for RS232 and the onboard RS485 at the same time? What to configure in the CODESYSControl file?
User avatar
Amar
KUNBUS
Posts: 167
Joined: 15 Jul 2019, 12:58

Re: USB-RS232 and onboard RS485 in parallel

Post by Amar »

Hi,
Yes, you can use different serial ports (USB for RS232 and onboard for RS485) at the same time in CODESYS, as long as each serial port is mapped to a unique device file (for example /dev/ttyUSB0, /dev/ttyUSB2, /dev/ttyUSB3).

Each instance of the serial COM Port (SysCom in CODESYS) requires a unique Linux device file.
Ensure that no two CODESYS serial channels point to the same file (port).
Double-check that your USB-to-RS232 adapters and onboard RS485 don't conflict in resource or driver.

Identifying the Ports
Example Connect S/SE :
Onboard RS485: /dev/ttyRS485-0 is a symlink to /dev/ttyUSB0
USB RS232 #1 external adapter : /dev/ttyUSB2
USB RS232 #2 external adapter : /dev/ttyUSB3

Configuring CODESYSControl_User.cfg
To map the serial interfaces in CODESYS, add or update the [SysCom] section of the configuration file.
You need to specify each device file explicitly:

Code: Select all

[SysCom]

; COM Port 1: onboard RS485
Linux.Devicefile.1=/dev/ttyRS485-0

; COM Port 2: USB RS232 #1
Linux.Devicefile.2=/dev/ttyUSB2

; COM Port 3: USB RS232 #2
Linux.Devicefile.3=/dev/ttyUSB3
The numbering (.1, .2, .3) associates each device file with a COM port number in your CODESYS project (for example, COM1 in your program maps to .1).
If you use /dev/ttyUSB0 directly, you can also do so (since /dev/ttyRS485-0 points to it).
Do not use a wildcard like Linux.Devicefile=/dev/ttyUSB—that only works if you have one USB serial device.

You must restart the CODESYS Control service after editing the config file for changes to take effect.
sudo systemctl restart codesyscontrol
KUNBUS
Post Reply