View Single Post
  #4   Spotlight this post!  
Unread 02-04-2013, 17:31
Dragonslayerend Dragonslayerend is offline
DuncanDynamics lead programmer
AKA: Tom Xiong
FRC #3970 (DuncanDynamics)
Team Role: Programmer
 
Join Date: Oct 2012
Rookie Year: 2012
Location: Fresno, CA, Duncanpoly Tech
Posts: 33
Dragonslayerend will become famous soon enoughDragonslayerend will become famous soon enough
Re: Multiple Encoder issues

Quote:
Originally Posted by Joe Ross View Post
What does the 5v light on the digital sidecar do when the additional encoders are added? Can you post your code?

In 2009, we used 5 encoders. We've used 2 encoders each year since then.
This is my simple encoder code to test the encoders. Also the encoder wires work, I switch the wires connected to the ports.
#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
Encoder *Encoder1, *Encoder2;
CANJaguar *Jag1, *Jag2;
Servo *Shift;
DriverStationLCD *DsLCD;
Joystick *One;

public:
RobotDemo(void)
{
Encoder1 = new Encoder(2,3);
Encoder2 = new Encoder(4,5);
Jag1 = new CANJaguar(3);
Jag2 = new CANJaguar(4);
Shift = new Servo(1);
DsLCD = DriverStationLCD::GetInstance();
One = new Joystick(1);
}

void Autonomous(void)
{
}

void OperatorControl(void)
{
while (IsOperatorControl())
{
Encoder1->Start();
Encoder2->Start();
while(IsEnabled())
{
Jag1->Set(One->GetY());
Jag1->Set(One->GetY());
Shift->Set((One->GetRawAxis(4)/2)+.5);
DsLCD->Printf(DriverStationLCD::kUser_Line1,1,"Speed:%f" ,Encoder1->GetRate());
DsLCD->Printf(DriverStationLCD::kUser_Line2,2,"Speed:%f" ,Encoder2->Get());
DsLCD->UpdateLCD();
}
}
}
void Test() {

}
};

START_ROBOT_CLASS(RobotDemo);

Last edited by Dragonslayerend : 02-04-2013 at 17:36.