LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execute Task before While loop executes

Could someone help me figure out a way to ensure that something executes before
a while loop executes?  After someone presses a stop button, I need a couple of
DAQmx tasks to execute before the while loop exits.  I tried to place the stop
button for the while loop in a case structure, but that did not work.

0 Kudos
Message 1 of 10
(3,800 Views)

Hi dubs,

 

figure out a way to ensure that something executes before…

THINK DATAFLOW! 😄

DATAFLOW dictates the execution order, so just obey it!

 

Maybe it's easier to answer when you would attach your VI!?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,789 Views)

Hi GerdW,

 

Attached is a screenshot of the relevant part of the block diagram.  The only way I could think to incorporate data flow would be to put the stop button in a structure, and wire the error from one of the DAQmx tasks into it.  However, this does not seem to work.

 

Thanks,

 

Alexis

0 Kudos
Message 3 of 10
(3,781 Views)

Hi dubs,

 

The only way I could think to incorporate data flow would be to put the stop button in a structure, and wire the error from one of the DAQmx tasks into it

This way you produce a circular reference!

Your stop button is read to generate this boolean input into the DAQmx functions, but the output of those functions should be used to enforce dataflow to read the stop button???

 

Please clarify your algorithm behind all this!

When should the button be read? Before or after those DAQmx functions?

(You might solve that problem using a shift register/feedback node…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(3,770 Views)

I apologize for my lack of clarity in the previous post.

I would like the following to happen:

When someone presses the "Stop Pumps and End Data Collection" Boolean control, I would like the following to happen in the following order:

1. Both Digital Bool DAQmx tasks execute

2. True is written to the loop condition, which will cause the while loop to execute.

0 Kudos
Message 5 of 10
(3,748 Views)

Hi dubs,

 

both items are done according to your image.

But I cannot say WHEN this will be done as you only posted a small portion of your whole VI.

 

There's a reason why we often ask for full VI attachments instead of small images…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(3,741 Views)

@dubs.a wrote:

I apologize for my lack of clarity in the previous post.

I would like the following to happen:

When someone presses the "Stop Pumps and End Data Collection" Boolean control, I would like the following to happen in the following order:

1. Both Digital Bool DAQmx tasks execute

2. True is written to the loop condition, which will cause the while loop to execute.


Judging from your description and you need to modify your (also judging from your description since you haven't attached any code) "One big loop" architecture, and use a proper program architecture like a State Machine.

 

That way when someone presses the button it goes to the state to execute both DAQmx tasks and stops the program. (I am guessing a safe shutdown)

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 10
(3,739 Views)

I apologize as I thought that a screenshot of the relevant code would be more helpful than a VI.  I have attached the VI in question.

0 Kudos
Message 8 of 10
(3,730 Views)

I have found a typo in my previous post.  The following is what I meant to type:

 

I apologize for my lack of clarity in the previous post.

I would like the following to happen:

When someone presses the "Stop Pumps and End Data Collection" Boolean control, I would like the following to happen in the following order:

1. Both Digital Bool DAQmx tasks execute.

2. True is written to the loop condition, which will cause the while loop to exit.

0 Kudos
Message 9 of 10
(3,727 Views)

OMG, I was right...

 

You need to scrap that whole thing and start over using a proper programing architecture like a State Machine.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 10
(3,725 Views)