10-20-2021 08:08 AM
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.)
10-20-2021 09:09 AM - edited 10-20-2021 09:49 AM
@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.
10-20-2021 09:11 AM
Can the PLS interface not directly be the master and communicate to the slave instrument.
10-20-2021 11:39 AM
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.
10-20-2021 12:28 PM
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.
10-22-2021 03:19 AM
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
10-22-2021 04:02 AM
The free library linked by RTSLVU does support slave mode. If I remember well, it contains example code.
10-22-2021 09:10 AM - edited 10-22-2021 09:28 AM
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.
Inside my Initialize Serial Master VI is the Modbus library I linked to
Initializing a Modbus Slave instance would be exactly the same except you would change the Polymorphic Modbus VI to New Serial Slave
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.
Inside my "Get Primary Measurements" Vi
10-25-2021 12:46 AM
I tried it out and it worked perfectly.
Thanks a lot for all your help.