Hello everyone,
I have a problem with a project, and I cannot work it out. I want read out data of a Power Meter via modbus communication line (serial), but the received data is incorrect. Therefore I need help.
My system consists of the following:
- Arduino Mega 2560 v3 (new)
- Multifunctional Power Meter: Hobut M850 MP1 (Power Meters - Hobut Ltd.)
(with modbus module) - RS484 chip: Maxim MX485
- LCD shield for arduino
(to show measurement data of the power meter, for test purposes) - DC power supply 12V for arduino, 5V for Maxim MX485
- Notebook with newest version of Mpide and Modbus Master library (Arduino Playground - ModbusMaster Library)
The MX485 chip is connected between the arduino and power meter, see figure below. TX (arduino pin 0) connected to driver input MX485, RX (arduino pin 1) connected to receiver output MX485. The outputs A and B of MX485 are connected to A and B of the power meter, respectively. In order to switch the modus of the MX485 chip in driver/receiver, arduino pin D3 is used and controlled by software. During programming of the arduino, the pin TX and TX are disconnected from the MX485. After programming, the USB is disconnected and the power supply is turned on. From that moment, the LCD shield will display measurement values of the power meter.

This project is inspired by existing project, where some adjustment in the library was needed. See rs485 - Arduino as Modbus client with MAX485 doesn't get any response - Electrical Engineering Stack Exchange. Pin D3 is actually hardware coded in the library, in order to switch on the right time between driver/receiver modus of the MX485 chip. I did the same than described on that site.
A test program that I have used, to read out a single register of the power meter, is shown below:
#include <ModbusMaster.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
ModbusMaster node(1);
void setup() {
pinMode(3, OUTPUT);
digitalWrite(3, LOW);
node.begin(9600);
lcd.begin(16, 2);
}
void loop() {
uint16_t m_startAddress=0x07D6;
uint8_t m_length=2;
uint8_t result;
lcd.clear();
result = node.readHoldingRegisters(m_startAddress, m_length);
//result = node.readInputRegisters(m_startAddress, m_length);
if (result == node.ku8MBSuccess) {
lcd.print("DATA: ");
for (uint8_t j = 0; j < m_length; j++)
{
lcd.print(node.getResponseBuffer(j), HEX);
}
}
else {
lcd.print("ERR ");
lcd.print(result, HEX);
}
delay(1000);
}
The registers of the power meter are described in the manual (appendix) (see http://www.hobut.co.uk/images/M850%20Comprehensive%20User%20Manual_03%202011a.pdf). The problem is in fact that if I read out registers of the power meter, the received (HEX) data is either 00 (2 times zero) or FFFF FFFF (8 times F), depending of the register address. This last (8 times F) means that the requested register is not applicable, but I used the same registers as described in the manual. It is not a modbus error what is shown, because the request is successful (result=success). If I disconnect a cable (or switch connections A and B) an error E2 is shown in the display (timeout error). Thus it seems to be not a hardware problem.
The measurement data of the power meter can be read out from two different registers, namely:
- Input registers with address 3X (by power meter) and modbus function code 04
- Holding register with addres 4X (by power meter) and modbus function code 03
See the functions readInputRegisters and readHoldingRegisters in the arduino software. I have tried both functions, but without successful measurement data. A brief overview of the results is shown below:
[Register name] [register] [received data]
With function ReadInputRegister (function 04):
- Voltage V1, 0x0006, FFFF FFFF
- Voltage V2, 0x0008, FFFF FFFF
- Voltage V3, 0x000A, 00
- Frequency, 0x001E, 00
With function ReadHoldingRegister (function 03): - Voltage V1, 0x07D6, FFFF FFFF
- Voltage V2, 0x07D8, FFFF FFFF
- Voltage V3, 0x07DA, 00
- Frequency, 0x07EE, 00
The Hobut power meter is new, and works stand-alone perfectly. It measures 3 phase voltages correctly, and can also measure current, power and energy by using current transformers. For testing purposes, the current measurement (and thus the transformers) are omitted. During testing, the 3 voltage inputs of the power meter are connected to 240 Vac. The power meter shows fluctuating values around 240 Vac, but the received data with the arduino seems not to be fluctuating voltage values. What is the cause of this?? I have tried a lot for days, but I cannot come to a solution. Is it probably a modbus library error? Please help me??