Go to Post you know you're going to meet someone important, so you put on your robotics team shirt. - NorviewsVeteran [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 12-02-2009, 16:02
Zellboy Zellboy is offline
Registered User
FRC #1203
 
Join Date: Jan 2009
Location: West Babylon
Posts: 4
Zellboy is an unknown quantity at this point
Limit Switch problem

We're trying to program a digital input with a limit switch. How do we set the if statement?

This is what we have so far

Code:
if(Clamplimit -> Get() > 0)
{
       s[0] -> Set(false);
       s[1] -> Set(true);
}
Is it correct?

Last edited by Zellboy : 12-02-2009 at 16:29.
  #2   Spotlight this post!  
Unread 12-02-2009, 16:43
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: Limit Switch problem

How you write the if statement depends on what you want it to do.

What do you want it to do?
  #3   Spotlight this post!  
Unread 12-02-2009, 16:48
Zellboy Zellboy is offline
Registered User
FRC #1203
 
Join Date: Jan 2009
Location: West Babylon
Posts: 4
Zellboy is an unknown quantity at this point
Re: Limit Switch problem

We have a claw connected to solenoids 7 and 6. We want the limit switch to close the claw when it's hit
  #4   Spotlight this post!  
Unread 12-02-2009, 16:59
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: Limit Switch problem

You just need to turn
Code:
if (limit_switch_active)
{
    activate_solenoid_6;
    activate_solenoid_7;
}
into real code that compiles.

Replace limit_switch_active with whatever it takes to read your limit switch. That's something like Clamplimit->Get(), right? Replace the activate_solenoid_# with whatever it takes to put your solenoids in the desired state. I don't know how you've instantiated your limit switch or your solenoids, and I don't know how they are wired, so I can't give you working code to copy and paste.

I assume you'll want some way to open the claw later, right?
  #5   Spotlight this post!  
Unread 12-02-2009, 17:21
Zellboy Zellboy is offline
Registered User
FRC #1203
 
Join Date: Jan 2009
Location: West Babylon
Posts: 4
Zellboy is an unknown quantity at this point
Re: Limit Switch problem

This is how we have it set up

Code:
DigitalInput *Clamplimit;     //Limit Switch for clamp

Clamplimit = new DigitalInput(2); //Limit Switch for clamp (Digital Input)

if(Clamplimit)
{
       s[6] -> Set(false);
       s[7] -> Set(true);
}
Will this work as is?
  #6   Spotlight this post!  
Unread 12-02-2009, 19:38
Redneck's Avatar
Redneck Redneck is offline
Hacker Hick
AKA: Jamie (2.0) Moran
FRC #0599 (Robodox)
Team Role: Engineer
 
Join Date: Aug 2004
Rookie Year: 2004
Location: California
Posts: 90
Redneck is just really niceRedneck is just really niceRedneck is just really niceRedneck is just really nice
Send a message via AIM to Redneck
Re: Limit Switch problem

No, it needs to be:
Code:
DigitalInput *Clamplimit;     //Limit Switch for clamp

Clamplimit = new DigitalInput(2); //Limit Switch for clamp (Digital Input)

if(Clamplimit->Get())
{
       s[6] -> Set(false);
       s[7] -> Set(true);
}
Also, what class is s an instance of?
__________________


Which badges can you claim?
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
limit switch solomason519 Programming 9 09-02-2010 08:50
Limit Switch Problem Boydean Programming 3 13-02-2008 16:32
Using a limit switch to limit motion ManicMechanic Programming 16 20-12-2007 00:54
limit switch wedellm Electrical 4 16-02-2007 13:01


All times are GMT -5. The time now is 21:51.

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