🎄 Please Note: CO2Meter offices will be closed for the upcoming Holiday, 12/23-12/25, we will return refreshed and ready to serve you at 8:30AM ET on 12/26. We wish those celebrating a very Merry Christmas and a Happy New Year! 🎄

 

Using RS485 Protocol with Gas Sensors

Multiple sensors using RS485 protocol

At CO2Meter 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 we often receive are about sensors and devices that have standard serial UART (Rx/Tx) or I2C communications protocols on the spec sheet. Can they also support Modbus? The client may be asking 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.
  • They want to run over CAT-5 (Ethernet) cable so they can use existing wiring.

Or a combination of the above.

For example, the SenseAir K series sensors 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 offer these sensors on MX, EC and TX boards. It allows them to talk via RS485 Modbus.

RS485 Modbus Standards

It is important to understand the difference between a device that says it “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 addition 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 it 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 here's 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 or 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 sensor can be 1,000 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

CO2 Sensor using RS485

To show you how simple this is, I wired up a K-30 CO2 sensor to communicate with our free GasLab software 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 the 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.

RS485 Example Video

To show you how easy it is to connect our gas sensors using MX, TX or EC boards using RS485 I've created this video. It walks you through the entire process of talking to multiple sensors using our GasLab software

Video:

Connecting Gas Sensors using RS-485 Video

Parts used in the video:


Publicación más antigua Publicación más reciente