Open GoogleCodeExporter opened 8 years ago
In order for the Illegal data address to be set by the slave the starting
address must be equal or larger than the holding register array size. You have
a constant of 40 which means the slave will occupy 40 unsigned int registers.
From your code snippet it seems you are requesting 27 registers starting from
address 0. This is normal and should work perfectly (as you mentioned). The
arduino core keeps changing, they have changed the hardwareSerial core library
ring buffer size from 128 bytes to 64 bytes which means you can only request 29
unsigned int registers, but you are requesting only 27 which is ok. I can only
see that the Illegal data address error code is generated because of a buffer
overrun and/or garbled data in the frame buffer array. As mentioned the
starting address has to be equal or larger for the error code 2 to be set. This
means the third and/or fourth byte of the frame contains erroneous data bigger
or equal to 40.
Just to verify:
Does your slave go offline permanently?
What is the retry value of your master?
How does your RS485 driver circuit look like? Pull ups, pull downs, Rx tied
high.
Send me your slave example sketch..
Original comment by bester.j...@gmail.com
on 8 Jan 2014 at 7:30
The request is 27 in HEX which then corresponds to 39 DEC think could be the
problem now if the buffersize is 64 corresponding to 29 unsigned int.
I use Arduino IDE 1.0.5 is confident that the buffersize is 64? Can I verify
this ?
Answering questions:
1 Yes the slave go off permanently until I perform a soft reset. Answers always
<01> <83> ...
2 The return value is always <01> <83>
3 I have the pull ups and pull dows rx is pulled up
Original comment by max.bene...@gmail.com
on 8 Jan 2014 at 8:52
There will definitely be a buffer overrun in the HardwareSerial core library.
They changed the core lib in version 1.05. This is easy to change by altering
the define constant 64 to "SERIAL_BUFFER_SIZE 128" on line 59 in the
HardwareSerial.cpp file. Located at C:\Documents and Settings\USER\My
Documents\arduino-1.0.5\hardware\arduino\cores\arduino\HardwareSerial.cpp
Original comment by bester.j...@gmail.com
on 10 Jan 2014 at 7:49
Ok Thanks.
Original comment by max.bene...@gmail.com
on 10 Jan 2014 at 10:47
Hello GoogleCodeExporter,
I am stuck with reading data from my energy meter for about a month. I have tried many things/programs. But still cannot read data till now. I seek your help. Please reply and I will share details with you. Thank you.
By the way, I am using Arduino mega 2650. and trying to read ELmeasure meter. From Modbus tester software I am getting results successfully. https://photos.app.goo.gl/xmgm7CEy7VauBQpX7
But from Arduino, I cannot read the register value. Maybe my code is wrong. I am getting error code 2 as: https://photos.app.goo.gl/dWgKTUT3uuDbSHbq6
My code is: https://drive.google.com/file/d/1CXekL9WriItWfD32gOoH42hecTbEXxai/view?usp=sharing
The library I 've used is: https://github.com/4-20ma/ModbusMaster
I am using a max 485 module for communication between Arduino and energy meter.
Many thanks to you in advance.
Original issue reported on code.google.com by
max.bene...@gmail.com
on 26 Dec 2013 at 11:05