Modbus RTU with the Monarco HAT on Raspberry Pi
cechurat last edited by cechurat
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 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:
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.
Doubleclick MNR function block in your EXEC file:
Click "Configure" and set RS-485 bus parameters:
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.