Go to Post I want to understand the physics. - Molten [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 21-07-2014, 14:30
5339 5339 is offline
Registered User
FRC #5914
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2104
Location: Caledonia, minnesota
Posts: 9
5339 is an unknown quantity at this point
Spike relay help

Here is our program part for the spike but it doesn't work. Why?
It says there are no errors.

package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Relay;

import edu.wpi.first.wpilibj.SimpleRobot;

public class RobotTemplate extends SimpleRobot {
public Joystick leftStick = new Joystick(1);
public Victor leftDrive = new Victor(1);
public Victor rightDrive = new Victor(2);
public Jaguar middleDrive = new Jaguar(3);
public Relay spike = new Relay(1);

public void autonomous() {
}

public void operatorControl() {
while (isOperatorControl() && isEnabled()) {

{if (leftStick.getRawButton(1)== true) {
spike.set(Relay.Value.kOn);
}
else {
spike.set(Relay.Value.kOff);}}

{if (leftStick.getRawButton(2)== true) {
leftDrive.set((leftStick.getX()+ leftStick.getY()));
rightDrive.set((leftStick.getX()- leftStick.getY()));

}else{
leftDrive.set(0);
rightDrive.set(0);
}}

}
} public void test() {

}
}

Last edited by 5339 : 21-07-2014 at 18:41.
Reply With Quote
  #2   Spotlight this post!  
Unread 21-07-2014, 14:42
Bryce Paputa's Avatar
Bryce Paputa Bryce Paputa is offline
FF TSL: Frog Farce
FRC #0503 (Frog Force)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Novi Michigan
Posts: 454
Bryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond reputeBryce Paputa has a reputation beyond repute
Re: Spike relay help

"spike.set(Relay.Value.kOn;" should be "spike.set(Relay.Value.kOn);"

Try putting System.out.println statements inside the for statements to see if it's getting to the set commands.

I can't see all of your code, but you probably shouldn't use delay().

Next time please give more details, if adding the parenthesis doesn't help and you can't figure it out with the println statements, give some more details and I'll try to help more.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-07-2014, 14:45
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,565
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Spike relay help

Is kOn what you really want? Read the description here: http://wpilib.screenstepslive.com/s/...hanisms-relays
Reply With Quote
  #4   Spotlight this post!  
Unread 21-07-2014, 14:47
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Spike relay help

Quote:
Originally Posted by 5339 View Post
Here is our program part for the spike but it doesn't work. Why?

if (leftstick.getRawButton(1) == true) {
spike.set(Relay.Value.kOn;
Timer.delay(.1);
}
else {
spike.set(Relay.Value.kOff);}
Why do you think it doesn't work? Does the Spike LED change between yellow/orange and off? Do the red and green relay status LEDs on the Digital Sidecar both go on, then both go off?

The kOn constant sets both M- and M+ outputs of the Spike to battery voltage. Depending on what you have connected to it, that probably won't do what you want. Instead, use kForward. That will set M+ to battery and M- to "ground", powering whatever is connected between them.
Reply With Quote
  #5   Spotlight this post!  
Unread 21-07-2014, 17:59
NotInControl NotInControl is offline
Controls Engineer
AKA: Kevin
FRC #2168 (Aluminum Falcons)
Team Role: Engineer
 
Join Date: Oct 2011
Rookie Year: 2004
Location: Groton, CT
Posts: 261
NotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond repute
Re: Spike relay help

Here are some simple but important troubleshooting steps in addition to the great responses so far. Do make sure you have communication to the Relay, and proper power wired to it and that you are using the proper relay channel to control your spike. When the robot turns on, the LED on the spike should be orange, signaling that it has power.

Can you paste the code of your call to the constructor as well?

Again, you are only trying to set the value of the relay in either Teleop, Auto, or Test modes correct, while the robot is enabled?

Relay outputs are non-active while the robot is disabled. Are you also sure that you are hitting the proper button on the left stick. I am not sure what controller you used, but make sure you are pressing the button defined as "1".

Your code is fine and should command the relay (assuming you want kOn instead of kForward), if everything is wired up correctly and your code is placed in the proper location. So start with checking those first.

Also what kind of Robot Framework are you using, Simple, Iterative, or CommandBase? If the code running is not in a loop which is the default for SimpleRobot, then the code will run once and end, never giving you the option to hit the button. You would need to place it in a loop. If you are using Iterative, or Command Base, then the code should be in one of the Autonomous, Teleop, or Test - Periodic methods.


Regards,
Kevin
__________________
Controls Engineer, Team 2168 - The Aluminum Falcons
[2016 Season] - World Championship Controls Award, District Controls Award, 3rd BlueBanner
-World Championship- #45 seed in Quals, World Championship Innovation in Controls Award - Curie
-NE Championship- #26 seed in Quals, winner(195,125,2168)
[2015 Season] - NE Championship Controls Award, 2nd Blue Banner
-NE Championship- #26 seed in Quals, NE Championship Innovation in Controls Award
-MA District Event- #17 seed in Quals, Winner(2168,3718,3146)
[2014 Season] - NE Championship Controls Award & Semi-finalists, District Controls Award, Creativity Award, & Finalists
-NE Championship- #36 seed in Quals, SemiFinalist(228,2168,3525), NE Championship Innovation in Controls Award
-RI District Event- #7 seed in Quals, Finalist(1519,2168,5163), Innovation in Controls Award
-Groton District Event- #9 seed in Quals, QuarterFinalist(2168, 125, 5112), Creativity Award
[2013 Season] - WPI Regional Winner - 1st Blue Banner

Last edited by NotInControl : 21-07-2014 at 18:20.
Reply With Quote
  #6   Spotlight this post!  
Unread 21-07-2014, 18:15
NotInControl NotInControl is offline
Controls Engineer
AKA: Kevin
FRC #2168 (Aluminum Falcons)
Team Role: Engineer
 
Join Date: Oct 2011
Rookie Year: 2004
Location: Groton, CT
Posts: 261
NotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond repute
Re: Spike relay help

Also,

what is the purpose for Timer.delay?

Unless you are running a multi-threaded robot, you should remove this line of code. This code halts your entire robot for that amount of time.

Generally speaking, you should never use a delay function on a robot, unless you are doing it purposefully, understand exactly what is being delayed, and are running a multi-threaded robot.

This line, Timer.delay(0.1) will halt your entire robot (unless it is in a separate thread from Robot Main) for 1/10th of a second. The control loop of the robot, expects to run once every 50ms, this line of code is preventing your robot from doing so, and it can/will lead to watchdog errors or communication problems, especially if you use larger delays else where in code.

Regards,
Kevin
__________________
Controls Engineer, Team 2168 - The Aluminum Falcons
[2016 Season] - World Championship Controls Award, District Controls Award, 3rd BlueBanner
-World Championship- #45 seed in Quals, World Championship Innovation in Controls Award - Curie
-NE Championship- #26 seed in Quals, winner(195,125,2168)
[2015 Season] - NE Championship Controls Award, 2nd Blue Banner
-NE Championship- #26 seed in Quals, NE Championship Innovation in Controls Award
-MA District Event- #17 seed in Quals, Winner(2168,3718,3146)
[2014 Season] - NE Championship Controls Award & Semi-finalists, District Controls Award, Creativity Award, & Finalists
-NE Championship- #36 seed in Quals, SemiFinalist(228,2168,3525), NE Championship Innovation in Controls Award
-RI District Event- #7 seed in Quals, Finalist(1519,2168,5163), Innovation in Controls Award
-Groton District Event- #9 seed in Quals, QuarterFinalist(2168, 125, 5112), Creativity Award
[2013 Season] - WPI Regional Winner - 1st Blue Banner
Reply With Quote
  #7   Spotlight this post!  
Unread 23-07-2014, 15:43
NotInControl NotInControl is offline
Controls Engineer
AKA: Kevin
FRC #2168 (Aluminum Falcons)
Team Role: Engineer
 
Join Date: Oct 2011
Rookie Year: 2004
Location: Groton, CT
Posts: 261
NotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond reputeNotInControl has a reputation beyond repute
Re: Spike relay help

Thanks for posting more of your code.

I do not see any obvious errors with your code. But I would do the following in your code:

1. Change kOn to kForward
2. Post what joystick model you are using, and ensure you are pressing the correct button.
3. Add print statements to your code so you can see if you are pressing the proper button

for example:

Code:
if (leftStick.getRawButton(1) == true) 
{
	spike.set(Relay.Value.kOn);
	System.out.println("Button 1 Pressed, Relay LED should be Green");
} 
else 
{
	spike.set(Relay.Value.kOff);
	System.out.println("Button 1 Not Pressed, Relay LED should be Orange");
}

Then check the wiring and answer the following questions here so we can help you further:

1. Make sure you plugged your spike in to relay channel 1 of the DSC. Are you using a 4 slot cRIO or an 8 slot? \
2. Does the DSC have its 12V and 5V power leds lit up?
3. Does the joystick drive commands work when button 2 is pressed?
4. Ensure that you are enabling the robot in Teleop mode from the driver station.
5. What is the color of the Relay LED when you enable the robot?
6. Post the print output of the code from above
__________________
Controls Engineer, Team 2168 - The Aluminum Falcons
[2016 Season] - World Championship Controls Award, District Controls Award, 3rd BlueBanner
-World Championship- #45 seed in Quals, World Championship Innovation in Controls Award - Curie
-NE Championship- #26 seed in Quals, winner(195,125,2168)
[2015 Season] - NE Championship Controls Award, 2nd Blue Banner
-NE Championship- #26 seed in Quals, NE Championship Innovation in Controls Award
-MA District Event- #17 seed in Quals, Winner(2168,3718,3146)
[2014 Season] - NE Championship Controls Award & Semi-finalists, District Controls Award, Creativity Award, & Finalists
-NE Championship- #36 seed in Quals, SemiFinalist(228,2168,3525), NE Championship Innovation in Controls Award
-RI District Event- #7 seed in Quals, Finalist(1519,2168,5163), Innovation in Controls Award
-Groton District Event- #9 seed in Quals, QuarterFinalist(2168, 125, 5112), Creativity Award
[2013 Season] - WPI Regional Winner - 1st Blue Banner
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 06:42.

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