Modbus RS485 Troubleshooting Quick Reference
Modbus RS485 Troubleshooting Quick Reference
Troubleshooting Quick
Reference
Emile Ackbarali
Hi, I'm Emile Ackbarali. I am an Automation Engineer and ASP.NET Web Developer.
This guide is intended for Automation engineers and technicians who do the practical
implementation and troubleshooting of Modbus RS485 networks in the field. It is meant
to be a means for rapidly retrieving key pieces of data so that network issues can be
resolved in the fastest possible manner.
The information in here was derived from information I personally keep with me when I
Modbus RS485 Troubleshooting Quick Reference | 6/20/2015
1
Modbus RS485 Troubleshooting Quick
Reference
Emile Ackbarali
Table of Contents
2
Modbus RS485 Troubleshooting Quick
Reference
Emile Ackbarali
All devices that communicate via RS485 must obviously have an RS485 port. This port
may take the form of simple screw terminals or it may be implemented via a DB9 or
RJ45 connector. However it is built, in the majority of cases you will be looking for just
three pinouts. They are +, - and ground. Some devices will have the pinouts labeled as
A, B and ground. And you may, though not often, also see these same pinouts labeled
as Tx/Rx+, Tx/Rx- and ground.
The diagram below illustrates the typical way in which RS485 devices are connected
using a daisy chain method.
3
If you have connected your network in this way and you are getting no communication
or unreliable communication, here are the checks that you should do:
(1) Start at the very basic level and check to see that all of your connections have been
properly terminated and are tightly connected. As simple as it sounds, loose wire
connections can cause intermittent communication issues on a RS485 network, which
can be a task to troubleshoot.
(2) One of the devices may have a bad RS485 port. Try replacing the RS485 devices
one at a time with a known good device. If you're doing multi-drop RS485 then any one
device with a bad serial port can cause problems for all the other devices on that cable.
(3) Even though RS485 is very resistant to electrical noise, if the communications cable
is run too close to machines / equipment that generate significant electrical noise, then
this could cause an issue. If this is the case, the cables should be re-run so that it is not
as exposed.
(4) A ground loop. If more than one device on the RS485 cable connects the shield to
ground it can cause a ground loop. A ground loop can interfere with data by distorting
the RS485 signal. If the shield is grounded in the middle of the cable (because it's
4
more than two terminations in any system that does not use repeaters. Always
recalculate the bias resistors when you add termination to a system.
If all of your cabling is looking good, then the next thing to look at is the configuration of
the communication settings on all of the devices on the network. The communication
settings will essentially be the RS485 port settings on every device. Each setting will
consist of the following data parameters:
Baud rate, Start bits, Parity, Stop Bits.
These settings can have many different combinations, which is fine. What you have to
check and ensure is that the settings are exactly the same from device to device.
Mismatched port settings most times will result in no communication taking place on the
network. A master would send a query to a slave and the slave would simply not
respond.
Modbus RS485 Troubleshooting Quick Reference | 6/20/2015
Or even worse, the slave may respond! Let me explain this one. I have had instances of
a master sending a query to a slave and even though the slave had a different port
setting, it would send back a response with a Modbus error code. Due to the
mismatched port settings, the slave would interpret the data sent in some way and
"think" it was an erroneous Modbus query.
So the bottom line is to check to ensure all the devices on your network have the same
RS485 port settings.
5
Modbus RS485 Troubleshooting Quick
Reference
Emile Ackbarali
This chapter contains the key Modbus information that you will need to quickly refer to
in the field. I may refer to this information when I talk about troubleshooting steps in
Chapter 3 of this book.
6
Modbus RS485 Troubleshooting Quick Reference | 6/20/2015
7
(3) Modbus Typical Query-Response Cycle
The following diagrams illustrate the makeup of the data byte streams that make up a
typical Modbus Query-Response cycle.
8
(4) Modbus Exception Codes
01 - ILLEGAL FUNCTION: The function code received in the query is not an allowable
action for the slave. If a Poll Program Complete command was issued, this code
indicates that no program function preceded it.
02 - ILLEGAL DATA ADDRESS: The data address received in the query is not an
allowable address for the slave.
03 - ILLEGAL DATA VALUE: A value contained in the query data field is not an
allowable value for the slave.
04 - SLAVE DEVICE FAILURE: An unrecoverable error occurred while the slave was
attempting to perform the requested action.
05 - ACKNOWLEDGE: The slave has accepted the request and is processing it, but a
long duration of time will be required to do so. This response is returned to prevent a
timeout error from occurring in the master. The master can next issue a Poll Program
Complete message to determine if processing is completed.
06 - SLAVE DEVICE BUSY: The slave is engaged in processing a long–duration
Modbus RS485 Troubleshooting Quick Reference | 6/20/2015
program command. The master should retransmit the message later when the slave is
free.
07 - NEGATIVE ACKNOWLEDGE: The slave cannot perform the program function
received in the query. This code is returned for an unsuccessful programming request
using function code 13 or 14 decimal. The master should request diagnostic or error
information from the slave.
08 - MEMORY PARITY ERROR: The slave attempted to read extended memory, but
detected a parity error in the memory. The master can retry the request, but service
may be required on the slave device.
9
(5) Example of an Exception Code Query-Response
10
Modbus RS485 Troubleshooting Quick
Reference
Emile Ackbarali
In this chapter, I am assuming that you would have already made all of the checks to
the cabling and that you also ensured that the RS485 port settings were the same for all
of the devices. Hence I will be concentrating on troubleshooting techniques directly
related to Modbus protocol issues. Below are the methods that I use to implement new
and troubleshoot existing Modbus networks.
Let's assume that you encounter an existing Modbus RS485 network or you have just
Modbus RS485 Troubleshooting Quick Reference | 6/20/2015
set up one and no communication is taking place at all on the network. Here are the
checks you should make:
Every device on a Modbus network must have a unique Unit ID. If a network is
experiencing issues, the first thing to check is that the Unit ID on each device is set up
such that there are no duplicates. Even though you may have checked this already,
check it again. The Unit ID of some devices are set using dip switches, or a local
display. Some however require set up via connection to a computer with use of the
appropriate manufacturer's software.
11
(2) Modbus Master Configuration Check
You must remember that the Modbus master is responsible for orchestrating all of the
communication that occurs on the network. The Modbus master must therefore be
configured to know the following:
(i) The Unit ID of each slave on the network.
(ii) What registers to read from and write to for each respective slave.
This information is user configured, in most cases via the use of a computer and the
appropriate manufacturer's software.
You must ensure that the Modbus master has the correct list of slave Unit ID's on the
network as well as the correct register listing for each respective slave.
In order to execute this method, you need to have a computer (preferably a laptop) and
a usb-to-RS485 converter connected to it. Then you need to run a Modbus master
The idea here is to remove the Modbus master device and then connect the usb-to-
RS485 converter to the network and then use the laptop as the Modbus master to try to
communicate with each slave on the network. If you are able to communicate
effectively, then you would know that the problem exists in the original Modbus master
device that you would have disconnected. At that point you can re-look at the original
Modbus master configuration.
If it is the Modscan32 software can't communicate with any of the slave devices on the
network, then what you should do is to disconnect all of the slave devices and then re-
connect them one at a time and try to communicate with each individually, in the event
that one of the slave devices may be causing a problem on the network.
In the event that you are getting communication to the slaves but no data, you should
check the Response data streams to see if there are exception responses coming back.
If there are, you can then look at the exception codes being returned.
12
(4) Modbus Slave Substitution
Typically I would use this method when I am dealing with a new piece of equipment that
is to act as a Modbus master. I use this method to verify that the configuration method
indicated in the user manual for the Modbus master is accurate.
So here you would use your laptop and usb-to-RS485 converter as well. The idea here
is to run a Modbus slave simulator application on the laptop so that it acts as a Modbus
slave. There are several applications you can run but I prefer to use Modsim32 from
win-tech.
So the Modbus master is connected to the RS485 converter and therefore to the laptop.
The Modsim32 application is then run and a simulated slave is created within it. The
Modbus master device will then be configured to read data from the simulated slave.
The data values in Modsim32 can then be changed and the Modbus master checked to
see if it is reading the data values properly.
So using Modscan32 and Modsim32, you can controlled test situations that allow for
effective troubleshooting of the network.
Modbus RS485 Troubleshooting Quick Reference | 6/20/2015
13
Modbus RS485 Troubleshooting Quick
Reference
Emile Ackbarali
Summary
The information and techniques that I have put down in this guide are the very same
that I use when I am out in the field implementing and troubleshooting Modbus RS485
networks. I have tried to put down the techniques in the order in which I use them so as
to solve issues in the least possible time.
If you have any questions / comments based on what I have written here, I would be
happy to hear them. Please contact me on [email protected].
14
Modbus RS485 Troubleshooting Quick
Reference
Emile Ackbarali
Resources
The usb-to-RS485 converter that I use is called the " Baitaihem USB to RS485 USB-485
DB9 Serial Port COM". I bought it on www.amazon.com for just under $20.00 inclusive
of shipping. I have used it for quite a while now with no complaints. You can simply type
in the name in Amazon and you will find it.
Modbus RS485 Troubleshooting Quick Reference | 6/20/2015
15