NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Running 2 threads in TestStand in Parallel

Hello,
 
I am trying to create a Labveiw Step in TestStand that will run in a parallel thread with the main sequence. The VI will be running in a loop and monitering the 6508 Digital Card for any changes. For example, if I am running a test in the main loop then I should only be expecting outputs 1,2,3 to turn on, however by monitering all the other outputs I want to make sure nothing besides 1,2,3 turned on. If anything other than the intended output was observed onthe digital card then, the VI should set a flag and pass it to my teststand for result recording.
 
I will appreciate any help on this if it is something can be done.
 
Regards,
Ayman
0 Kudos
Message 1 of 9
(9,462 Views)

Hi,

The easies way is to put you labview step in it's own sequence and then call that sequence via a SequenceCall  steptype. You can then set the sequencecall step to run in a seperate Execution or Thread.

In you main sequence you can add a wait step to wait for that new execution / new thread to complete before closing the main executions.

Hope this helps

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 2 of 9
(9,450 Views)
Hi Ayman,

You could also use one of the LabVIEW Utility steps "Run VI Asynchronously" to achieve similar results. One of the options in the configuration of this step is to "Automatically wait for the Thread to Complete at the End of the Current Sequence".

Hope this helps Ayman. Let us know if you have any more questions.
Dan Weiland
0 Kudos
Message 3 of 9
(9,429 Views)

Hello,

I know how to run a sequence in a separate thread, but the tricky part is to constantly update the controls of the second thread while its running in parallel with thread 1. Thread 2 will be running in a loop to monitor a Digital Card. If an unexpected digital output occurs, thread  2 should set a flag and exit execution. Then thread 1 will use that flag to perform a particular task.

I hope this is a better explanation of what I am trying to do.

Regards,

Ayman

0 Kudos
Message 4 of 9
(9,413 Views)
Hi Ayman,

How exactly is Thread 1 going to react to the flag being set by Thread 2? Is it continuously checking this flag or only at the end of Thread 1's execution?

The first thing that comes to mind is using a StationGlobal that both Thread 1 and Thread 2 could reference.

Let me know if this won't work for you. Thanks Ayman.

Dan Weiland
0 Kudos
Message 5 of 9
(9,391 Views)
Hi Dan,
 
I used global variables to pass data back and forth between threads, however the variable will not update on the fly. It waits for the second loop to end before it updates. If I know how to update the inputs and outputs of the VI running in the second thread through the global variable then I will be all set.
 

Attached is an example of what I am trying to do.
 
 
Thanks,
Ayman
0 Kudos
Message 6 of 9
(9,381 Views)

Hi,

Are you expecting to change the values sent to your VI from the data you input in the MessagePopups in the For / next loop.

You will have to pass the SequenceContext to you VI so that you can use the activeX invoke Node and use the GetValNumber() method to pick up the new values from the FileGlobals.

One other thing. If you use the 'Run VI Asynchronously' method then you dont have to put it in a SequenceCall, which has then been set to run in a new thread.

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 7 of 9
(9,373 Views)
Hi Ayman,

You may also use the "TestStand - Get Property Value" and "TestStand - Set Property Value" VIs in your TestStand palette to  get and set values using the Sequence Context.
Dan Weiland
0 Kudos
Message 8 of 9
(9,356 Views)

Thanks Ray,

I used sequence context then invoke node with method GetValNumber, and that worked perfect.

Ayman

0 Kudos
Message 9 of 9
(9,352 Views)