Reading register using Modbus master/arduino uno

Discussion in 'Embedded Systems and Microcontrollers' started by Vindhyachal Takniki, Sep 13, 2016.

  1. Vindhyachal Takniki

    Thread Starter Member

    Nov 3, 2014
    1. I ma using this modbus library to read (EM)6433, meter from scheider.

    2. (EM)6433 documentation is here:

    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?
  2. Vindhyachal Takniki

    Thread Starter Member

    Nov 3, 2014
    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:
  3. Huỳnh Nguyễn Minh Nhựt

    New Member

    Apr 16, 2017
    have you finish this? Can you share me? <email address snipped> Thanks so much.

    Moderator's note: please do not post email addresses. It attracts spammers to you and us, too.
    Last edited by a moderator: Oct 2, 2017