Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Using Spike Relays in Java? (http://www.chiefdelphi.com/forums/showthread.php?t=113655)

Negative 9 16-02-2013 12:51

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);
and I'm supposed to control the Relay by doing something like this:

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);
}

If that's all good then the other possibility is that it's wired incorrectly. Does anyone know which section of the DigitalSidecar the triple wire is supposed to be plugged in? The diagnostic light on the Relay is a solid yellow-orange color which I assume mean that it's been initialized but isn't receiving any signals.

Any and all help is appreciated!

gixxy 16-02-2013 14:37

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


ClockworkPirate 16-02-2013 20:04

Re: Using Spike Relays in Java?
 
Quote:

Originally Posted by gixxy (Post 1234401)
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


We have our relays wired what seems to be correctly (PWMs from relay area on the sidecar, orange light), and my code is exactly like yours (besides variable names :P), 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?

gixxy 16-02-2013 20:18

Re: Using Spike Relays in Java?
 
I would have to see your code in its entirety.

ClockworkPirate 16-02-2013 21:05

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);
}

on it, nothing happens.

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)

Negative 9 17-02-2013 16:06

Re: Using Spike Relays in Java?
 
Quote:

Originally Posted by gixxy (Post 1234401)
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


Thanks, this got our code working!


All times are GMT -5. The time now is 10:13.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi