RS485 Bricklet

Features

  • Supports low-level RS485 as well as Modbus RTU master/slave
  • Modbus RTU implementation is fully compliant for reading and writing of coils and registers
  • Supports full- and half-duplex
  • Configurable baudrate, parity, stop bits and word length
  • Switchable 120 Ohm termination

Description

The RS485 Bricklet can be used to extend the features of Bricks by the capability to send and receive differential data with RS-485.

It supports full- and half-duplex and has configurable termination.

You can use the Bricklet in RS485, Modbus RTU master and Modbus RTU slave mode.

In RS485 mode you can send and receive arbitrary data. The Modbus modes are fully Modbus compliant. In Modbus RTU master mode you can write and read any coils/registers from a slave. In Modbus RTU slave mode you can provide data for coil/register reads and you receive the data that a Modbus master writes to the coils/registers.

The RS485 Bricklet has a 7 pole Bricklet connector and is connected to a Brick with a 7p-10p Bricklet cable.

Technical Specifications

Property Value
Current Consumption 64mW (12.8mA at 5V, idle)
   
Baudrate 100 - 2000000 baud
Parity none / odd / even
Stop bits 1 / 2
Word length 5 / 6 / 7 / 8
Duplex half / full
   
Dimensions (W x D x H) 40 x 40 x 14mm (1.57 x 1.57 x 0.55")
Weight 13g

Resources

Connectivity

In full-duplex mode you have to connect TX+, TX-, RX+, RX- and GND.

In half-duplex mode TX+ / RX+ and TX- / RX- are shorted, so you can connect either TX+ / TX- / GND or RX+ / RX- / GND. You can also use this to chain-connect other devices.

RS485 Bricklet connection possibilities

Duplex and Termination configuration

The DIP switch on the Bricklet can be used to configure duplex and termination configuration.

You can configure between Full-Duplex and Half-Duplex and you can enable or disable a 120 Ohm termination resistor.

RS485 Bricklet DIP settings

A legend of the different configuration possibilities can also be found in the bottom of the Bricklet.

Modbus RTU Functions

The Bricklet can be configured to operate on Modbus RTU master/slave mode. In this mode Modbus specific protocol messages can be sent and received. A Modbus master can send a request to a Modbus slave connected to the bus. These Modbus functions are based on callbacks.

To better understand the general concept a scenario is described. In this scenario two RS485 Bricklets are present on the bus. One operating in Modbus master mode and the other in Modbus slave mode:

  1. The Modbus master wants to read 4 registers starting from address 2 from Modbus slave at address 8.
  2. The master registers the modbus_master_read_holding_registers_response callback which will be called when the slave sends a response to the master. The Bricklet that is operating in slave mode registers the modbus_slave_read_holding_registers_request callback which will be called when a corresponding request is received.
  3. The master calls the function modbus_master_read_holding_registers. Parameters of this function specifies the slave address, starting address and the number of registers to read. This function sends the request on the bus.
  4. On the slave side the registered callback is invoked with the parameters which specifies that the master wants to read 4 registers starting from address 2.
  5. The slave calls the function modbus_slave_answer_read_holding_registers_request with the requested data which sends the response on the bus.
  6. Upon receiving the response from the slave the modbus_master_read_holding_registers_response callback is called on the master side with the data provided by the slave.

For details of these functions refer to the programming interface section.

All of the available Modbus functions can also be used in Brick Viewer:

RS485 Bricklet in Brick Viewer

Test your RS485 Bricklet

To test a RS485 Bricklet you need to have Brick Daemon and Brick Viewer installed. Brick Daemon acts as a proxy between the USB interface of the Bricks and the API bindings. Brick Viewer connects to Brick Daemon. It helps to figure out basic information about the connected Bricks and Bricklets and allows to test them.

Connect the RS485 Bricklet to a Brick with a Bricklet Cable. Connect the RX to the TX pins with a cable to make the Bricklet read back its own output.

If you connect the Brick to the PC over USB, you should see a new tab named "RS485 Bricklet" in the Brick Viewer after a moment. Select this tab. If everything went as expected you can now type some text into the input editbox and hit enter. The same text should then show up in the textarea above.

RS485 Bricklet in Brick Viewer

After this test you can go on with writing your own application. See the Programming Interface section for the API of the RS485 Bricklet and examples in different programming languages.

Case

A laser-cut case for the RS485 Bricklet is available.

Case for RS485 Bricklet

The assembly is easiest if you follow the following steps:

  • Screw spacers to the Bricklet,
  • screw bottom plate to bottom spacers,
  • build up side plates,
  • plug side plates into bottom plate and
  • screw top plate to top spacers.

Below you can see an exploded assembly drawing of the RS485 Bricklet case:

Exploded assembly drawing for RS485 Bricklet

Hint: There is a protective film on both sides of the plates, you have to remove it before assembly.

Programming Interface

See Programming Interface for a detailed description.

Language API Examples Installation
C/C++ API Examples Installation
C# API Examples Installation
Delphi/Lazarus API Examples Installation
Java API Examples Installation
JavaScript API Examples Installation
LabVIEW API Examples Installation
Mathematica API Examples Installation
MATLAB/Octave API Examples Installation
Perl API Examples Installation
PHP API Examples Installation
Python API Examples Installation
Ruby API Examples Installation
Shell API Examples Installation
Visual Basic .NET API Examples Installation
TCP/IP API    
Modbus API