Jump to content

LabVIEW Modbus


Recommended Posts

Hi,

So my task is to read the status registers of the PLC using RS485 Modbus. I tried out it in a different software called Modbus poll. First I configure, that is give the type of connection which is Modbus RTU, then the COM port, baud rate, data bits, parity, flow control and then device id. Then I give the command as read holding registers from address 0 to a length of 10. Then I click ok and I will get the output  that is the value in address 0 till length of 10.  Next I tried in labview. In labview I use create serial master and I give the same values that is COM port, baud rate, device id, Modbus RTU connection, parity and flow control, then I use read holding register and give the start address of 0 and length of 10. In the Modbus poll I will get the output which is an array of 10 values and each value will be different values accordingly, for e.g. the first value in the array will be 7, whereas when I tried in labview all I am getting is a single value array and that too the value is 0 and not 7. 7 is the correct value which I am expecting. I have attached the screenshot of my program. Can you please help me what is my mistake? I am doing the same thing in labview as in the other program. So why am I not getting an output. I am also not getting an error. Kindly help me. 

IOeco RS485 error.jpg

Link to comment

I just used a different modbus library but the same program that is configure and read. But now I am getting a error at modbus read holding registers. The error is -1073807339 , VISA Read in MB Master.lvlib:MB_ADU_RTU.lvclass:RX ADU.vi:1->MB Master.lvlib:MB_Master_Serial.lvclass:Querry.vi:1->MB Master.lvlib:Read Holding Registers.vi:1->Untitled 2. Can anyone help me what is the reason of this error. I have attached a new screenshot of program and the error. Here no output is also coming. Onyl error. Kindly do help me. 

Thank you. 

Modbus Read Error.jpg

Link to comment

It's been a while but when using the NI Modbus library I found there was some weirdness regarding what the base of the system is. This might just be my misunderstanding of Modbus but for example to read a holding register that was at address 40001 I would actually need to use the Read Holding Register VI with an address of 1 (or 0).

This snippet works fine for reading multiple registers, but see the VI I had to write on the left to do the register address translation.

image.png.a4ab6562e328421e8ba9571fb55f07e1.png

 

image.png.6d2fae723c3914e26635ac7754f8fcc1.png

Link to comment
2 hours ago, govindsankarmr said:

The error is -1073807339 , VISA Read in MB Master.lvlib:MB_ADU_RTU.lvclass:RX ADU.vi:1->MB Master.lvlib:MB_Master_Serial.lvclass:Querry.vi:1->MB Master.lvlib:Read Holding Registers.vi:1->Untitled 2. Can anyone help me what is the reason of this error.

Here is some information about this error: VISA Error -1073807339 (0xbfff0015) Timeout Expired Before Operation Completed - National Instruments (ni.com)

There could be many reasons for a timeout error. The error message only indicates that a timeout occurred before a reply was received, which is not very useful. NI IO Trace might give you some additional clues.

Maybe put the master in a shift-register on your while loop. Not sure if that makes a difference.
image.png.feb9eeba807a99128c7da381aff56ea5.png

1 hour ago, Neil Pate said:

It's been a while but when using the NI Modbus library I found there was some weirdness regarding what the base of the system is. This might just be my misunderstanding of Modbus but for example to read a holding register that was at address 40001 I would actually need to use the Read Holding Register VI with an address of 1 (or 0).

This is specified in the Modbus Application Protocol, although implementations vary between 1-based and 0-based. The mapping of addresses is typically resolved internally.

Quote

The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore registers numbered 1-16 are addressed as 0-15.

-- MODBUS Application Protocol 1 1 b

 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

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