From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loops

I have to loops in my program and when I exit the first loop and go into the second loop. Once the second loop executes I want to go back into the first loop and repeat that cycle until I hit a stop button. 

does and one know how to do that or is it even possible? 

thanks 

Tristan 

0 Kudos
Message 1 of 5
(864 Views)

It sounds like you have very little programming experience, so I would recommend you learn more about LabVIEW from here. How to Learn LV

 

When you describe something as going being multiple steps, it sounds like you want to be using a "state machine" architecture.  But before you attempt that, you need to learn the basics about loops.

 

 

0 Kudos
Message 2 of 5
(850 Views)

 

I have attached a picture of my program below, I'm creating Ramping up a signal and a ramping down signal. So far it's working but once it ramps up and down I can't get it to ramp back up automatically I have to restart the programme. I'm only new to LabVIEW and to programming. Any suggestions or point me in the right direction? would be great! 

thanks 

0 Kudos
Message 3 of 5
(838 Views)

Well, you could put a while loop around the entire code.  That isn't what I would do, but it would do exactly what you described in your original post.

 

A tip:

That initialize while loop with a start button in it.  We call that a CPU burner.  It will run as fast it possibly can just polling the start button.  You might have noticed your PC's fans ramp up to the speed of a jet engine until you hit the start button.  Put a small wait function inside that loop.

 

0 Kudos
Message 4 of 5
(828 Views)

As has been said, you need exactly one loop and a case structure containing one case for each of the three states.

 

  1. Wait for start (with a reasonable delay. No need to read the button millions of times per second).
  2. Run code currently inside loop of second frame
  3. Run code currently inside loop of third frame

 

Use a shift register for the count to disconnect from the iteration terminal and start counting from zero again when states change. Delete the sequence structure. Give your terminals reasonable names, your output is typically NOT a "number (0 to 1)", etc. Use a shift register to keep track of the current state and increment if needed.

0 Kudos
Message 5 of 5
(801 Views)