LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Breaking the execution in the attcahed VI

Hello everyone,

 

i am currently working on a pattern matching project using Labview.

 

i have two boolean controls in it , one is a SYSTEM START button and the other is a OTP GENERATOR button. The SYSTEM START button is used to run the template code and the other is used generate a random number with every click of the button. for that i have changed the mechanical action of the OTP GENERATOR Boolean control to SWITCH UNTIL RELEASED.

 

My issue is that i cannnot operate both the boolean controls at the same time . if my  SYSTEM START button is on then the OTP GENERATOR Button take a long time to run which is not my requirement.

 

i have even tried using a Global variable but the problem persists 

 

Please help me two operate both the boolean controls simultaneously 

 

Regards

 

Jalashwa

 

 

0 Kudos
Message 1 of 9
(3,064 Views)

Hi Jalashwa,

 

how do you run your VI when there is no while loop used?

Best regards,
GerdW


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

As Gerd already mentioned, you need while loops. Run each independent code part in its own while loop and they will not interfere. Learn about design patterns, though and some other basic programming rules. Use a UI loop for user interaction and a consumer loop for parallel background tasks.

 

Also note that you could run your three sequence frames in parallel, better utilizing all available CPU cores. The sequence structure forces sequential operation, which is inefficient..You could also use a parallel FOR loop for the mathcin operations (assuming the image tools are reentrant)..

Message 3 of 9
(3,050 Views)

dear altenbach and gerd,

 

thanks a ton!!!!!

 

i was earlier using the run continously button to operate the vi.

 

i have made the correction in the vi as you suggested and it is now working fine.  Replacing the sequence structure also seems to be a brilliant suggestion. i shall work on it.

 

I need one more favour, i want the vi stop working when i feed in value to the control x2. Further , i want the START LED to switch off as well. 

 

i made some modifications in the vi . 

 

Your ideas to improve the vi are welcome.

 

 

Thanks again 

 

Regards

 

JALASHWA

0 Kudos
Message 4 of 9
(2,997 Views)

You code is still overly convoluted.

 

Upper loop:

  1. If the OTP generator is FALSE, the loop spins as fast as the computer allows, millions of times per second, occupying a CPU core 100%. the wait needs to be outside the case (for better response, make it smaller, e.g. 100ms).
  2. Keep number in a shift register instead of a local variable.
  3. Use an event structure with 3 events: OTP, x2, system stop value changed. Now the loop does not spin at all unless needed. (no wait required anymore).

Lower loop:

  1. Also consumes 100%  CPU while doing nothing except monitoring the start and stop buttons.
  2. You still have not parallelized the code. All three sequence frames can operate in parallel because none of the frames depend on each other.
  3. If you would place the "Start" terminal after the case structure, you would not need the local varaible in the FALSE case.

@Sindhurakshak wrote:

I need one more favour, i want the vi stop working when i feed in value to the control x2. Further , i want the START LED to switch off as well. 


You cannot interrupt the VI while it is busy running a subVI (unless the subVI is designed for it). It will only react to the user next time the control is encountered. How long does each analysis take? You should still have a look at established desing patterns, such as state machines. Have a look at consumer/producer designs.

 

Message 5 of 9
(2,982 Views)

Mr Christian Altenbach,

 

i thank you from the bottom of my heart for your analysis of my vi. It is a great learning  experience for me . i hope i can learn more from you in the days to come.

 

The suggestions you have prescribed need through analysis and some more digging into LabVIEW.

 

I request you to give some more time so that i can change the VI. I will post  the updated VI soon .

 

I hope you will help me out if i fall into more trouble.

 

Thanks again 

 

With Warm Regards

 

JALASHWA

 

 

 

0 Kudos
Message 6 of 9
(2,953 Views)

altenbach,

 

as advised by you i am working on converting the sequence structure into parallel loops.

 

i did run the vi and i found out that it takes longer and most of the times the result is not accurate.

 

i have attached the vi . i will be delighted if you could have a look at it.

 

with warm regards

 

JALASHWA

0 Kudos
Message 7 of 9
(2,914 Views)

PS: i have also tried it with  a for loop but no luck with that with that as well 

0 Kudos
Message 8 of 9
(2,908 Views)

As I said, I don't have IMAQ, so there might be issues with reentrancies. In what way are the results different?

 

  • You still have completely useless sequence frames cluttering the diagram.
  • You still use 100% CPU while doing nothing. There needs to be a small wait function.
  • You still have a useless local varaible in the false case. If you place the LED after the case structure, you would not need it.
  • The system start button should also be latch action, else you constantly repeat the same heavy computation with the same data. The computation needs to be done exaclty once, and again whenever one of the inputs changes.
  • Same for the stop button mechanical action. Why did you change it from the default latch action to switch action? That decision makes no sense.
  • In what way did you try a FOR loop? 
0 Kudos
Message 9 of 9
(2,886 Views)