Go to Post Most of the people who fit the profile of long tenured FIRST mentor are either already on a team or locked up in an institution where they belong... - PayneTrain [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-16-2013, 12:51 PM
Negative 9 Negative 9 is offline
Registered User
FRC #0611
 
Join Date: Dec 2012
Location: Mclean, VA
Posts: 46
Negative 9 is an unknown quantity at this point
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!
Reply With Quote
  #2   Spotlight this post!  
Unread 02-16-2013, 02:37 PM
gixxy's Avatar
gixxy gixxy is offline
Programming and Arduino Mentor
AKA: Gustave Michel III
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Ruston, LA
Posts: 207
gixxy is on a distinguished road
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
__________________
Programmer - A creature known for converting Caffeine into Code.
Studying Computer Science @ Louisiana Tech University
Associate Consultant @ Fenway Group

2012-13: 3946 - Head of Programming, Electrical and Web
2014 - 3468 - Programming Mentor
2015 - Present - Lurker
Reply With Quote
  #3   Spotlight this post!  
Unread 02-16-2013, 08:04 PM
ClockworkPirate ClockworkPirate is offline
Registered User
AKA: Mario Guerrieri
FRC #0670 (Homestead Robotics Team)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Sunnyvale, CA
Posts: 2
ClockworkPirate is an unknown quantity at this point
Re: Using Spike Relays in Java?

Quote:
Originally Posted by gixxy View Post
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 ), 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?
Reply With Quote
  #4   Spotlight this post!  
Unread 02-16-2013, 08:18 PM
gixxy's Avatar
gixxy gixxy is offline
Programming and Arduino Mentor
AKA: Gustave Michel III
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Ruston, LA
Posts: 207
gixxy is on a distinguished road
Re: Using Spike Relays in Java?

I would have to see your code in its entirety.
__________________
Programmer - A creature known for converting Caffeine into Code.
Studying Computer Science @ Louisiana Tech University
Associate Consultant @ Fenway Group

2012-13: 3946 - Head of Programming, Electrical and Web
2014 - 3468 - Programming Mentor
2015 - Present - Lurker
Reply With Quote
  #5   Spotlight this post!  
Unread 02-16-2013, 09:05 PM
ClockworkPirate ClockworkPirate is offline
Registered User
AKA: Mario Guerrieri
FRC #0670 (Homestead Robotics Team)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Sunnyvale, CA
Posts: 2
ClockworkPirate is an unknown quantity at this point
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)

Last edited by ClockworkPirate : 02-16-2013 at 09:20 PM.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-17-2013, 04:06 PM
Negative 9 Negative 9 is offline
Registered User
FRC #0611
 
Join Date: Dec 2012
Location: Mclean, VA
Posts: 46
Negative 9 is an unknown quantity at this point
Re: Using Spike Relays in Java?

Quote:
Originally Posted by gixxy View Post
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!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:52 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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