shopify site analytics

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quick Start Guide to connecting to a Modbus device
It is not the intention of this guide to like many available on the internet to explain the technicalities of how Modbus works, with endless technical information & hex tables but to provide instructions and examples of how to set up Modbus slave and read data that you can use!

In this basic example our slave will be an electricity meter, probably one of the most common Modbus devices when it comes to integration with BMS systems. It could also be the Modbus interface on a chiller packaged unit, down flow unit or other device that might require interfacing with an energy management system. Our master device will be a laptop but could just as easily be the BMS head end, or BMS outstation.

This is the slave for this example, an Eastron SDM120 the cheapest electricity meter with a Modbus interface I could find on ebay. A wide range of modbus meters can also be found in this section on amazon here

[Image: meter_test.jpg]

To connect this meter to the laptop we need to use an interface, for this example using a USB to RS485 serial converter cable made by FTDI, however there are numerous similar devices available from the likes of Amazon here

[Image: USB_RS485_cable.jpg]

First step is to install any drivers that came with the USB to RS485 interface

Then go to look up the datasheet of both the USB to RS485 cable and the electric meter to determine how to connect the interface between them.
[Image: connection_details.jpg]

[Image: meter_connection.jpg]

We want to connect the "+A" cable from the converter to the "+A" on the meter and then do the same for "-B". So I will connect the orange cable to terminal 10 and the yellow cable to terminal 9.

The next piece of information you will require is the Modbus register or table for the slave which lists the devices communication parameters such as baud rate, stop bits and parity. It should also list the addresses at which the values of the meter can be read out. If the data sheets didn’t come with the device they can usually be found on the internet or by speaking to the manufacture.

[Image: Eastron_SDM120Modbus_com_settings.jpg]

[Image: Eastron_SDM120Modbus_register.jpg]
Some meters are factory set with the default slave address, baud rate, stop bits and parity. Some of this may be none adjustable, adjustable via buttons on the meter or adjustable via the Modbus interface itself. The data sheet for this meter listed what the default communications parameters are and also explains how some of them can be altered.

So now we have all the information we need first step is to plug in the USB - RS485 interface in and get it setup with the laptop.
On a windows 7 PC go to Control Panel > System > Device Manager

[Image: Device_Manager.jpg]

Here we can see that the USB adapter has assigned its self to COM port 1.

Depending on what other applications you have running this may auto assign to another COM port and you may need to manually change this in a minute, as the Modbus interrogation tools we are about to use will use will only work on COM 1-4.

The first program I am going to show is Modbus tester is a free Modbus interrogation tool available from [url=]
This site appears to be down at the time of writing but can also be downloaded from software informer here
Once installed open and browse to the “Modbus settings” tab. Here we need to configure the program for communication with the meter. For me the USB to RS485 adaptor is installed as COM1 this may be different depending on your PC.

[Image: Modbus_Tester_setup.jpg]

Bellow that the baud rate, stop bits and parity is information that can be found on the meter datasheet, as seen bellow, On this meter there is the facility to alter these settings by writing to certain points. You will find some Modbus devices these settings maybe altered through dip switches or selected through an LCD screen. Some may be factory set by the manufacturer not have the functionality to change these at all.

Next over to the “view data” tab and decide what information to browse from the meter, for this example I chose that I wanted to read the voltage from the meter. Populate the fields here with the data gleamed from the data sheet.

First input the slave address of the meter, the documentation tells us the default address is 1. It also tells us the data is stored on an input register. So we want to change the Modbus Tester setting for this too, from the drop down box.

The address for the voltage is 30001. we ignore the 3 because this was signifying that it is an input register. So we are left with address 0001 so put this as the start address.

The length setting is for the number of address we want to read out after 0001. By default this is 100. Some devices may not respond well to having more than 1 address read out and Modbus Tester may come up with time out errors. So I have shortened this to 10. From experience with other devices I know that this may even need to be shorter, but for this example 10 works fine.

[Image: Modbus_Tester_connecting_up.jpg]

Now click connect, the read status should show as OK, the No. of polls & No. of responses counters should both be counting, showing successful communication. If you are using the same RS485 adapter as me both the red (polling) and the green (response) LEDs should be flashing rapidly.

This is what we now have, but the reading I am getting back for my chosen value is obviously not correct. I wanted to look up volts but the data I am getting back says “-1.595047....” I know this is not the correct voltage, i should be getting a figure around 230-240.

[Image: Modbus_Tester_wrong_float.jpg]

As Modbus data has varying ways of being interpreted we need to look at other ways of viewing this point. The datasheet informs me it is a “float” and that’s what I’ve set Modbus tester to read. But if I change this to a Swapped floating point. I can read out the correct value as seen bellow. Understanding why I did this and more in depth Modbus information in later posts.

[Image: Modbus_Tester_voltage_float.jpg]

I can now move on and look at other values that I might want to read off an electrical meter such as KWH, Amps, Watts & Hz.

Keeping all other settings the same in Modbus tester, just altering the start address field to that found on the datasheet. So for example for Amps change the start address to 7 or for  Hz change to 71. as shown bellow.

[Image: Modbus_Tester_frequency.jpg]

The basis of this article was to provide enough basic information to enable read out data from a Modbus slave. 

If you think i have missed anything out let me know! Smile


Forum Jump:

Users browsing this thread: 1 Guest(s)