View Full Version : On Button press, run a sequence (Not momentary!)
As the title suggests, I'm trying to figure out how to run a sequence of events (Actuate solenoid, get reed switch value and when it's true, stop solenoid) on a button press. I've tried a structure, but I can't figure out how to run a sequence of events on a button press. This issue I'm running in to is that since a button press is momentary, the sequence begins to run, but when the button is released, the sequence stops.
Any ideas?
Thanks so much!
dwmcc
Alan Anderson
16-02-2012, 23:01
The Flat Sequence structure is a natural for sequences of events. Each frame of the sequence will run in turn as the previous frame's functions complete. Put one in a neverending While in the Periodic Tasks vi, and make the first frame wait for the button press.
compboy07
16-02-2012, 23:03
try something like this psuedocode, point being use an 'isActive' type boolean. If you're using labview, you'll have to look at this yourself, and find a similar concept (never used it)
bool solenoidRunning = false; //at init
//following in main loop
if (!solenoidRunning && buttonPressed){
solenoidRunning = true;
activateSolenoid();
} else if (solenoidRunning && switchActivated) {
stopSolenoid();
solenoidRunning = false;
}
Edit: Sorry, forgot to look at the forum category...
The Flat Sequence structure is a natural for sequences of events. Each frame of the sequence will run in turn as the previous frame's functions complete. Put one in a neverending While in the Periodic Tasks vi, and make the first frame wait for the button press.
Thank you both for your reply. Alan, I have inserted my code into the Periodic Tasks vi in a neverending while loop, but how can I tell it to run it when I press the joystick button?
Thanks!
dwmcc
Alan Anderson
18-02-2012, 00:33
Try this.
Try this.
Thank you so much! Worked perfectly.
gabrielc97
19-02-2012, 12:27
[QUOTE=Alan Anderson;1129266]Try this
how can i program this to control a motor?
Pirate programe
19-02-2012, 12:52
[QUOTE=Alan Anderson;1129266]Try this
how can i program this to control a motor?
Change the DIO VIs to MotorControl VIs, with parameters controlling it as you need to?
gabrielc97
19-02-2012, 13:03
[QUOTE=gabrielc97;1130131]
Change the DIO VIs to MotorControl VIs, with parameters controlling it as you need to?
Thanks! we'll try that.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.