|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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);
}
Last edited by Zellboy : 12-02-2009 at 16:29. |
|
#2
|
|||||
|
|||||
|
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
|
|||
|
|||
|
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
|
|||||
|
|||||
|
Re: Limit Switch problem
You just need to turn
Code:
if (limit_switch_active)
{
activate_solenoid_6;
activate_solenoid_7;
}
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
|
|||
|
|||
|
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);
}
|
|
#6
|
||||
|
||||
|
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);
}
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |