Hello Everyone!!!
I am trying to read holding register of a magnetic flow-meter via RS485 using Modbus RTU but unable to do. I have read many forum discussions and tried to implement them but didn't succeed.
Actually I am new to Arduino and getting so much confused by different library e.g. ModbusMaster.h and SimpleModbusMaster.h etc.
I am using TTL to RS-485 module and also have 1 arduino mega and 2 UNO.
slave id -1
baudrate -9600
format - 8N1
length - 8
It is easily giving readings using software and USB to RS485.
Please help me out and thanks in advance.
And please let me know if any other information I need to provide.
Modbus protocol illegal data address exception.
The data address received in the query is not an allowable address for
the server (or slave). More specifically, the combination of reference
number and transfer length is invalid. For a controller with 100
registers, the ADU addresses the first register as 0, and the last one
as 99. If a request is submitted with a starting register address of 96
and a quantity of registers of 4, then this request will successfully
operate (address-wise at least) on registers 96, 97, 98, 99. If a
request is submitted with a starting register address of 96 and a
quantity of registers of 5, then this request will fail with Exception
Code 0x02 "Illegal Data Address" since it attempts to operate on
registers 96, 97, 98, 99 and 100, and there is no register with address
100.
@ingroup constant
*/
static const uint8_t ku8MBIllegalDataAddress = 0x02;
assumption: you are sending a wrong adress to the server and the server doesn't know that address
try instead:
result = node.readHoldingRegisters(0, 2); // start with 0 and only two values
further more, print your result codes in HEX - makes debugging easier.
See the file ModbusMaster.h for all response codes.
double check and tripple check your wiring.
I would connect a RS485 - USB Adapter to the RS485-TTL Adapter and just open a Plain Serial Programm (like Coolterm) to see in HEX what the client is really sending.
for your debug printing. And you still include Softserial. Remove that.
What I see on your screenshots, it seems you send to register 12292, 12293, (+40001) - but I can't see that in your code.
The Screenshots in #7 and #8 show that you request 8 bytes - but that is not in the Code you posted in #7.
We can only see the information you provide - but that doesn't look consistant.
Can you provide a datasheet of your sensor which points out the real registers?
Have you terminated your bus line with resistor(s)?