07-16-2009 07:35 PM
The LCD is to display the user's score and top score.
My initial plan was to ask the user to input their name, select the level, and the game starts automatically. THat is what we're doing now right?
07-16-2009 09:25 PM
07-17-2009 12:40 AM
I think the vi uses reference to a wrong typedef, so the elements doesn't correspond to the cases in the code 😞
When you place the mouse over any state machine relayted item (array or single element) the context help (Ctrl + H) should say Typedef 'def_StatesMainLoop.ctl'. Is that also the case with your code?
That control has 11 states from Idle to WriteToLeds, your case structure should have 11 cases, one for each state.
You better remove all the versions from your PC or at least rename the actual folder that you are using now, make a complete new folder and copy the latest versions of code and typedef into that folder.
The LCD vi's use hardware lines to write some data to an LCD display connect to a DAQ device, correct?
Are you sure that those lines are different than the ones used for your LED's & Buttons?
Place the Init LCD vi in the Init sequence of the code, state Init-Controls or Init-DAQmx, your choice
Place all the other vi's in the "WriteToLCD" state and call it when needed.
Use a new sting control "LCDMessage" to pass data between different states and the LCD state.
In the state that want to write someting to the LCD wirte the message in the "LCDMessage" control.
Wire that control to the "Input string" connector of the LCD Wrap vi.
Got this procedure? Good luck!
07-17-2009 02:22 AM
THanks Alain, I removed the other versions and its working now.
The LCD is connected to a DAQ device.. I'm having a seperate DAQ for the LCD.. so far I havent tried using all 3 yet but shall do so either today or tomorrow.
I get what you mean about the LCD part and I'll do it and post it up here ASAP.
07-17-2009 10:30 PM
07-17-2009 10:38 PM
07-18-2009 03:09 AM
Hello,
I think i am late to the discussion, but its intresting one !!
OK
1. Have you tested your LCD codes independently? i meant before integrating it to this code? have you seen whether the clock is working properly? Do you think there should be delay between the two VI's where you are making the pulse for the clock?
2. DI Read, Are you getting any specific error there? or it just reads 0? Probe the task where you create it and just before reading, just check what it displays.
3. Clock discrepeancy is bound to happen the way in which it has been implemented because it will always take different amount of time to execute different number of states before updating the clock value again.
Regards,
Krunal K Patel.
07-18-2009 04:36 AM
Hi and welcome to the discussion 😃
Everything works independently but there's errors when its being integrated into one big program =( still trying to troubleshoot it
07-18-2009 05:26 AM
I looked at your code and see that you added two wait instructions with a delay of "LevelTimeOutTime".
One in state "Write to LEDs" and one in state "ReadFromPushButtons".
Why do you think you need those delays?
Now you're holding your code two times up. That's wrong, all timing stuff is done in the Timeout state of the event case in the Idle state of the statemachine.
I changed the following in the code:
a) The Idle state should also be the Default state, so I added Default in the selector.
b) I added 1 sate to the array with initial states and moved two others. It make more sence to first initialize the hardware before entering some user data.
c) I added one control so that you can see what's read by the DAQmx read push buttons task.
Do you understend the use of both controls "TimeGameOver" & "TimeOut-1Code"?
For the rest I don't have problems with the 7segment timer, it indeed starts at 59 but from 59 to 0 that makes 60 seconds 🙂
At first I would focus on one thing, led's and push buttons.
Forget about the LCD, delete that code completely and try to make the led's & push buttons working as it should be.
Once that's ok try the LCD stuff in a sepearte VI and once you know it's working implement it in this code. Where did you get that llb?
Are you sure the LCD code is correct and that it doesn't interract with your LED's & push buttons? Using the same hardware line twice?
07-18-2009 11:03 AM
Thanks Alain, I think the timer malfunctioned because of the wait function.
What are the game time over and time out 1 for? I'm not that sure..
the LCD is from another DAQ, and its working independently in its own VI which I tried out. it was given to me by one of my seniors.