LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wait for front panel activity state machine

Wait for input state.JPG

So, pardon the barely started .vi, but I am trying to figure out how to sync the "wait for front panel activity" function to the control right above it, labeled "voltage range" for this state machine.  I want the .vi to run through the starting state, but then pause and wait for the user to pick which one comes next.

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

So, I have kind of changed my mind about how I want it to work, the following seems like it will be easier and less code:

 

Wait for input state.JPG

But I still do not know how to tie the "wait for front panel response" to the (now labeled) "voltage range 2" selector before the final case structure.

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

Is there a reason why you are not using an event structure?

 

Lynn

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

uhh...  I'm a noob and I've never used an event structure before?

0 Kudos
Message 4 of 9
(3,609 Views)

Dig into the examples that ship with LV dealing with event-driven programming. There is even a design-pattern template available to get you started. Events are, to my mind, one of the top 3 new features ever added to LV. They allow you to increase the efficiency of your code while improving its responsiveness and maintainability.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
Message 5 of 9
(3,596 Views)

Wait for input state.JPG

I found a pretty good example to give me an idea for what I want, what I ended up with is shown above.  I set it to wait for a value change on the "start next range" control, the only thing I am not convinced of is if there is going to be a race condition between the isolated "start next range" control and the rest of the code inside the event structure, i.e. will all the code execute before it waits for me to click "start next range," or will it wait for me to click "start next range" before executing the code in the event structure?

0 Kudos
Message 6 of 9
(3,589 Views)

No there won't be a race condition because the thing that causes to event to fire is the control's change of state - you don't really care what it changed to in this case, just that it changed. Note that if you do care about the value of a control with a value change event, the event data nodes (the things on the left side that look kind of like unbundle by name nodes) contain two items: OldVal and NewVal which contain the values of the control before and after the event fired.

 

The other recommendation would be to create another value change event for the voltage range control. That event's job would be to update the values in the two shift registers. In the start next range value change event case use the values in the shift register and passes them through unmodified.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
Message 7 of 9
(3,586 Views)

A few other points:

 

1. You have nothing connected to the termination terminal in your while loop.  How do you stop this?  Using the Abort button on the toolbar is not a good way to do this because it stops the program immediately without allowing time to shut down your instruments gracefully.  Use a Stop button on your front panel (and add a Stop: Value Changed event case to your event structure.

 

2. You appear to be using a GPIB instrument.  Doing all the initialization and reading in the event case may take quite a bit of time. While executing the code inside the event case nothing else can happen, making your program appear very unresponsive to users.  Look at the Producer/Consumer (Events) Design Pattern for a good way to avoid this.

 

Lynn

0 Kudos
Message 8 of 9
(3,576 Views)

Thanks for the tips guys,

As for your comments Lynn, the program is barely written as it is, the majority of the content still needs to be placed inside the for loop, which is why it seems so bare, why its missing some obvious things (like a way to stop the while loop), and why, as of right now, it doesn't do anything other than just set up 2 of the instruments.

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