Difference between revisions of "Template:Modbus RTU Relay Manual"

From Diustou Wiki
Line 23: Line 23:
 
; Run example
 
; Run example
 
Use the following commands to run the demo codes
 
Use the following commands to run the demo codes
 +
<pre>
 
wget https://{{SERVERNAME}}/en/w/upload/f/f9/Modbus_RTU_Relay_Code.zip
 
wget https://{{SERVERNAME}}/en/w/upload/f/f9/Modbus_RTU_Relay_Code.zip
 
unzip Modbus_RTU_Relay_Code.zip
 
unzip Modbus_RTU_Relay_Code.zip
 
cd Modbus_RTU_Relay_Code/Python3
 
cd Modbus_RTU_Relay_Code/Python3
 
sudo python3 main.py
 
sudo python3 main.py
 +
</pre>
  
 
===STM32===
 
===STM32===

Revision as of 18:10, 23 March 2021

Hardware testing

  • Connect USB to 485 moduble to Modbus RTU Relay board by wires. Connect A to A and B to B. Then connect the USB to 485 module to your PC
Modbus-RTU-Relay connet.jpg
  • Download the SSCOM software and Open it in your PC. Select the correct COM port (according to Devices Manager), set baud rate to 9600. Click Extension and send the commands to test
Modbus-RTU-Relay-2.png

If you want to send other commands, please check HEX option and choose ModbusCRC16 parity. Input the commands and send.

Modbus-RTU-Relay-3.png
For more details of the commands, please refero Protocol Manual of Modbus RTU Relay

Examples

Raspberry Pi

Enable Serial port
  • Open terminal of Raspberry Pi
  • Run the following command to configure
sudo raspi-config
  • Choose Interfacing Options -> Serial -> No -> Yes
  • Then reboot Raspberry Pi
sudo reboot
Hardware connection

You need to connect and RS485 devices to Raspberry Pi (the demo codes provided is based on our RS485 CAN HAT), Connect Modbus RTU Relay module to the RS485 CAN HAT, A to A and B to B.

Run example

Use the following commands to run the demo codes

wget https://{{SERVERNAME}}/en/w/upload/f/f9/Modbus_RTU_Relay_Code.zip
unzip Modbus_RTU_Relay_Code.zip
cd Modbus_RTU_Relay_Code/Python3
sudo python3 main.py

STM32

The Demo codes for STM32 is based on NULCEO-F103RB and RS485 CAN Shield module Download the #demo codes and open the STM32 project by Keil software. Program the codes to NUCLEO board The codes will run and toggle the relay in turn.

Arduino

The Arduino demo is based on Waveshare UNO Plus and RS485 CAN Shield Open Arduino project and program it to the UNO board.

The codes will run and toggle the relay in turn.