View Single Post
  #1   Spotlight this post!  
Unread 22-01-2017, 19:45
Robochris Robochris is offline
Registered User
FRC #6722
 
Join Date: Jan 2017
Location: Florida
Posts: 3
Robochris is an unknown quantity at this point
CIM coders help!

Im having trouble programming the CIMcoders. Please correct me if you see something wrong im new at this.
So I have the Encoder plugged into the DIO on the roboRIO. From left to right on the encoder when placed on a motor, I have the 1st pin in DIO 0: 5V, 2nd pin in DIO 1: signal, 3rd pin in DIO 0: GRN, 4th pin in DIO 0: signal.

On the code side I am using C++. The Encoder stuff is inside a command and none of it is in the Robot.cpp or the main one. The "DriveCommand" is an Autonmous btw, not sure if that helps. When ever i run it in the FRC Drive Station, I get these errors. Need anymore information fill free to let me know. Thanks

Quote:
ERROR -1029 HAL: Resource already allocated, Minimum Value: 0, Maximum Value: 20, Requested Value: 0 PWM [PWM.cpp:43]
ERROR -1029 HAL: Resource already allocated, Minimum Value: 0, Maximum Value: 20, Requested Value: 1 PWM [PWM.cpp:43]
ERROR -1029 HAL: Resource already allocated, Minimum Value: 0, Maximum Value: 31, Requested Value: 0 DigitalInput [DigitalInput.cpp:43]
ERROR -1029 HAL: Resource already allocated, Minimum Value: 0, Maximum Value: 31, Requested Value: 1 DigitalInput [DigitalInput.cpp:43]
ERROR -1098 HAL: A handle parameter was passed incorrectly InitEncoder [Encoder.cpp:43]
Them sick codez
Code:
#include "DriveCommand.h"
#include "WPILib.h"
#include "CANTalon.h"

using namespace frc;

bool done = false;
Victor *victor;
CANTalon *talon;
Victor *victor2;
CANTalon *talon2;
Encoder *CIM;

DriveCommand::DriveCommand() {
	victor = new Victor(0);
	victor2 = new Victor(1);
	talon = new CANTalon(1);
	talon2 = new CANTalon(2);
	CIM = new Encoder(0, 1, false, Encoder::EncodingType::k4X);
}

void DriveCommand::Initialize() {
}

void DriveCommand::Execute() {
	if (!done) {
		victor->Set(CIM->Get() > 5 ? 0 : 1);
		done=true;
	}
}

execute()
bool DriveCommand::IsFinished() {
	return done;
}

void DriveCommand::End() {
	victor->Set(0);
	talon->Set(0);
}

void DriveCommand::Interrupted() {

}
Thanks for your help!
Reply With Quote