LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pause a while loop with case structure

Sorry in advance for the code filled with flaws, Im new to labview and this is part of my assignemnt (to create a smart house). 

Problem im currently facing is, I have more than 10 fan in for my smart house however the only ways i could think of to make it all run indenpendently was to put it in 2 while loop(bad practice ><). Worst case scenario, due to i need all of the fan to be able to switch on and off by Knob, i need to keep all these (20) loops to keep running.

I did my research regarding using event case and make a string register to pause it with -1, but i have no idea on how to implement it to my scenario. 

my vi file attached below shows how I make it run 

 

what I was expected:

Fan will be off at 0, Speed decresing according to increasing number of knob respectively (i just connect  knob to timer).

 

Please do lend me a hand on the fan =((( This is the only last part im struggling for >< thanks

0 Kudos
Message 1 of 6
(3,975 Views)

use a single loop running at a sifficiently fast rate (e.g. 1ms loop time), then use quotient and remainder of the iteration count and the array of speeds to see which loop needs to advance.

 

Some glaring mistakes:

  • You are abusing while loops as fake FOR loops. Why not use a FOR loop iinstead? You don't really need the inner loops at all, though.
  • If you would place the Fan LEDs outside the case structure, you would not need the local variables.
  • Use integers for the speed. There should be no orange.
0 Kudos
Message 2 of 6
(3,962 Views)

 

Thanks for helping me =)) i realllly appriciate it 😃

I tried to edit the code according to your comment, it works =)) 

however =(, after i set it as 0 to stop it, it will no longer run again. is there any way to make it still able to run like pausing the loop and continue it when its not 0 ? 

 

again, sorry for my ignorance >< i really dont get use to code with labview >< its so different ><

 

0 Kudos
Message 3 of 6
(3,940 Views)

@kavierkoo wrote:

however =(, after i set it as 0 to stop it, it will no longer run again.


Of course it does.  You told the loop to stop.

 

I think you just want to use a case stucutre around the terminal so that you only update it when the value it above 0.  You should also use a seperate button to stop the loop.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 6
(3,911 Views)

Thanks for the guiding, I tried the code but when my knob is at 0 the loop is not stopping but increase even faster >< i need a way to pause the loop because if 20 loops run together at the same time, my system will be very not efficient =(

0 Kudos
Message 5 of 6
(3,904 Views)

Then use a Select function.  If your value is 0, set the delay to 100.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(3,896 Views)