So I have put Compressor on the back burner while we wire up and work with the encoders and now I get the same exact thing with them as I was getting with the Compressor. I am posting my code, can someone help me figure out what I am doing wrong. I imagine its to do with code or not activating something properly, but I am willing to try other things if you got ideas.
Code:
#include <iostream.h>
#include "WPILib.h"
#include <taskLib.h>
#include "DashboardDataFormat.h"
/**
* This is a demo program showing the use of the IterativeRobot base class.
*
* The IterativeRobot class is the base of a robot application that uses similar control
* flow to that used in the FRC default code in prior years.
*
* This robot provides identically the same external behavior as the SimpleRobot demo program.
*
* This code assumes the following connections:
* Driver Station:
* Joystick 1 - The "right" joystick. Used for either "arcade drive" or "right" stick for tank drive
* Joystick 2 - The "left" joystick. Used as the "left" stick for tank drive
*/
class IterativeDemo : public IterativeRobot
{
// Declare variable for the robot drive system
RobotDrive *myRobot; // robot will use PWM 1-4 for drive motors
// Declare a variable to use to access the driver station object
DriverStation *ds; // driver station object
DriverStationLCD *dsLCD; //driver station LCD update
// Declare variables for up to three joysticks being used
Joystick *rightStick; // joystick 1 (arcade stick or right tank stick)
Joystick *leftStick; // joystick 2 (tank left stick)
//Encoder setup
Encoder *leftencoder;
Encoder *rightencoder;
//Compressor
//Compressor *cpress;
// Local variables to count the number of periodic loops performed
int auto_periodic_loops;
int disabled_periodic_loops;
int tele_periodic_loops;
int dash_periodic_loops;
public:
/**
* Constructor for this "IterativeRobotDemo" Class.
* Create an instance of a RobotDrive with left and right motors plugged into PWM
* ports 0 and 1 on the first digital module.
*/
IterativeDemo(void) {
cout << "IterativeDemo Constructor Started\n";
// Create a robot using standard right/left robot drive on PWMS 1, 2, 3, and #4
myRobot = new RobotDrive(1, 3, 2, 4);
// Define joysticks being used at USB port #1 and USB port #2 on the Drivers Station
rightStick = new Joystick(2);
leftStick = new Joystick(1);
// Acquire the Driver Station object
ds = DriverStation::GetInstance();
dsLCD = DriverStationLCD::GetInstance();
// Counters to record the number of loops completed in autonomous and teleop modes
auto_periodic_loops = 0;
disabled_periodic_loops = 0;
tele_periodic_loops = 0;
//Compressor Instance
//cpress = new Compressor(3,1); //Input DIO Port 1, Relay 1
//cpress->Start(); //Start compressor
//Encoder Instances
leftencoder = new Encoder(9,10,true,Encoder::k4X);
rightencoder = new Encoder(11,12,true,Encoder::k4X);
cout << "RobotDemo Constructor Completed\n";
}
/********************************** Init Routines *************************************/
void DisabledInit(void) {
disabled_periodic_loops = 0; // Reset the loop counter for disabled mode
}
void AutonomousInit(void) {
auto_periodic_loops = 0; // Reset the loop counter for autonomous mode
}
void TeleopInit(void) {
tele_periodic_loops = 0; // Reset the loop counter for teleop mode
dash_periodic_loops = 0;
}
/********************************** Periodic Routines *************************************/
void DisabledPeriodic(void) {
// feed the user watchdog at every period when disabled
GetWatchdog().Feed();
// increment the number of disabled periodic loops completed
disabled_periodic_loops++;
}
void AutonomousPeriodic(void) {
// feed the user watchdog at every period when in autonomous
GetWatchdog().Feed();
auto_periodic_loops++;
if (auto_periodic_loops == 1) {
// When on the first periodic loop in autonomous mode, start driving forwards at half speed
myRobot->Drive(0.5, 0.0); // drive forwards at half speed
}
if (auto_periodic_loops == 200) {
// After 200 loops (2 seconds given 10ms loops), stop the robot
myRobot->Drive(0.0, 0.0); // stop robot
}
}
void TeleopPeriodic(void) {
// feed the user watchdog at every period when in autonomous
GetWatchdog().Feed();
// increment the number of teleop periodic loops completed
tele_periodic_loops++;
dash_periodic_loops++;
// determine if tank or arcade mode; default with no jumper is for tank drive
myRobot->TankDrive(leftStick, rightStick); // drive with tank style
//Dashboard update
if (dash_periodic_loops >= 20) {
sendIOPortData();
dsLCD->Printf(DriverStationLCD::kMain_Line6,1,"Code 6:");
dsLCD->Printf(DriverStationLCD::kUser_Line2,1,"Left encoder: %d",leftencoder->Get());
dsLCD->Printf(DriverStationLCD::kUser_Line3,1,"Right encoder: %d",rightencoder->Get());
dsLCD->UpdateLCD();
dash_periodic_loops = 0;
}
}
/********************************** Continuous Routines *************************************/
/*
* These routines are not used in the imitation of the SimpleDemo robot
*
*
void DisabledContinuous(void) {
}
void AutonomousContinuous(void) {
}
void TeleopContinuous(void) {
}
*/
};
START_ROBOT_CLASS(IterativeDemo);
I can't see anything wrong with the code, but I don't know what else to do. If I comment out the encoder code and the compressor code it works fine. Anyone know what's going on? Am I doing pointers or something wrong?