LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI isnt working as planned

Solved!
Go to solution

Hi,

I am trying to create a game but my VI isn't working as I want it to. Im pretty much a beginner at labview and have no idea what is wrong with my code. Help Plz!!!

 

So far I have only added the 'up' and 'down' button, and I want the red square to stop at a black square, or otherwise follow the instruction of the button that is pressed.

Im not entirely sure how I should go about doing it. My try ended up in horrible failure.

 

Any help would be appreciated!

Thanks

 

0 Kudos
Message 1 of 4
(2,737 Views)

How are you learning LabVIEW?  Have you taken as many of the On-Line Tutorials as you can find?  Have you looked at Example code, particularly code a good LabVIEW programmer has written to do something only slightly complicated?

 

LabVIEW responds very well to "Good Style" -- without it, the perjorative phrase "Spaghetti Code" takes on a whole new meaning.  One of the best ways to prevent Code Sprawl is to encapsulate functions in sub-VI.  Looking at your code, I see multiple loops that "do something", but I have no idea what this is.  If each loop was a sub-VI that had a name (maybe "Move One Square Right") and an icon (maybe with a right-pointing arrow, or the words "Move 1 Right"), your main VI would be much simpler to comprehend, and to debug.

 

Bob Schor

0 Kudos
Message 2 of 4
(2,702 Views)

It is not entirely clear at a quick glance exactly what you are trying to do.  Have you drawn a flow chart or state diagram on paper describing exactly what the program should do?

 

I suspect that you have way too many loops.  One or two is probably enough.

 

You have a lot of duplicated code or code which differs only by data values. That can probably be consolidated.

 

Terminals shoudl be inside the event case, especially for latch action booleans. You should also have a separate event case for the stop button.

 

Lynn

0 Kudos
Message 3 of 4
(2,698 Views)
Solution
Accepted by topic author Mechasaiyan

1. Stop using local variables.  They are causing race conditions and you can be using data flow for every thing.  The main thing is the have your "build map" loops pass data to your event loop.  This includes initializing your shift registers..

2. Make an event for your stop button.

3. Put the controls in their corresponding events.  This will allow the buttons to latch.

4. Work on having things line up better.  It will help a ton keeping your paths easier to read.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(2,694 Views)