LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

comparing digital input and output from two different DAQs

I think you should quit all those loops and use a state machine mechanisme.

State 1 : Initialize controls

State 2 : Initialize DAQmx tasks

State 3 : Do some LCD stuff maybe

State 4 : Write an output value to the led's

State 5 : Read digital inputs

State 6 : Compare inputs with led's if not equal goto state 5, if equal goto state 7

State 7 : Update score and display

State 8 : Check stop button if pressed goto state 9, if not pressed goto state 4

State 9 : ...

... ...

 

This way your digital inputs will read continously while now it's only read after each game-level-time.
This way you also be able to determine the reaction time.

 

So, if I were you I would review the architecture of the code Smiley Surprised

0 Kudos
Message 11 of 58
(1,035 Views)
once again, thanks Alain. I'm not too familliar with the state machine though as I only started self-learning LabView a few months ago. Perhaps if you could start me off with the state machine thing for me to have a better understanding?
0 Kudos
Message 12 of 58
(1,027 Views)
You can find a brief introduction to state machines here.  You can find a template to start with in LabVIEW. Select File»New... then navigate to VI»From Template»Frameworks»Design Patterns»Standard State Machine.  Search these forums or the web for many other examples.  The only caveat I would give you is to avoid state machines which switch on strings - always use a typedef enum.  This will make your future development much easier.
0 Kudos
Message 13 of 58
(1,020 Views)

DFGray wrote: 
The only caveat I would give you is to avoid state machines which switch on strings - always use a typedef enum.  This will make your future development much easier.

Absolutely!!! typedef is the only right way to go:)

But how to make a typedef?

Don't bother use this one as a start, just replace all the state names with your own state names.

 

 

0 Kudos
Message 14 of 58
(1,015 Views)

And now the whole framework for a state machine. Please note that the code inside the states doesn't mean anything now since I removed most of the controls of that program.

Up to you now to:

  • Copy all of your controls into this framework
  • Define some well defined states
  • Modify the code and type defs according to those states
  • Maybe you can use the "Settings" stuff to store the last top scores with player name and DT stamp 😉

You can download the Open G tools as discribed here

 

Share all of your new code so that we all can play that game Smiley Very Happy

 

Good luck !

0 Kudos
Message 15 of 58
(1,007 Views)
Oeps, forgot the code Smiley Surprised
0 Kudos
Message 16 of 58
(1,005 Views)
thanks a lot! SHall be posting it up once I finish it 🙂
0 Kudos
Message 17 of 58
(995 Views)

I've completed my code and can someone tell me if its working in sequence as stated below? I think i made a mess of things  :S thanks..

 

 

1) Enter user name

2) Select level

3)Remaining time is displayed on the 7-segment 

3) LEDs light up at random for 1 minute

4) Corresponding push button is pressed

5)Correct score? +1 mark

6) Remaining 5 secs, plays a beep.

7)End of game, another beep. 

😎 Score is displayed on the LCD

9)  Score displayed on monitor

10) Beep if new high score is set 

 

 

Download All
0 Kudos
Message 18 of 58
(986 Views)

One thing is for sure, you're using a state machine!

But is it well implemented? Not 100% sure about that Smiley Sad

 

What I miss is an Idle state like in the statemacine I posted.

In the Idle state you should put the event structure and use it as an event structure.

Now you use an event structure as a level time out for the user.

You should implement the level time out as follow

Write a code to the led's

Add the level time out to the actual time (ticks since midnight)

In the Time out state of the event structure in the Idle state, compare that time with the actual time.

Is it overdue, go to the state "Write to LED's"

 

You're Stop button is in the "Start Timer" state 😞   Really confusing 😞

 

The user inputs name & Level selector should be in a state, same for the message at the end

 

Both cases of the case structure in "Compare read and write" go to "Write to LEDs" state ?!?

 

Skip the Wait function with 125ms because now you read you're inputs at maximum 8Hz

 

Clean up all those blue wires at the top of your VI. I didn't check what they are for but I'm sure there's a better way ... ...

 

 

I hope I didn't discourage you too much

0 Kudos
Message 19 of 58
(981 Views)
Ok.. but could you elaborate more? I'm getting confused.. And what exactly is the idle state for? And for the level time out, am i supposed to write everything in 1 event structure? or seperate?
0 Kudos
Message 20 of 58
(974 Views)