Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   A Simple Improvement to Driving (http://www.chiefdelphi.com/forums/showthread.php?t=30032)

Astronouth7303 31-12-2004 11:50

Re: A Simple Improvement to Driving
 
I just went through the thread and spotted a minor error. Sorry to bring it up.

Quote:

Originally Posted by generalbrando
Well if you work through the math, it should be 0 and 256 averaged=128. Then average between that and the originals...64 and 194. Technically 127 is center (right?) so that's a tiny bit off, but the results is a slower spin. I thought there might be a quirk where I would need to handle an exception for such a thing like this, but in testing, I found it works fine all around.

Not quite. The maximum you should ever set the PWMs (motors) to is 254. 0 and 254 averaged is 127 (which is center).

Now here's an interesting tidbit: If you were to assign (for testing purposes) 256 to p1_y and 0 to p2_y, and proceeded to try it, the robot would go straight back. Why? Because 256 (Hex 100) is too big for a byte! It wraps to zero! So you end up averaging zero and zero, taking half the difference, etc., etc.

generalbrando 01-01-2005 15:32

Re: A Simple Improvement to Driving
 
Quote:

Originally Posted by Astronouth7303
I just went through the thread and spotted a minor error. Sorry to bring it up.



Not quite. The maximum you should ever set the PWMs (motors) to is 254. 0 and 254 averaged is 127 (which is center).

Now here's an interesting tidbit: If you were to assign (for testing purposes) 256 to p1_y and 0 to p2_y, and proceeded to try it, the robot would go straight back. Why? Because 256 (Hex 100) is too big for a byte! It wraps to zero! So you end up averaging zero and zero, taking half the difference, etc., etc.

YES! Honestly, as I mentioned, I'm not knowledgable about the programming for the robot (yet). But I could never get an explanation for that odd quirk of 127 being the middle. Thanks and thanks again to everyone for taking a look and giving more advice and input.


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

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi