View Single Post
  #6   Spotlight this post!  
Unread 18-03-2013, 22:33
Jaysonscott Jaysonscott is offline
Registered User
FRC #1846
 
Join Date: Mar 2013
Location: Sarnia, Ontario
Posts: 10
Jaysonscott is an unknown quantity at this point
Re: Pneumatics Programming help

So my code should look like this to activate the compressor if im using relay port 2 and DIO port 3?

Also how do i program a double valve solenoid to extend with button 6 and retract with button 7?

ive tried many ways ive seen on here but no luck so far i shall continue to try but help is greatly appreciated.



#include "WPILib.h"


class RobotDemo : public SimpleRobot
{
RobotDrive myRobot; // robot drive system
Joystick stick; // only joystick
Victor SFX_Shooter1_Victor3;
Victor SFX_Shooter2_Victor4;
Jaguar SFX_Loader_Victor5;
Relay SFX_Tiltmotor; //spike connected to motor

DigitalInput DigitalInput_High;
DigitalInput DigitalInput_Low;

float Shoot1_Victor3_float;
float Shoot2_Victor4_float;
float Loader_Victor5_float;


public:
RobotDemo(void):
myRobot(1, 2), // these must be initialized in the same order
stick(1), // as they are declared above.
SFX_Shooter1_Victor3(3),
SFX_Shooter2_Victor4(4),
SFX_Loader_Victor5(5),
SFX_Tiltmotor(1),
DigitalInput_High(1),
DigitalInput_Low(2),



Compress(2,3)




{
myRobot.SetExpiration(0.1);
}

/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous(void)
{

SFX_Shooter1_Victor3.Set(1.0);
SFX_Shooter2_Victor4.Set(1.0);
SFX_Loader_Victor5.Set(Relay::kOn);


}

/**
* Runs the motors with arcade steering.
*/
void OperatorControl(void)
{
myRobot.SetSafetyEnabled(true);




Compress.Start();





while (IsOperatorControl())
{
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)






//Activates shooter at full speed with button 1
if(stick.GetRawButton(1)== 1){
SFX_Shooter1_Victor3.Set(1.0);
SFX_Shooter2_Victor4.Set(1.0);
} else{
SFX_Shooter1_Victor3.Set(0.0);
SFX_Shooter2_Victor4.Set(0.0);
}





//Actvates loader at full speed with button 2
if(stick.GetRawButton(2)==1){
SFX_Loader_Victor5.Set(Relay::kOn);
}else{
SFX_Loader_Victor5.Set(Relay::kOff);
}





//Activates tilt in either forward or reverse dependant on button and sensor
if((stick.GetRawButton(4)==1)&& (DigitalInput_High.Get()==0)) {
SFX_Tiltmotor.Set(Relay::kForward);
//SFX_Tiltmotor.Set(Relay::kOn);

}else if((stick.GetRawButton(5)==1) && (DigitalInput_Low.Get()==0)) {
SFX_Tiltmotor.Set(Relay::kReverse);
//SFX_Tiltmotor.Set(Relay::kOn);
}
else{
SFX_Tiltmotor.Set(Relay::kOff);

}





/*
if(stick.GetRawButton(6)==1){
//Solenoid1.Set(True);
Relay_Solenoid.Set(Relay::kForward);
Relay_Solenoid.Set(Relay::kOn);
}else{
Relay_Solenoid.Set(Relay::kOff);
}*/







Wait(0.005); // wait for a motor update time
}





Compress.Stop();
}








void Test() {

}
};

START_ROBOT_CLASS(RobotDemo);
Reply With Quote