View Single Post
  #3   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