Go to Post I have to remind myself you guys are from Kansas when I hear the country music...I'm not even sure any Texas Teams do that ;) - JohnSchneider [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
  #12   Spotlight this post!  
Unread 12-02-2012, 08:07
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

I don't have a robot to load your code on right now......but it looks fine.

This sounds like an electrical/wiring issue. At first thought, it seems like it might be drawing too much current and lowering the voltage of the battery to the point where the cRio is losing it's minimum voltage to operate.

There's of course of ton of things you could do to try and troubleshoot this.

1. Try changing your code to run only two motors instead of four. Use one on the left and one on the right like tank drive. Re-create the situation that causes it to stop and see if it persists.

2. Instead of changing the code, try unhooking the PWM cables to one jaguar at a time. Create the same situation that causes it to stop for each unhooked PWM cable.

3. Enable the relay code ( code it so a joystick button press sets it to kForward, so its off when it first starts until you press the button) , plug in all jaguars, but disconnect the spike from the digital sidecar. Run the robot and press the button you assigned in the code to turn on the spike relay (pretending its plugged in, even though it isn't). If it still jerks and dies, then it's code related. If not, you've got a wiring issue.

I'm not too sure that the relay problem is directly related to the motor issue.

Let me know if any of that gets you some results. I'll think of some more things to do for troubleshooting. If you could, PM me a picture of your control system including all components.

-Sean
__________________
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
  #13   Spotlight this post!  
Unread 12-02-2012, 11:45
alberth alberth is offline
Programmer and Engineer
FRC #4067 (The Incredible Hawk)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Maryland
Posts: 9
alberth is an unknown quantity at this point
Re: Spike Relay code failing

We'll be trying some of those suggestions you've provided. Thanks!
Reply With Quote
  #14   Spotlight this post!  
Unread 12-02-2012, 13:29
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
Re: Spike Relay code failing

We had similar issue and after 3 hours of trying to fix it, we figured someone forgot to power the Digital Sidecar.

Before powering it, it could only handle 2 CIM motors, anything more would just make everything not work. And even Relay caused it to jerk and become unresponsive. (Same issue as you are having.)

After powering it, all the lights turned on, including the team light, and everything worked fine.

I would double check the wiring for powering the Digital Sidecar to 20 amps breaker. And also see if your team light is working.

Hope that helps.
Reply With Quote
  #15   Spotlight this post!  
Unread 13-02-2012, 19:29
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

So we did check the sidecar. It is being powered properly. Can someone please run this code on their robot? Just to confirm that it is not a programming issue.

We did try binding the relay to a trigger. Whenever we hit the trigger the same thing happens. In other words, activating the relay causes it to jerk. Also, we tried to disconnect the relay but still run it. We got the same issue. We did try running the relay but commenting out the robot drive object and related methods. This didnt get the relay to run but the cim motors didnt jerk at least.

Thank You.

Last edited by kingkurry : 13-02-2012 at 19:32.
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 12:54.

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