|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Compressor Programming Help
i have code that starts and stops the compressor but it doesnt seem to work. Can anyone see whats wrong with the code
Code:
#include "WPIlib.h"
#include "compressor.h"
class RobotDemo : public SimpleRobot
{
RobotDrive Frankbot; // robot drive system
Joystick leftjoy;
Joystick rightjoy;
Joystick joystick3;
Relay Comp;
Jaguar Winch;
Jaguar Claw;
Jaguar Granata;
Solenoid Sol1;
Solenoid Sol2;
Solenoid Sol3;
Solenoid Sol4;
public:
RobotDemo(void):
Frankbot(1, 2), //these are the PWM ports
leftjoy(1),
rightjoy(2),
joystick3(3),
Comp(1, 1),
Winch(7),
Claw(9),
Granata(5),
Sol1(1, 1),
Sol2(1, 2),
Sol3(1, 3),
Sol4(1, 4)
{
// usermessages = DriverStationLCD::GetInstance();
// Camera->WriteResolution(AxisCamera::kResolution_160x120);
// Camera->WriteCompression(20);
// Camera->WriteWhite
// Balance(AxisCameraParams::kWhiteBalance_FixedIndoor);
// Camera->WriteMaxFPS(30);
// Camera = &AxisCamera::GetInstance();
// myRobot.SetExpiration(0.1); // test
}
void Autonomous(void)
{
Compressor *c = new Compressor(1, 1);
c->Start();
}
void OperatorControl(void)
{
int Off = 7;
int On = 8;
int ClawTurn = 10;
int ClawTurn1 = 11;
int Claw1 = 4;
int Claw2 = 5;
int WinchUp = 4;
int WinchDown = 5;
int Solup = 2;
int Soldown = 3;
int Sol2Up = 2;
int Sol2Down = 3;
static float speedModifier = 0.7;
static float speedModifier2 = -0.8;
Frankbot.SetSafetyEnabled(true);
Compressor *c = new Compressor(1, 1);
c->Start();
while (IsOperatorControl())
{
Frankbot.TankDrive(-leftjoy.GetY() * speedModifier, rightjoy.GetY() * speedModifier2);
if(joystick3.GetRawButton(On)){
c->Start();
}
else if(joystick3.GetRawButton(Off)) {
c->Stop();
}
else {
c->Stop();
}
if(leftjoy.GetRawButton(WinchUp)) {
Winch.Set(0.5);
}
else if(leftjoy.GetRawButton(WinchDown)) {
Winch.Set(-0.5);
}
else {
Winch.Set(0.0);
}
if(rightjoy.GetRawButton(Claw1)) {
Claw.Set(0.5);
}
else if(rightjoy.GetRawButton(Claw2)) {
Claw.Set(-0.5);
}
else {
Claw.Set(0.0);
}
if(rightjoy.GetRawButton(ClawTurn)) {
Granata.Set(0.2);
}
else if(rightjoy.GetRawButton(ClawTurn1)) {
Granata.Set(-0.2);
}
else {
Granata.Set(0.0);
}
if(leftjoy.GetRawButton(Solup)){
Sol1.Set(true);
Sol2.Set(false);
}
else if(leftjoy.GetRawButton(Soldown)){
Sol1.Set(false);
Sol2.Set(true);
}
else {
Sol1.Set(false);
Sol2.Set(false);
}
if(rightjoy.GetRawButton(Sol2Up)){
Sol3.Set(true);
Sol4.Set(false);
}
else if(rightjoy.GetRawButton(Sol2Down)){
Sol3.Set(false);
Sol4.Set(true);
}
else {
Sol3.Set(false);
Sol4.Set(false);
}
}
}
};
START_ROBOT_CLASS(RobotDemo);
|
|
#2
|
||||
|
||||
|
Re: Compressor Programming Help
Code:
if(joystick3.GetRawButton(On)){
c->Start();
}
else if(joystick3.GetRawButton(Off)) {
c->Stop();
}
else {
c->Stop();
}
|
|
#3
|
|||
|
|||
|
Re: Compressor Programming Help
that was intended, but is there anyway to do it so that when the button is pressed it turns on and then turns off according to the pressure switch, besides that is anything else wrong with the compressor code because it doesn't run at all.
|
|
#4
|
||||
|
||||
|
Re: Compressor Programming Help
The call to C->Start() will start the thread that automatically checks the Pressure Switch and shuts off the compressor as needed. Is there a properly connected pressure switched plugged into DIO 1? Also, have you tried using a Relay object and manually starting the compressor? If so, does it function?
|
|
#5
|
|||
|
|||
|
Re: Compressor Programming Help
yeah i used a relay object and it worked the compressor turned on, but it doesnt work with the code currently on it
|
|
#6
|
||||
|
||||
|
Re: Compressor Programming Help
Can you use a multimeter on your pressure switch to determine whether or not there is an output voltage?
|
|
#7
|
|||
|
|||
|
Re: Compressor Programming Help
thank you for everything, we figured it out, it was our electronics, the pressure switch was wired wrong
|
|
#8
|
|||
|
|||
|
Re: Compressor Programming Help
Why don't you initialize and start the compressor in the constructor for the Robot?
That is what we we do, and never have to deal with anywhere else. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|