LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuously running a subprogram with the main program

Hi all,

 

I am trying to build a LabVIEW application where I want a small part of the program to continuously run irrespective of whether the program is running or stopped.

 

It is something analogous to have a time clock that starts ticking when the LabVIEW application is opened until it is closed. The program will have a run (Xcontrol) button that allows the main part of the program to start, and stops when the required acquisition is completed. I may also have to use the run button multiple times for successive acquisitions. All this while I want the clock to keep displaying time.

 

I have been using two different programs - one the main part and the second the clock part, frequently switching between the two. I wanted to combine it into a single program and later into an application.

 

The actual program is not concerned with the clock. The clock is just an example. I am using LabVIEW 2021 community version.

 

Thank and Regards,

Pradeep.

0 Kudos
Message 1 of 13
(356 Views)

It would be a lot easier to help you if you could share some code. There are multiple ways to do this, but the easiest transition will depend upon how your current code is written. 

 

What you are trying to achieve is common, by the way, so easily achievable.

0 Kudos
Message 2 of 13
(341 Views)

Dear johntrich1971,

 

Thank you for your reply.

 

I have attached two programs. The main VI - Zscan 2.0.vi and the subprogram Bmean.vi

It was my usual practice to check for the Bmean value (laser intensity) in Bmean.vi to be constant for a few seconds and choose that value for the filename in Zscan 2.0.vi and run it. When both programs are combined, I thought it would be better if the Beam is continuously captured so that I can vary the intensity of laser (for each experimental run) to the desired value and continue with my acquisition.

 

Regards,

Pradeep.

Download All
0 Kudos
Message 3 of 13
(314 Views)

Thanks for uploading these. Unfortunately I can't open them because I am still using LabVIEW 2019. Could you backsave to LabVIEW 2019 or earlier? This is usually good practice when uploading to the forum as many forum users do not use the latest LabVIEW version.

0 Kudos
Message 4 of 13
(309 Views)

Hi pclab,

 

it would help when you convert your VIs to LV2020 or LV2019 as already requested by John. I could open that Bmean VI:

 

I would simplify it like this:

 

You should be able to run that VI in parallel to your other VI. You "just" need to add some notifier/queue to transfer the Bmean value to your other VI…

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
Download All
0 Kudos
Message 5 of 13
(293 Views)

Hi John and Gerd,

 

Thanks for notifying me. I will keep in mind to upload the previous version hereafter.

 

I have uploaded the requested files.

 

@Gerd: The B value (laser intensity) is acquired every 0.1 seconds. To have a good look at the value I average 10 to 15 laser pulses. Yet there will be some variations. like 30 +/- 3. So again I have to make a vague approximation. (I don't want to increase the averaging samples, then I have to wait too long to know the intensity when I am varying it). I have to know this value before running the actual program so that I can enter the value in the filename for my reference. 

That is why I wanted to run Bmean part continuously or independently with respect to the main program.

 

Thanks and Regards,

Pradeep.

0 Kudos
Message 6 of 13
(281 Views)

Hi Pradeep,

 

Please us zip files instead of rar files when uploading. I understand that rar has some advantages, but many of us only have the ability to use the built-in zip  application.

0 Kudos
Message 7 of 13
(268 Views)

@pclab wrote:

 

The B value (laser intensity) is acquired every 0.1 seconds. To have a good look at the value I average 10 to 15 laser pulses. Yet there will be some variations. like 30 +/- 3. So again I have to make a vague approximation. (I don't want to increase the averaging samples, then I have to wait too long to know the intensity when I am varying it). I have to know this value before running the actual program so that I can enter the value in the filename for my reference. 

That is why I wanted to run Bmean part continuously or independently with respect to the main program.

 


Running the code in parallel is not an issue. Where you have the issue is that you need to structure the code in the Zscan file to run continuously but be in standby mode except when you press a button.

0 Kudos
Message 8 of 13
(263 Views)

@John: Please find the zip file in the attachment.

0 Kudos
Message 9 of 13
(255 Views)

A built application should never be stopped, so all you need is a simple state machine that goes to an idle state polling the start button (for example). Having a self-start x-control is a horrible kludge that should never (never!!!) be used!

 

(Sorry for starting all this mess in 2009!! It was meant as a demonstration that it can be done, but should never be used in a real application!)

 

Once you have a proper state machine, you can place the permanently running VI outside the toplevel loop so it starts when the VI is run. Make sure there is a mechanism to stop everything at the end.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 10 of 13
(238 Views)