LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to comminucate with multiple PLCs with Modbus TCP/IP using dynamic multithreads?

I have an application in which I communicate with several PLCs using MODBUS TCP/IP toolkit. There is an array of IP addresses that the user can configure. Using for loops allows to work with this however if one PLC is out, the program waits for the timeout before polling the next PLC. I would like to use a multithreading type in order that all PLCs are polled at once and is not dependent of each other. In other words, I would like to dynamically simulate several while loops happening at the same time. Is this possible?

 

 

Thanks

arikb

0 Kudos
Message 1 of 4
(2,822 Views)

Hi arikb,

 

Why don't you put the code into a subVI and have each iteration of the loop call the subvi. Make sure you set it as a reenterant VI (VI Properties>>Execution).

Hope that helps.

 

Flash

National Instruments
Applications Engineer
0 Kudos
Message 2 of 4
(2,807 Views)

Thanks A_Patel,

 

I thought of doing that but do I need to run this as a VI server in that case? How would I pass inputs and outputs of the subvi?

 

Appreciate the help,

arikb

0 Kudos
Message 3 of 4
(2,804 Views)

arikb wrote:

Thanks A_Patel,

 

I thought of doing that but do I need to run this as a VI server in that case? How would I pass inputs and outputs of the subvi?

 

Appreciate the help,

arikb


 

Take a look at my Nugget on dynamically creating occurences found here.

 

Just ignore the Occurence stuff and the rest of the code and verbage should help you. The example code creates a bunch of background processes and passes a unique parameter to each.

 

Have fun,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 4
(2,797 Views)