LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Back and Forward Buttons

I'm working on a queued state machine.  The VI below is an example of a VI that is used in one of the cases.  It contains a BACKWARD_BUTTON and a FORWARD_BUTTON with hidden BACKWARD and FORWARD indicators and a NEXT_BUTTON.  There is a numeric control in which the user enters a number to be validated.  When the user types the number and enters it via the NEXT button, the VI attempts to validate the data and lights up the green PASS LED if the data is good or the red FAIL LED if the data is bad.
 
I have added a blank terminal to this VI.  I want to send a number out of this terminal to an ENQUEUE ELEMENT VI to indicate which case should happen next.  If the FAIL indicator is true, I would like to send out a 1.  If the PASS indicator is true, I would like to send out a 2.  If at any time when the VI is running the user presses the BACKWARD_BUTTON, I would like to send out a 0. If at any time when the VI is running the user presses the FORWARD_BUTTON, I would like to send out a 2.
 
 
I'm having a little bit of trouble figuring out the logic to do this, and I'd like the solution to be generic enough that I could apply it to other VIs that I am using in other cases within the program.  Can anyone help me?
0 Kudos
Message 1 of 13
(3,555 Views)
Give this a try. It uses the event structure. I also removed the sequence structure because there's no reason for it and removed the initialize to default because I don't think it's necessary.
0 Kudos
Message 2 of 13
(3,534 Views)
The white field above the numeric control in the VI is a string control called "QUERY.”  It corresponds to the input terminal of the VI.  When I run the modified VI you sent me, the string input doesn't appear in the string control.  The original VI was designed to print a generic question in the string control that would vary according to the string constant that was wired to the input terminal of the VI.  Can the VI you created be modified to accommodate this?
0 Kudos
Message 3 of 13
(3,530 Views)
The one I posted did not delete the reinit to default. Remove that. You should also set the mechanical action of the next button to Latch when Released.
0 Kudos
Message 4 of 13
(3,515 Views)
Dennis,
 
I took out the reinit all to default, and set the mechanical action of the NEXT button to latch when released.  Now the BACKWARD and FORWARD buttons don't work anymore.  I'd like, if possible, to keep a short 2 second delay between subsequent frames, and have a reinit all to default before the case loads so that everything is reinitialized before the query "What is the truck number?" is loaded.  I was going to send you my latest attempt at getting the VI to work the way I want it to, but I guess I'll just send you the entire program so that you can see the grand scheme of what I am trying to do.  I appreciate your help.
 
Thanks,
 
Drew
0 Kudos
Message 5 of 13
(3,506 Views)
Leaving in the reinit to default can be a problem. If you call it first, it's liable to clear the text display and if you put it last, it will clear your indicators. Every time I run the example I made, the truck number reinints to zero. It doesn't remember the last entry. What else do you need to initialize? Also, in my example, clicking the forward or back stops the VI and returns the values you asked for. What else do you want them to do? I deleted the hidden indicators but you can put them back if you need them. If you want a delay, put a wait or delay statement in the events or outside the while loop. If outside, you use dataflow to control when it is run. The dealy function has an error in connection so if you put a error cluster inside the while loop and wire it out to the delay function, the dealy will happen after the while loop finishes.
 
Also, you only posted the top level VI. That does not include all subVIs. To post everything, go to Save with Options and select Development Distribution. that will create an LLB with all files.
0 Kudos
Message 6 of 13
(3,496 Views)

Dennis,

 

I think the reinit was the earlier cause of the blank text display.  Clearing the indicators after each frame is something I want to happen.  If a frame has to be repeated for some reason, like an invalid entry, I would like the user to have a reinitialized frame to work with.  Indicators and controls must be cleared, and the proper query must reappear in the text display.  I would like to see the delay only on valid or invalid data entries.  Not when skipping from frame to frame.

 

Thanks for the hot tip on sending LLBs.  I’ll try sending you the whole program and maybe you’ll better understand what I’m trying to do.  Again, I appreciate your help.  I think that once I’m able to use my backward and forward buttons to skip from frame to frame, I should be good for a while.  Well here it is.  Let me know what you think.  In the meantime, I’ll try experimenting with those error cluster/delay arrangements you mentioned.

 

Thanks,

 

Drew
0 Kudos
Message 7 of 13
(3,486 Views)
Clearing the indicators in the subVI will mean that the only thing that the subVI will return is the default value. It will not return the results of the next, back, forward, pass, fail, or anything else. If you want your subVI to do anything, you do the clearing before the while loop runs and I simply don't see a reason to clear anything. If the main VI calls the subVI again, the query will be whatever you pass to it again.
0 Kudos
Message 8 of 13
(3,484 Views)
If I run the program and run through the Truck Number VI and then try to stop and rerun the program.  The LED indicator in the Truck Number VI is still lit.  That is why I need to reinitialize the VI.  Those indicators need to be cleared whenever the user restarts the program.
0 Kudos
Message 9 of 13
(3,481 Views)
Okay, I see that now. Still, you do this in the beginning and not at the end. All you have to do is write a false constant to local variables of the indicators.
0 Kudos
Message 10 of 13
(3,476 Views)