Announcement

Collapse
No announcement yet.

Understanding Registers Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • bburford
    replied
    Fernando, all of that was written by a programmer - Yuk.
    Most of it describes how Modbus works and isn't relevant to just using it.

    What you need is probably in Tables 6-15, 6-30, 6-31 and 6-32
    Print them and use the programming option of Windows Calculator to convert them back to Decimal Register values ie 0FFDH is Hex value 0FFD = 4093 Decimal.

    Word means it is 16 bit (one "register" only), DWord means it is 32 bit (two consecutive "registers" - but in some instances they are in reverse order).
    It doesn't say they are Signed Values (1st bit is a +/- sign) so assume not.

    16 bit Registers are a gimme because there is no possibility of Big Endian / Little Endian reverse order problems - they are either there or not. Try and find these first.

    R/W means you can read and Write from the register in this case Read means Type 3 "Read Holding Registers" and Write is Type 16 "Write Multiple Holding Registers".

    The Modbus PlugIn sorts the Type 3 / Type 16 out itself depending on whether you ask it to Read or Write but does need to be told to to write Multiple Registers (Register Write Function) because single Register Writes (Type 6) are not valid for your meter.

    Create a Modbus IP Gateway pointed at the Slave (Meter) IP address and TCP Port 502 (unless it has been changed). Set a 10 Sec poll interval for now and remember the Write Multiple Register option. Leave Big Endian and Zero Addressing blank. Note if you have multiple Modbus IP Slaves they will need a gateway setup for each.

    I would start by trying to read the Baud Rate at 1002H (4098) as it is a 16 bit register and you know what you've set it to.

    Create a device (Register) within the Gateway.
    In Status Graphics Tab you need to Add New Range Value and give it Value Limits (-65438 => 65438 should be safe although Float Values can be very large). If the value received is outside these limits the Modbus Plugin will stop with an Error. At first just try to Read the Register - set Status-Control to Status.

    In the Modbus Tab, select the Gateway you just set up, Register Type Holding Register, Slave ID 1 (usually default for IP Modbus because the IP Address itself is unique - sometimes it is still 1 even if an alternative address is able to be programmed!). Add the Register Address (4098), Return (Data) Type of Int16, leave Signed Value blank, Multiplier 1, and select Read Only and Device Enabled.

    If it doesn't work, try one register lower and then one register higher. If one of these works you can toggle Zero Based Addressing in the Gateway to offset the Registers by one and try to make them line up with the documentation.If you cant it doesn't matter - just adjust your Register List to suit. If you need to adjust this register then every other Register in the device WILL have the same Offset (unless the documentation is extremely poor).

    Note if you cant find 16 bit data at any of the three consecutive addresses it is most likely you have a comms problem of some sort as it should be easy.

    After you've found a Register and tested on a few other 16 Bit Registers move to Table 30 etc. These have an Address of two "Registers" so are either 32 Bit Float or Int32 (dword) as specified. Usually the lowest address of the two is the "Register Address" that you enter.

    Here's where it gets tricky. The two 16 Bit words are normally read and the bits lined up in order 32->17 16->1 but not always. Depending upon the vagaries of the device programmer they may be lined up in Reverse Order 16->1 32->17. The Big Endian toggle will fix this.

    Again look for something you know and keep trying until you find a a valid entry. Line Voltage is always a safe bet in an Energy Meter.

    Coils are easier - the same Register Offset will apply but data possibilities are only 0 and 1. Again the Plugin will switch to Type 1 Read or Type 5 Write Single Coils or Type 15 Write Multiple Coils as required.

    Sometimes binary data is stored in a standard Holding Register - it may even be available in both so you can choose. Sometimes you get a choice of data type ie Float in one Register Range and Int in another with both containing the same data.
    Modbus' biggest strength is that it is extremely configurable.
    Modbus' biggest weakness is that it is extremely configurable.
    You need to work out what the programmer was trying to achieve.

    Leave a comment:


  • FernandoSolanes
    replied
    Thanks guys for your response.

    I have the device connected to my ethernet network and can read the values on the web page but they update slowly and figured Modbus would be the best way to update the virtual homeseer devices..


    Here is the link to the device manual, and also a paste of the section that includes how the device comunicates its values.

    https://www.accuenergy.com/files/acu...-1040E1303.pdf



    5.2.10 Description of Modbus-TCP protocol
    The Modbus-TCP protocol is used for communication in Ethernet modules. The
    protocol sets up master/slave link in Ethernet. First, master device (client) sets
    up TCP link with slave device (server). Second, master device sends request
    frame to slave device, and slave device receives request frame and returns
    response frame to master device. Fig 5-41 displays working mode of ModbusTCP
    protocol.
    159
    Modbus Client Modbus Server
    Request Indication
    Confirmation Response
    Fig 5-41
    1. Protocol
    a. Data Frame Format
    Table 5-2
    MBAP Header Function Data
    7x8-Bits 8-Bits Nx8-Bits
    b. Modbus Application Header (MBAP Header) Field
    The Modbus application header field is the start of the data frame and consists
    of seven bytes.
    Table 5-3
    Field Length Description
    Transaction
    Identifier 2 Bytes Identification of a Modbus Request/Response transaction
    Protocol Identifier 2 Bytes Modbus protocol=0
    Length 2 Bytes Number of following bytes
    Unit Identifier 1 Byte Slave address, in the range of 0~247 decimal.
    c. Function Field
    The function code field of a message frame contains eight bits. Valid codes are
    in the range of 1~255 decimal. When a message is sent from a client to a server
    device the function code field tells the server what kind of action to perform.
    160
    Table 5-4
    Code Meaning Action
    01 Read Relay Output Status Obtain current status of Relay Output
    02 Read Digital Input(DI) Status Obtain current status of Digital Input
    03 Read Data Obtain current binary value in one or more registers
    05 Control Single Relay Output Force Relay to a state of on or off
    16 Write Multiple-registers Place specific value into a series of consecutive
    multiple-registers
    d. Data Field
    The data field is constructed using sets of two hexadecimal digits, in the range
    of 00 to FF hexadecimal. The data field of messages sent from a master to slave
    devices contains additional information which the slave must use to take the
    action defined by the function code. This can include items like discrete and
    register addresses, the quantity of items to be handled, and the count of actual
    data bytes in the field. For example, if the master requests a slave to read a
    group of holding registers (function code 03), and the data field specifies the
    starting register and how many registers are to be read. If the master writes to
    a group of registers in the slave (function code 10 hexadecimal), the data field
    specifies the starting register, how many registers to write, the count of data
    bytes to follow in the data field, and the data to be written into the registers.
    2. Format of communication
    Explanation of frame
    Table 5-5
    Transaction
    identifier hi
    Transaction
    identifier lo
    Protocol
    identifier hi
    Protocol
    identifier lo Length hi Length lo Unit
    identifier
    00H 00H 00H 00H 00H 06H 01H
    Fun Data start reg hi Data start reg lo Data #of regs hi Data #of regs lo
    03H 40H 00H 00H 48H
    161
    As shown in Table 5-5 the meaning of each abbreviated word is:
    Transaction identifier hi: Transaction Identifier high byte
    Transaction identifier lo: Transaction Identifier low byte
    Protocol identifier hi: Protocol Identifier high byte
    Protocol identifier lo: Protocol Identifier low byte
    Length hi: length high byte
    Length lo: length low byte
    Unit identifier: slave address
    Fun: function code
    Data start reg hi: start register address high byte
    Data start reg lo: start register address low byte
    Data #of regs hi: number of register high byte
    Data #of regs lo: number of register low byte
    a. Read Status Relay (Function Code 01)
    Function Code 01
    This function code is used to read relay status in Acuvim II series meter.
    1=On 0=Off
    There are 8 Relays in the meter, and the starting address is 0000H.
    The following query is to read 2 Relays Status of the meter Address 1.
    162
    Query
    Table 5-6 Read 2 Relays Status Query Message
    Transaction
    identifier hi
    Transaction
    identifier lo
    Protocol
    identifier hi
    Protocol
    identifier lo Length hi Length lo Unit
    identifier
    00H 00H 00H 00H 00H 06H 01H
    Fun Data start reg hi Data start reg lo Data #of regs hi Data #of regs lo
    01H 00H 00H 00H 02H
    Response
    The Acuvim II series meter response includes MBAP Header, function code,
    quantity of data byte and the data. For example response to read the status of
    Relay 1 and Relay 2 is shown as Table 5-6. The status of Relay 1 and Relay 2 is
    responding to the last 2 bit of the data.
    Table 5-7 Read 2 Relays Status Response Message
    Relay 1: bit0 Relay 2: bit1
    Transaction
    identifier hi
    Transaction
    identifier lo
    Protocol
    identifier hi
    Protocol
    identifier lo Length hi Length lo Unit
    identifier
    00H 00H 00H 00H 00H 04H 01H
    Fun Byte count Data
    01H 01H 02H
    The content of the data is,
    7 6 5 4 3 2 1 0
    0 0 0 0 0 0 1 0
    MSB LSB
    (Relay 1 = OFF , Relay 2=ON)
    163
    b. Read Status of DI (Function Code 02)
    Function Code 02
    1=On 0=Off
    There are 38 DIs in the meter, and the starting address is 0000H.
    The following query is to read the 4 DIs Status of address 1 of Acuvim II series
    meter.
    Query
    Table 5-8 Read 4 DIs Query Message
    Transaction
    identifier hi
    Transaction
    identifier lo
    Protocol
    identifier hi
    Protocol
    identifier lo Length hi Length lo Unit
    identifier
    00H 00H 00H 00H 00H 06H 01H
    Fun Data start
    reg hi
    Data start
    reg lo
    Data #of regs
    hi
    Data #of regs
    lo
    02H 00H 00H 00H 04H
    Response
    The response includes MBAP Header, function code, quantity of data characters
    and the data characters.
    An example response to read the status of 4 DIs (DI1=On, DI2=On, DI3=On, DI4=
    On) is shown as Table 5-9. The status of each is responding to the last 4 bit of the
    data.
    164
    Table 5-9 Read 4 DIs Response Message
    DI1: bit0 DI2: bit1 DI3: bit2 DI4: bit3
    Transaction
    identifier hi
    Transaction
    identifier lo
    Protocol
    identifier hi
    Protocol
    identifier lo Length hi Length lo Unit
    identifier
    00H 00H 00H 00H 00H 04H 01H
    Fun Byte count Data
    02H 01H 0FH
    The content of the data is,
    7 6 5 4 3 2 1 0
    0 0 0 0 1 1 1 1
    MSB LSB
    c. Read Data (Function Code 03)
    Query
    This function allows the users to obtain the measurement results of Acuvim II
    series meter.
    Table 5-9 is an example of reading the 6 measured data (Time) from server
    device address 1, the data start address is 1040H.
    Table 5-10 Read Time Query Message
    Transaction
    identifier hi
    Transaction
    identifier lo
    Protocol
    identifier hi
    Protocol
    identifier lo Length hi Length lo Unit
    identifier
    00H 00H 00H 00H 00H 06H 01H
    Fun Data start
    reg hi
    Data start
    reg lo
    Data #of
    regs hi
    Data #of
    regs lo
    03H 10H 40H 00H 06H
    165
    Response
    An example response to read Time (2006-12-18 14:15:20) is shown as Table 5-10.
    Table 5-11 Read Time Response Message
    Transaction
    identifier hi
    Transaction
    identifier lo
    Protocol
    identifier hi
    Protocol
    identifier lo Length hi Length lo Unit
    identifier
    00H 00H 00H 00H 00H 0FH 01H
    Fun Byte
    count
    Data1
    hi
    Data1
    lo
    Data2
    hi
    Data2
    lo
    Data3
    hi
    Data3
    lo
    Data4
    hi
    Data4
    lo
    Data5
    hi
    Data5
    lo
    Data6
    hi
    Data6
    lo
    03H 0CH 07H D6H 00H 0CH 00H 12H 00H 0EH 00H 0FH 00H 14H

    Leave a comment:


  • beerygaz
    replied
    1. Does your meter support Modbus?
    2. What protocol?
    3. Do you have an IP to RS485/RS232 modbus gateway or a direct serial connection to the meter?
    4. Do you have any documentation for the meter that might help us work out how to get you connected?

    Leave a comment:


  • Qbus
    replied
    There is a lot more than Modbus in book, but this is what I give to new techs in the building automation industry.

    https://www.ccontrols.com/ncbpost.htm

    Leave a comment:


  • FernandoSolanes
    started a topic Understanding Registers Help

    Understanding Registers Help

    I managed to get the plugin in trial installed and i believe the gateway (IP) tests fine

    Im trying to poll my Acuvim II utility meter but i have absolutely no clue how the register and values work.
    I tried random settings etc but can get any value responses
    Is anyone familiar with the AcuvimII meter?
Working...
X