RaspberryPi and Arduino Modbus RTU

rKtiC
2018-03-12
2018-03-12
  • rKtiC - 2018-03-12

    Hi everyone,

    I'm using the following setup:
    - Raspberrry Pi 3 as Modbus RTU Master (MODBUS_COM_Port_1)
    - Arduino UNO as Modbus RTU Slave
    both are connected via USB
    I use ModbusSerial library for Arduino from here:

    https://github.com/andresarmento/modbus ... /libraries

    I tested the Arduino with qModMaster on my Windows-PC via USB port. This worked well as you can see in the screenshots. Therefore I assume that the Arduino setup and code are correct.
    Further, I also assigned the RaspberryPi USB Com Port described here:

    l viewtopic.php?f=21&t=6755&p=14284&hilit=modbus+rtu#p14284 l

    But as you can see in the screenshot, the Modbus slave is not running (red triangle) and status of Modbus Slave is 'Bus error'.
    Thank you for your help!

    rKtiC

    IMG: Modbus_Arduino_5.PNG

    IMG: Modbus_Arduino_4.PNG

    IMG: Modbus_Arduino_3.PNG

    IMG: Modbus_Arduino_2.PNG

    IMG: Modbus_Arduino_1.PNG

     
  • Ernest - 2018-03-12

    Hi

    I used this code

    sudo nano /etc/CODESYSControl.cfg

    [SysCom]
    Linux.Devicefile=/dev/ttyUSB
    portnum := COM.SysCom.SYS_COMPORT1;

    sudo /etc/init.d/codesyscontrol restart

    try it

    also make sure that in the point of updating the variables you have a mode (always in the task of the bus cycle) number 2.

    But this will not be the only problem with the modbus rtu

    After the reboot, you will have a loss of communication between Arduino and Raspberry

    I have not been able to solve this problem yet.

    If you find solutions please let me know

    Good luck

     
  • Bifogad - 2018-03-12

    I added this.

    [SysCom]
    Linux.Devicefile=/dev/ttyACM

    There is some command to see the name of the com port but I can't remember. In my case it wasn't ttyUSB.
    I also didn't need to add "portnum := COM.SysCom.SYS_COMPORT1;"

    /Martin

     
  • Ernest - 2018-03-12

    Bifogad hat geschrieben:
    I added this.
    [SysCom]
    Linux.Devicefile=/dev/ttyACM
    There is some command to see the name of the com port but I can't remember. In my case it wasn't ttyUSB.
    I also didn't need to add "portnum := COM.SysCom.SYS_COMPORT1;"
    /Martin

    Did you have a problem with the loss of communication between Raspberry and Arduino after the reboot?

     

Log in to post a comment.