LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure inside a while loop

Solved!
Go to solution

Hi, i been trying to use a case structure inside a while loop that has to numerical controls connected to it, and when one connector changes value the output from the case structure should change to that value and when the other nummerical control changes value that value replaces the previous one.

My problem is that when i have another logic in the while loop and its running the output from the case structure becomes 0 after every iteration.

How can i keep the value from the case structure? Is there some logic i can have after it or prehaps a loop inside the loop?

 

 

 

0 Kudos
Message 1 of 10
(523 Views)

Hi Bowika,

 


@Bowika2000 wrote:

How can i keep the value from the case structure? Is there some logic i can have after it or prehaps a loop inside the loop?


Use a shift register to keep values for the next iteration of your loop!

(This is VERY basic LabVIEW stuff...)

 


@Bowika2000 wrote:

i been trying to use a case structure inside a while loop that has to numerical controls connected to it, and when one connector changes value the output from the case structure should change to that value and when the other nummerical control changes value that value replaces the previous one


You don't use a case structure, but an event structure with several event cases!

Best regards,
GerdW


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

sorry i meant an event structure 😄 , anyway its not possible with an shift register becouse it goes always back to 0 the next iteration and the shift register will get that value.

0 Kudos
Message 3 of 10
(508 Views)

@Bowika2000 wrote:

sorry i meant an event structure 😄 , anyway it's not possible with a shift register because it goes always back to 0 the next iteration and the shift register will get that value.


Then you need to wire the value of the shift register through the unused event cases.  There is a handle feature to help this.  If you right-click on an output tunnel, there is an option to create a linked tunnel.  This will automatically wire from the input tunnel to the output tunnel whenever you create a new event case.


GCentral
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 10
(491 Views)
Solution
Accepted by topic author Bowika2000

Try this:

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 10
(479 Views)

Thank you so much for the try i checked the code and it looked great.
Problem is that now it works yes but i have a am obtaining the values that i want to change with through tcp/ip and they need the while loop to run and if it does then the values always go back to 0 from the event structure and in this case it works but the while loop is not running which i can check by wiring a indicator to the small i in the left corner.

0 Kudos
Message 6 of 10
(430 Views)

Hi Bowika,

 


@Bowika2000 wrote:

then the values always go back to 0 from the event structure and in this case it works but the while loop is not running which i can check by wiring a indicator to the small i in the left corner.


When the value still "goes back to 0" then you forgot to wire a "default if unwired" tunnel.

And when the loop does not iterate then you forgot to add a timeout event to your event structure…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(426 Views)

@Bowika2000 wrote:

Thank you so much for the try i checked the code and it looked great.
Problem is that now it works yes but i have a am obtaining the values that i want to change with through tcp/ip and they need the while loop to run and if it does then the values always go back to 0 from the event structure and in this case it works but the while loop is not running which i can check by wiring a indicator to the small i in the left corner.


Well that's more complicated than just changing an indicator base on an event.   

 

I suggest you search the LabVIEW Help for tcp/ip and look at the "Simple TCP.lvproj" example.

 


========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 10
(415 Views)

I think i got it working with this code now.
Thank you guys! 
I will ask more if i run into trouble but as far as i can see this solved it for me!

0 Kudos
Message 9 of 10
(405 Views)

Can you make the event structure change values by overwriting the other while one value comes from a numerical controller and the second from a numerical controller but it is transformed to a string first then back to a number.

 

I cant get it working and it must do this while the loop is running.

0 Kudos
Message 10 of 10
(288 Views)