RevPi RS485 config for use in CodeSys
RevPi RS485 config for use in CodeSys
Hello RevPi world,
My colleague and I are currently evaluating the Revolution PI Connect 4 as a controller based on CodeSys.
The system image is installed as delivered.
We plan to use the RS485 interface in CodeSys and have tested the original CodeSys sample project for the SysCom library as a template.
Unfortunately, we cannot get a valid handle for the underlying COM port.
Searching the Internet, there were various hints as to what (or what not) to enter in the two files CODESYSControl.cfg and CODESYSControl_User.cfg.....
Unfortunately, we were unsuccessful.
Hence the question:
What should be entered in the CodeSys*.cfg files so that the RS485 interface can be used as COM1, for example? The physical connection is located here under /dev/ttyRS485 sym link /dev/ttyAMA5.
My colleague and I are currently evaluating the Revolution PI Connect 4 as a controller based on CodeSys.
The system image is installed as delivered.
We plan to use the RS485 interface in CodeSys and have tested the original CodeSys sample project for the SysCom library as a template.
Unfortunately, we cannot get a valid handle for the underlying COM port.
Searching the Internet, there were various hints as to what (or what not) to enter in the two files CODESYSControl.cfg and CODESYSControl_User.cfg.....
Unfortunately, we were unsuccessful.
Hence the question:
What should be entered in the CodeSys*.cfg files so that the RS485 interface can be used as COM1, for example? The physical connection is located here under /dev/ttyRS485 sym link /dev/ttyAMA5.
Re: RevPi RS485 config for use in CodeSys
Hello PVCS, take a look here
https://revolutionpi.com/en/tutorials/b ... rect=en_US
https://revolutionpi.com/en/tutorials/b ... rect=en_US
-
- Posts: 8
- Joined: 15 Apr 2024, 07:34
Re: RevPi RS485 config for use in CodeSys
Hello PVCS,
I am working at the same problem trying to get Modbus RTU running on codesys with a fresh RevPi Connect 4.
Up to now it was not possible for me to establish connection to the RS485 interface. But maybe we can share our findings and get ist running together.
You wrote that you use the image as delivered. On my RevPi te image Bullseye RevPi Bullseye 64-bit was installed as delivered. But as per this article 64-bit image is not supported for CODESYS.
https://kunbus-gmbh.atlassian.net/servi ... 2687893508
To get the examples running it looks like we have to change the image to a 32-bit version. Furthermore there it is neccessary to enter following code to the /etc/CODESYSConfig_User.cfg:
For CODESYS Control for Raspberry Pi MC SL - 4.10.0.0 or higher
[SysFile]
PlaceholderFilePath.2=/etc/revpi, $configrsc$
On the other hand Kunbus offers a new Codesys library that supports 64-bit which is still in BETA. I think the Release will be soon, maybe end of this month.
viewtopic.php?t=4293
But to use this library it can run only with CODESYS Control for Linux ARM SL. In this case the 64-bit image can stay on the RevPI.
When using this library the entry into /etc/CODESYSConfig_User.cfg should be:
[SysFile]
PlaceholderFilePath.1=/etc/revpi, $configrsc$
For the entry into the CODESYS*.cfg for accessing the RS485 I am also confused by different posts.
Accoding to the tutorial it should be
Linux.Devicefile=/dev/ttyUSB
But im my opinion USB are the On-Board USB ports.
According to this post viewtopic.php?t=3484 (German) Kunbus mentioned, that the entry should be /dev/ttyRS485. And user Inoak wrote it must be Linux.Devicefile.1=/dev/ttyRS485 (Why .1?)
In another post I found the entry
[SysCom]
/dev/ttyAMA
Also this entry sounds for me plausible, because /dev/RS485 is sym linked to /dev/ttyAMA5.
Looking into the CODESYSControl_User.cfg there is already an entry
[SysCom]
Linux.Devicefile=/dev/ttyS
but I don't know what this entry means.
Maybe someone from Kunbus support can leave some comments on this findings and can tell us the exact entry into the CODESYS*.cfg.
I guess the entry must be done in the CODESYSControl_User.config and not in the CODESYSControl.cfg like said in the tutorial.
I hope I could give you some information more on our common problem. Next week I will do further tests to get it running. Maybe we can share our results.
Best regards
Wolfgang
I am working at the same problem trying to get Modbus RTU running on codesys with a fresh RevPi Connect 4.
Up to now it was not possible for me to establish connection to the RS485 interface. But maybe we can share our findings and get ist running together.
You wrote that you use the image as delivered. On my RevPi te image Bullseye RevPi Bullseye 64-bit was installed as delivered. But as per this article 64-bit image is not supported for CODESYS.
https://kunbus-gmbh.atlassian.net/servi ... 2687893508
To get the examples running it looks like we have to change the image to a 32-bit version. Furthermore there it is neccessary to enter following code to the /etc/CODESYSConfig_User.cfg:
For CODESYS Control for Raspberry Pi MC SL - 4.10.0.0 or higher
[SysFile]
PlaceholderFilePath.2=/etc/revpi, $configrsc$
On the other hand Kunbus offers a new Codesys library that supports 64-bit which is still in BETA. I think the Release will be soon, maybe end of this month.
viewtopic.php?t=4293
But to use this library it can run only with CODESYS Control for Linux ARM SL. In this case the 64-bit image can stay on the RevPI.
When using this library the entry into /etc/CODESYSConfig_User.cfg should be:
[SysFile]
PlaceholderFilePath.1=/etc/revpi, $configrsc$
For the entry into the CODESYS*.cfg for accessing the RS485 I am also confused by different posts.
Accoding to the tutorial it should be
Linux.Devicefile=/dev/ttyUSB
But im my opinion USB are the On-Board USB ports.
According to this post viewtopic.php?t=3484 (German) Kunbus mentioned, that the entry should be /dev/ttyRS485. And user Inoak wrote it must be Linux.Devicefile.1=/dev/ttyRS485 (Why .1?)
In another post I found the entry
[SysCom]
/dev/ttyAMA
Also this entry sounds for me plausible, because /dev/RS485 is sym linked to /dev/ttyAMA5.
Looking into the CODESYSControl_User.cfg there is already an entry
[SysCom]
Linux.Devicefile=/dev/ttyS
but I don't know what this entry means.
Maybe someone from Kunbus support can leave some comments on this findings and can tell us the exact entry into the CODESYS*.cfg.
I guess the entry must be done in the CODESYSControl_User.config and not in the CODESYSControl.cfg like said in the tutorial.
I hope I could give you some information more on our common problem. Next week I will do further tests to get it running. Maybe we can share our results.
Best regards
Wolfgang
Re: RevPi RS485 config for use in CodeSys
Not much a CODESYS expert, but the correct device is /dev/RS485 which is a symlink to the effective serial device. The effective serial devices differ between different RevPi types, so make sure to use the symlink.
There is also the beta of our CODESYS library, which finally supports 64-bit systems. The new library version also works with the native CODESYS arm runtime which works with the new license model. Maybe you can give it a shot? Customer feedback looks good so far and we will probably release it in May (among support for latest CODESYS V3.5 SP20).
See viewtopic.php?t=4293
Nicolai
There is also the beta of our CODESYS library, which finally supports 64-bit systems. The new library version also works with the native CODESYS arm runtime which works with the new license model. Maybe you can give it a shot? Customer feedback looks good so far and we will probably release it in May (among support for latest CODESYS V3.5 SP20).
See viewtopic.php?t=4293
Nicolai
Re: RevPi RS485 config for use in CodeSys
Hello PVCS,
Under General->Serial Port Configuration tab of MODBUS_COM device in codesys tree
COM Port selected will be as follows
/dev/ttyUSB0 -> COM Port 1
/dev/ttyUSB1 -> COM Port 2 ...
/dev/ttyUSBn -> COM Port n
In /etc/CODESYSControl_User.cfg you can try configuring following:
Try using port 6. If it does not work, try port 5 also.
You can check out example ModbusTCP-RTU-Master which is however for Connect 3/S
Lastly it may be perhaps CODESYS needing COM description in /dev/ttyUSB* format in /etc/CODESYSControl_User.cfg
For this you can try creating following symlink:
/dev/ttyUSB5 -> ttyAMA5
In /etc/CODESYSControl_User.cfg you can configure:
And then try with port 6 or 5 if it works.
Please let us know your findings accordingly.
Regards, Amar
Under General->Serial Port Configuration tab of MODBUS_COM device in codesys tree
COM Port selected will be as follows
/dev/ttyUSB0 -> COM Port 1
/dev/ttyUSB1 -> COM Port 2 ...
/dev/ttyUSBn -> COM Port n
In /etc/CODESYSControl_User.cfg you can try configuring following:
Code: Select all
[SysCom]
Linux.Devicefile=/dev/ttyAMA
You can check out example ModbusTCP-RTU-Master which is however for Connect 3/S
Lastly it may be perhaps CODESYS needing COM description in /dev/ttyUSB* format in /etc/CODESYSControl_User.cfg
For this you can try creating following symlink:
/dev/ttyUSB5 -> ttyAMA5
In /etc/CODESYSControl_User.cfg you can configure:
Code: Select all
[SysCom]
Linux.Devicefile=/dev/ttyUSB
Please let us know your findings accordingly.
Regards, Amar
KUNBUS
-
- Posts: 8
- Joined: 15 Apr 2024, 07:34
Re: RevPi RS485 config for use in CodeSys
After several trials I was not able to get Modbus communication running on CODESYS (V3.5.20.0) with RevPi Connect 4 and the delivered 64bit image. So, I changed my setup like described in the CODESYS Checklist.
https://kunbus-gmbh.atlassian.net/servi ... 2687893508
Finally I got it working.
My new setup:
- RevPi Bullseye 32-bit (02/2024) (ID: 7792)
- CODESYS Development System V3.5.19.0
- Revolution Pi Library for CODESYS V1.4.1.0 (ID: 7530)
- CODESYS Control for Raspberry Pi 4.10.0.0 (ID: 7533)
CODESYSControl.cfg:
[SysCom]
Linux.Devicefile.1=/dev/ttyRS485
CODESYSControl_User.cfg:
[SysFile]
PlaceholderFilePath.2=/etc/revpi, $configrsc$
In CODESYS the Com-Port will be COM1.
Regards
Wolfgang
https://kunbus-gmbh.atlassian.net/servi ... 2687893508
Finally I got it working.
My new setup:
- RevPi Bullseye 32-bit (02/2024) (ID: 7792)
- CODESYS Development System V3.5.19.0
- Revolution Pi Library for CODESYS V1.4.1.0 (ID: 7530)
- CODESYS Control for Raspberry Pi 4.10.0.0 (ID: 7533)
CODESYSControl.cfg:
[SysCom]
Linux.Devicefile.1=/dev/ttyRS485
CODESYSControl_User.cfg:
[SysFile]
PlaceholderFilePath.2=/etc/revpi, $configrsc$
In CODESYS the Com-Port will be COM1.
Regards
Wolfgang
Re: RevPi RS485 config for use in CodeSys
Hello Wolfgang and PVCS,
Modbus RTU with Connect 4 on 64 bit image shall work with following settings:
Configure COM port default interface for Connect4 in /etc/CODESYSControl_User.cfg
running CODESYS Control for Linux ARM64 SL
In CODESYS project, the COM port 6 will have to be used
You can check out a sample Modbus RTU application for Connect 4 on 64bit image running CODESYS Control for Linux ARM64 SL
Example: Additional comment:
In Connect 4, the RS-485 port is linked to ttyAMA5 using symlink
/dev/ttyRS485 -> ttyAMA5
In Connect 3, the RS-485 port is linked to ttyUSB0 using smbolic link
/dev/ttyRS485 -> ttyUSB0
Regards, Amar
Modbus RTU with Connect 4 on 64 bit image shall work with following settings:
Configure COM port default interface for Connect4 in /etc/CODESYSControl_User.cfg
running CODESYS Control for Linux ARM64 SL
Code: Select all
[SysFile]
PlaceholderFilePath.1=/etc/revpi, $configrsc$
[SysCom]
Linux.Devicefile=/dev/ttyAMA
You can check out a sample Modbus RTU application for Connect 4 on 64bit image running CODESYS Control for Linux ARM64 SL
Example: Additional comment:
In Connect 4, the RS-485 port is linked to ttyAMA5 using symlink
/dev/ttyRS485 -> ttyAMA5
In Connect 3, the RS-485 port is linked to ttyUSB0 using smbolic link
/dev/ttyRS485 -> ttyUSB0
Regards, Amar
KUNBUS