2

i have an arduino UNO with RS485 module.

I have made this connection:RS485 module connection

And i have an problem with communication of this module with power meter "InePro PRO-1Mod" (datasheet) over ModBus protocol. I want for example read an L1 Voltage value, which i know from the manual (page 24 & 25) that this value is stored in "read holding register" with adrress 5002. I should communicate with these paramaters:

  • Baud rate 9600
  • 8 data bits
  • even parity
  • 1 stop bit

There is also mention about 120 ohms resistor placed by the power meter (but it is 15cm long cable, and even with the resistor there is no change)

I have tried using many of ModBus libraries and for now none of them doesn't work. I have tried "Modbus-Master-Slave-for-Arduino" , "ModbusMaster and now at last i am using this "simple-modbus".

I think that with that simple modbus library i went far as i can, but it is still doesn't working, but i see on the display of power meter that there is some try to communication (i see a black dot which shows modbus communication) but i don't receive any useful data.

I am using this code:

    #include <SimpleModbusMaster.h>
#include <AltSoftSerial.h>

#define TxEnablePin 2                    // RS485 modbus direction control pin:
#define baud 9600                           // modbus port speed:
#define timeout 1000                        // modbus timeout in mSec:
#define polling 500                         // modbus scan rate in mSec:
#define retry_count 15

#define TOTAL_NO_OF_REGISTERS 1// number of registers to poll for:

AltSoftSerial altSerial;

enum
{
 PACKET1,
 TOTAL_NO_OF_PACKETS                       // leave this last entry
};

Packet packets[TOTAL_NO_OF_PACKETS];        // array of Packets to be configured

//struct packetPointer packet1 = &packets[PACKET1];
unsigned int regs[TOTAL_NO_OF_REGISTERS];   // master register array
long previousMillis = 0;
long interval = 1200;
unsigned long currentMillis;

void setup() {
 Serial.begin(9600);
 altSerial.begin(9600);
 altSerial.println("Hello World");
 modbus_construct(&packets[PACKET1], 5, READ_HOLDING_REGISTERS, 5000, 2, 0);  //initialize packet
 modbus_configure(&Serial, baud, SERIAL_8E1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
}

void loop() {
 modbus_update();


 float Power;
 unsigned long temp = (unsigned long)regs[1] << 16 | regs[0];
 Power = *(float*)&temp;

  currentMillis = millis();
 if (currentMillis - previousMillis >= interval)
 {  
   altSerial.print("Exception errors: ");
   altSerial.println(packets[PACKET1].exception_errors);


   altSerial.print("Failed requests: ");
   altSerial.println(packets[PACKET1].failed_requests);


   altSerial.print("Successful requests: ");
   altSerial.println(packets[PACKET1].successful_requests);
   altSerial.print("Low byte: ");
   altSerial.println(regs[0]);
   altSerial.print("High byte: ");
   altSerial.println(regs[1]);
   altSerial.print("Power ");
   altSerial.println(Power);
   altSerial.println("----------");

   previousMillis = currentMillis;
 }

}

And i have got only this output in the pc (its repeating of course):

----------
Exception errors: 0
Failed requests: 5
Successful requests: 0
Low byte: 0
High byte: 260
Power 0.00
----------

Altserial library i am using together with USB2TTL convertor on pins 8 & 9, to see output.

I should mention that there is only A and B screw terminals on power meter, so i have no option to make common ground connection. I also using an 15cm twisted pair cable UTP.

Can someone help me to make it work ? I have tried to change adrress of holding register to 0x5000 or 5002, tried changing number of registers.

I have tried to connect rs485 module with USB2TTL to pc and run software called "qModMaster" and it works, but with arduino it doesn't work.

Slave ID (power meter) is 5.

Thank you, for your help.

  • Can u help me,, i have a same problem. i try to read value from pulse meter autonics and display to serial monitor arduino. my pulse meter setting is : baud rate 9600 address 02 with your code above, can i solve my problem? or any code have to change... thankyou... – Yaay Oct 15 '18 at 8:31
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – Michel Keijzers Oct 15 '18 at 9:35
  • I don't know which type of "pulse meter autonics" you use but i found manual for these types: MP5S_MP5Y_MP5W_MP5M and in manual they said that they are NOT using PARITY BIT. So you should change "SERIAL_8E1" to "SERIAL_8N1" – Vasekdvor Oct 16 '18 at 10:55
  • I edited my answer, for more help look at it. – Vasekdvor Oct 16 '18 at 11:45
  • My reference is this vidio link. in that video show that pulse meter Mp5Y can communicate with other system (mkrokontroller/arduino) and the measurement result/ PV can display on 7 segmen – Yaay Oct 20 '18 at 4:40
3

I have made it. Now it is working. I only checks A & B cables (tried a new one) and change address of register from 5000 to 0x5000 and now it works. I thought that this library already give 0x before address, because i didn't see it anywhere with 0x before.

An advice for people with the same problems: Most of the devices which is using RS485 and ModBus protocol (and have an some kind of display) shows an communication (over 485 & modbus) on display by some kind of mark, for example in my case it was an "dot" which blinks when there's an communication. When this mark is shown, it is sign of that the communication settings is right, so data, parity bit, stop bit & baudrate is OK (data has successfully reached the dest. device).

After that, these devices send you an error message back on its line. So if you have problems with getting data, you should send your message (ask) from the arduino to that device, over an Transmit pin from arduino (of course trough an converter, for example max485) and the Receiving pin (side) connect to your PC through again some kind of converter from UART to USB. (Warning: you should have the same ground potential, so wire all grounds together)

Install some software to communication for modBus on PC (i am using this soft: https://www.simplymodbus.ca/ | you can use demo ) After that let arduino sent an message and receive it by PC. (in simplymodbus look at the "response") read that code and look to the manual for the device you using, where there should be an description of error codes, if not look at this doc.: http://www.simplymodbus.ca/exceptions.htm or THIS).After that you will have an better look on what is going on and where there is a problem.

  • Using the solution i write above, i figured out that there was a problem with "Illegal Data Address", received "02" exception response code. – Vasekdvor Oct 16 '18 at 11:43
1

I'm using a mp5w pulse meter, the settings:

  • Baud rate : 9600
  • Address : 02
  • Parity : none
  • Stop bit : 1

Modbus memory map table for measurement value /(PV) :

  • Modebus : 31002
  • Address : 03E9
  • Size : 5
  • As i look into the manual, there is NO sign that these pulse meters uses an ModBus protocol, only an RS485. In this manual link on page M-26 (M-27 is last page) so the first before last page. There is this text: "The comunication control ordering of MP5 series is a private protocol (not compatible with other system)" and then the description of this private protocol follows. – Vasekdvor Oct 19 '18 at 20:25
  • Then you can't use this library, it will not work at any settings. – Vasekdvor Oct 19 '18 at 20:27
  • My reference is this vidio link. in that video show that pulse meter Mp5Y can communicate with other system (mkrokontroller/arduino) and the measurement result/ PV can display on 7 segmen. – Yaay Oct 20 '18 at 4:34

protected by Community Oct 10 at 11:52

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.