View Single Post
  #2   Spotlight this post!  
Unread 18-02-2002, 14:03
Jnadke Jnadke is offline
Go Badgers!
#0093
Team Role: Alumni
 
Join Date: Jan 2002
Location: Appleton, WI
Posts: 775
Jnadke is on a distinguished road
Send a message via ICQ to Jnadke Send a message via AIM to Jnadke Send a message via Yahoo to Jnadke
Here's the acceleration code we use to make sure the drivers aren't crunching gears... Use it ONLY if you learn something from it. Take a look and figure out how it works...

Code:
SAFE_ZONE		CON	1000
MAX_ACC		CON	10
MAX_ACC_VAL 	CON	SAFE_ZONE + MAX_ACC
MIN_ACC_VAL 	CON	SAFE_ZONE - MAX_ACC


left_motor:
	if (abs(left_control - 127) > DEAD_ZONE) then left_calc
	left_control = MOTOR_OFF

left_calc:
	speed_l = speed_l + (((left_control - speed_l + SAFE_ZONE) min MIN_ACC_VAL max MAX_ACC_VAL) - SAFE_ZONE)

right_motor:
	if (abs(right_control - 127) > DEAD_ZONE) then right_calc
	right_control = MOTOR_OFF

right_calc:
	speed_r = speed_r + (((right_control - speed_r + SAFE_ZONE) min MIN_ACC_VAL max MAX_ACC_VAL) - SAFE_ZONE)