LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RS485 communication

Hope anyone can assist me. 

I am struggeling to find out how to create modbus rs485 communication. I have a need to gather data from a slave instrument, do some calculations on these measurements and pass on the results to a client interface. So first to gather the instrument data my program needs to be the master as the instrument is slave, but afterwards my program must be slave to pass on the finished data to the client PLS interface. 

 

Can anyone help me with how to set up my program to be both a master and a slave at the same time (but on different com ports.)

 

 

0 Kudos
Message 1 of 9
(2,440 Views)

@KRT123 wrote:

Hope anyone can assist me. 

I am struggeling to find out how to create modbus rs485 communication. I have a need to gather data from a slave instrument, do some calculations on these measurements and pass on the results to a client interface. So first to gather the instrument data my program needs to be the master as the instrument is slave, but afterwards my program must be slave to pass on the finished data to the client PLS interface. 

 

Can anyone help me with how to set up my program to be both a master and a slave at the same time (but on different com ports.)

 

 


There is a free Modbus library for LabVIEW that takes care of a lot of the "hairy details" of the Modbus protocol.

 

EDIT: I just re-read your post and since you are using two com ports I see no problem with opening up a session as Master on one com port and another session as Slave on a second com port using the library I linked to.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 9
(2,410 Views)

Can the PLS interface not directly be the master and communicate to the slave instrument.

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 9
(2,408 Views)

Hello! 

 

Several instruments are connected up towards the pc running labview. Data coming from the instrument is raw data and need signal processing before being combined to get the final results to be sent to the client PLS. So the PC running labview has several slave instruments and also it self need to be a slave towrards the client. 

0 Kudos
Message 4 of 9
(2,383 Views)

I see no reason that you would not be able to do this. I would recommend parallel loops for your various tasks. One task would be your master task which will read the data from the devices. The other task will be your slave task which will allow the upstream process to read the resulting data. Use a queue or notifier to transfer the data from your master task to your slave task.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 9
(2,374 Views)

Hello! 

 

The solution you describe is what I am looking for and have been trying to find out. I am using the plasmionique and have the master communication to the slave instrument up and running. But the plasmionique library does not have support for being a slave as far as I understand. 

Can you tell me which library to use and are you also able to give me an example of how to use this? This will help out a lot. 

 

Thanks

0 Kudos
Message 6 of 9
(2,331 Views)

The free library linked by RTSLVU does support slave mode. If I remember well, it contains example code.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 7 of 9
(2,326 Views)

There is a free Modbus library for LabVIEW that takes care of a lot of the "hairy details" of the Modbus protocol and supports Modbus Master and Slave modes.

 

In my application I use Modbus Master and have 12 Modbus devices on the bus. So I made a sub VI and put it in a For Loop.

 

mb1Capture.PNG

 

Inside my Initialize Serial Master VI is the Modbus library I linked to

MB2Capture.PNG

 

Initializing a Modbus Slave instance would be exactly the same except you would change the Polymorphic Modbus VI to New Serial Slave

mb3Capture.PNG

 

When it comes to getting data I again since I have 12 devices on the bus made a sub-vi and put it in a For-Loop. I used an Enumerated Type-Def to select the measurements I am interested in.

 

mb4Capture.PNG

 

Inside my "Get Primary Measurements" Vi

mb3Capture.PNG

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 9
(2,313 Views)

I tried it out and it worked perfectly. 

 

Thanks a lot for all your help.

Message 9 of 9
(2,272 Views)