Jump to content

Recommended Posts

          I'm trying to read six input registers from a remote device but the software I put together doesn't seem to do much; no errors but no read-backs either.  I'm a beginner, so the answer is probably simple.  The remote device input registers start at 200 hex.  The device uses TCP and the IP address is correct.  My computer communicates well with the remote device through QmodMaster.  Any help you could give would be appreciated.  Thanks, Mike.

 

 

Modbus Read 01.pdf So far 01.vi

Link to comment

Most problems about Modbus communication are related to the different address notations that are commonly used and the fact that some are 0 based while others are 1 based.

I also find the distinction between registers, holding registers, coils, and discrete inputs rather confusing. Basically discrete inputs are boolean inputs, coils are boolean outputs and registers are 16 bit inputs and holding registers are 16 bit outputs. Then there is the fact that two registers can often be used together as a 32-bit register or a 32-bit floating point number but as far as the Modbus protocol is concerned need to be treated as 2 consecutive 16-bit values.

The valid address range for each of these four types is 0 - 0xFF00

But there is an alternative address writing called entity form. Here the first digit indicates the type of register (0 - coils, 1 - discrete input, 3 - input register, 4 - holding register) and the next four digits indicate the entity address which is 1 based.

There are many LabVIEW libraries to do Modbus, but most of them do use the standard address and function code input. Not sure which library you exactly use, but that 256 needs some checkin. 0x200 would be 512 in decimal notation.

Link to comment

A couple of notes:

a) The code you have will work for reading *Holding* registers (not input) from a slave/server on the given IP and port, but only if that server ignores the unit id or happens to have unit id=1. If it requires a different unit id (many Modbus TCP servers expect it to be 0), right click on the modbus master wire and insert the "Set Unit ID"-function, then wire the correct id to that.

b) Assuming the unit id is not preventing the server from bothering to answer you should still get replies from the device even if it does not have any holding registers available, but the replies will then be exception responses and the functions you use will then return an error looking like this (create an indicator within the loop to see it imemdiately):
 

Error -389112 occurred at an unidentified location

Possible reason(s):

LabVIEW: (Hex 0xFFFA1008) The Modbus slave does not accept the data address contained in the query.
Function 3

c) Why two Modbus master connections to the same device? It might support it, but during troubleshooting I would remove the second loop and focus on getting one working.

Edited by Mads
Link to comment

Mads,

Thanks for your help.  Wouldn't the software read the register specified by the starting address whether it was an input register or holding register?  Or is there some built-in protocol that would get confused?

Link to comment
5 minutes ago, BeeEyeBye said:

Mads,

Thanks for your help.  Wouldn't the software read the register specified by the starting address whether it was an input register or holding register?  Or is there some built-in protocol that would get confused?

Input registers are a totally different entity than holding registers and the Modbus protocol uses different function codes to read them. And a third function code to write to the holding registers. The LabVIEW VIs hide this function code from the user but you have to use the correct read function to cause the correct registers to be read.

Link to comment

Rolf,

Thanks for your help.  I switched the Master Holding Register Read to a Master Input Register Read but still get nothing.  The slave doesn't seem to care about the unit id.  Qmodmaster returns data whether the unit id is 0, 1 or 2.  Address hex 100 works well for Qmodmaster so I used 256 decimal in Labview.  Tried 100 hex also, just in case.  I'm wondering if Labview is finding its way out of the computer at all.  There are no messages and no data.  The register value window is greyed out.  The DATA TYPE tab is greyed out on the Properties window.  Any thoughts?  Thanks for your help.

 

Link to comment
1 hour ago, BeeEyeBye said:

Rolf,

Thanks for your help.  I switched the Master Holding Register Read to a Master Input Register Read but still get nothing.  The slave doesn't seem to care about the unit id.  Qmodmaster returns data whether the unit id is 0, 1 or 2.  Address hex 100 works well for Qmodmaster so I used 256 decimal in Labview.  Tried 100 hex also, just in case.  I'm wondering if Labview is finding its way out of the computer at all.  There are no messages and no data.  The register value window is greyed out.  The DATA TYPE tab is greyed out on the Properties window.  Any thoughts?  Thanks for your help.

 

What error code does the Modbus VIs return, if any?

Can you try it towards a local Modbus TCP server/simulator, does that work better? Can you temporarily disable the firewall?

I used your code as it was, just changed the IP, and it connected immediately to my local Modbus server and was able to read the registers, I also changed the addresses out of that server's range to verify that I got the expected exception response/error I showed earlier.

If you can install Wireshark I would use that to sniff and compare the traffic from the LabVIEW code with the one you generate with Qmodmaster (post the Modbus traffic here and we can decode, Wireshark can help you as it is able to decode Modbus too).

Edited by Mads
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By Porter
      View File Plasmionique Modbus Master
      This package contains the Plasmionique Modbus Master library for LabVIEW.
      It supports RTU, ASCII and TCP modes with the following function codes:
      0x01 - Read Coils
      0x02 - Read Discrete Inputs
      0x03 - Read Holding Registers
      0x04 - Read Input Registers
      0x05 - Write Single Coil
      0x06 - Write Single Register
      0x07 - Read Exception Status
      0x0F - Write Multiple Coils
      0x10 - Write Multiple Registers
      0x16 - Mask Write Register
      0x17 - Read/Write Multiple Registers
      0x2B/0x0E - Read Device Identification
      Other features include:
      - Sharing a COM port across multiple Modbus sessions using VISA locks (10 second timeout).
      - Sharing a Modbus session across multiple communication loops.
      - TCP transaction ID handling to ensure that requests and responses are matched up correctly in case responses are received out of order.
      - Modbus Comm Tester, available through the "Tools->Plasmionique" menu, for testing communication with a slave device without writing any code. 
      - Detailed help document available through the "Help->Plasmionique" menu.
      Examples are included in "<LabVIEW>\examples\Plasmionique\MB Master\":
      MB_Master Comm Tester.vi: Demonstrates usage of API to open/close connection and communicate with a Modbus slave device. MB_Master Multiple Sessions.vi: Demonstrates usage of API to open concurrent Modbus sessions. MB_Master Simple Serial.vi: Demonstrates polling of a single input register over serial line. Download a copy of the user guide here: MB_Master - User Guide.pdf
      Note that Version 1.3.4 of this library has been certified compatible with LabVIEW and has been released on the LabVIEW Tools Network: http://sine.ni.com/nips/cds/view/p/lang/en/nid/214230
      The most recent version of this library will always be released on LAVA first before going through NI's certification process.
      ***This project is now available on GitHub: https://github.com/rfporter/Modbus-Master
      Submitter Porter Submitted 04/01/2016 Category LabVIEW Tools Network Certified LabVIEW Version 2012 License Type BSD (Most common)  
    • By Porter
      This package contains the Plasmionique Modbus Master library for LabVIEW.
      It supports RTU, ASCII and TCP modes with the following function codes:
      0x01 - Read Coils
      0x02 - Read Discrete Inputs
      0x03 - Read Holding Registers
      0x04 - Read Input Registers
      0x05 - Write Single Coil
      0x06 - Write Single Register
      0x07 - Read Exception Status
      0x0F - Write Multiple Coils
      0x10 - Write Multiple Registers
      0x16 - Mask Write Register
      0x17 - Read/Write Multiple Registers
      0x2B/0x0E - Read Device Identification
      Other features include:
      - Sharing a COM port across multiple Modbus sessions using VISA locks (10 second timeout).
      - Sharing a Modbus session across multiple communication loops.
      - TCP transaction ID handling to ensure that requests and responses are matched up correctly in case responses are received out of order.
      - Modbus Comm Tester, available through the "Tools->Plasmionique" menu, for testing communication with a slave device without writing any code. 
      - Detailed help document available through the "Help->Plasmionique" menu.
      Examples are included in "<LabVIEW>\examples\Plasmionique\MB Master\":
      MB_Master Comm Tester.vi: Demonstrates usage of API to open/close connection and communicate with a Modbus slave device. MB_Master Multiple Sessions.vi: Demonstrates usage of API to open concurrent Modbus sessions. MB_Master Simple Serial.vi: Demonstrates polling of a single input register over serial line. Download a copy of the user guide here: MB_Master - User Guide.pdf
      Note that Version 1.3.4 of this library has been certified compatible with LabVIEW and has been released on the LabVIEW Tools Network: http://sine.ni.com/nips/cds/view/p/lang/en/nid/214230
      The most recent version of this library will always be released on LAVA first before going through NI's certification process.
      ***This project is now available on GitHub: https://github.com/rfporter/Modbus-Master
    • By Porter
      NI Labs Modbus API is now on GitHub!
      Password protection of VIs has been removed.
      https://github.com/NISystemsEngineering/LabVIEW-Modbus-API
    • By ensegre
      This is a DSC module question: has anybody here experience with building standalone executables which include shared variables bound to DSC modbus i/o servers? I have an issue with deployment, possibly related to licensing. I posted on the dark side, but haven't got feedback yet.
      https://forums.ni.com/t5/LabVIEW/shared-variable-bound-to-Modbus-i-o-not-working-in-deployed/td-p/3809801
      TIA, Enrico
    • By daoudi
      Hi,
      How i can to send the data through modbus TCP/IP (behavior of a PLC) and receive the data in other client computer with ( station , I/O ADRESSE)
      can you send me an example for this operation please.
       
      Thank you for your help.
       
       
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.