Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   On Button press, run a sequence (Not momentary!) (http://www.chiefdelphi.com/forums/showthread.php?t=103045)

dwmcc 16-02-2012 22:28

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

Re: On Button press, run a sequence (Not momentary!)
 
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

Re: On Button press, run a sequence (Not momentary!)
 
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...

dwmcc 17-02-2012 18:56

Re: On Button press, run a sequence (Not momentary!)
 
Quote:

Originally Posted by Alan Anderson (Post 1128493)
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

Re: On Button press, run a sequence (Not momentary!)
 
1 Attachment(s)
Try this.

dwmcc 18-02-2012 14:21

Re: On Button press, run a sequence (Not momentary!)
 
Quote:

Originally Posted by Alan Anderson (Post 1129266)
Try this.

Thank you so much! Worked perfectly.

gabrielc97 19-02-2012 12:27

Re: On Button press, run a sequence (Not momentary!)
 
[quote=Alan Anderson;1129266]Try this


how can i program this to control a motor?

Pirate programe 19-02-2012 12:52

Re: On Button press, run a sequence (Not momentary!)
 
[quote=gabrielc97;1130131]
Quote:

Originally Posted by Alan Anderson (Post 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

Re: On Button press, run a sequence (Not momentary!)
 
[quote=Pirate programe;1130143]
Quote:

Originally Posted by gabrielc97 (Post 1130131)

Change the DIO VIs to MotorControl VIs, with parameters controlling it as you need to?

Thanks! we'll try that.


All times are GMT -5. The time now is 11:18.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi