LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to stop while loop in event structure

Solved!
Go to solution

I'm looking for the correct way to stop my event structure + while loop combo, and every method I try seems to have some sort of drawback. (See attachment).

 

This my program is CNG station and i want to stop filling tank in its run time by just clicking a STOP  button , i tried my all knowledge of LABVIEW  ,but i failed every time  as i m in basic ,

 

I want the code to execute so that i can choose  stop, the main code should not execute.

 

Thanks in advance 🙂 🙂

0 Kudos
Message 1 of 9
(4,597 Views)
Solution
Accepted by zua0226

Hi, Zua0226,

   I have made very small change in your code, so that  you can stop this operation whenever you want. 

Hope it helps !

Kudos are welcome 😉

Regards,

Dhans 😉

Best Regards,
Dhans 😉
Kudos are welcome 😉
Aspirant Labview Programmer (Labview 14) 😉
0 Kudos
Message 2 of 9
(4,566 Views)
thnku very much
0 Kudos
Message 3 of 9
(4,544 Views)

thanks

0 Kudos
Message 4 of 9
(4,541 Views)

Some problems with your VI (i opened the modified one which is a wrong solution from dhans):

  • Best practice to put your controls in their corresponding Event case!
  • No Event case was created for the "Stop" (System shutdown) button, so it will not stop your VI.
    • You could have an "Abort button" which only acts during the "Filling" state, and only use the System Shutdown exclusively to stop the VI!
  • Do not hide the label of the "Stop" (System shutdown) button
  • You initialize your shift register with a string value of "500". That is why you get first a 500 in your built string. It should be an empty string.

In overall, I really recommend you to study further the State Machine concept. There is even a template for that in LabVIEW. Take the online Core 1-2 courses too, it will help a lot to understand shift registers, etc...

 

By the way, why do you thanks twice the wrong VI, plus marking your answers as solution?

0 Kudos
Message 5 of 9
(4,529 Views)

Hi, Blokk,,

  I will explain about those points mentioned in your statement.

1. I was just seeking for a solution so i didn't bother about placement of controls in that VI

2. Yes, I have deleted it accidentally and forgot to add. My apologize.

3. Reason for label hidden is it overlap with surrounding blocks. Thats all. There is no any other intention. Failed to update.

4. Initialzing value is done for testing my modified code. If the user wants they can delete them and run it.

 

After all, I just see the possible solution in the given VI so that user can easily adapt it. Thats why I didn't mention about state machines. But thanks for the mentioning of m mistakes Blokk.

As Blokk said, State machine is even more easier to you handle this task Mr. Zuo0226 .

 

Regards, 

Dhans,

 

Best Regards,
Dhans 😉
Kudos are welcome 😉
Aspirant Labview Programmer (Labview 14) 😉
0 Kudos
Message 6 of 9
(4,517 Views)

Hi Zua0226 and Blokk,

  As per suggestions noted by Blokk, I have made some changes in that modified code.

I will make clear about my side in previous code.

  • Instead of using buttons I directy input value in the blank string.
  • Instead of using new control to stop the process during tank filling alone , I have deleted shutdown event and used it for stopping a tankfilling as well as whole process.

I rectified these problems and updated the requirement code in this reply.

 

Hope it helps 😉

Kudos are Welocme 😉

 

Regards,

Dhans 😉

Best Regards,
Dhans 😉
Kudos are welcome 😉
Aspirant Labview Programmer (Labview 14) 😉
0 Kudos
Message 7 of 9
(4,502 Views)

Hi zua,

 

why do you send PMs to people not related to your thread?

Do you think you get more help by spamming our message boxes?

 

To get attention:

- post useful messages (containing relevant information) in this thread. This will keep the thread visible on the first page of the LabVIEW forum!

- don't mark your own "Thank you" answers as solution! Threads with a solution mark are less likely to be visited by the forum volunteers: why should we peek into threads when there is a solution already?

- Please read the forum introduction!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(4,482 Views)

Let me echo GerdW's reply -- do not send PMs hoping someone who hasn't been commenting on your posts will just jump up and solve your problem for you.

 

You need to spend some time and to learn LabVIEW.  Take a week and carefully go through all of the tutorial material that you can find.  Learn about State Machines.  Look at the Examples and Templates (including State Machines) that ship with LabVIEW.  You will undoubtedly find that there is code you don't understand -- spend the time to learn why the code is written in that manner.  There are also books about LabVIEW ...

 

Bob Schor

0 Kudos
Message 9 of 9
(4,429 Views)