03-18-2024 08:53 AM - edited 03-18-2024 08:54 AM
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?
Solved! Go to Solution.
03-18-2024 09:02 AM
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!
03-18-2024 09:04 AM
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.
03-18-2024 09:15 AM
@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.
03-18-2024 09:19 AM
Try this:
03-18-2024 09:58 AM
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.
03-18-2024 10:07 AM
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…
03-18-2024 10:25 AM
@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.
03-18-2024 10:35 AM
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!
03-19-2024 03:31 PM
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.