Modbus RTU with the Monarco HAT on Raspberry Pi


  • administrators

    Monarco HAT MCU (microcontroller) is connected as UART device on the Raspberry Pi UART-0 (/dev/ttyAMA0). Data on this interface is normally forwarded between Monarco HAT RS-485 and Raspberry Pi UART-0 in both directions with correct buffering for half-duplex operation.

    The configuration of the RS-485 bus on the Monarco HAT consists of two parts:

    • Configuration of internal UART communication between the Raspberry Pi and the MCU of the Monarco HAT.
    • Configuration of the external RS-485 communication interface.
      0_1551274669761_Monarco-HAT-RS485.png

    Internal UART communication (host side communication)

    By default, the Monarco HAT MCU expects UART communication with 115200 Baud, 8 data bits, no parity, 1 stop bit. Therefore it is necessary to use these settings in Modbus Configuration dialog:

    0_1551277894499_2b6b3a35-e595-458f-9eb0-8042cad4a8e3-image.png

    Note: It is typically not necessary to change the internal communication baudrate. If needed, it's possible using the 0x012 service register of the Monarco HAT (see the Monarco HAT SPI Protocol Reference Manual for details).

    For more details about Modbus driver in REXYGEN see MbDrv - Driver for Modbus Communication.

    External RS-485 interface

    The external RS-485 bus can be fully configured by Monarco Driver Configuration dialog in REXYGEN Studio.

    1. Doubleclick MNR function block in your EXEC file:
      0_1551275768750_myproject_iocfg_monarco.png

    2. Click "Configure" and set RS-485 bus parameters:
      0_1551275849549_monarcodrv_dialog.png

    Default parameters are: 9600 Baud, no parity, 1 stop bit.

    For more details about MonarcoDrv see MonarcoDrv - Driver for Monarco HAT.
    For more details about Monarco HAT see Monarco HAT Knowledge Base.