Go to Post Dreams come and go, but once life throws a football you have to think fast. - Pavan Dave [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 23-03-2013, 13:00
cisasteelersfan cisasteelersfan is offline
Registered User
FRC #0222
 
Join Date: Nov 2012
Location: Tunkhannock
Posts: 1
cisasteelersfan is an unknown quantity at this point
Run a series of instructions when button is pressed

Hi all,
I'm trying to figure out how to 'automate' our shooting process. Currently in teleop we simply have a button wired to a solenoid: true means forward, and reverse means back.

When a button is held down, we want the solenoid to go forward and back four times in a certain amount of time.

What I've tried is putting a global variable that is true when the button is pressed. This gets passed to periodic tasks where if true, it runs a for loop four times. This outputs to another global variable that is passed to teleop that controls the solenoid (forward or reverse).

It doesn't work as programmed. Does anybody have any ideas? I considered putting an autonomous-style loop in teleop, but is that the optimal solution?

Any suggestions are greatly appreciated!
Reply With Quote
  #2   Spotlight this post!  
Unread 23-03-2013, 14:14
Suitster's Avatar
Suitster Suitster is offline
Registered User
AKA: Ethan Pellittiere
FRC #3951 (SUITS)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Honeoye
Posts: 79
Suitster is on a distinguished road
Re: Run a series of instructions when button is pressed

Putting a loop in teleop is usually the least optimal solution. It will drain processing speed, and likely cause lag.
The way that we programmed our shooter this year used the wheel RPM as an indicator for if a frisbee was shot. If the RPM suddenly dropped, then a frisbee was launched.

Another way we programmed it was using a timing VI, which would send a boolean based on the elapsed time. That timer can be kept in teleop without slowing down the program.

We got the fastest and most consistent shooting using the first method, paired with RPM monitoring in periodic tasks. The RPM sensor would write to an array, and the last 25 numbers in the array were sampled and tested to see if they were within 3% of one another. When the wheel speed leveled off,
we would send a true global variable to teleop, which would send the solenoid forward. When the RPM dropped from the disk leaving, that would change the variable to false, and the solenoid would retract.
__________________
2012 FLR Regional Champs, with 1507 and 191
Reply With Quote
  #3   Spotlight this post!  
Unread 23-03-2013, 17:37
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Run a series of instructions when button is pressed

Quote:
Originally Posted by cisasteelersfan View Post
What I've tried is putting a global variable that is true when the button is pressed. This gets passed to periodic tasks where if true, it runs a for loop four times. This outputs to another global variable that is passed to teleop that controls the solenoid (forward or reverse).
That seems kind of the long way around to do it. Why not just do everything in Periodic Tasks? Read the controller button and use it to either do nothing or run the For loop. Set the solenoid right there inside the For. Put the whole thing inside a While loop that has a 20 ms delay.
Reply With Quote
  #4   Spotlight this post!  
Unread 23-03-2013, 18:42
NeatNit's Avatar
NeatNit NeatNit is offline
Alumni Programmer
FRC #1577 (Steampunk)
Team Role: Teacher
 
Join Date: Sep 2011
Rookie Year: 2011
Location: Israel
Posts: 60
NeatNit is an unknown quantity at this point
Re: Run a series of instructions when button is pressed

If you want the process to stop when you let go of the button, the code gets more complicated. You would need a State Machine.
Reply With Quote
  #5   Spotlight this post!  
Unread 31-03-2013, 16:08
lorem3k's Avatar
lorem3k lorem3k is offline
1 + 1 = 0 (in Z/2Z)
AKA: Andy D.
FRC #1482 (Bishop Grandin Ghosts)
Team Role: Alumni
 
Join Date: Apr 2012
Rookie Year: 2011
Location: Calgary, AB
Posts: 165
lorem3k is a splendid one to beholdlorem3k is a splendid one to beholdlorem3k is a splendid one to beholdlorem3k is a splendid one to beholdlorem3k is a splendid one to beholdlorem3k is a splendid one to behold
Re: Run a series of instructions when button is pressed

We have a similar setup. In Teleop, we set a global variable whenever the shoot button is pressed, and then in Periodic Tasks, we have a flat sequence structure for timing the solenoid's activation. This structure is inside one of Periodic Task's while loops, so it runs continuously while the button is being held down. I've attached our code so you can take a look.
Attached Files
File Type: vi Shoot2.vi (24.2 KB, 17 views)
File Type: vi Solenoid Cycle.vi (34.4 KB, 12 views)
__________________
Boo! Bishop Grandin High School / GM Canada / Tenaris
2013 Western Canada - Quarterfinalists (thanks 288/4719) / 2012 GTR West - Quarterfinalists (thanks 188/1075) / 2011 GTR East - Regional Winners (thanks 1114/1503)
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 22:53.

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