LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

please help with structure of my program

I am hoping someone can help me with a motor control program that I am writing.  The program is too large to post here, but I attached a rough outline of the program.  I think the problem is with the higher level logic, so hopefully that will provide the necessary information. 

I have a front panel with lots of buttons to control the motors (eg: power, stop, start).  There is an event structure that contains most of those buttons (power, start, etc), but if that structure is exectuting, the other buttons won't work.  I need to be able to stop the motors and exit at any time (for safety), so I made another event structure that contains the stop and exit buttons.  Is this the right way to do this?

Also, I want all the loops in the program to run continually until the exit button is pressed.  Since the exit button actually calls exit.vi and closes the whole program, I just wired a F constant to the stop on the while loops so they never stop.  Could this be causing my problems? 

Hopefully I provided enough information here, but if not, please write back and let me know.

Thanks,
Kasey

PS. In case anyone wonders why the whole thing is in a sequence, I need it for other aspects of the program (safety lights, etc...).  I doubt it makes a difference, but I wanted to include it.
0 Kudos
Message 1 of 4
(2,742 Views)
This is the first time I have seen a case where it is useful to have two or more event structures in one program.  Since they are in separate parallel loops, I would think there would not be a problem.  I like the idea that the program can be stopped in the middle of an event, for safety reasons.  Great structure, Kasey.  The only thing I would add is to make sure that your exit vi gracefully shuts down the program.  Like if files or references are open, they get closed before terminating the vi.  Just be on the look out for race conditions since you have 3 events that can happen at one time.  One event might affect some indicator that is being handled by another event.  Also, instead of wiring a false to the other loops, maybe you could use local variables of one general stop boolean.  Since your exit vi stops all execution, it may not make much of a difference.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 4
(2,717 Views)

Have you read:

"Caveats and Recommendations when Using Events in LabVIEW " in the help?

As you see there, Event structures are tricky.  I dont immediately see what you are violating, But:

Have you unchecked "Lock front panel until the event case for this event completes" for all events

otherwise ALL front panel events are blocked, not just the configured ones.

0 Kudos
Message 3 of 4
(2,717 Views)
Thank you for the suggestion.  I'm glad that no one sees any major problems.  Maybe it is something small.  I tried to uncheck the "lock front panel" in the event structures, but there are a lot of events and I could have missed one.  I'll double check that and the other caveats.

Thanks again.
Kasey

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