LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reset while loop with time and button?

I am trying to get the while loop to stop and reset with a button or if time runs out. So when I switch the button it should stop the indicator; when I switch the button back on it should reset the time and start reading data again. Likewise, when time runs out it should stop the indicator and I want to flip the switch to start a new run and reset the time again. I have attached my vi for some clearification. If you have trouble understanding please let me know and Ill try and explain more. Thanks.

0 Kudos
Message 1 of 12
(5,996 Views)

I think I figured it out on my own. For anyone wondering, you need to create a separate case structure and while loop for your time controls and indicators/boolean. Then connect each loop with producer/ consumer design and run the boolean to each loop. 

0 Kudos
Message 2 of 12
(5,963 Views)

It doesn't look like you are actually using a producer consumer.  You have a bunch of nested loops.

Have you considered using an event structure with an input wired to the Timeout?  I think it might be more suited to what you are trying to do.

0 Kudos
Message 3 of 12
(5,955 Views)

@Relient wrote:

I think I figured it out on my own. For anyone wondering, you need to create a separate case structure and while loop for your time controls and indicators/boolean. Then connect each loop with producer/ consumer design and run the boolean to each loop. 


NO! Don't add more structures. You already have too many!

 

Your original code is highly flawed and has e.g. way too many stacked loops. Also, the innermost while loop has no purpose. It can only be reached if the case boolean is true, at which case the loop stops after one iteration, same as if you remove the loop.

 

All you probably need is a single outer loop and the "elapsed time" express VI. Try it.

 

(Feel free to show us your final code so we can help improve it)

0 Kudos
Message 4 of 12
(5,948 Views)

I know my program is not efficient at all, Im inexperienced with labview and my company needs it soon so I'm trying to get it out quick. Attached is what I have so far. It is very messy!!  However it is nearly working how we want. The producer/ consumer design is needed because I am implementing this into my other program and each loop  has a different job than the other loops. This is just a mock version as I am trying to figure out the process.

 

The stop buttons aren't needed but the button labeled boolean should reset the time and stop the run. When the run is stopped I want to re-enter a 'test time' and hit the button again for a new run. I just need to be able to reset the original time... Is the producer/consumer the best way to connect while loops because it seems messy?

 

Again sorry if it is hard to follow and if its not the best way to go about it; I'm doing the best with what I know. Thanks for the help.

 

 

0 Kudos
Message 5 of 12
(5,936 Views)

@Relient wrote:

I know my program is not efficient at all, Im inexperienced with labview and my company needs it soon so I'm trying to get it out quick. Attached is what I have so far. It is very messy!!  However it is nearly working how we want. The producer/ consumer design is needed because I am implementing this into my other program and each loop  has a different job than the other loops. This is just a mock version as I am trying to figure out the process.

 

The stop buttons aren't needed but the button labeled boolean should reset the time and stop the run. When the run is stopped I want to re-enter a 'test time' and hit the button again for a new run. I just need to be able to reset the original time... Is the producer/consumer the best way to connect while loops because it seems messy?

 

Again sorry if it is hard to follow and if its not the best way to go about it; I'm doing the best with what I know. Thanks for the help.

 

 


I realize you may need this soon but you will regret it later (or the next person to touch this code) when you need to touch it again. It is overly comnplicated, messy and not very well designed. Doing a bad job quickly is never the right answer. A little extra time spent up front to do it right can save tons more time later on.

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 12
(5,905 Views)

I don't know labview well enough. I'm sure I can make a few things more effecient but like I said I'm inexperienced (still more experienced than the other guys though so I get to work on it). So you saying make it cleaner and have a better design doesn't help much because that is close to the best that I know how to do.

0 Kudos
Message 7 of 12
(5,883 Views)

@Relient wrote:

I don't know labview well enough. I'm sure I can make a few things more effecient but like I said I'm inexperienced (still more experienced than the other guys though so I get to work on it). So you saying make it cleaner and have a better design doesn't help much because that is close to the best that I know how to do.


So are you asking how to do the best with what you know?  Because I believe that you are doing the best you can.

Rephrasing your question: "How do I increase my LabVIEW knowledge so that my code is efficient and maintainable to meet the goals of my company?"

 

NI LabVIEW training is great for that if your company will sponsor it. (Sounds like they should)

The NI Tutorials are also pretty good and cost nothing but time.  (Sounds like you may be short on the time aspect)

Asking questions on the forum is also pretty good as long as the questions are asked with an open mind.

 

Another possible rephrasing of your question would be: "How does my company get this problem solved within their goal timeline?"

There are lots of NI integrators and LabVIEW programming houses/contractors that your company can hire.

 

Generally the forums are focused on learning rather than quick solutions and respondents tend to shut down quickly if they get the impression that the asker is only willing to learn for a specified period of time.

 

That said, posters have made suggestions of things to try.  Have you tried them?  They've already mentioned that your current approaches are not going to be suitable long term.

 

0 Kudos
Message 8 of 12
(5,880 Views)

e creado una programacion donde hago abquision de datos por medio de la DAQ de temperatura, presión, lo e  logrado dentro un while loop., deseo crear un botón reset que deje todos indicadores (numéricos / gráficos) queden en cero y pantalla limpia como lograr esto.???.Ya que que con el botón stop solo se sale y detiene el ciclo pero no me borra los datos... 

0 Kudos
Message 9 of 12
(5,720 Views)

@HELEN13 wrote:

Ya que que con el botón stop solo se sale y detiene el ciclo pero no me borra los datos... 


Please attach your VI.

0 Kudos
Message 10 of 12
(5,702 Views)