Go to Post make sure to make it look really cool, it makes it easier for teams to remember you, which comes in handy for alliance selections ;) - Holtzman [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-02-2014, 23:01
Wildcats1378 Wildcats1378 is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: hawaii
Posts: 93
Wildcats1378 is an unknown quantity at this point
Waiting Until Limit Switch Is Pressed

Hello everyone!

So I am the programmer mentor and team lead for the Wildcats #3878 here in Hawaii.

I am writing a piece of code for our shooter that will continue moving a motor until it hits a certain limit switch, and then continues onto the next frame.

I am writing the code in an autonomous program as part of a flat sequence to $@#$@#$@#$@# the catapult to a set area based on limit switch, to determine the power of the shot we want.

How might this be accomplished?

Thanks everyone,
#3878 Head Programmer
  #2   Spotlight this post!  
Unread 07-02-2014, 23:14
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Waiting Until Limit Switch Is Pressed

Put it in a loop? I'm not sure how specific to get - depends on what framework you are using. Something like this..

...
while(limit input is not asserted and still in auto mode)
{
set motor speed
}

stop motor
...
__________________
Fast, cheap or working - pick any two!
  #3   Spotlight this post!  
Unread 08-02-2014, 00:14
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Waiting Until Limit Switch Is Pressed

I would recommend hooking the limit switch up to the Jaguar, so it automatically turns itself off. No code required.

Read the Jaguar's datasheet to determine how the limit switch functionality works and where you need to hook it up to.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #4   Spotlight this post!  
Unread 08-02-2014, 00:51
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: Waiting Until Limit Switch Is Pressed

Quote:
Originally Posted by Wildcats1378 View Post
I am writing a piece of code for our shooter that will continue moving a motor until it hits a certain limit switch, and then continues onto the next frame...
How might this be accomplished?
You mentioned a flat sequence, so I assume you're using LabVIEW.

Just put a while loop in the frame, reading the limit switch inside the loop and using the returned value as the termination condition for the loop. It'll keep looping until the switch is activated. Be sure to also put a 10 ms delay (or thereabouts) inside the loop so it doesn't use up all the CPU cycles just waiting for the switch.

Quote:
Originally Posted by virtuald View Post
I would recommend hooking the limit switch up to the Jaguar, so it automatically turns itself off. No code required.
In this case, code is definitely required. This is a sequence of events that waits at one step until the switch is hit, so the program needs to be reading the switch.
  #5   Spotlight this post!  
Unread 08-02-2014, 22:05
tcjinaz tcjinaz is offline
Tim
FRC #3853
Team Role: Mentor
 
Join Date: May 2011
Rookie Year: 2011
Location: Arizona
Posts: 206
tcjinaz has a spectacular aura abouttcjinaz has a spectacular aura about
Re: Waiting Until Limit Switch Is Pressed

Is 10MS good enough to catch one of those switches with the lever arm and roller on the end? I am fretting about catching the signal in time to prevent arms slamming into supports.

I am almost wishing for interrupt driven controls here. Is there a way?

Tim
__________________
Software Mentor
3853 Pridetronics[

  #6   Spotlight this post!  
Unread 08-02-2014, 23:28
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Waiting Until Limit Switch Is Pressed

Quote:
Originally Posted by tcjinaz View Post
Is 10MS good enough to catch one of those switches with the lever arm and roller on the end? I am fretting about catching the signal in time to prevent arms slamming into supports.
How far will the mechanism travel in 10ms? How quickly will the motor stop? And is that distance dangerous? In FRC, it is hard to imagine 10ms being too long for most any event-driven response but I would do the math.

HTH
__________________
Fast, cheap or working - pick any two!
  #7   Spotlight this post!  
Unread 09-02-2014, 00:42
Adamz_'s Avatar
Adamz_ Adamz_ is offline
Who wants coffee?
AKA: Connor Adams
FRC #4519 (Kings Mechavaliers)
Team Role: Mentor
 
Join Date: May 2013
Rookie Year: 2013
Location: Oakville
Posts: 33
Adamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to behold
Re: Waiting Until Limit Switch Is Pressed

i dont know what language your using, but in java it would look something like this

Code:
if(!limitSwitch.get()){
   motor.set(1.0);
 }else if(limitSwitch.get()){
   motor.set(0.0);
}
in englsih all this is doing is saing, if the limit switch if false (not pressed) spin the motor, then in the else if statement, it checks if the limit switch is true (pressed) and if it is, it will stop the motor, if you want it so once its in this state, you press a button to shoot, the code would be this;

Code:
if(!limitSwitch.get()){
   motor.set(1.0);
 }else if(limitSwitch.get()){
   motor.set(0.0);
 }else if(controller.getRawButton(1)){
  motor.set(1.0);
}
__________________
2016 North Bay Regional Finalists
2016 Greater Toronto Central Regional Semi-Finalists
2015 Windsor Essex Great Lakes Regional Quarter-Finalists
2014 Windsor Essex Great Lakes Regional Semi-Finalists
2014 Waterloo Regional Quarter-finalists
2013 Waterloo Regional Highest Rookie Seed
2013 Waterloo Regional Rookie All Star Recipient
  #8   Spotlight this post!  
Unread 09-02-2014, 00:45
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: Waiting Until Limit Switch Is Pressed

When we're worried that we might miss a brief switch input between samples, we open the input as a counter instead. Then we watch for the counter to change values, and that tells us the switch was hit.

If something pulses quickly enough to be missed by the FPGA, we've already got some re-engineering to do.
  #9   Spotlight this post!  
Unread 09-02-2014, 09:14
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 577
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
Re: Waiting Until Limit Switch Is Pressed

This is as much a question of programming as it is of limit switch positioning.

It's often easier to modify the limit switch position to solve end position problems like this.
__________________
2016-17 events: 10000 Lakes Regional, Northern Lights Regional, FTC Burnsville Qualifying Tournament

2011 - present · FRC 3081 Kennedy RoboEagles mentor
2013 - present · event volunteer at 10000 Lakes Regional, Northern Lights Regional, North Star Regional, Lake Superior Regional, Minnesota State Tournament, PNW District 4 Glacier Peak, MN FTC, CMP
http://twitter.com/MrRoboSteve · www.linkedin.com/in/speterson
  #10   Spotlight this post!  
Unread 09-02-2014, 13:52
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Waiting Until Limit Switch Is Pressed

I would be less worried about detecting the limit switch as I would stopping a fast moving part with a lot of inertia. Programming can only minimally impact the latter.
  #11   Spotlight this post!  
Unread 08-02-2014, 22:06
Whippet's Avatar
Whippet Whippet is offline
MIT Class of 2020
AKA: Luis Trueba
FRC #4301 (New Tech Narcissists)
Team Role: Alumni
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Cambridge, MA
Posts: 1,187
Whippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond reputeWhippet has a reputation beyond repute
Send a message via Yahoo to Whippet
Re: Waiting Until Limit Switch Is Pressed

Quote:
Originally Posted by Wildcats1378 View Post
...flat sequence to $@#$@#$@#$@# the catapult...
Wow, CD really doesn't like for people to reload their launchers...
__________________
2010: FRC 3043, Build Assistant
2011: FRC 3043, Head of Minibot subteam; FLL 12762, Team Captain
2012: FRC 3043, Electrical; FLL 12762, Team Captain; FTC 5670, Team Captain
2013: FRC 4301, Electrical, Team Co-Captain
2014: FRC 4301, Electrical/Programming, Team Co-Captain
2015: FRC 4301, Electrical/Programming, Team Captain
2016: FRC 4301, Chief Technical Officer; FTC 10860, 10861, and 11004: Mentor. Winner, Hub City Regional (3310 & 4063)
Closed Thread


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 02:35.

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