Go to Post Representing data in a good way is an art in its own right. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Motors
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average. Display Modes
  #1   Spotlight this post!  
Unread 05-02-2007, 10:19
Mark_Benedict Mark_Benedict is offline
Registered User
FRC #0612
 
Join Date: Jan 2007
Location: Northern VA
Posts: 3
Mark_Benedict will become famous soon enoughMark_Benedict will become famous soon enough
Exclamation Save the Gearbox, Save the Game

Chantilly Academy Robotics Team 612 has developed code that slows the wear on the kit-of-parts planetary gearbox.

The code gradually changes the speed based on the joystick value.

NOTE: in this code, pwm01 is the left side, pwm02 is the right. This also assumes that you are using 2 joystick drive, with the left joystick Port 1 on the Operator Interface, and with the right joystick on Port 2 on the Operator Interface.

Here it is:

/***** Put these lines of code into user_routines.c at the top *****/
#define aRate 3 //This is the rate at which the motor speeds up
#define dRate 8 //This is the rate at which the motor slows down
void accelR(int); //method explained below
void accelL(int); //method explained below


/***** This goes with the above
*FUNCTION NAME: accelL
*PURPOSE: to gradually increase or decrease motor output on pwm01
*CALLED FROM: user_routines.c
*ARGUMENTS: num, the input target value for the motor output
*RETURNS: void
*****/
void accelL(int num)
{
static int leftMotorTemp = 127;
if(pwm01 >= 127)
{
if(num > leftMotorTemp)
leftMotorTemp += aRate;
else if(num < leftMotorTemp)
leftMotorTemp -= dRate;
}
else if(pwm01 < 127)
{
if(num > leftMotorTemp)
leftMotorTemp += dRate;
else if(num < leftMotorTemp)
leftMotorTemp -= aRate;
}
if(leftMotorTemp > 255)
leftMotorTemp = 255;
else if(leftMotorTemp < 0)
leftMotorTemp = 0;

pwm01 = leftMotorTemp;
}


/***** This goes with the above
*FUNCTION NAME: accelR
*PURPOSE: to gradually increase or decrease motor output on pwm02
*CALLED FROM: user_routines.c
*ARGUMENTS: num, the input target value for the motor output
*RETURNS: void
*****/
void accelR(int num)
{
static int rightMotorTemp = 127;
if(pwm02 >= 127)
{
if(num > rightMotorTemp)
rightMotorTemp += aRate;
else if(num < rightMotorTemp)
rightMotorTemp -= dRate;
}
else if(pwm02 < 127)
{
if(num > rightMotorTemp)
rightMotorTemp += dRate;
else if(num < rightMotorTemp)
rightMotorTemp -= aRate;
}
if(rightMotorTemp > 255)
rightMotorTemp = 255;
else if(rightMotorTemp < 0)
rightMotorTemp = 0;

pwm02 = rightMotorTemp;
}


/***** Put this into Process_Data_From_Master_uP
accelL(p1_y); Changes left side based on left joystick y-value
accelR(p2_y); Changes right side bases on right joystick y-value

//End of code


What this code does is gradually change the speed. This will do several things:
  • Make driving easier by decreasing sensitivity
  • Prevent circuit breaker pops
  • Decrease gearbox wear
  • Prevent or slow chain and/or belt wear

Our driver really likes the code, so we will keep it after FIRST sends out the fix.

Sorry about the edit. We have several versions of the same code floating around.

Last edited by Mark_Benedict : 05-02-2007 at 14:00. Reason: version control mess-up
  #2   Spotlight this post!  
Unread 05-02-2007, 10:40
pheadxdll pheadxdll is offline
Registered User
AKA: Alex
FRC #1225 (Amperage Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: North Carolina
Posts: 168
pheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud of
Re: Save the Gearbox, Save the Game

Interesting idea. Thanks for the code!

One question. Is their any lag having to do with speeding up and slowing down so much?
__________________
Amperage Robotics Team 1225
Site under-going revamp. :/
  #3   Spotlight this post!  
Unread 05-02-2007, 11:22
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,363
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Save the Gearbox, Save the Game

I believe that the problem with the carrier plate will come about from shock loads. Software will not help with that. Properly engineered materials will.
  #4   Spotlight this post!  
Unread 05-02-2007, 11:25
MrForbes's Avatar
MrForbes MrForbes is offline
Registered User
AKA: Jim
FRC #1726 (N.E.R.D.S.)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Sierra Vista AZ
Posts: 5,989
MrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond reputeMrForbes has a reputation beyond repute
Re: Save the Gearbox, Save the Game

The shock load comes about because of the sudden reversal of direction of the motor...the motor is under software control.....please think about it....
  #5   Spotlight this post!  
Unread 05-02-2007, 12:03
esquared's Avatar
esquared esquared is offline
Keeps saying 3-2-1-Rush...
AKA: Angry Eric
no team (Volunteer!)
Team Role: Mascot
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Boston, MA
Posts: 192
esquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond reputeesquared has a reputation beyond repute
Re: Save the Gearbox, Save the Game

Interesting.

You could also write this as 1 function by passing the joystick & pwm by reference to your acceleration function. Also, there is nothing wrong with modifying the pwm output variable directly, since the actual pwm output value isn't changed until the Putdata() in Process_Data_From_Master_uP().

What happens if the joystick input is 5, your current pwm output is 8, and it decrements the pwm output by 12? At first glance it looks like your temporary value would go negative. I could be wrong though
  #6   Spotlight this post!  
Unread 05-02-2007, 12:43
ZZII 527's Avatar
ZZII 527 ZZII 527 is offline
"Scale Electric Vehicle"
AKA: Shane Colton
FRC #0097
Team Role: College Student
 
Join Date: Feb 2004
Rookie Year: 2003
Location: Cambridge, MA
Posts: 366
ZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond reputeZZII 527 has a reputation beyond repute
Send a message via AIM to ZZII 527
Re: Save the Gearbox, Save the Game

Thanks for posting this code. I think this is a very simple fix that will be very helpful for teams using the BaneBots gearboxes. With everyone working on materials fixes, it's easy to forget the simpler ways to alleviate the problem.

Another suggestion: Keep your chains in tension. Any backlash will increase impulsive loading a lot.
__________________
MIT Mechanical Engineering
>> College Mentor, Team 97: Cambridge Rindge and Latin School with The Edgerton Center, MIT Mechanical Engineering, Bluefin Robotics, and Draper Laboratory
>> Alumnus, Team 527: Plainedge HS
  #7   Spotlight this post!  
Unread 05-02-2007, 12:53
Mark_Benedict Mark_Benedict is offline
Registered User
FRC #0612
 
Join Date: Jan 2007
Location: Northern VA
Posts: 3
Mark_Benedict will become famous soon enoughMark_Benedict will become famous soon enough
Re: Save the Gearbox, Save the Game

Depending on your gearing, you can change the aRate and dRate. 8 and 12 worked well for us. Feel free to change it to suit your needs.

To get more responive braking, put the Victor jumper on "B", the inner 2 pins. This will cause the robot to actually stop after you tell it to.

About the negative or >255 pwm outputs, you can put a limiter on the temporary pwm. something along the lines of (* is wildcard):

if (pwm**temp > 255)
pwm**temp = 255;
else if (pwm** < 0)
pwm** = 0;

If the bad pwm's give you a problem, put these lines of code before the pwm assignment, but after the if/else block, replacing th *'s with the approprate number.

Last edited by Mark_Benedict : 05-02-2007 at 13:07. Reason: to create a more clear message
  #8   Spotlight this post!  
Unread 05-02-2007, 13:06
Donut Donut is offline
The Arizona Mentor
AKA: Andrew
FRC #2662 (RoboKrew)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2004
Location: Goodyear, AZ
Posts: 1,289
Donut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond repute
Re: Save the Gearbox, Save the Game

Quote:
Originally Posted by esquared View Post
You could also write this as 1 function by passing the joystick & pwm by reference to your acceleration function. Also, there is nothing wrong with modifying the pwm output variable directly, since the actual pwm output value isn't changed until the Putdata() in Process_Data_From_Master_uP().
Ask, and ye shall receive. Below is the code we've been using for 2 years now, you pass in the speed you want, your current speed, and the limit for how much your speed can change by, it takes care of the rest from there.

This goes in a .c file:

Code:
/*******************************************************************************
*
*	FUNCTION:		motor ramping()
*
*	PURPOSE:		Makes the motor gradually change speed		
*
*	PARAMETERS:		desired_speed, current_speed, 
*					change_speed  //small interval to change the motor speed
*
*	RETURNS:		mew_motor_speed   the small change from the current motor speed
*
*	COMMENTS:
*
*******************************************************************************/

unsigned char ramp_motor_speed(unsigned char requested_speed, 
							   unsigned char present_speed, 
				               unsigned char modified_speed)
{
	unsigned char new_motor_speed;
 
	// comparing the desired speed to the current speed, 
	//   if they are the same if moves on, if not it goes to the else
	if (requested_speed == present_speed)   
	{
		new_motor_speed = requested_speed;  
	}
	else
	{
		if (requested_speed < present_speed)
		{
			// if the requested speed is less then the current speed 
			//    it will subtract the desired speed from the current speed 
			//    to get the interval to change the speed
			if ((present_speed - requested_speed) < modified_speed) 
			{
				modified_speed = present_speed - requested_speed;
				new_motor_speed = present_speed - modified_speed;
			}
			else
			{
				new_motor_speed = present_speed - modified_speed;
			}
		}
	
		else if (requested_speed > present_speed)
		{
			// if the requested speed is greater then the current speed 
			//    it will subtract the current speed from the desired speed 
			//    to get the interval to change the speed                   
			if ((requested_speed - present_speed) < modified_speed) 
			{
				modified_speed = requested_speed - present_speed;
				new_motor_speed = present_speed + modified_speed;
			}
			else 
			{
				new_motor_speed = present_speed + modified_speed;
			}
		}
	}
 	return (new_motor_speed);
}
This goes in a .h file:

Code:
//example to call function

//	current_speed = pwm
//	// change the motor speed by the change_speed value
//  pwm = ramp_motor_speed(desired_speed, current_speed, drive_interval)
//	 

//variables for above function
#define DRIVE_INTERVAL 6 		//limits drive motors to changing 6 pwm values per loop

unsigned char ramp_motor_speed(unsigned char requested_speed, unsigned char present_speed, unsigned char modified_speed);
On a side note, if you're using the drive setup 612 is, their code looks easier to setup and use than ours. Ours is designed open ended since we use it for both arm motors and drive motors.
__________________
FRC Team 498 (Peoria, AZ), Student: 2004 - 2007
FRC Team 498 (Peoria, AZ), Mentor: 2008 - 2011
FRC Team 167 (Iowa City, IA), Mentor: 2012 - 2014
FRC Team 2662 (Tolleson, AZ), Mentor: 2014 - Present
  #9   Spotlight this post!  
Unread 05-02-2007, 13:16
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Save the Gearbox, Save the Game

Very nice, you might also want to look in to using PID to attain certain speeds, with low P gains it would ramp up and adjust to speeds gently.

Also, you can use [code] tags to neaten up your posting and make it easier to read.

Also, do you like Heroes?
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #10   Spotlight this post!  
Unread 05-02-2007, 18:30
MARS-CJ's Avatar
MARS-CJ MARS-CJ is offline
Registered User
AKA: Carl Jalm
FRC #1523 (M.A.R.S.)
Team Role: Scout
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Jupiter, FL
Posts: 32
MARS-CJ is on a distinguished road
Send a message via AIM to MARS-CJ
Re: Save the Gearbox, Save the Game

We at MARS have our own acceleration code, written by your's truly. It's very simple, and it didn't take too long to type up. We use different acceleration rates for autonomous mode and human control. Here it is:

Code:
//these two variables are declared at the top of user_routines_fast.c

int AUTON_RATE_LIMIT = 1;//wheels accelerate at about 40 per sec (3 secs to max)
int RATE_LIMIT = 5; //faster accel. during manual control

//The function was added in at the bottom of the file.
//Make sure to make a prototype for this in user_routines.h!!

/*******************************************************************************
* FUNCTION NAME: Motor_Accel
* PURPOSE:       Motors accelerate at certain rate (prevents wearing of transmission)
* CALLED FROM:   user_routines_fast.c
* ARGUMENTS:     
*     Argument             Type    IO   Description
*     --------             ----    --   -----------
*     pwm_out              int     O    Value being sent to pwm
*     pwm_in               int     I    Pwm that value is being sent to
* RETURNS:       int
*******************************************************************************/
int Motor_Accel(int pwm_out, int pwm_in)
{
	if (autonomous_mode) //while autonomous is running...
	{
		printf("Motor_Accel running...\r\n");
		
		if (pwm_out > (pwm_in + AUTON_RATE_LIMIT)) //If the input is more than your pwm, + 1...
			return (pwm_in + AUTON_RATE_LIMIT); //Make it your pwm, + 1
		
		else if (pwm_out < (pwm_in - AUTON_RATE_LIMIT)) //If it is less than your pwm, - 1...
			return (pwm_in - AUTON_RATE_LIMIT); //Make it your pwm, - 1
		
		else //And if it is within 1 either way (or the same)...
			return pwm_out; //Send it as is
	} //end autonomous acceleration code

	else //While under human control
	{
		if (pwm_out > (pwm_in + RATE_LIMIT)) //If the input is more than your pwm, + 5...
			return (pwm_in + RATE_LIMIT); //Make it your pwm, + 5
		
		else if (pwm_out < (pwm_in - RATE_LIMIT)) //If it is less than your pwm, - 5...
			return (pwm_in - RATE_LIMIT); //Make it your pwm, - 5
		
		else //If it is within 5 either way...
			return pwm_out; //Send it as is
	} //end human control acceleration code
} //end Motor_Accel
And there it is! As I said, very simple. The only complication is having to put the pwm name in twice...

Code:
pwm03 = Motor_Accel(p1_y, pwm03);
EDIT: I forgot to mention, this isn't final. We're still taking a look at exactly how it will work. We know it works, but we don't know how well it works...

EDIT (#2): Turning seems to be a problem, since the acceleration rates make it hard to shift from one side of 127 to the other...

Last edited by MARS-CJ : 05-02-2007 at 18:52.
  #11   Spotlight this post!  
Unread 05-02-2007, 18:36
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,363
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Save the Gearbox, Save the Game

2 robots collide head on with each going 6 FPS. The shock and stress to the drive train will happen and software will not protect against this. Too many shocks and some thing fails. The baines bot carrier plate is 1 point of failure. The gears are a concern of mine. Yes, they are hard, but can they endure the stress that some teams inflict on their drive trains. Planetary gear boxes have some pluses. They also need higher strength and precision than the plate and gear sandwich gear boxes like the Andy Mark's. Our team is playing it safe with the AM solution and will watch the BB story unfold. Good luck to the teams that are going with the BB's. Train your drivers not to smash into objects at full speed. As a side note, The power tools and equipment that I have at work and has survived my constant abuse for years and years do not have planetary transmissions.
  #12   Spotlight this post!  
Unread 05-02-2007, 18:43
Lil' Lavery Lil' Lavery is offline
TSIMFD
AKA: Sean Lavery
FRC #1712 (DAWGMA)
Team Role: Mentor
 
Join Date: Nov 2003
Rookie Year: 2003
Location: Philadelphia, PA
Posts: 6,608
Lil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond reputeLil' Lavery has a reputation beyond repute
Send a message via AIM to Lil' Lavery
Re: Save the Gearbox, Save the Game

First off, great work 612. Our neighbors down the street keep continuously trying to make life easier for other teams, and helping out FIRST.
This is a great way to try and prevent your own robot from damaging your Banebots transmissions, but, as mentioned, it does not protect from outside forces, so be wary. It may or may not impede impulses enough to prevent damage when using 2 CIMs, but it will certainly mitigate the damage. Basically, a word of caution, this is a great start on saving your transmissions, but it isn't perfect (no solution will be), and there will still be certain risks imposed upon your transmissions.
__________________
Being correct doesn't mean you don't have to explain yourself.
  #13   Spotlight this post!  
Unread 05-02-2007, 20:07
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Save the Gearbox, Save the Game

We put a low-pass filter on the motor speed command almost every year. A more compact way to accomplish this follows. Note that you can (and I always do) use integers for the fractional part, but it's quicker to show you what's going on with floats:

Code:
// Put this at the top of "user_routines.c"
#define K_LP .2

// Put these at the top of Default_Routine()
static unsigned char pwm01_old = 127;

// Put these in your drive code
pwm01 = (your drive code here)
pwm01 = (unsigned char)(K_LP*pwm01) + (unsigned char)((1.0-K_LP)*pwm01_old);
pwm01_old = pwm01;
Adjust the "K_LP" parameter to change the response of the filter. Higher numbers make the system more responsive, but with more noise. Lower numbers make the system smoother, but with more lag.
  #14   Spotlight this post!  
Unread 06-02-2007, 00:14
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Save the Gearbox, Save the Game

Quote:
Originally Posted by Abwehr View Post
We put a low-pass filter on the motor speed command almost every year. A more compact way to accomplish this follows. Note that you can (and I always do) use integers for the fractional part, but it's quicker to show you what's going on with floats:

Code:
// Put this at the top of "user_routines.c"
#define K_LP .2

// Put these at the top of Default_Routine()
static unsigned char pwm01_old = 127;

// Put these in your drive code
pwm01 = (your drive code here)
pwm01 = (unsigned char)(K_LP*pwm01) + (unsigned char)((1.0-K_LP)*pwm01_old);
pwm01_old = pwm01;
Adjust the "K_LP" parameter to change the response of the filter. Higher numbers make the system more responsive, but with more noise. Lower numbers make the system smoother, but with more lag.
Actually, that's going to make the motors go full reverse, since you're handling everything as an 8-bit integer value calculation, anything between 1 and 0 as a decimal defaults to zero, and you're multiplying both sides of the plus by 0, so you'd end with 0 + 0 = 0.

The concept is right but might I suggest a better execution?

Code:
// Put this at the top of "user_routines.c"
#define K_LP 2
unsigned int temp_pwm01;

// Put these in your drive code
pwm01 = (your drive code here)
temp_pwm01 = (unsigned int)((K_LP*pwm01)/10) + (unsigned int)(((10-K_LP)*pwm01_old)/10);
if(temp_pwm01 > 255)
{
   temp_pwm01 = 255;
}
pwm01_old = pwm01 = (unsigned char)temp_pwm01;
This scales everything up for the calculations to avoid floating point (MUCH FASTER, and the extra int we used is still less memory than a float), then divides it back down to minimize rounding errors, then checks to make sure its not too large for a char and sets pwm01 to it.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #15   Spotlight this post!  
Unread 14-02-2007, 18:20
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: Save the Gearbox, Save the Game

Quote:
Originally Posted by Abwehr View Post
We put a low-pass filter on the motor speed command almost every year. A more compact way to accomplish this follows.
This is almost exactly the code our team has used as well. We try to err on the side of responsiveness, however, so after two competitions all the mechanisms have definitely picked up some slop.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[wiki]: how to save more than one prog. in the RC Edourdo FIRSTwiki 1 04-02-2007 17:29
Save a variable dawonn Programming 7 23-04-2005 08:30
SCRRF Save the Regional Redhead Jokes Southern California Regional Robotics Forum 0 03-05-2003 14:54
Duel on the Delaware - Save $$$ Now MOEWidow Off-Season Events 11 30-04-2003 21:28
Save the rookies!!! Please help us to design a crate... Eugene Technical Discussion 7 05-02-2002 20:22


All times are GMT -5. The time now is 05:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi