04-28-2009 10:44 AM
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
04-28-2009 10:57 AM
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.
04-28-2009 11:09 AM
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. 🙂
04-28-2009 11:12 AM
Raven's Fan,
I made the changes and the vi seems to be working properly. Thanks for the help.
04-29-2009 03:23 PM
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
04-29-2009 03:51 PM
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.
04-29-2009 04:38 PM - edited 04-29-2009 04:39 PM
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).
05-13-2009 01:22 AM
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
05-13-2009 01:27 AM
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
05-13-2009 09:54 AM
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.