LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with my code

I need a little help.  My skill as a LabView programmer are mediocre at best and I can't wrap my head around a good way to solve this issue.  I am writing a program that control relay for cycle testing an electric motor.  The green LEDs represent the relays.  On starting the program the user can enter times for each relay and start the program using the play button.  On pressing play the first relay will activate and the motor rotates forward for the set amount of time, then the second relay will activate and the motor turns in the reverse direction for the set amount of time.  I have successfully done this using a event driven state machine.  The problem comes when I want to pause or abort the program mid-cycle.  When I press the Pause/Abort button the relay (Green LED) will not stop until the wait time has passed, but I want the relay to shut off instantly when pressing Pause/Abort.  What is a better way to do this?  I open to any suggestions, improvements, or complete reconfiguration of code.  If there is something fundamental that I am missing here, I am self taught, so please educate me.  I have attached my code for evaluation. 

0 Kudos
Message 1 of 4
(1,858 Views)

You are making your loops take a long time because of the large wait value.  You should look into using the Elapsed Timer Express VI.  You need your loops to cycle back to the same state frequently and see if the time has passed.That gives the code a chance to handle any new commands coming in right away.

 

I think you are going to run into problems with your multiple queue structure.  A user could accidentally queue up multiple run commands in the time it takes for the first one to complete its process.  I think you should try to get it working with a single queue and single consumer loop.

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

Thank you! I needed guidance on how to think about this and you have given me a direction.  I will definitely try all of your suggestions out.  

0 Kudos
Message 3 of 4
(1,786 Views)

Look into my tag cloud for Grandma.

 

There are rules you need to encode to a Message Handler.

 

Posting via phone


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 4
(1,761 Views)