LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic Pause (through program) and Manual Resume through front panel Button

Solved!
Go to solution

Hi, I am trying to implement a system which measures voltage and current for a varying source voltage at varying temperature. The program acquires 5 pairs of voltage and current data. The issue here is that the source voltage is varied by manually changing the value of the variable resistor. What I would like to do is somehow pause the program automatically once the loop (for acquiring 5 V and I data pairs) has completed. Then, after the user manually changes the value of the variable resistor (and enters the new value through a front panel indicator), the user should be able to resume the program through a front panel button like in this example: https://decibel.ni.com/content/docs/DOC-10792

 

Is it possible to implement this in LabView?

 

In summary: I would like to implement a system in which the program would pause automatically after a condition has been fulfilled, and can be resumed through a front panel button.

 

Thank you in advance for any help and suggestions. I hope I made my query clear. I'm not sure whether attaching the program would help but I included it just in case 🙂

0 Kudos
Message 1 of 10
(4,099 Views)

Yes, of course you can do this in LabVIEW - LabVIEW is a programming language so you can do just about anything!

 

I suggest you look into state machines and the event structure - do your data acquisition in the state machine and when the data acquisition has finished, go into an 'idle' state and use the event structure to detect when the button has been pressed and then start the data acquisition again.

 

I had a look at your VI and it is very messy and hard to follow - I suggest you have a look at some LabVIEW tutorials to help you restructure your program. Things like having lots of backwards wires and while loops inside while loops are generally considered ill-advised. If you learn about the state machine it will help you to restructure your program and it will be easier for you to do what you want.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 10
(4,084 Views)

Hi Sam,

 

Thanks for your prompt reply. Good to know that it's actually possible. I'm still new to LabView and have tried following several tutorials (only up to while and for loops sadly :p) but I'll try to read up more on state machines and event structure. 

 

Now that you mention it, I do have plenty of while loops running inside while loops. I'm at loss though as to how else I can achieve what I'm trying to do with my program but I'll try to read up some more. 🙂 

0 Kudos
Message 3 of 10
(4,049 Views)
Solution
Accepted by topic author amndk

Sam put you on the right track.  You certainly don't need while loops inside of while loops.

 

You can accomplish what you want to do with a while loop, a case structure, and an event structure.  The while loop is the outer most structure.  Inside that, you have the case structure controlling the state you're in.  Inside one state, you have an event structure.  The event structure will want to have an event for the stop button and the start button as well as a timeout.  You'll want to iterate through your measurements using a state, or states depending on duration of your measurement.

 

It should be relatively easy to pick up.

0 Kudos
Message 4 of 10
(4,042 Views)
This may not be of much help right at the moment, but I am finishing up a blog post that will address what you are wanting to do. The post will publish next Monday.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 10
(4,018 Views)

Thank you all for your reply! Looking forward to your blog post on Monday, Mike, but I'm going to try coming up with something--to the extent of my capability anyway.

 

I tried out some tutorials on state machines and I'm beginning to grasp the concept. I still find it somewhat difficult to comprehend event structures. 😕 Pardon the very basic question, but I need to confirm some things.

- Suppose that I have an Idle, Run (for data acquisition) and Quit state. If I wanted the program to go to the Idle state (where the user will have to press a button to commence measurement) once the while loop in the Run state has finished, to accomplish this by the event structure, would the Event I'm looking for be 'Value Change'? And would the value would be the Boolean value linked to the Stop If True in the while loop?

- I also read up a bit more on Sequence Structures and apparently using them isn't particularly good coding practice? (In the case of my program, I used them to ensure that it is only after the temperature has reached the established setpoint that temperature measurement is conducted). I think it would be possible though to substitute the Sequence Structure with a Case Structure instead. Would this be better?

 

Best,

 

Amanda

0 Kudos
Message 6 of 10
(3,993 Views)

@amndk wrote:

 I think it would be possible though to substitute the Sequence Structure with a Case Structure instead. Would this be better?


http://www.ni.com/newsletter/51735/en/

 

Sequence structures have their uses but the article above highlights some ways that they are misused.  The link below should give you more ideas on when to use them and when case structures may be a better idea.

 

http://zone.ni.com/reference/en-XX/help/371361L-01/lvhowto/avoid_overusing_sequence_structures/

 

If you run into trouble post what you have so we can help you out.

Matt J | National Instruments | CLA
0 Kudos
Message 7 of 10
(3,985 Views)
More to the point, there is never a reason to use a sequence structure with more than one frame. They are superfluous and could be removed from the language with no loss in functionality.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 10
(3,970 Views)

Hi all! I've overhauled my program after learning how to create state machines in LabVIEW. I think I've managed to make it able to pause program execution by staying in the Initialize state if Pause After Measurement is set to True, only resuming measurement once the user has pressed the front panel button to Acquire Data. Attached is the code for the program.

 

Thanks to you all for leading me to the right direction (I hope) 🙂 

 

I have other questions though for some other functions I want to implement in the program (which are not very relevant to the original topic title). Would it be better to start a new topic or continue the discussion here?

0 Kudos
Message 9 of 10
(3,883 Views)
My approach would be to start a new thread tondeal with a different issue, but reference this thread in the first post.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 10
(3,868 Views)