LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine vi executes only one out of multiple events

Hi,

 

I just started learning to use the state machine vi architecture and I built a simple state machine vi from a tutorial. The vi has a menu of 5 different tasks and when I run the vi, one state executes automatically. The vi will not respond to calls on any of the menu items on the front panel afterwards. The vi is supposed to stay in default state until a user clicks a button on the front panel menu. After the state executes the user command, the vi goes back the default state which is designated "-1, default".  I've attached the code and I'll appreciate any help on this problem.

 

Thanks

 

 

0 Kudos
Message 1 of 21
(4,030 Views)

Only your stop case should have a True wired to the stop terminal for the loop and have all the rest false.

 

You should also turn your enum into a type def and get rid of the control and turn it into a constant.  As it is right now, your control as a set of states and they are numbered from 0.  However your actual states have numbers that don't match.

0 Kudos
Message 2 of 21
(4,024 Views)

Ravens Fan wrote:

Only your stop case should have a True wired to the stop terminal for the loop and have all the rest false.


Even easier, change the output tunnel to "use defaults if unwired" and delete all the "false" diagram constant, leaving a single TRUE in the stop case. Less code. 🙂

0 Kudos
Message 3 of 21
(4,016 Views)

Raven's Fan,

 

I made the changes and the vi seems to be working properly. Thanks for the help.

0 Kudos
Message 4 of 21
(4,015 Views)

Raven's Fan,

 

Here is another vi with similar architecture that isn't working well. The vi was supposed to keep track of the number of times each button on the front panel was clicked. When I tried to wire the cluster across the false case structure I got an error message. Also I was wondering what value to assign to the array output tunnel in the same false case. 

 

Thanks

0 Kudos
Message 5 of 21
(3,983 Views)

That's because you are wiring a cluster to an array.  You would have to conver the cluster to an array just like you did in the True case.

 

I'm not sure why you would store those values in a cluster anyway.  I would just define all of those wires as a 1-D array with 4 elements, then all the cluster to array and array to cluster conversions could be eliminated along that wire.

0 Kudos
Message 6 of 21
(3,976 Views)

If you want to stay with a cluster, convert the array back to a cluster inside the TRUE case and wire the cluster across unchanged in the FALSE case

 

As Ravens already mentioned, it would be better to stick with arrays. Here's a simple rewrite to give you some ideas. Even better would be to upgrade to a newer LabVIEW version where you can use the "in-place" structure to do all the array element gymnastics in one step. (see image).

 

Message Edited by altenbach on 04-29-2009 02:39 PM
Download All
Message 7 of 21
(3,966 Views)

Hi,

 

I'm having a hard time getting my vi to work. When I run the vi I get an error message about the case structure not having a default state but I don't really understand how to fix it.  I'll really appreciate some assistance here. Please see attached code.

 

Thanks

0 Kudos
Message 8 of 21
(3,873 Views)

http://zone.ni.com/reference/en-XX/help/371361E-01/lvhowto/specify_default_case/

 

You needs to specify a default case for ur case structure.Find the fixed vi

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 9 of 21
(3,870 Views)

Hi Baji,

 

Thanks for the input. I made the change, however, the vi gives an error message when I try to run it. Run the vi yourself so you can see it. Here is the error message message below:

 

                     Error -20315 occurred at Tone measurement/Amplitude and Level Measurements -> fixed Analyze and Present Data.vi

                      Possible reasons the waveform dt parameter <=0

 

 Again I appreciate the help. Thanks.

0 Kudos
Message 10 of 21
(3,842 Views)