LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read multiple slave devices in a modbus RS485 2 wire RTU network without changing slave address manually?

Solved!
Go to solution

Hi,

 

Currently, i can read data off multiple DAQ devices using the attached VI by manually changing the slave address on the front panel which determines which slave to read data from. However, i would like the VI to do this automatically for me instead of me manually clicking the front panel buttons to change the slave address. In other words, the VI should read data off the 3 slave devices and write them to a data base every 1 second (sampling interval of 1 sec). I have tried using case structures, timed sequences and time delays but i am still unable to get what i wanted. My current VI is a modified version of a VI in the modbus library - "MB Serial Master Query Read Input Registers". Any idea how to do this?

0 Kudos
Message 1 of 8
(12,730 Views)
Solution
Accepted by topic author J.R

Im quite new to LabVIEW, so dont kill me if im far off here 🙂

Could replacing the "Serial Parameters" cluster with the attached structure solve this?

The true case will just set the value back to default(1).

 

-Tom

 

0 Kudos
Message 2 of 8
(12,718 Views)

Yes, that could do the job, but instead of doing it in small separate loop, you must do it in a main loop.

0 Kudos
Message 3 of 8
(12,700 Views)

Yes.  The serial parameters cluster that contains the slave address is something you will just programmatically change as needed as opposed to using a front panel control.

 

By the way, you don't need to have 30 copies of the index array.  Create one copy.  Expand the bottom downwards.  It looks like you start at #16, so just wire a 16 at the top, the ones below it will be successively 17, 18, 19.....  If you need to jump to another number, then just wire a constant in for that one.

 

You also have some awkward datatype conversion to the dynamic datatype.  This is going to cause you problems somewhere down the line.  If you want an array from 3 scalars, just use Build Array!

 

 

Message 4 of 8
(12,695 Views)

Hi all,

 

Thanks for the replies, with your help i've managed to get what i wanted. Really appreciate it.

0 Kudos
Message 5 of 8
(12,651 Views)

hey man, how did you make that vi? I need to make a vi that read data from a multmeter that use a modbus-rtu protocol and use a USB to RS-485 converter to communicate to the computer but I don't know how to do that. I have the ni modbus library and dsc library but I don't know how use it. When i connect the converter on my computer that appear as COM4.

0 Kudos
Message 6 of 8
(12,236 Views)

I have 32 Modbus RTU sensors connected to one USB to RS485 converter.

The IDs are from 1 to 32. How can I programmatically select any device without stopping the VI.

 

Thanks for any help.

0 Kudos
Message 7 of 8
(8,936 Views)

Just iterate through them in a loop.

 

When you want to talk to #1, then put one in the slaved address.  For #28, put in a 28.

It is just basic programming concepts.

0 Kudos
Message 8 of 8
(8,932 Views)