Go to Post I never cease to be amazed at the creative engineering employed by some teams. - Karthik [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2010, 12:05
Rikard023's Avatar
Rikard023 Rikard023 is offline
Programmer/Animator/Captain/Ninja
AKA: Rikard
FRC #0522 (The Robowizards)
Team Role: Programmer
 
Join Date: Sep 2009
Rookie Year: 2008
Location: Staten Island,NY
Posts: 20
Rikard023 is an unknown quantity at this point
Send a message via AIM to Rikard023
Program Delay

In windriver is there a way to program a button to activate lets say a jaguar to turn on a motor for short time then hav the same button activate a piston a second later
__________________
"Sharp edges are prone to cause bleeding trust me i know" T.T

http://www.robowizards.com
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2010, 13:18
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Program Delay

There exists a way to program your robot to do pretty much anything. You have to define the conditions you want things to operate in. For instance:

You have Switch A, and Switch B.

If Switch A is on, then pressing Switch B causes action X to happen.
If Switch A is off, then pressing Switch B causes action Y to happen.

You can also cause a switch to perform one action, such as turning a motor on, then activate a timer, and when the timer expires, do something else.
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2010, 14:22
Rikard023's Avatar
Rikard023 Rikard023 is offline
Programmer/Animator/Captain/Ninja
AKA: Rikard
FRC #0522 (The Robowizards)
Team Role: Programmer
 
Join Date: Sep 2009
Rookie Year: 2008
Location: Staten Island,NY
Posts: 20
Rikard023 is an unknown quantity at this point
Send a message via AIM to Rikard023
Re: Program Delay

how would i make it activate the timer
__________________
"Sharp edges are prone to cause bleeding trust me i know" T.T

http://www.robowizards.com
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2010, 15:49
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Program Delay

You need to instantiate an object of the Timer class, and then call the Timer->Start(); function in your button code. Then in the routine that runs when the timer expires, you do something else.

Look up the WPILib Documentation on the Timer class.
Reply With Quote
  #5   Spotlight this post!  
Unread 10-02-2010, 09:25
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Program Delay

Rikard, if I'm understanding your original post, you want to perform two actions with a single input, with the first action occurring immediately and the second occurring a second later. Instead using a timer (which would force you to continuoulsy check to see if a second has elapsed), you could use a Notifier class.

To use the Notifier class, you first create a function you want called after your elapsed time period (i.e. a function that would activate the piston in your case). The function takes a void pointer. You could use this by passing in a pointer to the solonoid you want to actuate, for example, and cast it back to a Solonoid pointer in the function.

Now to use the notifier class, when you construct it, give it the name of the function you want called as the TimerEventHandler argument and the pointer you want to pass to the function as the param argument. Then, when the user presses the button (or whatever your input is), call Notifier::StartSingle with the delay in seconds as the argument. In that amount of time, your function will automatically be called with the parameter you provided it.

I know this is kind of advanced programming, and if you're confused, feel free to PM me, but I think it would be the best way to do it. Unlike a timer, the Notifier class will automatically call your function in the specified amount of time without you having to worry about it any more.
__________________
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A boolean delay m3rc1l3ss NI LabVIEW 1 18-02-2009 21:51
cRIO Program Delay bomber7 Programming 2 29-01-2009 21:35
Delay jasonpeinko Programming 8 18-01-2008 15:56
Delay in the segment of the program Lessa Programming 1 10-02-2006 02:06
Delay Gal Longin Programming 1 09-12-2004 10:37


All times are GMT -5. The time now is 15:13.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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