- An expansion shield to expand 1-way RS485 interface for LattePanda V1.0.
- Employ MORNSUN serial-to-RS485 module and Power module to ensure the signal isolation and Power isolation
- Industrial Connector(4pin: 12V, GND, 485A, 485B), easy to connect various RS485 devices.
- 12V output, max output current is about 150mA, can be used to test small-load RS485 device.
- ENIG, delicate appearance and quality PCB. Durable 2.0mm Pin header.
- Onboard 120Ω terminal matching resistance, can be controlled by a switch
- Free Copper columns for connecting your shield and LatttePanda.
- Operating Voltage: +5V
- EIA/TIA-232-F Standard Compliant
- Max Baud Rate: 115200 bps (LattePanda V1.0 TTL signal can only be adjusted to 115200 bps)
- Max 12V Power Output(Output current is small than 150mA)
- Isolated Voltage: 2500 VDC
- 1/8 Unit Load, Bus load up to 256 nodes
- Bus fault protection and Bus driver short-circuit protection
- Operating Temperature:-40℃ to +105℃
- ⚠ Note: Not Sopport Hot Plugging
The RS485 interface can be easily used in the Windows environment. (Compatible with Linux environment)
For LattePanda V1 Pin Definition, please refer to the Official WiKi.
RS485 Communication Protocol
RS485 communication is one of the typical serial communication standards.
RS485 interface is widely used in industry because of its good noise immunity, long transmission distance, multi-station capability and simple wiring.
RS485 communication protocol only defines the voltage, impedance and other electrical characteristics of transmission, but does not define the software protocol. The data signal adopts differential transmission mode, so it has the ability to suppress common mode interference. The bus transceiver has high sensitivity and can detect voltage as low as 200mV. RS-485 is very convenient for multi-point interconnection and can save many signal wires. It uses a pair of twisted pairs, one of which is defined as A and the other as B. Generally, the positive level between A and B is + 2 ~ + 6V, which is in the logic 1 state, and the negative level is - 2V ~ 6V, which is in the logic 0 state. The maximum transmission distance is about 1200 meters, and the transmission rate is inversely proportional to the transmission distance. Only in a very short distance can the highest transmission rate be obtained. RS485 needs two terminal resistors whose resistance value should be equal to the characteristic impedance of the transmission cable (generally 120Ω). In short distance transmission, there is no need for terminal resistance. Terminal resistors should be connected at both ends of the transmission bus.
ModBus Communication Protocol
Modbus protocol is a master/slave architecture protocol. It has one master node and the other nodes using Modbus protocol are slave nodes, each with a unique address. A MODBUS command contains the Modbus address of the device to be executed. All devices will receive commands, but only the device at the specified location will execute and respond to the commands (except for address 0, which is a broadcast command. All devices that receive the commands will run, but will not respond to the commands). All MODBUS commands include check code to make sure that the arrived command is not damaged. The basic MODBUS command can instruct an RTU to change a value of its register, control or read an I/O port, and ask the device to send back one or more data in its registers.
There are many variants of Modbus protocols:
- Modbus RTU — This is used in serial communication and makes use of a compact, binary representation of the data for protocol communication. The RTU format follows the commands/data with a cyclic redundancy check checksum as an error check mechanism to ensure the reliability of data. Modbus RTU is the most common implementation available for Modbus. A Modbus RTU message must be transmitted continuously without inter-character hesitations. Modbus messages are framed (separated) by idle (silent) periods.
- Modbus ASCII — This is used in serial communication and makes use of ASCII characters for protocol communication. The ASCII format uses a longitudinal redundancy check checksum. Modbus ASCII messages are framed by leading colon (":") and trailing newline (CR/LF).
- Modbus TCP/IP or Modbus TCP — This is a Modbus variant used for communications over TCP/IP networks, connecting over port 502. It does not require a checksum calculation, as lower layers already provide checksum protection.
This tutorial will demonstrate how to use LattePanda to control the DFR0290 8 Channel IoT Ethernet Relay Controller by RS485 shield.
Connect the Shield and LattePanda V1
Use the Copper Columns and screws to fix the shield on LattePanda Board.
1. Using Upper-computer Software
- Connect the LattePanda with RS485 connector shield, turn it on.
- Power on the 8 Channel IoT Ethernet Relay Controller.
- Open the DFRobot Upper-computer software on LattePanda, select COM1, and set baud rate to 115200.
- The relay module can be controlled by the uppper-computer software.
2. Using Serial Debugger
- Repeat the steps above.
- Use the serial debugger to send the related commands to control the relay module according to the user-defined communication principle of the 8 channel relay controller.
Turn on/off the relay No.1, shown as below.
3. Using Python ModBus Library
The following are the popular ModBus thrid-party Python libraries at present.
|Name||Source Code||Third-party Dependencies||Main Function|
|modbus_tk||https://github.com/ljean/modbus-tk||Pyserial||Support modbus TCP and RTU, both master and slave. Not support modbus ASCII. Heavyweight|
|pymodbus||https://github.com/riptideio/pymodbus/||Pyserial||Support modbus TCP/RTU/ASCII, master and slave. Heavyweight|
|minimalmodbus||https://github.com/pyhys/minimalmodbus||Pyserial||Only support Modbus RTU and ASCII, and only work in master(clinet). Very lightweight|
|uModbus||https://github.com/AdvancedClimateSystems/uModbus/||Pyserial||Support both Modbus client amd server (both TCP and RTU). Not support Modbus ASCII. Lightweight|
Here we will take modbus_tk as an example.
- Repeat the steps above.
- Install Python and modbus_tk and other dependency packages on LattePanda.
- Write Python codes to control the relay modudle according to the ModBus protocol principle of the 8 channel relay controller.
Run Python script to get device name and control device to turn on/off all relays in order, shown as below:
Click to download the Python3 Script Sample.
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.
Get RS485 Connector Expansion Shield For LattePanda V1.0 from DFRobot Store or DFRobot Distributor.
Turn to the Top