Go to Post Good tooling doesn't cost money, it makes money (and prevents doctor visits). - travis [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

 
View Poll Results: How Do i Program The speed Of Each Wheel
you may post new threads 5 83.33%
you may post replies 5 83.33%
you may post attachments 4 66.67%
you may edit your posts 4 66.67%
Multiple Choice Poll. Voters: 6. You may not vote on this poll

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 12-01-2003, 13:45
Kai Zhao Kai Zhao is offline
Registered User
#0686 (Bovine Intervention)
 
Join Date: Nov 2001
Location: Frederick, MD
Posts: 28
Kai Zhao is on a distinguished road
Send a message via AIM to Kai Zhao
Kinda complex answer

This is a cut and paste job from our code last year. Thanks to Joe Johnson for giving us parts of the following code in New York two years ago when our drive system was horrible.

Just as a note, all of the numbers are in hexadecimal and shifting by X = dividing by 2^x. If you have no idea what I'm talking about, email me (or reply) and I'll explain. Sorry for the really obfuscated code, you'll probably want some free time to analyze it fully.

Alan's Highly Scalable/Complex Speed Balancer -- (MESSAGE FROM ALAN: I don't understand either ) If you are not him, here is my (Kai's) explanation.

First we must seperate the code into three easy to digest portions '"((abs(PWM1-$80)" gets us the distance we are trying to travel from neutral, the answer will be signed then we multiply that answer by "(13 + (3 * ((PWM1 - $80)) >> 15 )) >> 4 )". If we are going forward, we get a zero from "(3 * ((PWM1 - $80)) >> 15 )", if we are going reverse, we get a 3.

The number we get out of that (0 or 3) is added to 13 which is then multiplied to the desired speed (NOT velocity).

After multiplying by either 13 or 16, we shift by 4 which is effectively dividing by 16. Therefore, we lower (by 13/16) the speed is the motor is going forward and keep it the same if we are going in reverse.

The last step of "* (1 - ((PWM1 - $80) >> 15 << 1)) + $80) MIN $24 MAX $DE" allows us add direction into speed and make it work.

We are using this equation as the example: "PWM1 = ((abs (PWM1 - $80) * (13 + (3 * ((PWM1 - $80)) >> 15 )) >> 4 ) * (1 - ((PWM1 - $80) >> 15 << 1)) + $80) MIN $24 MAX $DE"

If we need to change the ratio, we need to find denominator which is a power of 2. Now we need the numerator and we need to find the difference between the numerator and denominator.

([numerator] + ([numerator - denominator] * ((PWM1 - $80)) >> 15 )) >> [denominator who is a integer power of 2 (ex. 2,4,8,16,32,64,etc)] )

Code:
PWM1 = (((abs (PWM1 - $80) * (13 + (3 * ((PWM1 - $80) >> 15)))) >> 4 ) * (1 - ((PWM1 - $80) >> 15 << 1)) + $80) MIN $24 MAX $DE
PWM2 = (((abs (PWM2 - $80) * (13 + (3 * ((PWM2 - $80) >> 15)))) >> 4 ) * (1 - ((PWM2 - $80) >> 15 << 1)) + $80) MIN $24 MAX $DE
-Kai Zhao

Last edited by Kai Zhao : 12-01-2003 at 19:19.
 


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
2-week FIRST summer program @ WPI ColleenShaver General Forum 20 31-05-2009 03:02
Fried program slots? Jeff Waegelin Programming 18 19-03-2003 18:08
Ahh! Program trick confusing! archiver 2001 9 24-06-2002 02:26
"Motors and Drive train edition" of Fresh From the Forum Ken Leung CD Forum Support 6 29-01-2002 12:32
about how Drive Train push the robot... shouldn't the force accelerate the robot? Ken Leung Technical Discussion 12 26-11-2001 09:39


All times are GMT -5. The time now is 14:36.

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