No announcement yet.

Connect Homeseer to a BMS Control via Modbus

  • Filter
  • Time
  • Show
Clear All
new posts

    Connect Homeseer to a BMS Control via Modbus

    Hi all this is my first Homeseer entry so be gentle...

    I am a BMS Technician trying to interface Homeseer via Modbus with the brand of controls that we mostly use at work.
    These are the Mach-Pro series from Reliable Controls Canada which I don't suppose many of you will ever see but the setup process would be common to most Modbus devices. The MP controls can easily be set as either Master (Client) or Slave (Server) on either Modbus RTU or Modbus TCP). At first I had issues getting it to work but after a while I began to get the hang of it and thought I'd share.

    It's best to test connectivity between the Homeseer hardware box and the Modbus Slave device before running the application (Homeseer).
    I first made an RS485 serial connection with a good quality but standard USB-RS485 interface (Aztronics Aust S9721). It shows up in Windows Device manager as an FTDI serial port. I prefer the type that has a 2 wire RS485 screwed connection as you can only get it wrong once when wiring it. Different manufactures use A or B interchangeably for +ve so you need to trial and error it (should also be able to measure approx 5V with a multimeter). Network wiring and termination is very important when finally installed but if the two devices are side by side any 2 core flex will work at 19200 and for the moment.

    To test, open a Modbus scanner (I use a small, simple and ancient program called OmniScan but its a little hard to find now).
    Set the Comms port (look in device manager and remember to always plug the interface into the same USB socket), set the comms speed and protocol to match your Slave device or vice versa (19200/No Parity/8 Bits/ 1 Stop is pretty standard and bulletproof), set the Modbus ID of the Slave, select Number of Values (to return) =1, enter the Register Type (most devices use some Holding Registers), Data Type (these vary a lot and you will need to know what to expect from your Slave Device Register List) and enter a Register Location.
    You should get a reply. If you get a timeout or connection fail try swapping the two wires. An error generally means you've asked for a data type or register location that doesnt exist or isn't valid.

    I then repeated the process using the Modbus/TCP option which is nearly identical. The Slave Modbus address may not matter (use 1) because the Slave IP address is unique and the Modbus Port (nearly always 502) does. The beauty of this option is that you don't need any extra cabling - data is transferred in Modbus/Ethernet packets over the network you already have.

    There are two types of register addressing that can be alternatively labelled Modicon, Register or Logical Addressing but essentially some call the starting Register 0 and some call it 1. Its difficult to work out what you have - remember you also have choices both in the Modbus Scanning program you are testing with and the Homeseer Plug-In but whatever you have it will be consistent for the Slave device once you've worked the pattern out. The best way is to find a register that you know or can set and look for it. On a Genset this is always battery voltage and on an A/C it is Setpoint, Ambient Temp or Room Temp. If a query doesn't return correctly try one register lower then one higher.

    Note that with most common scanner programs they wont fall over if you make a mistake. It is entirely practical to set the Data Type and Size, start at Register 0 and just punch in incremental numbers until you find values that make sense, don't return Errors or you start to see the pattern.

    With 16 bit registers you can poll every one (ie 0, 1, 2, 3, 4). With 32 bit registers you can only poll every 2nd one (ie 1, 3, 5, 7) and with 64 bit registers only every 4th is valid (ie 1, 5, 9, 13). Requesting data from one of the intervening registers will almost always generate a fault. Many devices have a mixture of different size Registers ie accumulated power can be a huge number and may be in a 64 bit register while voltage is a small number and may be in 16 bit. Whatever size registers. the addressing system will always be consistent once discovered.

    Further Notes
    Some register lists use Word for 16 bit, DWord for 32 bit and QuadWord for 64 bit data.
    Holding registers start at 40000 but if it is in the range 40000 - 50000 it is always a holding register and you just drop the 4 so 40001 becomes 1. The other Register types are the same.
    You also need to know if its signed (meaning the highest bit may be a minus sign). SInt16 or Int16S IS signed - if no "S" assume that it is not.
    Modbus doesnt support fractions or decimal points. If expected numbers are small they will be multiplied in the Slave device register to produce integers (ie 2.10 Deg may be stored as 210) and you need to include the multiplier (0.1 / 0.01/0.001) etc to get the correct value back.

    There is another Modbus type called ModbusRTU/IP or Modbus/IP. This is what you end up with when a serial to Ethernet converter is added to network a standalone Serial Modbus device. The packets are different (the checksums are within the packet rather than at the end of it) and the two are not interchangeable.

    Once I had checked that the hardware worked, I loaded Homeseer and created a new Modbus device from the Plug-Ins/Modbus/Modbus Config menu location. The label IP-RTU Master is a bit misleading for Modbus TCP but it seems to work. The setup is pretty straightforward - unless you have an extreme number of slave devices or points Modbus should easily be able to update at 10 Sec intervals. The Modbus Gateway or IP Address is the Slave address - I guess you need a new Homeseer device for each Slave.
    The MP controllers I am using do not support Modbus Write Single Register (Function Code 6) but only Write Multiple Registers (Function Code 16 ) so I needed to uncheck this option to be able to write at all.

    Select Add Device. On the Config Tab give it a name.

    On the Status Tab you need to add a new Range Value (for analogue points) and set to Status (for Read) or Control (for Write) values. I'm not sure of the wisdom off trying to both Read and Write from the same Register at the same time - possibly its better to setup separate Read and Write Devices for the same Slave Register. Prefix and Suffix let you add a point label and Units. Homeseer often automatically throws an extra set of Range Values in this page when setting it up - just delete the extra one. You must set expected Lower and Higher Values in the Value boxes, exceeding these values will throw a Modbus Error and stop Homeseer updating (-65438 / 65438 should be OK).

    The Modbus Tab allows you to set the Gateway, Register Type (usually Holding Register - the output will be converted to "Write Single" or "Write Multiple" Addresses automatically when writing. Slave ID may be irrelevant, the Register you will read from the Device Register List or Fine Tune the hard way. Return Type refers to the Register Size and Data Type and whether it is signed should come from the Device Register List. Toggle Read Only Device "On" for Read Registers and "Off" for Write Registers.

    Issues. Return Type Int32 and Float32 appear to be swapped.
    Multiplier appears to be only applicable to incoming values - written values are unchanged and need to be pre-calculated.

    Current Date/Time: 22/12/2017 5:39:44 PM HomeSeer Version: HS3 Pro Edition Operating System: Microsoft Windows 10 Home - Work Station System Uptime: 0 Days 0 Hours 23 Minutes 59 Seconds IP Address: Number of Devices: 55 Number of Events: 2 Available Threads: 400 Enabled Plug-Ins 3.9.6431.26038: Modbus weatherXML Z-Wave

    Oops - Amendment

    Return Type Int32 and Float32 appear to be swapped WHEN WRITING


      Thanks, I seem to have a few bugs in the conversion and the big-endian calculations, will have a fix out in 1st week of Jan.
      Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin