Go to Post I truly love zipties. They're so elegant - permanent, yet disposable. Strong, yet flexible. Ubiquitous, yet somehow.... special. - Kris Verdeyen [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

 
Reply
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 20-02-2010, 21:11
whatabouteve whatabouteve is offline
Registered User
AKA: Dean Keithly
FRC #0245 (Adambots)
Team Role: Leadership
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rochester Hills,MI
Posts: 45
whatabouteve is an unknown quantity at this point
Re: Limit switch not working properly.

class RobotDemo : public SimpleRobot
{
DigitalInput *switch1;
}

public:
RobotDemo(void):
{
switch1 = new DigitalInput(4,2);//4 is the modual in cRio and 2 the input port
}


that is initializing it but you need to do the rest. you will get a 1 or 0 and need to declare a bool variable to take the number from it in the form

variable = switch1->Get();
or
use switch1->Get() in your conditional


hope it helps
Reply With Quote
  #3   Spotlight this post!  
Unread 20-02-2010, 21:24
TUBZ TUBZ is offline
Registered User
FRC #1622
 
Join Date: Jan 2009
Location: California
Posts: 7
TUBZ is an unknown quantity at this point
Re: Limit switch not working properly.

1) we tried what you said, even though the logic wasn't any different than our original, and we still had the same results.

2) we also found that when we actuate the limit switch, it not only blocks all relays but also all the PWM outs.
__________________
.~~~
SHIZAMLES!!!
Reply With Quote
  #4   Spotlight this post!  
Unread 20-02-2010, 21:48
whatabouteve whatabouteve is offline
Registered User
AKA: Dean Keithly
FRC #0245 (Adambots)
Team Role: Leadership
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rochester Hills,MI
Posts: 45
whatabouteve is an unknown quantity at this point
Re: Limit switch not working properly.

2 quick things you have things in the code posted that are not declared and things. if you posted the whole thing then i might be able to help better. sometimes there are just miniscule errors that someone else can see but you can't.

for the second thing how do you get the code to go into that grey box thing
Reply With Quote
  #5   Spotlight this post!  
Unread 20-02-2010, 22:32
TUBZ TUBZ is offline
Registered User
FRC #1622
 
Join Date: Jan 2009
Location: California
Posts: 7
TUBZ is an unknown quantity at this point
Re: Limit switch not working properly.

grey box thing? CRio?
__________________
.~~~
SHIZAMLES!!!
Reply With Quote
  #6   Spotlight this post!  
Unread 20-02-2010, 22:43
whatabouteve whatabouteve is offline
Registered User
AKA: Dean Keithly
FRC #0245 (Adambots)
Team Role: Leadership
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rochester Hills,MI
Posts: 45
whatabouteve is an unknown quantity at this point
Re: Limit switch not working properly.

no i mean on the forum where it says code and has the grey box of code

code:
(grey box with code)
Reply With Quote
  #7   Spotlight this post!  
Unread 20-02-2010, 23:01
TUBZ TUBZ is offline
Registered User
FRC #1622
 
Join Date: Jan 2009
Location: California
Posts: 7
TUBZ is an unknown quantity at this point
Re: Limit switch not working properly.

oh, haha sry. well we figured out was was wrong, we had some crossed wires.. but thank you for your help
__________________
.~~~
SHIZAMLES!!!
Reply With Quote
  #8   Spotlight this post!  
Unread 20-02-2010, 23:03
whatabouteve whatabouteve is offline
Registered User
AKA: Dean Keithly
FRC #0245 (Adambots)
Team Role: Leadership
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Rochester Hills,MI
Posts: 45
whatabouteve is an unknown quantity at this point
Re: Limit switch not working properly.

good luck
Reply With Quote
Reply


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
Code not loading properly Al3+ C/C++ 19 31-01-2010 01:11
Laptop is not finding the cRIO properly? Studentish Electrical 4 07-05-2009 12:03
1 joystick controls not turning properly andrew_4_life Programming 4 28-03-2008 01:22
Using a limit switch to limit motion ManicMechanic Programming 16 20-12-2007 00:54
PLEASE HELP: OI switch box not working RbtGal1351 Control System 2 18-02-2006 19:34


All times are GMT -5. The time now is 13:54.

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