Electronic – arduino – Struggling with serial communication over RS 485 using modbus protocol

arduinomodbusrs485

I have around 60-70 inverters that I want to talk to using arduino over RS-485. The connection that I am making with arduino is according to the attached image.

Now I think that my connection part is okay! Where I am falling behind is the coding part I guess. As for every request I am not able to make even one successful request. enter image description here

The modbus library that I am using is SimpleModbus Library here's the link to it: https://drive.google.com/folderview?id=0B0B286tJkafVSENVcU1RQVBfSzg&usp=drive_web

The data format that the inverter manufacturer is using is as follows: start byte, slave address, function code, data, check, end byte.

Whereas the request I am sending through my master device looks something like this:

packet1->id = 25;
packet1->function = READ_HOLDING_REGISTERS;
packet1->address = 3000;
packet1->no_of_registers = 3;
packet1->register_array = regs;

I am not including any start byte or end byte. Is it the reason why I am not able to receive any response from the slave device? or is it because I have to program the response of the slave devices as well?

As of now I am only playing around with the master device code and have not figured out on how to receive the response of the slave and how to decode it. Every modubs library seems to have two kinds of program one for the master and other for the slave. Whereas I use only the master code for sending requests to the slaves.

Do I have to program for slaves as well? if yes then how to program for both the master and slaves together on my master device arduino which is talking to my inverters?

I am new to arduino but experienced in programming. Just lack some basics in electronics and modubs protorcol over RS-485. Kindly please help me

Thanks in advance.

P.S: I have wired all my inverters through RS_485 ports correctly, I am connecting the negative end to the pin 7 on RS-485 chip and the positive wire to the pin 6 on the chip

Best Answer

I don't have great knowledge about the Arduino platform, but I have worked with Modbus over 485 lines. All processors I used, requires pull-up resistors on the Tx-Rx lines to the MAX485. Maybe Arduino board implements internal pull-up resistors, can you verify this?

I have much doubt about the manufacturer's specification on the "start byte" and "end byte", this does not appear in the specification of Modbus protocol.

And finally, 60-70 nodes is a large node number... maybe you must check the specification for Modbus over serial line.

You should also be careful about the way to end the transmission line and how to perform wiring. Check the specifications.

Here is an example of a circuit that I used for Modbus over 485.

enter image description here

In this case, is an isolated line, but is the same principle.

Related Topic