View Single Post
  #27   Spotlight this post!  
Unread 26-03-2004, 16:33
Tom Saxton's Avatar
Tom Saxton Tom Saxton is offline
Registered User
no team (Issaquah Robotics Society)
Team Role: Mentor
 
Join Date: Dec 2003
Rookie Year: 2003
Location: Sammamish, WA
Posts: 98
Tom Saxton has much to be proud ofTom Saxton has much to be proud ofTom Saxton has much to be proud ofTom Saxton has much to be proud ofTom Saxton has much to be proud ofTom Saxton has much to be proud ofTom Saxton has much to be proud ofTom Saxton has much to be proud ofTom Saxton has much to be proud ofTom Saxton has much to be proud of
Re: Development enviroments orther than MPLAB

Quote:
Originally Posted by CrashZero
Thats nothing all our robot did when we shipped it was spin in a circle. cuz the stupid build team put one of the fricking moters in backwards. I think that when we get there i can download a code that works but we will literally be testing it on our bot for the first time then. If anything goes wrong i am sure that all you programers out there know that it is me who will be blamed for screwing it up, even though if the builders whould have put it in right it would not have been a problem.
Our code has exactly one place in the code that knows how to run the drive motors.

Code:
// Set the left and right drive motors to the specified speed values.
//
// The speed values must be in the range [-127, 127].
// For both motors:
//    0 is stop
//    postive values move that wheel forward
//    negative values move that wheel backward
//
void SetDriveMotors(int speedLeft, int speedRight)
{
	pwmWheelL = pwm01 + speedLeft;
	pwmWheelR = pwm02 + speedRight;
}
This simple encapsulation has many advantages.

This chunk of code is the only place that has to keep track of "bigger than 127 goes forward, less is backward, proportional to the difference" or the other way around if either motor is wired the other way.

It's much easier to read "SetDriveMotors(10, -10)" than "pwm01 = 137; pwm02 = 117;" and know that it's asking for a slow right turn.

If one of the motors gets wired backwards, it's trivial to change the +/- for that motor in one well-defined place. (We also put polarized connectors on the motors, so that motors can't get reversed for anything less than a motor replacement.) It's also trivial to move the drive motor to a different PWM if need be.

The software team gets so little time with the working robot, it doesn't pay to spend time and energy blaming the build/electronics team for something being backwards. If you keep the knowledge localized in the code, it's trivial to adjust, compile and download. This is especially handy if you just finished a big repair two minutes before the next match and there's no time to crawl back in and reverse a couple of wires.
__________________
Tom Saxton
http://www.idleloop.com/