Go to Post In theory, there is no difference between theory and practice. In practice, however... - Alan Anderson [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 20-02-2013, 17:44
Anyun Anyun is offline
Co-Captain Team 1308
FRC #1308 (Wildcats)
Team Role: Programmer
 
Join Date: Aug 2012
Rookie Year: 2009
Location: Cleveland
Posts: 13
Anyun is an unknown quantity at this point
Re: How to code limit switch to stop movement

We're actually doing something similar. Our launcher is lifted using two motors (LifterA and Lifter B), and we wired our limit switches so that the upper is 1 when depressed and the lower is 1 when open. The upper limit becomes open onces the ramp reaches the furthest up we want it to go, while the lower limit becomes closed when it goes the furthest down we want it to go. Our code looks something like this:

if(stick.GetRawButton(4) && UpperLimit.Get() == 1)
// if button 4 is pressed and upper limit is pressed, lifter goes up
{
LifterA.Set(0.4);
LifterB.Set(0.4);
}
else if(stick.GetRawButton(5) && LowerLimit.Get() == 1)
// if button 5 is pressed and lower limit is not pressed, lifter goes down
{
LifterA.Set(-0.4);
LifterB.Set(-0.4);
}
else
{
LifterA.Set(0.0);
LifterB.Set(0.0);
}
Reply With Quote
 


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 12:06.

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