Go to Post According to a recent study, 63% of teams admit they are behind. The other 37% are lying. - nitneylion452 [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
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 18-02-2012, 22:20
demons858 demons858 is offline
Registered User
FRC #0858 (Demons)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2005
Location: grand rapids, michigan
Posts: 10
demons858 is an unknown quantity at this point
time delayed task

Hello,
Our robot has a button that when pressed gives full power to our shooting mechanism. We also have a belt that supplies the shooter with the balls. I have put together a function to run both the belt motor and the shooting motor when a button is pressed. However we need the belt to start 2 seconds after the shooting motor engages. I am having a major block here and can't figure out how to put a 2 second delay on a task after the button is pressed. I have looked all over and not found anything for the past few days. If anyone can offer any help or examples, it would be greatly appreciated.

thank you
Reply With Quote
  #2   Spotlight this post!  
Unread 19-02-2012, 08:22
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: time delayed task

Probably the easiest way is to call this function every time through teleop to update the state. In the function you use a shift register, feedback node, or even a global variable to remember the state of your device.

Your states are -- "off", "starting up", and "shooting". You can also remember things such as when you started applying power.

Each call to the loop you can look at the desired state and the actual state and do things to the motors and the state variables.

For example, let's say that you call the function with the button pressed and the device state is "off". Your function will set the shooter motor speed to 1.0, change the state variable to "starting up", and note that time t0 was when the motors were powered up.

On subsequent calls, you will see that the button is still pressed and the state is "starting up", so you will check to see if two seconds have elapsed since t0. If not, there is nothing to do.

On a call when the button is still down, the state is "spinning up", and two or more seconds have elapsed, you can update the other motor and set the state to "shooting".

If the function is called and the button is up, you update the motor speeds to zero and change the state to "off" and perhaps remember when you turned them off. You don't really need this info, but if you want to speed up subsequent shots, you may not need to wait a full two seconds if the last show was a half second ago.

This SW technique is called a state machine and it is used all the time. You may be able to find examples of it, or you can post more questions if you do not.

Greg McKaskle
Reply With Quote
  #3   Spotlight this post!  
Unread 19-02-2012, 14:19
demons858 demons858 is offline
Registered User
FRC #0858 (Demons)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2005
Location: grand rapids, michigan
Posts: 10
demons858 is an unknown quantity at this point
Re: time delayed task

Thank you, that helps
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


All times are GMT -5. The time now is 04:14.

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