Raspberry PI4 Serial Port

thewizard8
2024-03-18
2024-07-18
  • thewizard8 - 2024-03-18

    Hi Dear All,

    I'm using my raspberry PI4 as a CoDeSyS PLC (Build from scratch with custom electronics).
    I was able to implement all fieldbuses with the exception of Modbus Serial.
    I'm using the internal Port (GPIO) and I configured it in /etc/Codesyscontrol_user.cfg the following away:

    [SysCom]
    Linux.Devicefile.1=/dev/ttyUSB0
    Linux.Devicefile.2=/dev/ttyS0

    I'm using COM2 on Master configuration.
    I'm using a interface board from TTL/RS485 (bidirectional board), and it's works perfectly with other devices but not in CoDeSyS.

    I'm able to send data with python script and read it on my pc using putty, but when I use a modbus slave simulator to interface with codesys I always get red icons on master and slave. (Please find image attached).

    I'm pretty shure that this might be a bad parameter on my CoDeSyS runtime configurstion file.

    Can someone help me? I'm stuck and this is for my master degree certification.

     
  • eschwellinger

    eschwellinger - 2024-03-18

    no parameter seems ok but
    RS485 does only work with CODESYS if the send/receive is determined by hardware as I remember correct

     
    • thewizard8 - 2024-03-19

      Hi eschwellinger,

      Thanks for replying, but I'm not shure if I got it right.

      Do you mean that I have bad configuration on my CODESYS config file? Or in my project?

      Thanks in advance!

       
  • eschwellinger

    eschwellinger - 2024-03-19

    no config file is ok,
    the feedback is: your hardware must support this send/receive switching

     
  • thewizard8 - 2024-03-19

    Hi thanks once again,

    Yes it supports because using python scripting I'm able to send data from the rasberry
    raspberry and receive it on my pc and vice versa (Image attached).
    But when using the CoDeSyS I just got red flags.
    Any light on this problem?

     

    Last edit: thewizard8 2024-03-19
  • thewizard8 - 2024-03-19

    Hi All,

    I finally figured out how to solve it.
    The only away that I got it to work was to define parity to None on modbus configuration, and now works like
    a charm.
    Just for the record I'm using the GPIO port pins (8,10) and a RS485 to ttl shield that you can find online.
    Thanks all for the support!

    Regards
    Ricardo

     
    • nltheves - 2024-07-18

      Hi Ricardo.

      I was having the same problem with Codesys and a Raspberry Pi 2W while using the GPIO uart.
      Your post helped me a lot. Thanks!

      But could not understand why MODBUS parity bit makes Codesys MODBUS COM driver stopping to work after first request transmission.

      Did you see this @eschwellinger ?

      Regards,
      Nelson

       

Log in to post a comment.