![]() |
Help with limit mix
what's the point off adding 2000 to the following functions:
pwm01 = pwm03 = Limit_Mix(2000 + PWM_in1 + PWM_in2 - 127); /* LEFT WHEELS */ pwm02 = pwm04 = Limit_Mix(2000 + PWM_in2 - PWM_in1 + 127); /* RIGHT WHEELS */ the coding seems all fuzzy to me, i dont' get it |
Re: Help with limit mix
I'm n00b myself so maybe I'm wrong.
I had problems with this myself when I came across it. I think it has something to do with the hardware it is slower to run the program if it starts getting decimals (floating point #'s) I think later in the program it negates the 2000 correct me if I'm wrong :] |
Re: Help with limit mix
You're right, noob. (;)) It does that just so that it can get decent precision without decimals or negatives. :)
I think... ;) |
Re: Help with limit mix
Quote:
The Limit_Mix() function subtracts 2000 from its result, neatly compensating for the extra 2000 in its input. |
Re: Help with limit mix
The Limit_Mix function assumes that its input value has had 2000 added in, and thus subtracts it back out before returning.
Back in the Basic Stamp days, there were certain circumstances where it was necessary to avoid negative numbers. This Limit_Mix function is a legacy of those days. By rights, the function should now be: Code:
unsigned char Limit_Mix (int intermediate_value)Code:
pwm01 = pwm03 = Limit_Mix(PWM_in1 + PWM_in2 - 127); /* LEFT WHEELS */ |
Re: Help with limit mix
Quote:
Code:
pwm01 = pwm03 = Limit_Mix((int)PWM_in1 + PWM_in2 - 127); /* LEFT WHEELS */ |
Re: Help with limit mix
Quote:
does it make the PIC treat all variables (PWM_in2 & PWM_in1) in the Parenthesis like an int instead of a char ? |
Re: Help with limit mix
Quote:
|
Re: Help with limit mix
Quote:
This "Limit Mix / why add 2000?" question is one that gets asked A LOT by teams up in Canada. I usually refer people to a post on the FIRST Greater Toronto Regional forums: http://www.firstcanadianregional.org...opic.php?t=500 Hope that sheds some light into the situation! -SlimBoJones... |
| All times are GMT -5. The time now is 04:38. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi