|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Spike Relay code failing
We are using a spike relay to control a spinbrush in the front of the robot to sweep in balls. I created a new spike relay object and used the left trigger to get it to move. However, every time I hit the trigger, the ENTIRE robot jerks forward and then becomes unresponsive until I disable and renable teleop. And when i say jerk froward, I mean that the CIM motos, which are connected to our 4 jaguars, move and the spin brush moves too, albeit for a short period of time. Is there some issue in the code that could cause this to happen?
Code:
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Relay;
public class Test extends IterativeRobot {
Joystick leftStick;
Joystick rightStick;
RobotDrive robot;
Relay spike;
double leftValue, rightValue;
public void robotInit() {
leftStick = new Joystick(1);
rightStick = new Joystick(2);
robot = new RobotDrive(1,2,3,4);
spike = new Relay(5);
}
public void disabledPeriodic(){
}
public void autonomousPeriodic() {
}
public void teleopPeriodic() {
//robot.setSafetyEnabled(false);
robot.tankDrive(leftStick.getY(),rightStick.getY());
//robot.tankDrive(leftValue, rightValue);
//spike.set(Relay.Value.kForward);
if(leftStick.getRawButton(1)){
spike.set(Relay.Value.kForward);
}
}
|
|
#2
|
|||
|
|||
|
Re: Spike Relay code failing
Can you drive the robot around normally until you hit the trigger?
|
|
#3
|
||||
|
||||
|
Re: Spike Relay code failing
Could you try this: http://www.usfirst.org/sites/default...structions.pdf
We had very similar problems with out ribbon cable and ended up just using a previous year's cable. |
|
#4
|
|||
|
|||
|
Re: Spike Relay code failing
The robot does drive somewhat normally until we hit the trigger, however we have noticed that if we go full forward on the left side and full throttle reverse on the right side, the robot locks up and we need to disable and renable teleop for it to work again. Both sides forward, both sides backward, one side forward with the other side at 0 and Left reverse and right forward are fine. It's only going forward on the right side and reverse on the left that makes it lock up.
Also, we did change our ribbon cable. We are using this old printer cable. |
|
#5
|
|||
|
|||
|
Re: Spike Relay code failing
Hmm, doesn't sound like a programming issue to me, though I could be wrong. However, nothing comes to mind as to what could be the issue. I'll think it over today and hopefully come up with something!
|
|
#6
|
|||
|
|||
|
Re: Spike Relay code failing
For relays, we use the following to make our spikes operate.
Quote:
Here is a link to the Javadoc Last edited by Stimpy1901 : 05-02-2012 at 14:03. Reason: inserted actual code we use |
|
#7
|
|||
|
|||
|
Re: Spike Relay code failing
Well we managed to get past the joystick issues during driving through some limiting code. We limited the joystick y values to .6 only when driving the sides in opposite directions to keep the robot from locking up. I am not sure why but suppling any throttle value higher than around .6 to the jaguars when going opposite directions causes it to shut down. Im thinking that this may be a voltage issue, because if we use a battery that is only about 25% charged we can limit it at .75 without any problems. But the relays are still not working.
On a side note, to wire the relays do we need to modify a PWM cable, because only the B(closest to fuse) is labeled. The ground could be the middle pin which would require a modification of the cable. |
|
#8
|
|||
|
|||
|
Re: Spike Relay code failing
Just today, I wired a PWM from Relay to a Spike without problems, if that counts for anything.
|
|
#9
|
||||
|
||||
|
Re: Spike Relay code failing
so for clarification when coding something like:
Relay spike = new Relay(5); the spike relay would connect through PWM output 5 correct? |
|
#10
|
|||
|
|||
|
Re: Spike Relay code failing
It would actually connect to Relay output 5. PWM and Relay outputs use the same cable but different types of signals.
|
|
#11
|
|||
|
|||
|
Re: Spike Relay code failing
Could someone please try running this code on their robot? All it does is control a relay and drive the bot. We are getting weird problems with this:
Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Drivetrain extends IterativeRobot {
RobotDrive drive;
Joystick left,right;
double leftValue,rightValue;
Relay spike;
public void robotInit() {
drive = new RobotDrive(1,2,3,4);
left = new Joystick(1);
right = new Joystick(2);
spike = new Relay(1);
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
//spike.set(Relay.Value.kForward);
leftValue = left.getY();
rightValue = right.getY();
drive.tankDrive(left,right);
//drive.tankDrive(limit(leftValue), limit(rightValue));
}
public static double limit(double num) {
final double limit = .6;
if (num > limit) {
return limit;
}
if (num < -limit) {
return -limit;
}
return num;
}
}
Also, when we try and drive left forward and back reverse without limiting the values to around .6 it stops and becomes unresponsive. driving both wheels forwards or reverse works fine, as long as they are going the same direction, and driving left reverse and right forward doesn't give us any problem. If someone else could run this it would show us the the programming isnt the problem. Thanks in advance for your help. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|