View Single Post
  #1   Spotlight this post!  
Unread 18-02-2010, 21:10
dan_h dan_h is offline
EE Grad Student
AKA: Dan Huizenga
#0518
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Grand Rapids, MI
Posts: 20
dan_h is an unknown quantity at this point
Help! Can't get PWMs to work...

I'm trying to get our control system working, and everything seems to be communicating properly (diagnostics shows communication, robot code, stop button, left stick, enet link, ds radio, bridge, and robot as all green), and when I enable the robot in teleop the RSI light switchs to long on/ short off, however, output to the PWMs doesn't seem to be working. Our robot code is as follows:

Code:
#include "WPILib.h"

class DefaultRobot : public SimpleRobot
{
	RobotDrive *myRobot;			// robot drive system
	Joystick *rightStick;			// joystick 1 (arcade stick or right tank stick)
	DriverStation *ds;				// driver station object

public:
	/**
	 * 
	 * 
	 * 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.
	 */
	DefaultRobot(void)
	{
		ds = DriverStation::GetInstance();
		myRobot = new RobotDrive(1, 2, 3, 4);	// create robot drive base
		rightStick = new Joystick(1);			// create the joysticks
		//Update the motors at least every 100ms.
		GetWatchdog().SetExpiration(100);
	}

	/**
	 * Drive left & right motors for 2 seconds, enabled by a jumper (jumper
	 * must be in for autonomous to operate).
	 */
	void Autonomous(void)
	{
		GetWatchdog().SetEnabled(false);

		myRobot->Drive(0.5, 0.0);			// drive forwards half speed
		Wait(2000);							//    for 2 seconds
		myRobot->Drive(0.0, 0.0);			// stop robot

		GetWatchdog().SetEnabled(true);
	}

	void OperatorControl(void)
	{
		Jaguar temp(5);
		
		temp.Set(1.0); /* Expect, at the least, to see PWM5 on slot 4 move */
		
		while (IsOperatorControl())
		{
			GetWatchdog().Feed();
			myRobot->ArcadeDrive(rightStick);  // drive with arcade style (use right stick)
		}
	}
};

START_ROBOT_CLASS(DefaultRobot);
At the very least, I would expect to see PWM5 move. I also tried adding a printf to show the location of the joystick Y axis (through the target console in the debugger), and it updated as expected. Any help would be greatly appreciated!
__________________
--
Team 518 Home Page
Reply With Quote