Problems with the watchdog (I think)

Hello, we are having some problems with getting our code to work. At first, whenever we put the robot into enabled mode, it would immediately say watchdog not fed. The thing is, we are feeding the watch dog. I commented out the camera related code, which helped a lot, but consistently, about 2 minutes after the robot is turned on, it dies to the watch dog. I have the watch dog set to 100ms time out, which seems like plenty of time, especially considering that we don’t have much code yet. All we have is a bit of camera initialization (which I commented out anyway) and the code to control the mecanum wheels.

I have resolved the problem if I comment out all code except the feed statement, so I’m confident that that is working.

Anyways, does anyone have any idea what could because the watch dog to trigger? I also tried setting the time out up to 1000 which had no effect so I’m a little confused.

Could we please see your code? You might have returned the functions, caused an exception, overflow, endless loop, etc by accident that caused the cRio to break out of the function or keep cycling over the same code segment that does not include a feed function call.

Sure, I’m at home right now, but I can post the code after school tomorrow.

Are you running any printf()s to send data back to the target console? We were scratching our heads over why we were having so much trouble with the watchdog until we tried commenting out all the print statements. They are expensive.

Thanks for the responses. Unfortunately, our mentor was not at school today, so no robotics, so I still do not have code to post. :frowning:

As for the printfs, they are another issue I’ve been looking into. I have tried the code with and with our printfs and get the same result either way. I’m not sure whether this is relevant, but when I was using them, I was unable to get them to work. I have to do a little more investigation in to them though, so I think that is a separate issue.


They are expensive if you are using the serial port on the cRIO for console output (because of the 9600 baud rate). If you are using NetConsole, they are much less expensive.


Ok, here is the code. Sorry this took so long. It is based off of the Defaut Robot. The watchdog says it is not fed about 1:45 to 2:00 minutes into teleop mode.


#include <iostream.h>
#include "math.h"

//#include "Vision/AxisCamera2010.h"
#include "WPILib.h"
#include "Mecanum.cpp"

 * 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 DefaultRobot : public SimpleRobot
{			// robot drive system
	Joystick *rightStick;			// joystick 1 (arcade stick or right tank stick)
	Joystick *leftStick;			// joystick 2 (tank left stick)
	DriverStation *ds; 				// driver station object
	Mecanum *mecanum;				// Mecanum drive system


	 * Constructor for this robot subclass.
	 * Create an instance of a RobotDrive with left and right motors plugged into PWM
	 * ports 1 and 2 on the first digital module.
		ds = DriverStation::GetInstance();	// create robot drive base
		rightStick = new Joystick(1);			// create the joysticks
		leftStick = new Joystick(2);
		mecanum = new Mecanum(4, 1, 2, 3, 4);
		//Update the motors at least every 100ms.

	 * Drive left & right motors fo7r 2 seconds, enabled by a jumper (jumper
	 * must be in for autonomous to operate).
	void Autonomous(void)
		//Pull triger, fire rockets
		/*	myRobot->Drive(0.5, 0.0);			// drive forwards half speed
			Wait(2000);							//    for 2 seconds						//    for 2 seconds
			myRobot->Drive(-0.5, 0.0);			// reverse robot
			myRobot->Drive(0.0, 0.0);			// stop robot

	 * Runs the motors under driver control with either tank or arcade steering selected
	 * by a jumper in DS Digin 0. Also an arm will operate based on a joystick Y-axis. 
	void OperatorControl(void)
		while (true)
			mecanum->SetSpeeds(rightStick->GetX(), rightStick->GetY(), leftStick->GetX());  //It works when I comment this out.



 * Mecanum drive class
 * Team 2535
 * Theodore Dahlen
 * 2/1/2010

class Mecanum
	Victor *MotorFrontLeft;
	Victor *MotorFrontRight;
	Victor *MotorBackLeft;
	Victor *MotorBackRight;
	Mecanum(UINT32 slot,
			UINT32 FrontLeft,
			UINT32 FrontRight,
			UINT32 BackLeft,
			UINT32 BackRight)
		MotorFrontLeft = new Victor(slot, FrontLeft);
		MotorFrontRight = new Victor(slot, FrontRight);
		MotorBackLeft = new Victor(slot, BackLeft);
		MotorBackRight = new Victor(slot, BackRight);
	void SetSpeeds(float X, float Y, float Twist)
		float *Wheels[4]; // 0 is FL, 1 is FR, 2 is BL, 3 is BR
		*Wheels[0] = Y + X + Twist;
		*Wheels[1] = Y - X - Twist;
		*Wheels[2] = Y - X + Twist;
		*Wheels[3] = Y + X - Twist;

		if(*Wheels[0] > 1 || *Wheels[0] < -1)
			Divide(Wheels, 0);
		else if(*Wheels[1] > 1 || *Wheels[1] < -1)
			Divide(Wheels, 1);
		else if(*Wheels[2] > 1 || *Wheels[2] < -1)
			Divide(Wheels, 2);
		else if(*Wheels[3] > 1 || *Wheels[3] < -1)
			Divide(Wheels, 3);
	void Divide(float *Wheels[4], int Divide)
		float Divider = fabs(*Wheels[Divide]);
		*Wheels[0] = *Wheels[0] / Divider;
		*Wheels[1] = *Wheels[1] / Divider;
		*Wheels[2] = *Wheels[2] / Divider;
		*Wheels[3] = *Wheels[3] / Divider;
	void Drive(float *Wheels[4])


You have GetWatchdog().SetExpiration() set to 100 seconds, not 100 milliseconds. You probably want GetWatchdog().SetExpiration(0.1)

I’m not positive this is the cause of your problem, but it may be (it would make sense, 100s = 1m40s, so the watchdog might starve after not being fed for so long).

Good Call, thanks. But even if thats the case, why isn’t the watchdog getting fed? Seems to me that that would imply that there is something in the code freezing up, any idea what that might be? That would also explain why even during the time it was not disabled it was still not working. Anyway, thanks, that narrows my search for the problem a considerable amount.

Not sure if this is the problem, but in your tele-op phase, you never enable the watchdog…

Not sure if that is the problem?