View Single Post
  #2   Spotlight this post!  
Unread 10-02-2003, 13:05
Skabana159's Avatar
Skabana159 Skabana159 is offline
Robotics and Field Hockey
AKA: Jesse C. Owens
#0159 (Alpine Robotics)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2000
Location: Ft. Collins, CO
Posts: 92
Skabana159 is on a distinguished road
Send a message via AIM to Skabana159
Well, if you wanted your first wheel to go directly with the joystick, and you wanted your second wheel to go at about half that speed, you could do this:

pwm1 = p1_y
if p1_y > 127 then pwm2 = (127 + (abs(127 - p1_y)/2))
if p1_y < 127 then pwm2 = (127 - (abs(127 - p1_y)/2))

That was just off the top of my head, but I think it will work. You can use any scaling factor, but if you want it to be faster than half speed, you will have to multiply by a fraction, rather than divide. Let's say you wanted it to be 3/4 speed. You would have to multiply by (3/4) instead of dividing by .75, because PBasic cannot do numbers less than 1. I suggest using constants if you're not sure what ratio you want it to be.
__________________
"What most people do not understand is that the Buddha, the Godhead, resides just as comfortably in gears and circuits as in hills and trees. To believe otherwise is to dilute the Godhead."
-Robert Pirsig, Zen and the Art of Motorcycle Maintenance

Last edited by Skabana159 : 10-02-2003 at 13:20.