Our spike is not giving power to our motor. This is my code:
#include "WPILib.h"
/**
* This is a demo program showing the use of the RobotBase class.
* The SimpleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*/
class RobotDemo : public SimpleRobot
{
RobotDrive myRobot; // robot drive system
Joystick stickL; // LEFT joystick
Joystick stickR; // RIGHT joystick
Jaguar ballSucker; // Central ball aquiring mechanism
Relay door; // Ball release mechanism
public:
RobotDemo(void):
myRobot(2, 1), // these must be initialized in the same order
stickL(1), // as they are declared above.
stickR(2),
ballSucker(3),
door(4)
{
GetWatchdog().SetExpiration(0.1);
}
/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
myRobot.Drive(0.5, 0.0); // drive forwards half speed
Wait(2.0); // for 2 seconds
myRobot.Drive(0.0, 0.0); // stop robot
}
/**
* Runs the motors with arcade steering.
*/
void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
while (IsOperatorControl())
{
GetWatchdog().Feed();
myRobot.TankDrive(stickR, stickL); // drive with tank style
if (stickL.GetTrigger()) // If Left Joystick Trigger is HELD
ballSucker.Set(-1.0);
else // If Left Joystick Trigger is RELEASED
ballSucker.Set(0.0);
if (stickR.GetTrigger()) // If Right Joystick Trigger is HELD
door.Set(Relay::kForward);
else // If Right Joystick Trigger is RELEASED
door.Set(Relay::kOff);
Wait(0.005); // wait for a motor update time
}
}
};
START_ROBOT_CLASS(RobotDemo);
The Jaguar for ‘ballSucker’ works fine, I changed it from the left trigger to the right trigger to make sure both triggers were working properly. Are we setting up the Relay wrong?
It might be a wiring problem, also. We were not sure where to plug in the spike’s PWM cable on the digital sidecar. Right now it is plugged in to Relay port 4, but we have also tried the side for the Jaguars and it did not work. We tried turning the cables around, too.
The relay outputs are correct for connecting to Spike relays.
There are LEDs adjacent to the relay pins on the Digital Sidecar. When you tell the door relay (#4) to turn on forward, its associated green LED should light. Does it?
Are the Digital Sidecar’s 12v and 5v power LEDs lit? Is the RSL on steady?
OK so answer me this - all sidecar LED’s are green. Spike power is wired properly. Relay output light is turning on at the sidecar (using either the Compressor class or just a Relay class to turn the output on). Pump works fine when powered separately. RSL is solid orange when enabled. All this, but the pump doesn’t enable. The Spike LED remains orange. I’ve swapped out the PWM cable, twice. No dice.
All bots are programmed in Wind River. The firmware matches the software installation.
This has happened today, twice, on two different robots (neither of which are mine). I’m not quite sure what to try next. Hopefully there is a “duh” I’m missing and someone can help me correct the problem. Should I bust out the “Persuader” and take the sidecar out behind the woodshed? :rolleyes:
If the Digital Sidecar’s Relay LED is working, but the Spike wired to the Relay pins associated with that LED is not, with two different sets of wires having been tried, I would tend to suspect the Spike as the source of the fault.
Seconding the above–we had a Spike fail as well. It’s a bit of a pain to troubleshoot(since the spike has no error codes like a speed controller), but your symptoms match ours exactly.
Relay * motorRelay;
motorRelay = new Relay(...)
motorRelay->SetDirection(Relay::kForwardOnly);
motorRelay->Set(Relay::kOn);
Without the set direction, or even by giving it a value like Relay::kForward it would not move.
After this everything worked just fine, not sure why.
However if you are saying your digital sidecar is showing the correct value, and yet the spike is not re-acting, I would not know, have you tried a different relay output?
We determined the one failure WAS attributable to the Spike (never had that happen before!), but the problem on the robot where we swapped the Spike remains. I’ll have the rookie team recheck their crimp connections and wiring…