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.

Internal structure of the RS-485 interface of the Monarco HAT on Raspberry Pi

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. It is up to the user to configure UART port (/dev/ttyAMA0) of the Raspberry Pi to use these settings.

The following prerequisites must be met for the UART communication to work properly:

  1. Linux terminal must be disabled on /dev/ttyAMA0. Remove "console=serial0,115200" from the file /boot/cmdline.txt:
    sudo sed 's/console=serial0,[0-9]+//' -i /boot/cmdline.txt
  2. If you have Monarco HAT series E and older (shipped before 10/2017), it is necessary to update the ID EEPROM of your Monarco HAT.

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).

External RS-485 interface

The external RS-485 bus can be fully configured by service registers 0x010 and 0x011 of the Monarco HAT.

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

If you wish to change these settings, you will typically do it in the initialization phase of your program/script.

Please see the Monarco HAT SPI Protocol Reference Manual for details.