View Single Post
  #11   Spotlight this post!  
Unread 11-02-2012, 19:31
kingkurry kingkurry is offline
Registered User
FRC #4067
 
Join Date: Jan 2012
Location: Maryland
Posts: 20
kingkurry is an unknown quantity at this point
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;
    }
    
}
When we try and set the relay to forward, the cim motors(which are connected to the jaguars) jerk then become unresponsive. The relay code is commented out right now.

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.
Reply With Quote