• Free ground shipping in the US • Order online • Same day shipping for products ordered by 2pm EST.

 

Using RS485 Protocol with GasLab Sensors

RS485 several gas sensors

by Ray Hicks, President, GasLab.com

At GasLab we regularly field questions about using the RS485 protocol. The questions are not about devices that have actual RS485 ports like our MX, EX, TX and package products which communicate over lines labeled A&B with Rx (receive) and Tx (transmit). These are ready to go with multi-protocols using RS485 and the industrial standard Modbus protocol (see www.Modbus.org).

Instead the questions are about sensors and devices that have serial UART (Rx/Tx) and I2C communications. The client may be inquiring for a number of reasons. For example,

  • They need to have long-distance communication - 100’s of feet.
  • They need to connect multiple sensors from multiple manufacturers.
  • For multiple connections they cannot use I2C as it is distance limited to about 1 meter.
  • They are in an electrically noisy environment, i.e. welding, motors starting and stopping, and other large electromagnetic sources.
  • They need to connect a sensor to an industrial control unit like a PLC or industrial automation device or integrate in to a process or processing machine.
  • Allows RS485 over MODBUS or CAT-5 (Ethernet) cable so they can use any existing wiring.

Or a combination of any or all.

For example, the SenseAir K series sensor are RS485 compatible. This means that while they support RS485 and Modbus protocol, they lack a RS485 transceiver. All of them can be operated via serial UART, RS485 or I2C with GasLab.

However, the GSS, SST, Cubic, and Luminox optical gas measurement sensors only use serial UART (Rx/Tx) with no direction control so they cannot support the RS485 or Modbus protocol. This is why we supply the MX, EC and TX boards for quick sensor integration of these unique sensors.

RS485 Communicaton

It is important to understand the difference between a device that “supports RS485” or “supports RS485 Modbus” and is “RS485 compatible”. Most of our sensors support RS485 Modbus or other protocols, but they are not RS485 compatible without the additions of a UART to RS485 transceiver.

The transceiver converts logic level 3.3 or 5.0 voltage Rx/Tx signals to the RS485 A/B current drive signals, “A positive to B” meaning 1 and “B positive to A” meaning 0. Think about like swapping a battery end for end on a voltmeter. This “current” driven principal is how an 4-20 milliampere analog signal can work over 100’s of feet.

RS485 is used only in a master slave relationship where our sensor is a slave to the control system as master. The master requests the concentration of the slave, the slave transmits the concentration.

This is called half duplex: a command is sent, the slave replies. There can only be communication in one direction at a time. What is actually happening is the slave is given a command - and heres the important part – is also given permission to send or reply or turn the line around.

This is where the RS485 transceiver comes in. It is normally in listen (or receiver) mode. When a sensor receives a command, it can reply in several ways including do nothing at all. When it does reply it activates the direction control to transmit for the reply and back to receive at the end of the message.  All sensors that support RS485 will have signals for RX, TX and R/T for direction control.

There is nothing complex here, no code to write, just wire it up and your senor can be 1000 feet away. The transceivers are cheap and available for under $10. Here is the popular Max485 for Raspberry Pi and Arduino on Amazon. The Max485 has lots of sample code on Github. Here is the Comidox model also on Amazon.

Desktop Testing

RS485 testing

To show you how simple this is, I wired up a K-30 CO2 sensor to communicate with GasLab via RS485 in a few minutes from stuff on my desk, zero software, in between some other projects. At one point, I’ve connected up to 25 different sensors on MX and EC boards using RS485. The trick is that the sensors are all shipped with the same default address. You need to set each sensor to a unique address on the eprom, then restart.

Finally, to have all the sensors talk to our free GasLab software, I use an RS485 to USB Converter Adapter with an FTDI chip like this. I always stick with the FTDI chip based option as the driver is in WIN10 so there are no additional drivers to load or update.


Older Post Newer Post