Go to Post "You have not lived until you have done something for someone who can never repay you." - unknown - rufu5 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Spotlight this post!  
Unread 10-05-2005, 11:07
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,808
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: One Joystick Drive

Quote:
Originally Posted by mattsavela
One of the students on the team were saying something about how our left motor seems to move faster than our right motor. What I think I need to know is how to make our motors adjust to this...
You can rescale the power output of the faster motor to more closely match the slower motor using something proportional like:
Code:
#define LEFT_MOTOR_CORRECTION 42; // example value at full pwm (254)
 
signed int LeftPwm;
...
//Proportional drop in power
 
LeftPwm = (int)pwm15; //assume pwm15 has already been set by the joystick mixing code
LeftPwm -= 127; //Just because math is clearer if we make 0 neutral (-127 reverse, 127 forward)
 
if (LeftPwm > 0)
{
	LeftPwm = LeftPwm - (LeftPwm / 127 * LEFT_MOTOR_CORRECTION);
}
else if (LeftPwm < 0)
{
	LeftPwm = LeftPwm + (LeftPwm / 127 * LEFT_MOTOR_CORRECTION);
}
 
pwm15 = (unsigned char)(LeftPwm + 127); // restore the normal 0-254 range
This reduces the Left Motor pwm by an amount proportional to the “speed” requested by the joystick.

You’ll have to discover through measurement or trial & error what pwm value (e.g., 220 instead of 254) for the left motor matches the max pwm value on the right motor at full speed.

Also, be aware that reverse on your machine might require a completely different offset value, i.e., the right motor might be faster than the left motor in reverse. So measure in both directions and correct for them separately.
If that’s the case then something like the following might help:
Code:
#define LEFT_MOTOR_CORRECTION 42; // Correction value at full forward pwm (254)
#define RIGHT_MOTOR_CORRECTION 22; // Correction value at full reverse pwm (254)
// Assumes pwm15 is the Left motor,  pwm13 is the Right motor
…
if (pwm15 > 127) // Forward, slow the Left motor
{
	pwm15 -= (pwm15-127) / 127 * LEFT_MOTOR_CORRECTION;
}
 
if (pwm13 < 127) // Reverse, slow the Right motor
{ 
	pwm13 += (127 - pwm13) / 127 * RIGHT_MOTOR_CORRECTION;
}
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 10-05-2005 at 12:40. Reason: editing
 


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
If you could change one thing.... Koko Ed General Forum 48 31-03-2005 19:23
1 Joystick Drive or yaniv Programming 3 19-01-2005 14:18
Changing 1 joystick code to 2 (rookie team) Brawler006 Programming 5 20-02-2004 17:00
question about one joystick drive programing james700 Programming 13 29-01-2003 14:49
1 joystick drive Rickertsen2 Robotics Education and Curriculum 9 20-12-2002 20:00


All times are GMT -5. The time now is 04:11.

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