|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help Please!(Rookie Team)
I am looking for basic java programming code to turn on and off compressor. I have power from compressor connected to a spike relay per rules. I understand how to talk to a Jaguar, but believe that I plug PWM from spike into digital sidecar relay slots. IS this correct and if so please send a simple program that will use joystick(2) buttons 10 and 11 to turn power on and off to compressor using spike.
Thanks a million. NEAL and or anyone else that can help |
|
#2
|
||||
|
||||
|
Re: Help Please!(Rookie Team)
I don't really know the electrical side of things here, but I do know that there's a pretty simple method for using Spike relays: the Relay class.
Basically, you initialize one with the required port and the direction: Code:
Relay relay = new Relay(PORT,direction); // direction can be Relay.Direction.kFoward,Relay.Direction.kReverse, or Relay.Direction.kBoth Code:
relay.set(Relay.Value.kOff); // 0v-0v, any direction relay.set(Relay.Value.kForward); // 12v-0v, kForward or kBoth relay.set(Relay.Value.kReverse); // 0v-12v, kReverse or kBoth relay.set(Relay.Value.kOn); // 12v-12v, any direction |
|
#3
|
||||
|
||||
|
Re: Help Please!(Rookie Team)
Quote:
relay.set(Relay.Value.kForward or kReverse) Should be relay.setDirection(Relay.Direction.kForward or kReverse, or kBoth); Hope this helps! Happy Competitions! |
|
#4
|
||||
|
||||
|
Re: Help Please!(Rookie Team)
Quote:
I'm getting all my info about the relay from the source (from sunspotfrcsdk/lib/WPILibJ/src/edu/wpi/first/wpilibj/Relay.java in this case), in case you want to check my info ![]() |
|
#5
|
|||
|
|||
|
Re: Help Please!(Rookie Team)
As much as I love your avatar, I have to say you're wrong on this. .set() is what actually sets the value of the relay, .setDirection() is just the possible directions it can be set. Many a screwup on our team has been caused by mixing those up.
|
|
#6
|
||||
|
||||
|
Re: Help Please!(Rookie Team)
There is a compressor method that handles the relay for you.
Code:
Compressor(int pressureSwitchChannel, int compressorRelayChannel) Code:
Compressor compressor = new Compressor(1,1); ... compressor.start(); |
|
#7
|
|||
|
|||
|
Re: Help Please!(Rookie Team)
Awesome, but where does the code go ?
|
|
#8
|
||||
|
||||
|
Re: Help Please!(Rookie Team)
You can add that code in the constructor.
|
|
#9
|
|||
|
|||
|
Re: Help Please!(Rookie Team)
if (!airCompressor.getPressureSwitchValue())//check if the compressor is working
{ airCompressor.setRelayValue(Relay.Value.kOn); } else { airCompressor.setRelayValue(Relay.Value.kOff); } ^^^ You also need this in the continuous function |
|
#10
|
||||
|
||||
|
Re: Help Please!(Rookie Team)
no you don't... if the Compressor object is constructed properly, it will handle turning itself on and off automatically based on the pressure switch value.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|