View Single Post
  #1   Spotlight this post!  
Unread 20-02-2010, 21:04
TUBZ TUBZ is offline
Registered User
FRC #1622
 
Join Date: Jan 2009
Location: California
Posts: 7
TUBZ is an unknown quantity at this point
Exclamation Limit switch not working properly.

We want to use two limit switches to control a motor in forward and in reverse.

The limit switches are actuating on all channels of the digital sidecar, it does not matter which port we plug it into. We want the switch to stop the individual motors from running. We have tried both constructors (channel only, as well as slot and channel) with the same results. Our code is:

Code:
DigitalInput *limitSwitchReverse;
DigitalInput *limitSwitchForward;

// Ctr using only channel
limitSwitchReverse = new DigitalInput(13);
limitSwitchForward = new DigitalInput(14);

// Alternative: Ctr using slot and channel
//limitSwitchReverse = new DigitalInput(4, 13);
//limitSwitchForward = new DigitalInput(4, 14);


if (btn1)
{
	if(limitSwitchReverse->Get() == 0)
	{
		device->Set(Relay::kOff);
	}
	else
	{
		device->Set(Relay::kReverse);					
	}
}
else if (btn2)
{
	if(limitSwitchForward->Get() == 0)
	{
		device->Set(Relay::kOff);
	}
	else
	{
		device->Set(Relay::kForward);					
	}
}
else 
{
	device->Set(Relay::kOff);
}
could someone please post a sample code which demonstrates the correct way to use a limit switch connected to the Digital I/O, to interrupt a spike connected to the Relay.


Thanks
__________________
.~~~
SHIZAMLES!!!
Reply With Quote