|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Only ports 0 and 1 working on RoboRio
This is our current code:
Code:
package org.usfirst.frc.team4528.robot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Timer;
public class Robot15 extends SampleRobot {
Victor frontLeft;
Victor rearLeft;
Victor frontRight;
Victor rearRight;
Victor motor; //add-on
RobotDrive myRobot; // class that handles basic drive operations
XBoxJoystick gamepad; // declare gamepad as a Joystick object to get Joystick functionality, but with different buttons
public void Robot()
{
frontLeft = new Victor(1); //change port to appropriate PWM port on roboRIO
rearLeft = new Victor(2); //change port to appropriate PWM port on roboRIO
frontRight = new Victor(3); //change port to appropriate PWM port on roboRIO
rearRight = new Victor(4); //change port to appropriate PWM port on roboRIO
motor = new Victor(5); //add-on
myRobot = new RobotDrive(frontLeft, rearLeft, frontRight, rearRight); // robot drivetrain functionality; takes in front left motor, rear left motor, front right motor, rear right motor ports
gamepad = new XBoxJoystick(0); // port gamepad is plugged into
}
//add-on
public void runMotor()
{
if(gamepad.getLeftZ() > 0)
{
motor.set(gamepad.getLeftZ());
}
else if(gamepad.getRightZ() > 0)
{
motor.set(-gamepad.getRightZ());
}
else
{
motor.set(0.0);
}
}
//end of...
/**
* Runs the motors with tank steering.
*/
public void operatorControl()
{
myRobot.setSafetyEnabled(false);
while (isOperatorControl() && isEnabled())
{
myRobot.tankDrive(gamepad.getRightY(), gamepad.getLeftY());
Timer.delay(0.005); // wait for a motor update time
runMotor();
}
}
}
Any Victor we put in port 0 or 1 will turn solid when enabled, but any other will not. The PWM cable is not the issue either. We replaced the battery in case it was low voltage. This code was working 5 days ago. Now it is not. We've re-imaged the RoboRio and uploaded the code again. Still same issue. We don't even call port 0 in our code but it runs the victor connected to port 1. Last edited by mistersands : 11-02-2015 at 16:07. |
|
#2
|
|||||
|
|||||
|
Re: Only ports 0 and 1 working on RoboRio
Quote:
It is unfortunately easy to get the PWM connection not-quite-right on a Victor. Find someone with lots of practice and have him or her verify that the cables are correctly plugged in. And make doubly sure at both ends that the connectors are not plugged in backwards. |
|
#3
|
|||
|
|||
|
Re: Only ports 0 and 1 working on RoboRio
Quote:
But the big thing is, our code doesn't initialize PWM port 0. But everything I just said for Port 1 is also true for port 0. So I'm at a complete loss. |
|
#4
|
|||||
|
|||||
|
Re: Only port 1 working on RoboRio
An easy way to see if the PWM port is actually generating signals is to connect a servo to it. The servo will change angle when you change the applied "speed". At full forward or full reverse, servos may end up jamming against their stops and making a ticking sound. Don't do that for an extended time.
|
|
#5
|
|||||
|
|||||
|
Re: Only ports 0 and 1 working on RoboRio
...except for the mismatch between the class named Robot15 and the constructor Robot(). That might be a problem.
|
|
#6
|
||||
|
||||
|
Re: Only ports 0 and 1 working on RoboRio
Quote:
Don't change the name of the main class! |
|
#7
|
|||
|
|||
|
Re: Only port 1 working on RoboRio
Thanks! We completely reinstalled Java and Eclipse on the Classmate and then implemented the changes mentioned and it seems to be working.
Thanks so much for the help! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|