Go to Post Some of the most talented people in the world are designing robots in FIRST. If that were taken away, all of us would be poorer for it. - Andrew [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 18-12-2007, 16:35
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,369
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Using a limit switch to limit motion

Now that I have cleaned my glasses.....

One way that you can do what you need is to create you own functions like the ones in the FRC default code that I will copy in here. Just use these in place of the code you are now using that forces your arm back and then allows it to move forward again.

These examples are straight out of the default code and will need to be modified to match your existing code. These are examples only, and will not work "as is".

Code:
void Limit_Switch_Max(unsigned char switch_state, unsigned char *input_value)
{
  if (switch_state == CLOSED)
  { 
    if(*input_value > 127)
      *input_value = 127;
  }
}
And

Code:
void Limit_Switch_Min(unsigned char switch_state, unsigned char *input_value)
{
  if (switch_state == CLOSED)
  { 
    if(*input_value < 127)
      *input_value = 127;
  }
}
These two functions allow the motion to be limited in one direction, but not the other.

For your code, substitute in your PWM to be limited for "*input_value" and your limit switch input for "switch_state".

I assume someone on your team understands code, at least in a limited way, otherwise you would not have been able to get your code operating the way it is already. They should be able work with these.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #2   Spotlight this post!  
Unread 18-12-2007, 16:42
ManicMechanic ManicMechanic is offline
Registered User
AKA: Yolande
VRC #0438 (Metal Gear)
Team Role: Mentor
 
Join Date: Dec 2005
Rookie Year: 2003
Location: CA
Posts: 213
ManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond repute
Re: Using a limit switch to limit motion

Thanks for all the suggestions. Potentiometers are a bit beyond us (we're FTC, and I don't think Vex has a pot), but the gravity suggestion got us thinking that we need little or no motor input to back away from the limit. Before, we were running the motors at full power when we backed away, so there was lots of wobble. Slowing the motors, there was far less wobble, and it's now in the tolerable range.
__________________
He is no fool who gives what he cannot keep to gain that which he cannot lose. - Jim Elliot
  #3   Spotlight this post!  
Unread 18-12-2007, 18:36
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: Using a limit switch to limit motion

Quote:
Originally Posted by ManicMechanic View Post
Thanks for all the suggestions. Potentiometers are a bit beyond us (we're FTC, and I don't think Vex has a pot), but the gravity suggestion got us thinking that we need little or no motor input to back away from the limit. Before, we were running the motors at full power when we backed away, so there was lots of wobble. Slowing the motors, there was far less wobble, and it's now in the tolerable range.
Potentiometers are possible with Vex. Anyways, there is simple code to limit your joysticks from going full force on the way down.

http://www.chiefdelphi.com/forums/sh...ad.php?t=59901

The entire thread is useful, but the simplest way to do it is located in the second-to-last post.
__________________
  #4   Spotlight this post!  
Unread 19-12-2007, 00:55
ChrisH's Avatar Unsung FIRST Hero
ChrisH ChrisH is offline
Generally Useless
FRC #0330 (Beach 'Bots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 1,230
ChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond reputeChrisH has a reputation beyond repute
Re: Using a limit switch to limit motion

Quote:
Originally Posted by slavik262 View Post
Potentiometers are possible with Vex. Anyways, there is simple code to limit your joysticks from going full force on the way down.

http://www.chiefdelphi.com/forums/sh...ad.php?t=59901

The entire thread is useful, but the simplest way to do it is located in the second-to-last post.
A little birdie told me that Vex will be selling pots early in the new year.
__________________
Christopher H Husmann, PE

"Who is John Galt?"
  #5   Spotlight this post!  
Unread 19-12-2007, 00:58
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,369
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Using a limit switch to limit motion

Quote:
Originally Posted by ChrisH View Post
A little birdie told me that Vex will be selling pots early in the new year.
Sweet!!!
I won't have to make my own any more!
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #6   Spotlight this post!  
Unread 20-12-2007, 00:54
ManicMechanic ManicMechanic is offline
Registered User
AKA: Yolande
VRC #0438 (Metal Gear)
Team Role: Mentor
 
Join Date: Dec 2005
Rookie Year: 2003
Location: CA
Posts: 213
ManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond reputeManicMechanic has a reputation beyond repute
Re: Using a limit switch to limit motion

After some futzing with the terminal window, our programmer was able to retrieve the joystick position and use it to stop upward motion on the joysticks if the limit is reached, but still enable the joysticks for downward motion (now there is no wobble). His comment on this discovery was "Programming with Vex is Jawesome!"
Attached Thumbnails
Click image for larger version

Name:	yotsubot.JPG
Views:	56
Size:	49.6 KB
ID:	5862  
__________________
He is no fool who gives what he cannot keep to gain that which he cannot lose. - Jim Elliot
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a limit switch thunderbolt Programming 1 02-04-2007 19:36
limit switch wedellm Electrical 4 16-02-2007 13:01
Limit Switch Basics JWSnedden Programming 6 30-11-2006 19:48
Limit switch in easy c? chadbarbe Programming 6 02-02-2006 09:51


All times are GMT -5. The time now is 03:16.

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