Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Limit Switch problem (http://www.chiefdelphi.com/forums/showthread.php?t=74254)

Zellboy 12-02-2009 16:02

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?

Alan Anderson 12-02-2009 16:43

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?

Zellboy 12-02-2009 16:48

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

Alan Anderson 12-02-2009 16:59

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?

Zellboy 12-02-2009 17:21

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?

Redneck 12-02-2009 19:38

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?


All times are GMT -5. The time now is 02:24.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi