LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx - run - stop - save

Hello,

 

I tried to create a program which allows the user to do the following:

 

- Start measuring 2 channels ( lets say channel one measures force, channels two acceleration, but it's not very important) when 'Start' button is pressed.

- Save the measured data whenever the button 'Save' is pressed.

- Stop the program whenever the 'Stop' button is pressed.

 

I've added the program in attachment.

 

Now I think I know where my mistake is situated, I just don't know how to solve it 🙂

I think the program starts when I press start, but since the while loop only stops when the stop button is pressed, the shift register from the inner while loop doesn't send any measurements towards the shift register of the outer loop.

In that case whenever I press the SAVE button, an empty array will be saved.

Also, if I press start, then save and then stop, nothing happens.. ( the program continuous to run).

And last but not least, I've changed the 'Chart History Length' to 60,000. How many measurements will it be able to keep? ( Or isn't it as simple as that?)

 

I hope there is anyone out there who can help me.

Thank you in advance 🙂

 

 

Best regards,

Dries

0 Kudos
Message 1 of 9
(3,347 Views)

Dries, where do you think is your mistake?

 

Also, when you say "Also, if I press start, then save and then stop, nothing happens.. ( the program continuous to run)" do you mean that you havn't been able to make your Start, Save, Stop program work at all? I mean, you did say you get an emty array earlier.

0 Kudos
Message 2 of 9
(3,344 Views)

I think this is the problem:

Since the while loop only stops when the stop button is pressed, the shift register from the inner while loop doesn't send any measurements towards the shift register of the outer loop.

In this case whenever I press the SAVE button, an empty array will be saved.

 

A part of the program works, If I just press 'start' and 'stop', everything works just fine.

It's the save part which doesn't work properly.

If I run the vi and press start, the measurements are displayed on the chart. If I press stop, the vi stops.

However, if I start the vi, press start, then save and then stop, the stop button doesn't work.

 

 

Best regards,

Dries

0 Kudos
Message 3 of 9
(3,336 Views)

Your stop logic makes no sense.

 

What is the purpose of the stop button?  Is it to stop the logging or stop the VI?  It seems like you are using it for both.  That makes it a confusing user interface.

 

You store the value of Stop in a shift register.  If you press Save, then the value in the shift register gets lost.  The save event case puts the default boolean value of False into the shift register.  When you finall do hit stop, the value in the shift register gets used rather than a True value to stop the while loop.

 

It is a bad idea to have a while loop buried in an event case.  That event case will run a long time queueing up other events until you happen to stop the inner while loop.

 

You should look at the architecture in File/New.... called Producer/Consumer (Events).

Message 4 of 9
(3,321 Views)

Aah I see. Well if you put it that way it does make sense...

 

I've changed to stop buttons ( I made a 'Stop loggin' one and a 'Stop' )

Would this new vi do the trick?

 

If I press 'Stop Logging' before I press the 'Save' button, the saving should work?

 

Thank you for your fast help!

 

 

Best regards,

Dries

0 Kudos
Message 5 of 9
(3,293 Views)

Still a bit convoluted.

 

Now you need to press the Stop 3 button before pressing the Stop 2 button.  Because the Stop 3 button is read in the event case for stop 2.

 

I would look at a state machine.

I would look at an event based producer/consumer structure.

 

Even getting rid of the event structure altogether and polling the buttons every iteration and determining whether to start or stop logging would be better than you have now.

Message 6 of 9
(3,290 Views)

Thanks for the hints 🙂

 

I don't really understand what you mean with 'Because the Stop 3 button is read in the event case for stop 2.'

Could you explain that, please?

 

Also, I'm pretty new to LabVIEW and I don't know a lot about producer/consumer structures and state machines ( t.b.h. I don't know that at all).

I'm just looking for a way to solve my problem. It doesn't have to be the best solution, it only has to be a simple solutions which I understand... 🙂

 

Thank you,

 

 

Best regards,

Dries

0 Kudos
Message 7 of 9
(3,276 Views)

You have to hit Stop 3 before you hit Stop 2.

 

If you hit Stop 2 first, the value of Stop 3 will still be false when that event case runs.

 

If you don't hit Stop 2 at all, then Stop 3 is never read because the Stop 2 Value change event never runs.

Message 8 of 9
(3,266 Views)

Aaah, I get it, thanks.

 

What do you think would be the easiest solution for me ( an unexperienced LabVIEW user?)

 

Is it to work with both a Stop logging and a Stop button? Or just a Stop button? If possible, I'd like to continu using the event-case structure as to me, it seems to be not too hard to understand 🙂

 

 

Best regards,

Dries

0 Kudos
Message 9 of 9
(3,246 Views)