advertisement
from the IT department...
Error while reading from EM6436 energy meter.
Computers in manufacturing; also hardware discussion. topic
Posted by nikhil jain on 19 July, 2012 - 5:59 am
We are using EM6436 energy meter connected to a PC via RS232 to RS485 converter.

With my own code using modbus4j open source library,we are able to discover the Energy meter and obtain its ID using Modbus4j.
But when I try to read data address (3901 say) of the device(EM6436) using the following code:

SerialParameters params = new SerialParameters();
params.setCommPortId("COM1");
params.setBaudRate(9600);
params.setDataBits(SerialPort.DATABITS_8);
params.setParity(SerialPort.PARITY_EVEN);
params.setStopBits(SerialPort.STOPBITS_1);
ModbusMaster master = null;
ModbusFactory factory = null;
try
{
factory = new ModbusFactory();
master=factory.createRtuMaster(params, 0);
if (master == null){
return;
}
master.setTimeout(5000);
master.init();
Object obj = null;
NumericLocator locator = null;
try{
locator = new NumericLocator(1,
RegisterRange.HOLDING_REGISTER, 3901, DataType.FOUR_BYTE_FLOAT);
obj = master.getValue(locator);

}catch (Exception e) {
System.out.println("Exception occured : "+e.getMessage());
}

System.out.println("Value read"+"for------"+i+"----------->"+obj);

}
}
finally {
master.destroy();
}
}

We are getting error as Error Response Exception :Invalid data address or sometimes its giving TimeOut exception.
The same code is working fine with the simulators (Modbus PAL , Modbus PLC).

Even reading the same data address with ModScan32 (with the same connection) is also working but not with the above code. Please suggest.

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2013 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.


Fortune
Boys are beyond the range of anybody's sure understanding, at least
when they are between the ages of 18 months and 90 years.
-- James Thurber
Advertise here
Advertisement
our advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive