Go to Post Well, I know that I could crash the robot into a large object with even greater precision... but if you mean what could the kids do with it... yeah, they'd probably accomplish something creative and useful! - dtengineering [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 03-02-2012, 13:38
kingkurry kingkurry is offline
Registered User
FRC #4067
 
Join Date: Jan 2012
Location: Maryland
Posts: 20
kingkurry is an unknown quantity at this point
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);
        }
    
}
Also, I am plugging in the relay to the relay port of the sidecar. We are just using 5 here because we tried switching between different relay port numbers.
Reply With Quote
  #2   Spotlight this post!  
Unread 03-02-2012, 23:28
BurtGummer BurtGummer is offline
Electrical/Mechanical/Programming
FRC #3020
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Southern CA
Posts: 89
BurtGummer will become famous soon enoughBurtGummer will become famous soon enough
Re: Spike Relay code failing

Can you drive the robot around normally until you hit the trigger?
__________________
I'm a mentor looking for a home in Southern California! I know Java, C++, electrical and mechanical.

Need Java or C++ help? Send me a PM!
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2012, 09:17
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-02-2012, 11:47
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

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.
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2012, 09:03
BurtGummer BurtGummer is offline
Electrical/Mechanical/Programming
FRC #3020
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Southern CA
Posts: 89
BurtGummer will become famous soon enoughBurtGummer will become famous soon enough
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!
__________________
I'm a mentor looking for a home in Southern California! I know Java, C++, electrical and mechanical.

Need Java or C++ help? Send me a PM!
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2012, 12:36
Stimpy1901 Stimpy1901 is offline
Registered User
AKA: Bobby
FRC #2348 (Cool Geeks)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2008
Location: Honolulu
Posts: 57
Stimpy1901 will become famous soon enough
Re: Spike Relay code failing

For relays, we use the following to make our spikes operate.

Quote:
if (joy.getTrigger()) {
trigger.set(Relay.Value.kOn);
trigger.set(Relay.Value.kReverse);

} else {
trigger.set(Relay.Value.kOff);
}

Here is a link to the Javadoc
__________________
"The person who says it cannot be done should not interrupt the person doing it."
- Chinese Proverb

Last edited by Stimpy1901 : 05-02-2012 at 14:03. Reason: inserted actual code we use
Reply With Quote
  #7   Spotlight this post!  
Unread 06-02-2012, 21:33
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

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.
Reply With Quote
  #8   Spotlight this post!  
Unread 06-02-2012, 22:09
nickpeq nickpeq is offline
Turing-complete
FRC #1255 (Blarglefish)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Baytown, TX
Posts: 60
nickpeq is an unknown quantity at this point
Re: Spike Relay code failing

Just today, I wired a PWM from Relay to a Spike without problems, if that counts for anything.
Reply With Quote
  #9   Spotlight this post!  
Unread 07-02-2012, 19:23
korsuk19's Avatar
korsuk19 korsuk19 is offline
Registered User
FRC #3734 (Caxy's)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Lake Forest, Illinois
Posts: 14
korsuk19 is an unknown quantity at this point
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?
__________________
just wanna learn
Reply With Quote
  #10   Spotlight this post!  
Unread 07-02-2012, 20:45
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

It would actually connect to Relay output 5. PWM and Relay outputs use the same cable but different types of signals.
Reply With Quote
  #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
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 10:08.

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