|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using Spike Relays in Java?
Can anyone explain to me the best way to use Relays in code? The API confuses me. There are several ways to construct the relays and set them to values and I'm having trouble understanding the differences between them.
I'm trying to use a relay to control a window motor so from what I can tell I am supposed to construct the relay like this: Code:
relay = new Relay(1, Relay.Direction.kBoth); Code:
if(joyRight.getRawButton(4)) {
relay.set(Relay.Value.kON);
relay.set(Relay.Direction.kForward);
} else if(joyRight.getRawButton(5)) {
relay.set(Relay.Value.kON);
relay.set(Relay.Direction.kReverse);
} else {
relay.set(Relay.Value.kOff);
}
Any and all help is appreciated! |
|
#2
|
||||
|
||||
|
Re: Using Spike Relays in Java?
The Relay is hooked up to the Relay section on the Digital Sidecar (With the LED Recess).
Orange Light beens it is receiving no signal (or the kOff signal) which means it is powered. In my code I usually don't use the direction part, I stick to: Code:
Relay relay = new Relay(1); //Constructor relay.set(Relay.Value.kForward); //Power flows Positive to Negative, light green relay.set(Relay.Value.kOff); //No power flows, light orange relay.set(Relay.Value.kReverse); //Power flows Negative to Positive, light red |
|
#3
|
|||
|
|||
|
Re: Using Spike Relays in Java?
Quote:
), but the relays won't do anything. No matter what I call set() with (I've tried all four Relay.Value values), the light stays orange. What am I doing wrong? |
|
#4
|
||||
|
||||
|
Re: Using Spike Relays in Java?
I would have to see your code in its entirety.
|
|
#5
|
|||
|
|||
|
Re: Using Spike Relays in Java?
I have a field in my Shooter class with a field Relay pneuRelay, which I initialize in Shooter's constructor with pneuRelay = new Relay(1); (we have a relay plugged into the first plug on the sidecar). I call
Code:
public void setForward()
{
pneuRelay.set(Relay.Value.kForward);
}
There is kind of a bunch of abstracted stuff down to that "real" call, but nothing happens even when I put the call (new Relay(1).set(Relay.Value.kForward)) right in the constructor of our SimpleRobot subclass... It seems to me that either I'm not using the library right or the relay isn't wired correctly. Here's Pastebins of my code if you still want to see it (this is with the port 1 initialization in the SimpleRobot constructor, so the one in Shooter.java is changed to 2 to avoid a conflict): Robot2013.java (SimpleRobot subclass) DriveStation.java (has Shooter, DriveTrain, etc objects, interprets joystick controls) Shooter.java (controls the shooter motors, I'm trying to add the relay to control some related pneumatics) Last edited by ClockworkPirate : 16-02-2013 at 21:20. |
|
#6
|
|||
|
|||
|
Re: Using Spike Relays in Java?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|