From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus Labview Program

Solved!
Go to solution

Hi everyone, I have some Modbus Labview program  that controls the heat flow and temperature and I couldn't understand the working principle of that VI. I searched a lot. I look at modbus holding register address formatModbus wiki,MOdbus and etc but I couldn't solve the system. I put the snippet below. Can anybody explain what is the 5,9,11,17 and in the case structure 1,2,3 and 4 stand for? And in create serial master vi, there is parity and flow control part. The 'time left' and 'program' should be indicator but in here it is control. The RS 485 adapter is used. I couldn't understand all of them with respect to the internet pages that I searched. Can anybody give me a detailed explanation?  What do we expect? Thanks in advance.ModbusModbus

0 Kudos
Message 1 of 33
(4,861 Views)

Hi,

 

       Lets break down step by step.

1) Intialise the Connection using COM3.

 Inside the while loop:

2) Read Holding Registers.vi : This subvi is used to read the register information, Well there are 4 Inputs [(connection ref and error ), (Starting Address and Number of registers to read)]. In your program the starting address is '5' and No. of registers to read is '1'. This register mapping should be clearly stated in Manufacturers protocol manual. This register address 5 indicates some variable (eg: Voltage, current, power.....).

3) Write Single Coil.vi : Its a bool Input meaning you are switching something wrt Register address '9'. [This register mapping should be clearly stated in Manufacturers protocol manual.]

4) After this again you reading Holding registers 17 and 11 with same no of inputs. 

Inside the Case Structure:

 5) Here you are writting single Holding register : address is 11 and you are writting 2 registers. The "Numeric" gives input to the case structure. 1,2,3,4 stands for some function inside the case structure. 

 

Note : This is not the effecient way to program. Try to learn some basics and look at some examples. Please read the modbus information here http://www.simplymodbus.ca/FAQ.htm, it simple and gives you a clear picture.

 

If you need any help. Send me the details i can help you.

0 Kudos
Message 2 of 33
(4,829 Views)

Hi jay0909;

Thanks for replying. I see. Thanks for the link. I will search for that. One more thing. What is the parity(odd/even) and flow control (XON/XOFF etc.) in create serial master vi. ?

Sincerely.

0 Kudos
Message 3 of 33
(4,811 Views)

Flow control is probably none.  But that and parity would be whatever your device says it needs to be in the manual.

0 Kudos
Message 4 of 33
(4,806 Views)

Alright then. I will see what happens. Thanks.

0 Kudos
Message 5 of 33
(4,793 Views)

Hi again,

I tried the program but it gives 'Error 56 occured at RTU Data Unit.lvclass:Read ADU Packet.vi:1,

Possible Reason: The network operation exceeded the user-specified or system time limit.'

I found some cases about Error 56 at discussion forum of NI, I tried some of them but they didn't give a solution. I changed the type of flow control but again each case it took the same error. I looked those pages; Error 56 when using TCP readError 56NI forum Error 56 and knowledge error 56 but I couldn't solve the problem. How can I solve it?

Sincerely.

0 Kudos
Message 6 of 33
(4,780 Views)

By the way, I am not communicate with the network. I am using serial connection. The problem is,  I think, with the serial communication, not network but the error comes from there. I have signal converter and using com3. I checked from the device manager from the computer and it says this device working properly. I don't understand. Everything okey but there is an Error 56.

0 Kudos
Message 7 of 33
(4,771 Views)

Hi again 🙂

I can successfully handled with it. I solved the problem. Here this program is for only one slave, but I have 4 slave. I want to see data on each slave and put it into a waveform chart which each of them  comes from different addresses. I put the snippet below which includes the only part of the vi. Only reading the coming datas seperately. How can I find the each addresses/channels?

Sincerely.

diff adress.png

0 Kudos
Message 8 of 33
(4,768 Views)

When you have 4 slaves, you'll have to do 4 different Modbus Reads, one with each of the slave ID's assigned to it.

0 Kudos
Message 9 of 33
(4,753 Views)

Hi,

 

      Did you go through the protocol? Each slave has unique ID so try to communicate one by one first and then try 4 slaves. If you provide me more details i can give you my library which communicates with multiple slaves.

 

 

0 Kudos
Message 10 of 33
(4,738 Views)