LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Modbus

Solved!
Go to solution

I am trying to connect to a Modbus device using create serial master. I know all the parameters like baud rate is 38400, parity is even, flow control is none, serial type is RTU and I also know the COM port for VISA resource name. But what I don't know is Unit ID. I read the help definition of Unit ID and I didn't understand. Can anyone explain to me what exactly is the meaning of Unit ID so that I can ask my colleagues for the value of Unit ID. They know Modbus but don't know labview and I know labview but not Modbus. So if I just ask them what is unit id, then they will not know. I need to explain what it is, and then they can give me the value. Kindly help me. Thank you. 

0 Kudos
Message 1 of 26
(2,442 Views)

Unit ID is a number which identifies the specific device you're communicating to. This number is configured in the device itself.

 

Most of the time I don't think this actually matters, because you're communicating directly with a single device, but if you have multiple devices in an RS485 network, then this ID lets the devices in the network know which device the message was sent to.

 

I think most Modbus devices ignore the ID if they don't need it, but I'm not sure. In any case, it would depend on the specific device.


___________________
Try to take over the world!
0 Kudos
Message 2 of 26
(2,428 Views)

Thank you. Is there a way I can find out this device id in any another way. 

0 Kudos
Message 3 of 26
(2,414 Views)

@govindsankar  ha scritto:

Thank you. Is there a way I can find out this device id in any another way. 


If not documented, it's most probably 1.

You may also write a small test program iterating queries from 1 to N and see which is the successful one.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 26
(2,403 Views)

Thank you, I got it. So my task is to read the status registers of the PLC using RS485 Modbus. I tried out it in 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. 

0 Kudos
Message 5 of 26
(2,386 Views)

Could someone help me what could be wrong. What is my mistake which I explained in the above paragraph. Thank you. 

0 Kudos
Message 6 of 26
(2,334 Views)

I never used this Modbus library so I cannot help you much.

However, I see in your picture that member Read Holding Registers is called on the BD, while the warning on the FP refers to Write and Read Multiple Holding Registers, which is called by 24DIO.vi and not RS485 Checking.vi. Why?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 26
(2,327 Views)

 

Modbus Read Error.jpg

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. 

 

0 Kudos
Message 8 of 26
(2,313 Views)

Hi govindsankar,

 


@govindsankar wrote:

Can anyone help me what is the reason of this error.


Right-click the error cluster border and select "explain error"! (You should know how to do this from the LabVIEW training…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 26
(2,306 Views)

This the well known timeout error. Help -> Explain Error...

pincpanter_0-1611057997057.png

I'm sure you can get the description yourself sparing time to the other forum contributors...

It only states that there was no answer or (less probably) the answer was incomplete.

There are several possible reasons for that.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 10 of 26
(2,302 Views)