Hi. Having some troubles to get the RS485 port to work with Codesys.
The device is a RevPi Connect which have a built in RS485 port. The port is accessible from terminal via /dev/ttyRS485.
If I use this in the CodesysControl_User.cfg I only get bus failure in Codesys but if I use /dev/ttyUSB I get a green running.
But I have some troubles getting the device to act as a Modbus RTU slave so I am wondering if maybe /dev/ttyUSB is wrong anyways. How can I check this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
pi@RevPi11710:/dev$dmesg|grep"tty"[Â Â 0.000000]Kernelcommandline:bcm2708_fb.fbwidth=640bcm2708_fb.fbheight=480bcm2708_fb.fbswap=1smsc95xx.macaddr=B8:27:EB:4B:36:3Avc_mem.mem_base=0x3ec00000vc_mem.mem_size=0x40000000Â dwc_otg.lpm_enable=0console=tty1root=/dev/mmcblk0p2rootfstype=ext4elevator=deadlinefsck.repair=yesrootwaitnosplashplymouth.ignore-serial-consoles[Â Â 0.001842]console[tty1]enabled[Â Â 1.435344]3f201000.serial:ttyAMA0atMMIO0x3f201000(irq=87,base_baud=0)isaPL011rev2[Â Â 3.128774]systemd[1]:Createdslicesystem-getty.slice.[Â Â 6.221504]usb1-1.5.2:FTDIUSBSerialDeviceconverternowattachedtottyUSB0[Â Â 6.306834]usb1-1.5.3:FTDIUSBSerialDeviceconverternowattachedtottyUSB1
pi@RevPi11710:/dev $ lsautofs     cpu_dma_latency gpiochip1 log  loop7       mmcblk0p1      piControl0 ram12 ram6  rtc0    stdout tty14 tty21 tty29 tty36 tty43 tty50 tty58 tty8     uhid   vcs2  vcsa3   zeroblock     cuse       gpiochip2 loop0 loop-control   mmcblk0p2      ppp     ram13 ram7  serial   tty   tty15 tty22 tty3  tty37 tty44 tty51 tty59 tty9     uinput  vcs3  vcsa4btrfs-control disk       gpiomem  loop1 mapper      mmcblk0rpmb     ptmx    ram14 ram8  serial0  tty0  tty16 tty23 tty30 tty38 tty45 tty52 tty6  ttyAMA0    urandom vcs4  vcsa5bus      fb0       hwrng   loop2 mem        mqueue       pts     ram15 ram9  shm    tty1  tty17 tty24 tty31 tty39 tty46 tty53 tty60 ttyConBridge vchiq  vcs5  vcsa6cachefiles   fd        i2c-1   loop3 memory_bandwidth net         ram0    ram2  random snd    tty10  tty18 tty25 tty32 tty4  tty47 tty54 tty61 ttyprintk   vcio   vcs6  vcsmchar      full       initctl  loop4 mmcblk0      network_latency   ram1    ram3  raw   spidev0.0 tty11  tty19 tty26 tty33 tty40 tty48 tty55 tty62 ttyRS485   vc-mem  vcsa  vhcichar_dev    fuse       input   loop5 mmcblk0boot0   network_throughput ram10    ram4  rfkill stderr   tty12  tty2  tty27 tty34 tty41 tty49 tty56 tty63 ttyUSB0    vcs   vcsa1 watchdogconsole    gpiochip0    kmsg    loop6 mmcblk0boot1   null        ram11    ram5  rtc   stdin   tty13  tty20 tty28 tty35 tty42 tty5  tty57 tty7  ttyUSB1    vcs1   vcsa2 watchdog0
If I change for example baud rate from codesys then the baudrate changes for both /dev/ttyRS485 and /dev/ttyUSB0 so this seems fine.?
Maybe there is something else that doesnt work. The Modbus Master is sending some data to me but I am not getting anything in Codesys and I have no faults. How do I proceed?
Could it be that I havent bought the license yet as I am only testing the hardware? Shouldnt the bus function for 0,5h without license?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Sir Kevin. May I know how you came up with this solution. Im a bit confused but I tried to put this. [SysCom]
Linux.Devicefile=/dev/ttyRS48 (remember, no 5 at the end!)
then set com port in codesys to 6.
It also works for me but want to know where did you get this. Thank you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
usually the Serial port on a Raspberry pi is on /dev/ttyUSB0 then you need to set linux.DeviceFile=/dev/ttyUSB in codesys you then must set com port to 1 so i assumed codesys subtracts 1 from the number and adds this to the filename...
(in code it would look like this:
Hi. Having some troubles to get the RS485 port to work with Codesys.
The device is a RevPi Connect which have a built in RS485 port. The port is accessible from terminal via /dev/ttyRS485.
If I use this in the CodesysControl_User.cfg I only get bus failure in Codesys but if I use /dev/ttyUSB I get a green running.
But I have some troubles getting the device to act as a Modbus RTU slave so I am wondering if maybe /dev/ttyUSB is wrong anyways. How can I check this?
Related
Talk.ru: 1
My CodesysControl_User.cfg
If I change for example baud rate from codesys then the baudrate changes for both /dev/ttyRS485 and /dev/ttyUSB0 so this seems fine.?
Maybe there is something else that doesnt work. The Modbus Master is sending some data to me but I am not getting anything in Codesys and I have no faults. How do I proceed?
Could it be that I havent bought the license yet as I am only testing the hardware? Shouldnt the bus function for 0,5h without license?
Hi,
not sure,
if you receive with the terminal on /dev/ttyRS485
you should write:
[SysCom]
Linux.Devicefile=/dev/ttyRS485
that's it, then it should work.
BR
Edwin
i did this recently. the solution is:
[SysCom]
Linux.Devicefile=/dev/ttyRS48 (remember, no 5 at the end!)
then set com port in codesys to 6. that works
Hi Sir Kevin. May I know how you came up with this solution. Im a bit confused but I tried to put this.
[SysCom]
Linux.Devicefile=/dev/ttyRS48 (remember, no 5 at the end!)
then set com port in codesys to 6.
It also works for me but want to know where did you get this. Thank you.
I figured this out on my own with this logic:
usually the Serial port on a Raspberry pi is on /dev/ttyUSB0 then you need to set linux.DeviceFile=/dev/ttyUSB in codesys you then must set com port to 1 so i assumed codesys subtracts 1 from the number and adds this to the filename...
(in code it would look like this:
filaname then is /dev/ttyUSB0
RevPi uses ttyRS485 as Serial port so you must remove the last number from the name and set the com port to this number +1
i hope this is understandable ;-)
Last edit: kevinl 2023-12-11