Limit_Mix() Function

I understand the Limit_Mix function combines the 2 joystick values (x,y) into a PWM value - one for each side of the drive. Can someone explain to me exactly how this function works. I see the code (obviously) and understand it, but how does the mathematical side work? Also, I remember we had some acceleration problems and a cubed value of the actual joystick input would work better (between a certain range). Any help would be greatly appreciated.

Thanks,
Eric

Not meaning to pick apart your understanding, but Limit_Mix quite literally only limits the values passed to it to so that the returned value, to the calling function, is between 0 and 254.
The actual calculation of PWM values is done by the line that calls the Limit_Mix function. The arguments that are sent to Limit_Mix are then limited to between 0 and 254, then returned.
So, “pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);” is used to calculate for the right side motor, and " pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);" if for the left. What each of these lines do is to take the p1_Y value and add or subtract from it the p1_x value and add or subtract 127 from that. (When you add p1_x you subtract 127 and vise verse.) These are the offset by 2000 for good measure then sent to Limit_Mix. Limit_Mix limits the values and then removes the 2000 offset and returns the limited value.

Now, if you are totally confused, get out a piece of paper and right down the values with the joystick in various positions, substituting in the values for p1_x and p1_y for the various positions. It will become clear very quickly what the functions do. :smiley:

Thank you very much. Yes, I did understand that the actual mixing was don in the calling line, I just worded it wrong. Basically you said what I already knew, but somehow I feel I understand it more now, so… Thanks.