Modbus tcp read holding registers not returning requested quantity

Background:  I have a customer using an ELAU motion system - they are recording data to Holding Registers that they want to be able to read on a cRIO to match up with some analog data from FPGA (I have digital handshaking happening for that).
LabVIEW 2010 SP1
cRIO 9074
Using the NI MOdbus.llb VI Library to communicate with the other system.  I can open the TCP communication no problem, and actually get SOME registers, just not ALL of the register data I want to read. 
What I want to do is read 330 individual holding registers U16 values.  I know how the data is being split to represent various lengths (i.e. most data items are using 2 registers to represent one 32 bit number).  I just want to read all the individual registers and parse the data in another VI to convert it to the other data types.
I provide the MB Ethernet Master Query (poly).vi with the starting address for the first register and then the quantity of 330.  The polymorphic instance selected the is "Read Holding Registers".  The array returned from this VI via "Holding Registers" is only 74 elements and not 330 requested.  I get no exception codes and no LV errors.  Is there some inherent limit on the number of Holding Registers that can be read?
I am not using the MBAP Header input (not sure if that is needed).
Thank you.
Ryan Vallieu
Automation System Architect
Solved!
Go to Solution.

Simple solution once I dug into the MODBUS Serial protocol/TCP protocol documentation available out there via Google.
Serial based modbus history is the limitation that carried over to TCP - the maximum amount of bytes in one data pack can only be 256 bytes.  Thus I was limited to around ~125 registers at once.
256 bytes = 2048 bits.  Using 16 bit registers that gives 128 registers maximum.  I went with 125 to make keeping track of totals easier.
Ryan Vallieu
Automation System Architect

Similar Messages

  • Modbus RTU - Reading Holding registers problem - Novus myPCLab

    Hello,
    I'm trying for a few days to read Holding registers in Novus myPCLab (it uses Modbus RTU protocol). I used both DSC module and Modbus library with no success (it appears to connect correctly but cant read).
    I need to read the given current.
    Does anyone have any idea about what am I doing wrong? 
    Here are my vi and the modbus address.
    Via DSC
    I used the PLC address at "HR Inicial" and 1 at "numero de registros"
    Via library
    I used the PLC address in "starting address"
    Solved!
    Go to Solution.

    My problem now is that my VI doesn't stops after I stop the while loop, it is necessary for a flat sequence implementation.
    Or my other best option is to read and write without closing the Modbus connection. Is that possible with a global variable? 
    I guess I do have to execute this "Modbus VI" to get my variables at a Main VI if they are in the same project. So, can I make my "Modbus VI" works in the background while the Main VI (who reads and write the addresses from the global variable) works, and when I finish running it, they stop together?
    ModBUS VI

  • Reading Holding Registers Float Modbus RTU

    I'm having an issue with ready any floating point number correctly off of a Shark 100 Power Meter.
    I can sucessifully read a block of registers containing the meter name and serial number as 16 bit characters.
    For example when I read registers 1-16 on the map and flattening them to a string, I get a fully working string returned.
    When I try and read holding registers 1012-1013 (Amps A) I get really funny numbers when I convert to a float.
    Here is my code so far
    With my front pannel settings:
    Expected Value I'm looking to have returned: 11.11 Amps
    but
    When I use an indicator to read the registers: 19265, 0
    Same value when I do a conversion
    When I do a type casting to a float: 1.26484E+7
    I've tried some different combinations such as reading only one register and joining the numbers, both in big-endian and little-endian order, still no luck.
    Please Help!
    Here is the modbus float definition as defined the owners manual:
    Solved!
    Go to Solution.

    The float format you posted is the same as LV uses, so if you put example values (Register 1 = C4E1, Register 2 = 1DB9) in the code below it will give you right result.
    What is the full value of your "Output Registers"? You should have two values in numeric array for this to work.

  • Modbus - Issues with Reading Holding Registers

    I am trying to read the holding registers on a RS485 2 wire modbus power monitor (Veris Industries E50C2).I am receiving bytes from the device so there appears to be communication. However, the response string is the exact same string as my command string. For instance, I am sending the hexadecimal string 0103 0000 0005 in order to read the first 5 holding registers, but I am receiving this exact same string back via the read VISA read function. I have attached an image of my VI. I would expect to see the response as "0103 (the device ID and command) followed by the number of bytes to follow and the contents of the holding registers.
    The VI is running on a cRIO 9012 with 9111 chassis. I am using the 9871 c-series RS485/RS422 interface module.
    Any ideas what the issue may be?
    Kind Regards
    Adam
    Attachments:
    Modbus VI.png ‏15 KB

    I indeed manage to fix the issue for myself.
    I used the same method you are starting right now, i conencted the NI9871 to the rs485 adapter given by the supplier and tried sending and reading my own signals.
    After much hassle and some changes to your (and my) initial vi setup as shown in your first post, everything worked out fine:
    (see the attached picture)
    1. I used the NI modbus VIs, but it worked as well with the normal visa commands and building the modbus command on your own, but  way easier with the NI VIs.
    2. i added the function to resize the buffer to its maximum size (not sure if thats actually helping with anything, but better be safe then sorry).
    3. Change the wire mode for the 9871 to rs485/wire2-auto with a property node.
    4. remove the large delay between write and read
    5. Last but not least, the one thing that changed the fact that i only received my own echo:
    I changed the connection of the Rx+/Tx+ and Rx-/Tx- around, basically connecting the 2wire sensor the other way around the manufacturer said it should be connected to the master device.
    (6. Recheck the amount of stop bits, all modbus device i use in my lab are using 2 stop bits, but that could be a coincidence)
    Maybe  something of that list helps you
    Attachments:
    Modbustest01.jpg ‏95 KB

  • TCP Read w/ #bytes=4 returns wrong data.

    On an initial TCP Read to a just-open connection, I can read any number of bytes, always getting the first n bytes from the arriving data. Except when I try to read 4 bytes! Then I get 4 bytes, but they're the seventh through ninth bytes, not the first four. Haven't found any other number that gives problems - 1,2,3,5,6,7,8,16,40,1020,etc. all work fine. Ideas?

    You may want to try runnig the Data Client and Data Server example VIs which ship with LabVIEW and see if they work on your system. The Client example actually reads in 4 bytes every time. I ran it and it works fine, so if yours exhibits the behavior you've been seeing, then the problem could be with your connection. Otherwise, if the example does work, then it could be somewhere in your code. Let us know what you find.
    J.R. Allen

  • My epson NX420 got a paper jam.  I got the paper out but now the ink cartridge holder will not return to the usual place so I can replace ink.  It stays stuck in the corner and lid won't open.  Ideas?

    First time here; hope I'm not repeating.  Can't get my EpsonNX420 that I use with my MacBookPro to work correctly.  Had a paper jame.  Cleaned it out.  NOw the cartridge holder won't move from the corner so I can fully open it and replace ink.  Help

    Call Epson.  Tech support number is inside your user manual or E-mail us for assistance.

  • Adobe Reader 11 will not return to last page read, but version 10 did

    Hi,
    I have just installed Adobe Reader version 11. When I start reading a pdf, it will not begin on the page where I last left off.
    I had version 10 and it would begin on the page where I last left off (in the previous session).
    Is there a way to get version 11 to do what my version 10 would do?
    For example, if I studied from my Excel book and left off at page 70, closed Adobe Reader, then resumed later, Adobe Reader would automatically start at page 70 (for that Excel book that I am studying from).
    However, now with Adobe Reader version 11, it will only start at the front of the pdf book.
    Is there a way to get version 11 to remember the page that it is at when I close the pdf book?
    Thank you very much

    Edit>Preferences>Documents>Open settings, select "Restore last view settings..."

  • Read LVM VI not returning segments of specified size.

    All,
    I'm having trouble with the Read/Write LVM VIs. I'm writing to a series of multiple files, which works fine and has worked fine for quite a while now. Now the general behavior of the Read LVM VI is that it retrieves the signals from the file in small "chunks," either at the sampling frequency or a user specified number of samples. The behavior that I'm having trouble with is that even when I force the sample size to X, the VI returns an accumulated signal that grows in length with each iteration of the main for loop. The first iteration the VI will retrieve X samples, the next 2X samples, the next 3X samples, so on and so forth. As I said before the general behavior is X samples per iteration, which is how most of my VIs work, and I can't quite figure out why this VI is operating in such a manner.
    Thanks for the help!
    Regards,
    Kenneth Miller

    Hi Kenneth,
    can you upload your code or a picture of it?
    Mike

  • Detecting Error #59 while using TCP Read.vi

    I am using the TCP Read.vi to read data from a TCP connection. However, I need to know from the vi when the connection is lost, dropped, or reset. According to LabVIEW help, this should return back to me as Error #59. However, when I purposefully drop the connection on the server side, the TCP Read.vi does not return any errors.

    Here is my example. Its a small vi that simulates what I am trying to do. Let me know if you have questions.
    Attachments:
    TCP_Example.llb ‏159 KB

  • TCP Read does not detect network conncetion closed error (66)

    Hi Dear all,
    Instead of LAN i am using WLAN to connect PC and mobile. All communication read and write operations are performing ok. But the only problem i am facing is that once i disconnect network connection from mobile my labview TCP read operation does not detect it and only timesout at its specified interval. Although for Bluetooth network connection if i disconnect from mobile then BT read detects it as network conncetion closed by peer error (66).
    Can someone help me on this.
    Thanks & Regards
    awais qureshi
    Solved!
    Go to Solution.

    Awais Qureshi wrote:
    Hi Dear Norbert,
    I am still waiting for your reply. Whats error you get once you unplug LAN cable? i am unable to understand how to detect Disconnection during Read Time out. Kindly help me in this.Thanks
    Dear VT Kim,
    I studied your recommended article but which way Labview handles TCP close connection then. i am unable to understand how to detect Disconnection during Read Time out. Kindly help me in this.
    Regards
    awais qureshi
    I have not tested it but more likely than not you would get an error 59 when the network cable is unplugged. Error 66 is for when the network is still up and you attempt to communicate on an established connection that has been closed by the other side. This is not an error that you will se from a TCP read very often.
    Also, please keep you related question in a single thread rather than starting multiple threads for the same topic.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Modbus TCP server/slave implementation

    Does anybody have experience to implement a modbus server or slave application? My computer needs to communicate with a PLC. The configuration is: computer is TCP server or slave, PLC is TCP client or master. Computer to write input registers for PLC to read. Computer read holding registers from PLC. Cannot find any labwindows examples.
    Thanks a lot.

    Thank you all for the replies. Most the links are for modbus tcp client (master) instead of modbus server (slave).
    Now I am trying to use a modbus slave activeX control (trial version) from Automated Solutions Inc: http://www.automatedsolutions.com/products/modbusslave.asp.
    I created an instrument driver using Create ActiveX Controller wizard. I can get a correct object (modbusHandle) with the first line below (status = 0). But the second function (set a property) gives negative status return (status = -2147418113).
    status = ASMBSLVLib_New_DASMBSLV (NULL, 1, LOCALE_NEUTRAL, 0, &modbusHandle);
    status = ASMBSLVLib__DASMBSLVSetDataMode (modbusHandle, NULL, ASMBSLVLibConst_DATA_MODE_MB_TCP);
    Did I create the activeX control correctly? Automated Solutions told me that the ActiveX control is a windowless control. It's a runtime control. Is it a problem?
    Thanks in advance.
    jzhu0000.

  • FM HRTRV_IF_GET_TRIP does not return USERDATA

    Hi, it's me, yet again...
    I'm using the FM "HRTRV_IF_GET_TRIP" in FITE_VC_GENERA_DATA in a post exit of comp-controller method "ON_SHOW" to get the structure/Table USER/PTK99 from the TE Cluster for binding to the context afterwards. At least that's the plan. The FM does not return me the data I expect in parameter USERDATA, although there is data in the TE Cluster and within the FM, I can see the global Table USER being filled whilst the macro RP-IMP-C1-TE. But this data is not further process neither is seems the strucutre USERDATA to be touched at any point of the FM. Am I calling the FM 'wrong' in any way? I'm close to making an implicit enhancement at the end and forcefully fill userdata from user....
    Too long, didn't read: USERDATA is not returned filled --> WHY?
    CALL FUNCTION 'HRTRV_IF_GET_TRIP'
      EXPORTING
        employeenumber             = wd_assist->GS_COMMON_RFC_INPUT-employee_number
        tripnumber                 = lv_tripno
    *   LANGUAGE                   = SY-LANGU
    *   CALCULATE_AMOUNTS          = 'X'
    *   GET_TRIP_FROM_MEMORY       = ' '
      IMPORTING
    *   FRAMEDATA                  =
    *   STATUS                     =
        USERDATA                   = ls_user " should contain cluster values, but it doesn't
      tables
    *   RECEIPTS                   =
    *   ADDINFO                    =
    *   GUESTS                     =
    *   TEXT                       =
    *   MILEAGE                    =
    *   STOPOVER                   =
    *   DEDUCTIONS                 =
    *   COSTDIST_TRIP              =
    *   COSTDIST_STOP              =
    *   COSTDIST_RECE              =
    *   COSTDIST_MILE              =
    *   AMOUNTS                    =
    *   ADVANCES                   =
        return                     = lt_bapiret " says method was executed successful
    In the insides of the FM:
    *  IF CALCULATE_AMOUNTS <> 'X'. "XJY
    * import the trip because it was NOT imported before
      READ TABLE T_PERIO INDEX 1.
      TE-KEY-PERNR = T_PERIO-PERNR.
      TE-KEY-REINR = T_PERIO-REINR.
      TE-KEY-PERIO = T_PERIO-PERIO.
      TE-KEY-PDVRS = T_PERIO-PDVRS. " Once this line is executed, the global table USER is fileld with the data I expect
      RP-IMP-C1-TE.
    *  ENDIF. "XJY
      if t_perio-abrec = '0' or
         t_perio-abrec = '1'.
        clear te-key-pdvrs.
        import beler from memory id te-key.
      endif.
    I hope somebody has ever used this one and can tell me what I'm doing wrong...
    Cheers, Lukas

    good to know. that you have already implemented similar thing. In our case if employee want to pick a manager he will only be given option from a custom table entries.
    They way i was thinking was that there will be a checkbox that will say "Override Approver"
    and when that will be checked text filed will be enabled with search help restricted to custom table entries.
    I have one question. When I am enhancing FITE_VC_REVIEW and adding field in that view, I m finding it hard to track it. Looks like adding to General data screen will be much easier.
    R u using ABAP memory to track field and use it at SMOD or you are using SAP memory ?
    I am just starting on this one and not expert at webdynpros.. will ping you if i need any more help
    and yes i just added following like in FM HRTRV_IF_GET_TRIP
    read TABLE user INTO userdata INDEX 1
    to get it to load userdata..

  • TCP Read Error Code 1

    I met a problem in using "TCP Read" in LabView;
    First I use "TCP Open Connection" building connection successful with a instrument; and seem the connection ID as the global,equal to a "TCP Network Connection Refnum";
    Then I use the global as the connection ID,and use "TCP Write" send a command to a instrument;and use "TCP Read" Receive the instrument return message;this time a 56 error occurs,it is normal.
    But after I use this method Send/Receive two times successfully,when i use "TCP Read" receive message, the error 1 occurs,and nothing received.
    In each TCP operation,use the global "TCP Network Connection Refnum" as the "Connection ID" input.
    someone can tell me,why does it occur?

    JiangYu wrote:
    > I met a problem in using "TCP Read" in LabView;<br>First I use
    > "TCP Open Connection" building connection successful with a instrument;
    > and seem the connection ID as the global,equal to a "TCP Network
    > Connection Refnum";<br><br>Then I use the global as the connection ID,
    > and use "TCP Write" send a command to a instrument;and use "TCP Read"
    > Receive the instrument return message;this time a 56 error occurs,it is
    > normal.<br><br>But after I use this method Send/Receive two times successfully,
    > when i use "TCP Read" receive message, the error 1 occurs,and nothing received.
    > In each TCP operation,use the global "TCP Network Connection Refnum"
    > as the "Connection ID" input.<br><br>someone can tell me,why does it occur?
    Ouch, globals! That is usually the first sign of a bad application design.
    For the rest just watch out. LabVIEW refnums are garbage collected
    whenever the VI hierarchy which opened them goes idle (stops executing).
    So Executing a VI which Opens the TCP refnum and writes it into a global
    and then quits and then executing another VI which tries to use that
    refnum from the global will simply fail with error 1 as the refnum has
    been already automagically closed and is therefore invalid.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How do I read ModBus counter holding registers in Lookout 5

    We are using Lookout v5 with Zetron M1700 and M1716 RTUs. The M1700 is Modbus1 and the M1716 is Modbus2.
    We need to be able to count the number of times a digital input is turned on and off over a period of time.
    We are using digital input #9 on the M1716 RTU. According to the Zetron literature, the counter holding registers for digital input #9 are 42091-42093 for the value and 42094-42096 for the period.
    I tried to calculate the the value stored in the registers by using this formula which was suggested by Zetron in an expression:
    (((Modbus2.42093*10000)+Modbus2.42092)*10000)+Modbus2.42091
    However, this always returns zero.
    I read through your example on reading the BCD registers and doing calculation
    s on them but it hasn't helped me with my problem.
    Is there some command I need to use or a special type of an object I need to use to read the counter holding registers?
    I know we are communicating with Modbus2 properly because I can see when the digital input is on or off.
    Any help is greatly appreciated.

    Hi,
    Is it possible to share or point us to the Zetron literature explaining this calculation?
    If you just read the registers 42091-42093 individually from Modbus2, what do you get?
    Alternatively, you can maybe count the digital line directly in Lookout. For this, you would create a Counter object and specify the digital input as the "Count=" input. Not sure if this is a feasible option for you.
    Again, if you can share the Zetron documentation, I can take a look at it to see why it may not be working.
    Regards,
    Khalid

  • Dsc modbus - Serial communication input/holding registers

    Hello,
    I am trying to create a labview application to act as a Modbus master and control multiple stepper motors. I have the DSC module in labview and am using a serial communication with an RS-485 converter. I have followed this guide: http://www.ni.com/white-paper/13911/en/  However, the driver I am using does not support coils, it only uses input and holding registers and I have not found a guide or tutorial that shows me how to create a labview application that can read and write to a specific address. For now all I want to do is turn the motor on and off using labview. I have used a modbus simulator to communicate with the driver and can do everything I want to do through the simulator. I can not get labview to do anything for me. I would be very happy if someone could direct me to a tutorial that can help me understand labview dsc module for reading and writing to addresses using modbus. 
    Meesh

    Ok, so this is really strange. I solved my problem in a round about sort of way. I'm using a modbus simulator (mdbus) to help me communicate with the driver/stepper motor so I know which address to use. But after I use the simulator I get a communication port error when I try to use Labview. It's like the port is locked in with the simulator and I can't end the connection and let Labview use the same communication port. I can't find anyway to fix the problem except going to this NI site: http://www.ni.com/download/labview-run-time-engine-6.1/746/en/  downloading this software and using the "repair" function. Then I can do a system restart and cycle the power on the driver/motor and then Labview with work again through the correct port. But if I need to use the simulator again then I have to go through this whole process again. Does anyone know what the heck is going on? Or if there is a better way to clear the communication port?? 

Maybe you are looking for