Author Topic: Reading register using Modbus master/arduino uno  (Read 3447 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Reading register using Modbus master/arduino uno
« on: September 13, 2016, 09:49:10 am »
1. I ma using this modbus library to read (EM)6433, meter from scheider.
Lib: https://github.com/4-20ma/ModbusMaster
doc: http://4-20ma.io/ModbusMaster/

2. (EM)6433 documentation is here: http://tinyurl.com/z7696ys

3. Page 3 of above doc says that protocol is Modbus RTU, data:8 bits, baud: 9600(default) , parity:even, device address:1, stop bit:1

In uno code, default seting is 9600 & parity zero. Is below setting ok in code:

    ModbusMaster node;
    Serial.begin(9600, SERIAL_8E1);
    node.begin(1, Serial);


4. (EM)6433 doc on page 7 shows, read register "Average current", with address "3913" & reurn type is float 4 bytes in little endian.

However this library has function "readHoldingRegisters" to read holding register. But this function reads only 16 bit registers.

So should I use the function as:
    result = node.readHoldingRegisters(3913, 2);
    if (result == node.ku8MBSuccess)
    {
        for (j = 0; j < 2; j++)
        {
        data[j] = node.getResponseBuffer(j);
        }
    }

parameter 2, shows that 2 16 bit values are read.
How to convert it back to float?
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: Reading register using Modbus master/arduino uno
« Reply #1 on: October 05, 2016, 06:22:43 am »
1. I have interfaced EM-6433 using arduino over Rs485. Rs485 IC used is SN75HVD08.

2. EM-6433 settings are slave id:1 & baud:19200, even parity & 1 stop
Confirmed it aftr turing on meter & go to its settings table.

3. Case 1: If I permanently pull down N_RE pin & pull up DE pin of SN75HVD08, then when I used the attached code I always receive 0xE2 in return from device ie ku8MBResponseTimedOut. In code ignore the code which ouput high & low the RE & DE pin. This is used in case 2. In this case, this is commented out.

4. Case2: Since this SN75HVD08 is half duplex so I connected RE & DE pins to arduino as in attached circuit. Also I have modified ModbusMaster.cpp file in line 728 & 729, where I added code to disable Tx & enable rx from IC. When I use this code I receive error 0x02 in result, which is ku8MBIllegalDataAddress.
What am I doing wrong here. I also interchanged A & B pins to slave device EM-6433 + & -. But no correct result obtained.

5.All ckt diagram and code is here: https://drive.google.com/open?id=0B-jbeBk3wfkWaWo1ek5ISUxoTzA   
« Last Edit: October 05, 2016, 06:25:16 am by Vindhyachal.takniki »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf