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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with basic user events in Queued state machine example

Solved!
Go to solution

I have written a little queued state machine example to try to teach myself about creating and using user events.  The objective of the machine is to periodically choose a number (I'm doing it now with a control instead of a random number generator for troubleshooting), and compare that number with the number I have set in a control.  When they match, I want to cause an event to fire so I can do something about having found a match.  The examples in the LV Help file references show the events within the event structure, but I want to reach out of a state and cause an event ....

 

Can someone point me in the right direction here?

 

Thanks

 

Hummer1

0 Kudos
Message 1 of 9
(3,141 Views)
actually, the snippet looks quite a bit different than the program...so here is the program.
0 Kudos
Message 2 of 9
(3,139 Views)
Solution
Accepted by topic author Hummer1
I think the function you're looking for is Generate User Event.  Put that in your consumer loop, inside the case structure when the numbers match.
Message 3 of 9
(3,118 Views)

Yep....That was it...I had tried to do that but got fouled up with the variant definition...so defined the user event using a boolian and did the same in the case structure where I wanted to create the event and it worked great...

 

Thanks.

 

Here is the final version...not bulletproof, but does have a queued state machine using a user event to cause an event to fire.

 

Hope you find it useful.

 

Hummer1

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

One question: why are you using the Value (Signaling) property all over the place?  You're not catching those value change events in the event structure.

 

EDIT: also, I think you may still be partially misunderstanding user events.  There's no need for the "Right Number Hit" button on the front panel.  It's not tied in any way to the user event, you can use a constant instead as the input to Create User Event.

Message Edited by nathand on 02-23-2010 02:00 PM
Message 5 of 9
(3,103 Views)

Yep...force of habit.  value works fine...is that what you meant?

 

Thanks again.

 

Hummer1

 

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

I tried tying a T/F constant to the data type of the Create User Event and got an error...

 

Am I missing something?

 

Hummer1

 

0 Kudos
Message 7 of 9
(3,097 Views)
You were trying to use an unnamed constant.  If you give the constant a name (edit its label on the block diagram), it will work.
Message Edited by nathand on 02-23-2010 02:09 PM
Message 8 of 9
(3,093 Views)

Updated for constant definition and name of user even within the variant...same for generating user event.  Corrected the Val(signal) to value...

 

Example runs again.

 

Thanks...this is exactly what I needed to understand.

 

Hummer1

 

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