LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start and stop button at the same time....

Hi experts,

I am a beginner of the labview, I appreciate if you can help me out.

I have been doing to create a start and stop button for my program, but I got some trouble for creating a start button to make it in same status with stop button...

When I try to put a event structure outside of my while loop, the stop button inside the while loop won't work anyone, I don't know what should i do to deal with this situation, could u plz help me? Also I have a 'export' button to export the measurements, how can I to make it can be pressed anytime after I press the start button?

Thanks in advance!

0 Kudos
Message 1 of 12
(2,291 Views)

Hello Rivershen,

Your program looks good and I don't think there should be any problem with the stop button unless the program gets stuck in any of the subroutines.

If you want to export the data any time after the program starts the put the event structure inside the while loop. Notice there should be a timeout event with a timeout as per your requirement and there should be another event which is linked with the export button.


CLD Using LabVIEW since 2013
0 Kudos
Message 2 of 12
(2,269 Views)

Hi River,

 

your block diagram can be improved: after using AutoCleanup it immediatly fits into just one FullHD screen…

 

Other improvements:

  • Don't open and close the VISA resource in each iteration.
  • Use a FOR loop when you want to limit the number of iterations!
  • When you want to handle different things in parallel (event handling, data saving) you should program those parts in parallel. Right now your event structure is called AFTER the loop due to DATAFLOW!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 12
(2,260 Views)

Hi GerdW,

 

Thanks for your reply and your great advice!

I don't know if I understand it right, so I moved my 'data flow' event into the while loop, is that correct?

 

Also, what I mentioned at the beginning is that if I put a event structure outside my while loop and use a 'ok' button to control the it(which is shown in the new VI), the loop won't run in number of iterations and I can't use the stop or export button after I pressed the ok button...

One more question about the data flow, which is that I create one more case structure to let the user be able to use more channels, but the data saving can't accept more than one flowing into it, what should I do?

Really thanks for your time!

 

River

0 Kudos
Message 4 of 12
(2,240 Views)

Hi,

 

Thanks for your reply! I will try that!

 

Best wishes

River

0 Kudos
Message 5 of 12
(2,238 Views)

Hi River,

 

what should I do?

Read the LabVIEW help on the event structure. And the linked Caveats article!

 

Placing the event structure around your while loop is wrong.

Placing another event structure inside the loop inside the event case is wrong.

 

LabVIEW comes with a huge example library: did you examine the examples on event structure usage?

Best regards,
GerdW


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

Your second example is worse than the first for the reasons that GerdW has already noted. You should definitely look at some examples. You don't really need event structures for what you want to accomplish, though. Just put a case structure inside your loop and connect a Start/Stop button to it. No need for two buttons. You can do the same for your logging. No need for an event structure there either. As GerdW mentioned you should move your open and close connection outside your loop so that you're not performing this action every time through the loop.

0 Kudos
Message 7 of 12
(2,221 Views)

Hi GerdW,

 

I will go through the examples and the labview help, thanks for your advice!

 

Best wishes

River

0 Kudos
Message 8 of 12
(2,207 Views)

Hi,

 

Thanks for your advice, just start the labview programming and still need to improve a lot. Anyway, thanks for our advice!

 

Best wishes

River

0 Kudos
Message 9 of 12
(2,204 Views)

Hello RiverShen,

 

Am not an expert but if I can help, I uploaded a test example for you. The start boolean should be inside your events box. And the stop can be activated using another events.

 

If you do not put a while loop around the events box, it will run only once. If you put a while loop around the events box, it will run over and over until the stop condition to stop that loop is activated.

 

If you have more questions and if I can help, will be glad to do so.

0 Kudos
Message 10 of 12
(2,194 Views)