I am the head Programmer and Electrician for Team 1369 Minotaur and the robot is becoming a really big agitation to me. Here are some issues that I am having and I hope that you will comment, criticize, advise, etc. on ANY and EVERYthing.
Here are some issues:
1.) Robot Signal Light (RSL)
On our robot, our Digital SideCar (DSC) has properly functioned including the little green “blinky light.” When I connect the RSL to the DSC via the connector, it does not flash. This is annoying and perplexing for such a plug-n-play device. So my electricians and I have tested the points of metal exposure with a voltmeter all the way to the very insides of the RSL as as well as test the new and old lights, which the old light worked back in December 2011, and they both gave the same voltage reading, it was weird to read but it was oscillating. We even tried using other wires and other means of connections (bootleg placement of holding the wires there with three people to help = gave voltage, no lights).
Some say that the cRio layout could correspond to this so here is our layout (to the best of my memory):
Slot 1: empty
Slot 2: 9403
Slot 3: 9201
Slot 4: empty
Slot 5: 9472
Slot 6: empty
Slot 7: empty
Slot 8: empty
I am almost 200% sure that there is error and that it can be corrected. Please do whatever it takes to correct me.
2.) PWMs, Relays, and I/Os
-PWMs
I have 4 Jaguars for the PWM slots. The first 2 are tank Drive motors which have had no problem except for the occasional error in programming. They are all set-up accordingly to -+S on the DSC and the Jaguars. The other two Jaguars (shooter and conveyor) are non-responsive. These are button launchers (shown in code later below) that are remaining in the blinking yellow state. This is confusing, especially when the error is due to not updated enough error:mad:.
-Relays
We are using relays for the window motors we have on a collector and a lever arm. The relays are hooked up in Relay slot one and two. At one point, I got a simple code to run on it to toggle on and off. Now they remain unresponsive. The light is RED and the fuse is intact. There is 12V going into it and no output voltage. I unplugged the wires to the motor from the spike and manually hooked it up to the battery. This proved the motor and subsystem work, but there is no output. The PWMs going into it ae my main issue. I could not remember which way it hooks up, the DSC was not a helpful diagram, so I hooked them in every way on the DSC and the Spike and still no response. This was very perplexing so any diagram, pic or layout would be much appreciated.
-I/Os
I am new to sensors, but I have done some research on them. The ones that I am focusing on are only the encoders (2) and the microswitches (2). First, I would like to see a DETAILED wire diagram and/or pictures of your wiring so that I understand what to do. Also with the DSC with slot a,b,+5,GND and the cRio (I can’t think of the slot number or how to fully connect them.) With encoders, how do you mount them to CIM motors and window motors properly and how do you power encoders and microswitches.
3.) The program
I have tried code from Iterative (A COMPLETE PAIN TO RUN SIMPLEST THING) to SimpleRobot (Something that works decently).
Here are some of my codes (that I was very proud of):
NOTE: Some areas were commented out only for the sake of getting to the problem. They used to be active in the program! Plus I wrote these within three ours at different times with Iterative first.
IterativeRobot (PLEASE DO NOT STEAL!)
/**
* Team 1369 Minotaur: FRC 2012 Code
*
* Middleton Magnet High School
* Tampa, FL
*
* Programmers: Marco Schoener
* Marvin
* Richawn
*/
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Jaguar;
/**
* 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 MinotaurRobot extends IterativeRobot
{
/*/--------------------DECLARED GLOBAL VARIABLES--------------------/*/
//Motor Controls
Relay zipTieMotor; // Zip-tie wheel spike motor controller
Relay flagArmMotor; // Flag arm motor control
RobotDrive driveTrain; // 2 motor drive train
Jaguar conveyor; // Conveyor motor set-up
Jaguar launcher; // Launcher motor set-up
//Sensors
Encoder encode_1; // Encoder for Conveyor Belt System
Encoder encode_2; // Encoder for Flag Arm System
DigitalInput addSwitch; // Add the number of balls entering conveyor
DigitalInput minusSwitch; // Subtracts the number of balls in the conveyor
//Joysticks
Joystick controller1; // Used for driving and flag arms
Joystick controller2; // 2nd controller: used for launcher, conveyor
/*/-***Joystick Commands***-/*/
//Controller 1
public static final int CONT_1_LEFT_Y_AXIS = 2; // Controller 1: Left motor control (Tank Drive)
public static final int CONT_1_RIGHT_Y_AXIS = 4; // Controller 1: Right motor control (Tank Drive)
//Controller 2
public static final int LAUNCHER_CONTROLLER_FULL = 1; // Controls launcher at full speed
public static final int LAUNCHER_CONTROLLER_HALF = 2; // Controls launcher at alf speed
public static final int LAUNCHER_CONTROLLER_QUTR = 3; // Controls launcher at quarter speed
public static final int CONVEYOR_CONTROLLER = 4; // Controls conveyor belt movements
public static final int ZIP_TIE_WHEEL_BUTTON = 5; // Left Sholder: Value to activate zip-tie wheel
public static final int FLAG_ARM_CONTROLLER = 6; // Right Shoulder: Controls flag arm
public static final int CONT_2_LEFT_Y_AXIS = 2; // Controller 2:
public static final int CONT_2_RIGHT_Y_AXIS = 4; // Controller 2:
//Variables
boolean spikeOn_1; // Create a toggle variable for the zip-tie wheel spike relay
boolean spikeOn_2; // Create a toggle variable for the flag arm spike relay
public static final int CRIO_SLOT = 4; // Tells the slot for sensors to go on cRIO
public static final int PRELOADED_BALLS = 2; // Set the number for pre-loaded balls
//boolean zipTieWheel = false; // Allows the zip-tie wheel to move
//int totalBalls = 0; // Initial number of balls in conveyor
//public static final int plusBall = 1; // Sets up the ball count for adding in coveyor
//public static final int minusBall = 1; // Sets up the ball count for subtracting in coveyor
/*/--------------------CONSTRUCTOR CLASS----------------------------/*/
public MinotaurRobot()
{
getWatchdog().setEnabled(false); // The program overlord is set to sleep mode
driveTrain = new RobotDrive(1,2); // Drivetrain Motor PWM slots: 1 for left motor; 2 for right motor
conveyor = new Jaguar(3); // Conveyor Jaguar on PWM slot 3
launcher = new Jaguar(4); // Launcher Jaguar on PWM slot 4
zipTieMotor = new Relay(1); // Zip-Tie Spike in Relay slot 1
flagArmMotor = new Relay(2); // Flag Arm Spike in Relay slot 2
driveTrain.setSafetyEnabled(false);
//encode_1 = new Encoder(1, 2, false, Encoder.EncodingType.k4X); // Conveyor Belt: Sets encoder to Digital port 1 and 2, sets forward direction boolean, and detects encoder type
//encode_2 = new Encoder(3, 4, false, Encoder.EncodingType.k4X); // Flag Arm: Sets encoder to Digital port 3 and 4, sets forward direction boolean, and detects encoder type
//addSwitch = new DigitalInput(CRIO_SLOT, 5); // Attach the microswitch to the cRIO in slot 4 and on the sidecar in digital I/O slot 5
//minusSwitch = new DigitalInput(CRIO_SLOT, 6); // Attach the microswitch to the cRIO in slot 4 and on the sidecar in digital I/O slot 6
controller1 = new Joystick(1); // Controller 1
controller2 = new Joystick(2); // Controller 2
}
/*/--------------------ROBOT INITILIZATION--------------------------/*/
public void robotInit()
{
driveTrain.drive(0,0); // Motors are set of 0
driveTrain.stopMotor(); // Motors are off (Safety is HERE!)
zipTieMotor.setDirection(Relay.Direction.kForward); // Spike motor direction is forward
zipTieMotor.set(Relay.Value.kOff); // Spike is set to off
flagArmMotor.setDirection(Relay.Direction.kBoth); // Spike motor direction is forward and backward
flagArmMotor.set(Relay.Value.kOff); // Spike is set to off
spikeOn_1 = false; // Spike Relay for Zip-tie Motor toggle is set to off
spikeOn_2 = false; // Spike Relay for Flag Arm Motor toggle is set to off
encode_1.reset(); // Reset the conveyor belt encoder
encode_2.reset(); // Reset the flag arm encoder
}
/*/--------------------DISABLED ROBOT-------------------------------/*/
public void disabledPeriodic()
{
driveTrain.drive(0,0); // Motors are set of 0
driveTrain.stopMotor(); // Motors are off
zipTieMotor.set(Relay.Value.kOff); // Zip Tie Spike is set to off
flagArmMotor.set(Relay.Value.kOff); // Flag Arm Spike is set to off
}
/*/--------------------AUTONOMOUS PERIOD----------------------------/*/
public void autonomousPeriodic()
{
zipTieMotor.set(Relay.Value.kOff);
while(true)
{
zipTieMotor.set(Relay.Value.kOn);
Timer.delay(0.005);
}
//encode_1.stop(); // Stop the conveyor belt encoder
//encode_2.stop(); // Stop the flag arm encoder
}
/*/--------------------TELEOP PERIOD--------------------------------/*/
public void teleopPeriodic()
{
// Initial Variables: This is to be sure that it is active
spikeOn_1 = false;
spikeOn_2 = false;
zipTieMotor.set(Relay.Value.kOff);
flagArmMotor.set(Relay.Value.kOff);
// Subsystem Control
while(true)
{
// Tank Drive
driveTrain.tankDrive(controller1.getRawAxis(CONT_1_LEFT_Y_AXIS), controller1.getRawAxis(CONT_1_RIGHT_Y_AXIS));
Timer.delay(0.005);
// Fly-Wheel
if(controller2.getRawButton(ZIP_TIE_WHEEL_BUTTON))
{
if(spikeOn_1 == false)
{
spikeOn_1 = true;
zipTieMotor.set(Relay.Value.kOn);
}
Timer.delay(0.5);
if(spikeOn_1 == true)
{
spikeOn_1 = false;
zipTieMotor.set(Relay.Value.kOff);
}
Timer.delay(0.5);
}
// Conveyor
// Launcher
// Flag Arm Control
if(controller2.getRawButton(FLAG_ARM_CONTROLLER)) // Move the flag arm by button command
{
if(spikeOn_2 == false)
{
spikeOn_2 = true;
flagArmMotor.setDirection(Relay.Direction.kForward);
flagArmMotor.set(Relay.Value.kOn);
}
Timer.delay(0.5);
if(spikeOn_2 == true)
{
spikeOn_2 = false;
flagArmMotor.setDirection(Relay.Direction.kReverse);
flagArmMotor.set(Relay.Value.kOn);
}
Timer.delay(0.5);
}
//encode_1.stop(); // Stop the conveyor belt encoder
//encode_2.stop(); // Stop the flag arm encoder
zipTieMotor.set(Relay.Value.kOff); // Turn of Zip-Tie Spike
flagArmMotor.set(Relay.Value.kOff); // Turn off Flag Arm Spike
}
}
}
SimpleRobot (PLEASE DO NOT STEAL!)
/*----------------------------------------------------------------------------*/
/* 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.SimpleRobot;
import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Encoder;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SimpleRobot
* 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 MinotaurCode extends SimpleRobot
{
private DriverStationLCD dsLCD;
private RobotDrive driveTrain;
private Jaguar conveyor;
private Jaguar launcher;
private Relay zipTieWheel;
private Relay flagArmWheel;
private Joystick controller1;
private Joystick controller2;
private Timer time;
private Encoder conveyorControl;
private Encoder flagArmControl;
public static final int FLAG_ARM_AXIS = 6;
public static final int LEFT_Y_AXIS = 2;
public static final int RIGHT_Y_AXIS = 4;
public static final int ZIP_TIE_CONTROLLER = 1;
public static final int FLAG_ARM_CONTROLLER = 2;
public static final int PRELOADED_BALLS = 2;
public static final double LAUNCH_SPEED_DEFAULT = 0.5;
public static final double LAUNCH_SPEED_FULL = 1.0;
public static final double LAUNCH_SPEED_HALF = 0.5;
public static final double LAUNCH_SPEED_QUTR = 0.25;
public static final int LAUNCH_SPEED_FULL_BUTTON = 1;
public static final int LAUNCH_SPEED_HALF_BUTTON = 4;
public static final int LAUNCH_SPEED_QUTR_BUTTON = 3;
public static final int LAUNCH_BUTTON = 2;
public static final int CONVEYOR_BUTTON = 5;
boolean zipTieOn;
public MinotaurCode()
{
getWatchdog().setEnabled(false);
driveTrain = new RobotDrive(1, 2);
conveyor = new Jaguar(3);
launcher = new Jaguar(4);
zipTieWheel = new Relay(1, Relay.Direction.kForward);
flagArmWheel = new Relay(2, Relay.Direction.kBoth);
controller1 = new Joystick(1);
controller2 = new Joystick(2);
time = new Timer();
driveTrain.setSafetyEnabled(false);
conveyorControl = new Encoder(1, 2, false, Encoder.EncodingType.k4X);
flagArmControl = new Encoder(3, 4, false, Encoder.EncodingType.k4X);
}
public void robotInit()
{
// dsLCD.getInstance();
driveTrain.drive(0.0, 0.0);
driveTrain.stopMotor();
conveyor.stopMotor();
launcher.stopMotor();
zipTieWheel.set(Relay.Value.kOff);
flagArmWheel.set(Relay.Value.kOff);
conveyorControl.reset();
conveyorControl.stop();
flagArmControl.reset();
flagArmControl.stop();
zipTieOn = false;
}
public void disabled()
{
driveTrain.drive(0.0, 0.0);
driveTrain.stopMotor();
conveyor.stopMotor();
launcher.stopMotor();
zipTieWheel.set(Relay.Value.kOff);
flagArmWheel.set(Relay.Value.kOff);
conveyorControl.reset();
conveyorControl.stop();
flagArmControl.reset();
flagArmControl.stop();
}
/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous()
{
time.start();
while(isAutonomous() && isDisabled())
{
flagArmWheel.setDirection(Relay.Direction.kForward);
zipTieWheel.set(Relay.Value.kOn);
Timer.delay(0.005);
//flagArmWheel.set(Relay.Value.kOn);
if(time.get() < 4)
{
//driveTrain.drive(0.5, 0.0);
//Timer.delay(0.005);
}
/*while(time.get() > 0 && time.get() < 20)
{
conveyor.set(LAUNCH_SPEED_HALF);
Timer.delay(0.005);
launcher.set(LAUNCH_SPEED_FULL);
Timer.delay(0.005);
}*/
}
time.stop();
}
/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl()
{
while(isOperatorControl() && isEnabled())
{
// Drive Train
driveTrain.tankDrive(controller1.getRawAxis(LEFT_Y_AXIS), controller1.getRawAxis(RIGHT_Y_AXIS));
Timer.delay(0.005);
// Zip Tie Wheel
if(controller1.getRawButton(ZIP_TIE_CONTROLLER))
{
//zipTieOn = true;
zipTieWheel.set(Relay.Value.kOn);
}
// Flag Arm
/*while(controller2.getRawAxis(FLAG_ARM_AXIS) != 0)
{
if(controller2.getRawAxis(FLAG_ARM_AXIS) > 0)
{
flagArmWheel.setDirection(Relay.Direction.kForward);
flagArmWheel.set(Relay.Value.kOn);
}
else if(controller2.getRawAxis(FLAG_ARM_AXIS) < 0)
{
flagArmWheel.setDirection(Relay.Direction.kReverse);
flagArmWheel.set(Relay.Value.kOn);
}
Timer.delay(0.005);
}*/
// Conveyor
while(controller2.getRawButton(CONVEYOR_BUTTON))
{
conveyor.set(LAUNCH_SPEED_HALF);
Timer.delay(0.005);
}
// Launcher
//launcher.set(1.0);
Timer.delay(0.005);
while(controller2.getRawButton(LAUNCH_BUTTON))
{
if(controller2.getRawButton(LAUNCH_SPEED_FULL_BUTTON))
{
launcher.set(LAUNCH_SPEED_FULL);
Timer.delay(0.005);
}
else if(controller2.getRawButton(LAUNCH_SPEED_HALF_BUTTON))
{
launcher.set(LAUNCH_SPEED_HALF);
Timer.delay(0.005);
}
else if(controller2.getRawButton(LAUNCH_SPEED_QUTR_BUTTON))
{
launcher.set(LAUNCH_SPEED_QUTR);
Timer.delay(0.005);
}
else
{
launcher.set(LAUNCH_SPEED_DEFAULT);
Timer.delay(0.005);
}
}
}
}
}
There will be RobotDrive…Not updated enough in autonomous and operator control, but the drive train is the thing that works 98% of the time! Any comments or hints or etc. would be GREATLY APPRECIATED!
4.) Watchdog
I have to disable it at school to run the robot, but when competition comes, does it always stay on? (I know it stays on but why is there a difference where it is active?)
5.) Is DriverStationLCD required and if so, what does it do and how. I hear it is for user messages, but I haven’t gotten that far yet.
Thank you in advanced for you useful information in any way shape or form no matter how cruel. It’s crucnch time and we are all going to make it. Happy Competitions and be Professional Gracefully, like a robot!
P.S. I will be posting this in the Electrical thread under same name.
LINK:
http://www.chiefdelphi.com/forums/showthread.php?p=1127739#post1127739