07-14-2009 07:31 PM
07-15-2009 12:29 AM
The Idle state is for the moment that the computer has nothing to do
When all processing is done and you have no specific task to do, you send your state machine to the Idle state. In the Idle state the PC is waiting for something to happen, user click a button, did something with the mouse, a specific time is triggered, ... ...
That structure will have a case for each user button and the default Time out case, I would suggest a 10ms time out time wired to that event structure. That means that the code in the Time-out case is executed every 10ms.
In that Time out case you check the player-level-time-out, the playing time (1 minute I think), jump to the "Read Digital Input" case, ... ...
You can pass data between states in two ways.
First way, make a hugh cluster that contain all this data. That cluster is then available for all states using a shift register. Use "Bundle by name" & "Unbundle by name" to retrieve the data needed in each state.
Second way, use separate controls to hold the data. Then use property nodes to read/write to those controls.
I never had more than 3 shift registers. One for the error cluster, one for the array with states and one for the cluster with all the common data. If you use separate controls to pass data, you will have only two shift registers.
07-15-2009 01:14 AM
07-15-2009 01:21 AM
I see your confusion now
The cases in the even t structure are for buttons, switches, numerical inducators on the front panel, not for buttons, switches attached to digital I/O cards!
07-15-2009 01:40 AM
07-15-2009 01:48 AM
Then use a big cluster with all data that you need to pass between states and a shift register
or use this
In the block diagram right click the control you want a Property Node of.
Then select Create\Property Node\Value
By default you get a Read
Change it write?
Right click the Property Node
Then select Change To Write
Now you can wire something to the Property Node
07-16-2009 02:08 AM
07-16-2009 09:59 AM
Don't panick 🙂
Attached a modified running version of your code.
But it's not a final version.
I had to remove all the LCD stuff since I don't have those vi's
Since I don't have the necessary hardware I can't really check the read DAQmx stuff 😞
It's not clear to me what you entend to do with the start timer stuff, can you explain?
Now the program is running for 30 seconds and then quit with a message.
Try to understand the rest and if something is unclear ask 🙂
I hope you also will understand the state machine stuff with the array with this running version.
Next time please post all those LCD vi's in a zip file so that I don't need to delete that state again.
07-16-2009 11:59 AM
Alain, thanks again. You've been a big help. however, I can't seem to run the VI. The problem seems to lie in the Write to LEDs state, with the error Case structure: selector values are not unique.
The start timer is meant for the duration of the game, which in my case is 60secs(1 minute). The 7-segment display is supposed to show the remaining time of the game.
I've attached the VIs of the LCD as well, but I have no idea where to include them in.
07-16-2009 01:01 PM
We are getting there one step at the time 🙂
What are the LCD VI's for?
You should use both attachments, the vi istself and the type def with the different state names to avoid the error "Selector values are not unique"
So your start timer was more like a stop game
I start the game by starting the vi, is that a problem?
The stop button is a stop now, quit state.
If yoy want to start the game, then add a button and try to integrate it in the state machine.