Go to Post it seems to have all the basic food groups: liquid, sugar, sauce, and robotics components. - ChrisMcK2186 [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 14-02-2010, 23:49
z2daj z2daj is offline
Registered User
FRC #2836 (Team Beta)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Bethlehem, CT
Posts: 15
z2daj is an unknown quantity at this point
Send a message via AIM to z2daj
Limit Switch Draws Tears

Imagine yourself: 11 hours, 5 programmers, no mentors, 1 fiesty limit switch. The result? 5 programmers suffering a severe mental breakdown.

We are attempting to program a very simple limit switch that will disable a motor when the limit switch circuit is closed. We have wired the two limit switch wires into to the ground and signal connections on input four of the digital sidecar. We are programming in C++ and whenever we attempt to get a signal back from the input it always shows up as equaling one, no matter what we do. Please help us, it seemed so simple when we started 11 HOURS AGO!
__________________
There is nothing to fear, but fear itself
  #2   Spotlight this post!  
Unread 14-02-2010, 23:56
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Limit Switch Draws Tears

what are you using to discover the value? The Dashboard? If so the default dashboard code returns hard-coded values that do not reflect the status of the system

Make sure the digital module is on slot 4. Also make sure power is properly wired to the sidecar. Try last year's sidecar if you have to. Also try a different limit switch.

If you are using the CAN bus for motor control, you could just directly wire the limit switch to the Jaguar and forget about this entire mess
  #3   Spotlight this post!  
Unread 15-02-2010, 00:08
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 Draws Tears

Quote:
Originally Posted by z2daj View Post
We have wired the two limit switch wires into to the ground and signal connections on input four of the digital sidecar.
Have you verified that the switch works? How?

What are you using as a limit switch? The microswitches I'm familiar with have three connections.
  #4   Spotlight this post!  
Unread 15-02-2010, 00:14
z2daj z2daj is offline
Registered User
FRC #2836 (Team Beta)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Bethlehem, CT
Posts: 15
z2daj is an unknown quantity at this point
Send a message via AIM to z2daj
Re: Limit Switch Draws Tears

As far as we can tell everything is as you say, we have the module in slot 4 and are attemting to get the state of the input directly from the module itself not the dashboard. We simply created an object called Dig4 and set it equal to DigitalInput(1), here's the code.
Code:
#include "WPILib.h"
#include "Vision/AxisCamera.h"
#include "Vision/HSLImage.h"
#include "PIDController.h"
#include "Gyro.h"
#include "Target.h"
#include "DashboardDataSender.h"
#include "Jaguar.h"
#include "Compressor.h"
#include "Solenoid.h"
#include "Victor.h"


class DefaultRobot : public SimpleRobot
{
	
	//RobotDrive *myRobot;			// robot drive system
	Joystick *rightstick;			// joystick 2 
	Joystick *leftstick;			// joystick 1 
	Gyro *gyro;						// gyro initialization
	DashboardDataSender *dds;		// Driver station data sender
	DriverStation *ds;				// driver station object
	Victor *jag1;// single jaguar motor control
	Victor *jag2;
	Victor *jag3;
	Victor *jag4;
	Compressor *compressor; 		// new compressor object
	Solenoid *solleft;				// solenoid on left
	Solenoid *solright;				// solenoid on right
	DigitalInput *Dig1;
	
	enum Resolution_t
		{
			kResolution_320x240
		};
	/*enum							// Driver Station jumpers to control program operation
	{ ARCADE_MODE = 1,				// Tank/Arcade jumper is on DS Input 1 (Jumper present is arcade)
	  ENABLE_AUTONOMOUS = 2,		// Autonomous/Teleop jumper is on DS Input 2 (Jumper present is autonomous)
	} jumpers;	*/                            

public:
		DefaultRobot(void)
	{
		GetWatchdog().SetEnabled(false);
		ds = DriverStation::GetInstance();
		//myRobot = new RobotDrive(1, 3, 2, 4);	// create robot drive base
		leftstick = new Joystick(1);
		rightstick = new Joystick(2);			// create the joysticks
		dds = new DashboardDataSender();		// dashboard data sending
		
		compressor = new Compressor(10, 8);  //compressor on ports 10 and 8
		solleft = new Solenoid(1);			 //solenoid on ports 1 and 2(below)
		solright = new Solenoid(2);
		jag1= new Victor(1);
		jag2= new Victor(2);
		jag3= new Victor(3);
		jag4= new Victor(4);
		Dig1 = new DigitalInput(1, 1);
		
		//Update the motors at least every 100ms.
		
		

	}

	/**
	 * Drive left & right motors for 2 seconds, enabled by a jumper (jumper
	 * must be in for autonomous to operate).
	 */
	void Autonomous(void)
	{
		
	}

	
	void OperatorControl(void)
	{
		AxisCamera &camera = AxisCamera::GetInstance();
		camera.WriteResolution(AxisCameraParams::kResolution_320x240);
		camera.WriteBrightness(200);
		while (IsOperatorControl())
					
		{	GetWatchdog().Feed();
	
			if (Dig1->Get() == 0)
			{
				jag1->Set(0.0);
				jag2->Set(0.0);
				jag3->Set(0.0);
				jag4->Set(0.0);
			}
			else if(Dig1->Get() == 1)
			{
				jag1->Set(-leftstick->GetY());
				jag2->Set(rightstick->GetY());
				jag3->Set(-leftstick->GetY());
				jag4->Set(rightstick->GetY());
			}
			else
			{
				jag1->Set(-1.0);
				jag2->Set(1.0);
			}
			compressor->Start();
			if (leftstick->GetRawButton(2))
			{
				//jag->Set(1.0);
				solleft->Set(1);
				solright->Set(0);
			}
			else
			{
				//jag->Set(0.0);
				solleft->Set(0);
				solright->Set(1);
			}
			//myRobot->TankDrive(rightstick, leftstick);
			compressor->GetPressureSwitchValue();
		}
		};
	
};START_ROBOT_CLASS(DefaultRobot);
We have also used our multimeter to check the limit switch and the digital side car works for everything else we have used (motors, compressor, gyro and so on). We also found out earlier that this year it is illegal to connect the limit switch directly to the jaguar in accordance to R<54>.

Soo, we are still stuck.
__________________
There is nothing to fear, but fear itself
  #5   Spotlight this post!  
Unread 15-02-2010, 00:29
EricH's Avatar
EricH EricH is offline
New year, new team
FRC #1197 (Torbots)
Team Role: Engineer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: SoCal
Posts: 19,814
EricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond repute
Re: Limit Switch Draws Tears

Which rule was that? <R54> is the no modifying motors rule.

<R60-L> reads:
Quote:
L. If CAN-bus functionality is used, limit switch jumpers may be removed from a Jaguar speed controller and a custom limit switch circuit may be substituted (so that the cRIO-FRC may read the status of the limit switches).
Also see:
Quote:
<R68> All outputs from sensors, custom circuits and additional electronics shall connect to only
[...]
G. the CAN-bus if and only if all Jaguar speed controllers on the CAN-bus are wired in full compliance with Rule <R63> and Rule <R64>, or
H. the sensor inputs on the Jaguar speed controller.
__________________
Past teams:
2003-2007: FRC0330 BeachBots
2008: FRC1135 Shmoebotics
2012: FRC4046 Schroedinger's Dragons

"Rockets are tricky..."--Elon Musk

  #6   Spotlight this post!  
Unread 15-02-2010, 00:34
John G John G is offline
Registered User
FRC #0399 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Nov 2009
Rookie Year: 2009
Location: Lancaster, CA
Posts: 72
John G is on a distinguished road
Re: Limit Switch Draws Tears

This is going to sound very strange, but today (we haven't ever come in on sunday before) my team was supposed to spend 4 hours in the shop to clean up the wires on our bot for a revealing day/ showcase tommorow. After putting everything back together, our robot still didn't run. 5 hours later we realized that a limit switch was creating a short. It took us about a total of 13 hours to get it going. I feel your immense pain.
  #7   Spotlight this post!  
Unread 15-02-2010, 00:34
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Limit Switch Draws Tears

<<< Dig1 = new DigitalInput(1, 1); >>>

Your digital sidecar is in slot 4, so the line above should be

Dig1 = new DigitalInput(4,1);

if my memory serves me correctly, assuming that
you are using digital input 1 as the code implies.

Last edited by eugenebrooks : 15-02-2010 at 00:46.
  #8   Spotlight this post!  
Unread 15-02-2010, 00:35
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: Limit Switch Draws Tears

In your constructor, I see this line that stands out:

Code:
Dig1 = new DigitalInput(1, 1);
The DigitalInput constructor you're using looks like this:

Code:
DigitalInput::DigitalInput(UINT32 slot, UINT32 channel)
By constructing with DigitalInput(1, 1), it will try to look for a digital input on module 1. This won't work, since that's the analog module.

If you change it to look like this it should read Digital Input #1 from the default digital module (module #4).
Code:
Dig1 = new DigitalInput(1);
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
  #9   Spotlight this post!  
Unread 15-02-2010, 00:37
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Limit Switch Draws Tears

Quote:
Originally Posted by z2daj View Post
... Dig1 = new DigitalInput(1, 1);`...
In your original post you state that the swich is wired into input 4 on the digital sidecar. And, as Alan pointed out, the cRIO digital module should be plugged into slot 4.

Therefore, I would guess that the statement above should be

Dig1 = new DigitalInput(4, 4);

Or am I missing something?

Regards,

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #10   Spotlight this post!  
Unread 15-02-2010, 00:51
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 Draws Tears

Quote:
Originally Posted by z2daj View Post
...We simply created an object called Dig4 and set it equal to DigitalInput(1), here's the code.
Code:
		Dig1 = new DigitalInput(1, 1);
[edit]Yeah, lots of people caught this one.[/edit]

Last edited by Alan Anderson : 15-02-2010 at 00:52. Reason: took me too long to look up the documentation
  #11   Spotlight this post!  
Unread 15-02-2010, 01:28
z2daj z2daj is offline
Registered User
FRC #2836 (Team Beta)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Bethlehem, CT
Posts: 15
z2daj is an unknown quantity at this point
Send a message via AIM to z2daj
Re: Limit Switch Draws Tears

We have tried all of the possible solutions however they have all failed terrifically.
__________________
There is nothing to fear, but fear itself
  #12   Spotlight this post!  
Unread 15-02-2010, 01:57
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Limit Switch Draws Tears

Quote:
Originally Posted by z2daj View Post
We have tried all of the possible solutions however they have all failed terrifically.
OK. That statement really scares me...

Now, don't get me wrong. Your code has more than one problem (like 3 conditions for a Boolean condition) but, for anyone to help, you need to clearly define what is wired and what you want to do, in plain language please...

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #13   Spotlight this post!  
Unread 15-02-2010, 02:28
z2daj z2daj is offline
Registered User
FRC #2836 (Team Beta)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Bethlehem, CT
Posts: 15
z2daj is an unknown quantity at this point
Send a message via AIM to z2daj
Re: Limit Switch Draws Tears

where exactly would these 3 conditions for a boolean variable be?
__________________
There is nothing to fear, but fear itself
  #14   Spotlight this post!  
Unread 15-02-2010, 02:53
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Limit Switch Draws Tears

The digital input is one, or zero.
Don't count on the code handled by the final else
statement to ever get executed.

if (Dig1->Get() == 0)
{
jag1->Set(0.0);
jag2->Set(0.0);
jag3->Set(0.0);
jag4->Set(0.0);
}
else if(Dig1->Get() == 1)
{
jag1->Set(-leftstick->GetY());
jag2->Set(rightstick->GetY());
jag3->Set(-leftstick->GetY());
jag4->Set(rightstick->GetY());
}
else
{
jag1->Set(-1.0);
jag2->Set(1.0);
}
  #15   Spotlight this post!  
Unread 15-02-2010, 06:10
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Limit Switch Draws Tears

Ahhh... While I sleep, my minions carry on!

Thanks Doc.

A switch is either ON or OFF...
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
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
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
Limit Switch Basics JWSnedden Programming 6 30-11-2006 19:48


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

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