NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithreading/Parallel Testing/Run VI Asynchronous

Hello, hoping someone can give me some guidance...

 

Here is my situation...I need to run a VI continuously through the entire test to maintain communications with the UUT while taking measurements at different points. I also need to be able to change the inputs to the continuously running VI along the way to change outputs I'm measuring.

 

So, my first question...is it possible to do that solely in TestStand? I tried to put the continuously running VI in its own subsequence and putting that on a different thread, but the sequence freezes once it gets to that VI because it never ends.

 

I'm making progress with getting it to work running it Asynchronously, but changing the inputs while it's running has been a little challenging. I'm using a VI that gets called when I need to make the changes in TestStand that uses a global variable in LabView to pass data to the continuously running VI.

 

Just wondering if I'm on the right track or if there is a simpler, more direct way to go about this.

 

Thanks,

 

Luke

0 Kudos
Message 1 of 7
(5,477 Views)

Hey lbounds,

 

I've found an example that may be helpful to you:

https://decibel.ni.com/content/docs/DOC-34743

 

 

Also, it may be better to use queues instead of global variables to avoid race conditions:

http://www.ni.com/example/30108/en/

https://decibel.ni.com/content/docs/DOC-16854

Libby B.
Applications Engineering Specialist - RF Wireless
National Instruments
0 Kudos
Message 2 of 7
(5,424 Views)

Hi Luke,

 

Trying to understand this " I tried to put the continuously running VI in its own subsequence and putting that on a different thread, but the sequence freezes once it gets to that VI because it never ends."

This should have worked.Let me explain.

 

Your test sequence has a main sequence (with all tests) and a sub sequence (which has this looping vi).

So your main sequence looks like this :

Main Sequence :

  Run the sub sequence in a new thread.

  Test 1

  Test 2

   ....end

 

The sub sequence now runs in a new thread running the looping vi.

The main thread continues execution and not wait for the sub sequence to complete.

 

Few things which you need to consider :

 

1) By default the call sub sequence in a new thread is set to wait for the thread to complete i.e. the main sequence completes executing the steps and waits in the end for this sub sequence to end. So you need to communicate back to the thread about main sequence completed so that the VI execution ends.

 

2) You can check for queues and notification to pass data between threads.You can also use fileglobals but ensure that it should not be simultaneously accessed by both thread and main sequence.It can be done using locks step type.

 

Hope this helps.

 

Ravi

 

 

 

Message 3 of 7
(5,406 Views)

you will be surprised with what can you do in teststand.

 

 

I had a Similar situation where i needed to perform some actions while acquiring data from teststand.

 

I had a device that brodcasts udp messages all the time. the message will have value of some variables that will change when i press a button or a switch on my device.

 

What i did on this situations is:

 

i launched sequence in a new thread. In that sequence i had a VI continiously reading that information and passing that to a FileGlobal container aka cluster.

 

On my Main test i would read the values of the file globals for verification.

 

I think you sequence is freezing because  you are not terminating the thread when the main sequence finishes and teststand is still running the VI. You will need to add a notifier to let know that thread that the program is done and the program can finish.

 

 

CLAD, CTD
Message 4 of 7
(5,402 Views)

Thanks for the replies....what you both said makes sense, and is what I thought should work, but I must be missing something because it still won't work.

 

Let me describe what I'm trying to do a little better...

 

So, I have a VI that is in its own subsequence and set to run on its own thread. The VI itself is sending serial messages to the UUT so that it maintains communications throughout the whole test. The way I have this working is by putting the transmit part of the VI in a While loop that runs until I tell it to stop (Boolean control) or if an error occurs. So the VI is truly running continuously throughout the test. I think that may be the problem because this is what I'm seeing...the test sequence runs the subsequence and stalls out before running the next step.

 

From what I'm gathering from the replies here is that I need to have the VI transmit once on each run, end, and then loop the VI (instead of doing an internal loop) so that it runs one time after the other. Is that correct?

 

 

 

0 Kudos
Message 5 of 7
(5,395 Views)

could you post your sequence file.. that will give us a better idea...

CLAD, CTD
0 Kudos
Message 6 of 7
(5,392 Views)

Ok, so I have the new thread working in parallel with main sequence...but don't ask me how, it just started working like everyone said (and how I thought) it should work. I appreciate all the help!

 

While this thread is still fairly recent, I do have a follow up question...

 

So now I have this continuously running VI in a different thread and I need to pass data to it. Specfically, I need to pass numbers to the inputs of the VI that correspond to different message ID's and data that I need to change throughout the test sequence. The way I thought would work was to tie the inputs of the VI to File Globals and use expressions in the main sequence to change them. This works for an initial set when the new thread is first executed but doesn't work to update while the VI is running (ie the entire point of the test). I have the inputs inside the While loop that is making my VI continuously run so I thought it would look for the FileGlobal definition at every iteration, but that's not happening. As it's set up now, both threads are using the same resource (the file global), but I thought it would be fine because one is only writing and the other is only reading. Either way, it isn't working...

 

So, the question is- what is the best way to pass this type of data to my continuously running VI? I saw the comment about using queues and notifications, but unless I'm not just understanding it right, it looks like those are usually set up for one thread to wait until it is told to dequeue or go get the new info. That doesn't seem like it will work because I can't stop my VI to re-load the data. Am I understanding that right?

 

Also, I did try linking Globals from TestStand to Labview through a VI sent to me from someone at NI. Again, this worked for the initial set, but won't update while the test sequence is running and changing the globals.

0 Kudos
Message 7 of 7
(5,366 Views)