View Single Post
  #8   Spotlight this post!  
Unread 15-02-2009, 01:57
Redneck's Avatar
Redneck Redneck is offline
Hacker Hick
AKA: Jamie (2.0) Moran
FRC #0599 (Robodox)
Team Role: Engineer
 
Join Date: Aug 2004
Rookie Year: 2004
Location: California
Posts: 90
Redneck is just really niceRedneck is just really niceRedneck is just really niceRedneck is just really nice
Send a message via AIM to Redneck
Re: Inputs on Driver Station

Quote:
Originally Posted by z2daj View Post
Code:
#include "Encoder.h"

class RobotDemo : public SimpleRobot

{

		Encoder rotary;

public:

	RobotDemo(void):

		rotary(1, 2)

void Autonomous(void)

	{
		gyro.Reset();

		int display;
				
		
		while (IsAutonomous())

		{
		
			float anything;
			
			while(argument)

			{

				GetWatchdog().SetEnabled(false);	
			
				rotary = new Encoder(1,2);

				Wait(0.004);	
			
				display = rotary;

				printf (" %d \n ", display);

			}

           }

}

void OperatorControl(void)
{

}

};

any ideas?
Ok, couple of things to fix here:

1)You need to add a call to the Encoder class's Start() function.
2)You're creating a new Encoder in the autonomous. You don't need that, you already created it at the constructor.

Here's how things should look:
Code:
#include "Encoder.h"

class RobotDemo : public SimpleRobot

{

		Encoder rotary;

public:

	RobotDemo(void):

		rotary(1, 2)
               {
               }


void Autonomous(void)

	{
		gyro.Reset();
                rotary.Start();

		int display;
		
		while (IsAutonomous())

		{
		
			float anything;
			
			while(argument)

			{

				GetWatchdog().SetEnabled(false);	
			

				Wait(0.004);	
			
				display = rotary.Get();

				printf (" %d \n ", display);

			}

           }

}

void OperatorControl(void)
{

}

};

EDIT: Also, keep in mind that this only works for digital encoders connected to one of the cRIO's digital sidecars. If what you want is a knob on the driver station, then as Sentient mentioned previously you'll need to get a potentiometer and use the DriverStation GetAnalogIn() function.
__________________


Which badges can you claim?

Last edited by Redneck : 15-02-2009 at 02:02.
Reply With Quote