From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-01-2008 06:26 AM
Hi,
I'm working on a test sequence using a standard state machine from the LabVIEW examples.
At part of my test, I'm displaying a waveform on a scaled graph. The input for this is from a PXI-4070 DMM. This runs in a 'while loop' to continuously update the waveform. The display simulates an oscilloscope. The test operator needs to perform an adjustment while looking at this display. This bit works and I have no problem here.
On my front panel, there is a button to 'continue' to the next part of the test once the adjustment has been made. Some changes are then made to the setup, and the next adjustment needs to be made in the same way, i.e. look at the display, make the adjustment, press 'continue. This is where I have the problem.
I've tried using event structures within the while loop to stop the loop when the continue button is pressed. This works for the first adjustment, but when the test gets to the second adjustment stage, the event seems to be 'remembered' and the loop terminates immediately.
Is there away of resetting the event so that the button can be used again in the correct way
Regards.
Solved! Go to Solution.
10-01-2008 06:37 AM
10-01-2008 06:50 AM
Can you post your code?
R
10-01-2008 07:37 AM
Using a single event structure will prevent that kind of conflict. In the event case set a notifier or put a command into a queue (or multiple queues) to pass the information about the event to the state machine.
Examples of a queued state machine and an event driven state machine are in the Design Patterns which come with LV.
Lynn
10-01-2008 07:45 AM
I'll attach a simplified version of what I'm seeing.
All this does is count the number of iterations in the loop, until the continue button is pressed.
What I'd obviously like it to do is do test 1, counting iterations until I press to continue - then move on to test 2 to count iterations until I press continue again and so on.... But it doesn't.
How can I change this to get the behavior I need? I'll then be able to apply this to my test sequence.
Regards.
10-01-2008 08:59 AM - edited 10-01-2008 09:01 AM
You'll need to restructure your code to use a single event structure. When your code starts, each event structure starts listening for events, even if that event structure isn't currently executing (this is by design and a good thing, because it lets send events without worrying about whether the event structure is already active - you know that the events will queue and be processed when the event structure executes). So, all 4 of your event structures start listening for events on the same Continue button, and when you press the button they each receive a notification that an event has occurred. One possibility would be to create one case for all for Test enumeration values that includes the event structure, and then put another case statement inside that to handle each individual test case. Also, you don't need both a timeout case and a Wait inside your while loop; just let the event structure timeout handle your timing. If you're just waiting for an event to occur and don't need to count loop iterations, you don't even need the while loop and the timeout event.
EDIT as an added note: I find that any time I need copies of a local variable in multiple cases, it's a good indication that I can combine the duplicate cases in a way that eliminates the need for a local variable.
10-01-2008 09:01 AM - edited 10-01-2008 09:04 AM
You have some basic misunderstanding of event structures.
Here's a quick modification. See if it makes sense. 🙂
10-01-2008 10:45 AM
Hi,
yes, looking back at my example, I realised I didn't do the timing very well. It was just a 'quick and dirty' example to show what was happening. And I thought 'this is running too quick, so I'll slow it down with a 'wait'' - not even thinking that the timeout on the event structure would do exactly the same thing.
So now think I'm starting to understand about the event structure itself. But I'm going to need (a lot) more time to fully appreciate it's operation, and how to use it in this application.
I know it's probably a cop out, but I think I shall use multiple buttons in the same place on my front panel, starting with them invisible, and making them visible as and when I need them using property nodes. Not ideal, but it works and gives me what I want without too much time spent trying to get my head around this.
I will come back to event structures when I'm under less pressure to complete the test - honest!!!
Thanks for your inputs.
Regards,
Sebster.
((There are 10 types of people in this world - those who understand binary and those who don't.))
10-01-2008 11:24 AM - edited 10-01-2008 11:29 AM
When you do get a chance to investigate event structures you'll probably find that the right way to handle this is to separate your event handling from your test sequence. Put the test sequence in one while loop, the event handling in another, and use a notifier or a queue to send a message from the event handler to the test sequence. This would allow you to do exactly what you were trying to do in the first place in an efficient way. A very simplified version would look something like this.
10-01-2008 11:28 AM
sebster wrote:I know it's probably a cop out, but I think I shall use multiple buttons in the same place on my front panel, starting with them invisible, and making them visible as and when I need them using property nodes.
Voted "worst idea ever". Don't do it! 😮