LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create thread dynamically ?

Hi everyone,

I m using LV 8.2 or 8.5 and NI-VISA 4.1.
Several serial ports are emulated on my PC with USB-Serial cables. Then boxes which will be under tested are connected to those serial ports.
The first thing which must be done is to send a command when they are switched on at the same time. Therefore, I use multi-thread application with reentrant VIs. But we don't know how many serial ports are emulated and we don't want to limit the number of serial ports.

Have you got any idea about how to dynamically create thread and get thread ID (one thread by serial port) ?

Many thanks for your answer and for your help.

0 Kudos
Message 1 of 12
(5,010 Views)

Hi Zaboulou,

one way could be to create a vi template. This template can be start so often you need it.

Mike



Message Edited by MikeS81 on 02-12-2008 03:41 AM
0 Kudos
Message 2 of 12
(5,003 Views)
Thanks for your answer.
But if I use a VI template, I guest I need a For loop to start each instance. No delay should be introduced.

In attached llb, maximum number of serial ports is 4. But I want any number limitation.

Regards,
0 Kudos
Message 3 of 12
(4,986 Views)

Hi Zaboulou,

i think you need a loop. But you can do it in this way:

  1. create all instance of the vi you need
  2. configure each of them with the right COM Port and what else
  3. each instance wait for a notifier
  4. start each process at same time by using a Notifier which was send from a central point

By using something like this you can create all process in a while or for loop and anyhow all start at the same time.

Mike

0 Kudos
Message 4 of 12
(4,983 Views)

Hi Zaboulou

I'm writing because I want to do a similar program and I wondered if you found a solution to connect several devices to the serial ports.

I've been doing some proves using VI from templates but when they are called from the main, they are opened slowly and I don't want that.
I've tried to reduce the size of the templates and change the properties of the subVIs that are included in them but this things don't work.

I hope that you can share the solution if you found it or in other case give some suggestions in order to solve this problem.

Best regards, dtp.

0 Kudos
Message 5 of 12
(4,844 Views)
Hi,

You ll find my solution and I hope it helps.

Zaboulou
0 Kudos
Message 6 of 12
(4,817 Views)
Could u pls post those VIs in 8.2 ? I couldn't open yours as I don't have the version 8.5.. thx
0 Kudos
Message 7 of 12
(4,803 Views)

Hi m_min,

here it is for LV80.

Hope it helps.

Mike

0 Kudos
Message 8 of 12
(4,800 Views)

Thank you. I'm going to check it out

regards, dtp

0 Kudos
Message 9 of 12
(4,765 Views)
Hi Zaboulou,
 
I opened the VIs that you sent me but it seems that a VI is missing, its name is Enter SM.vi and appears in the vit.
Could you send it, please?
 
regards, dtp
 
0 Kudos
Message 10 of 12
(4,749 Views)