Go to Post I guess we're going amish this year. - Jon Anderson [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

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average. Display Modes
Prev Previous Post   Next Post Next
  #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.
 


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 18:06.

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