View Single Post
  #1   Spotlight this post!  
Unread 13-02-2003, 18:45
EvilDeathCrab EvilDeathCrab is offline
Registered User
#0620
 
Join Date: Feb 2003
Location: Virginia
Posts: 1
EvilDeathCrab is an unknown quantity at this point
Send a message via ICQ to EvilDeathCrab Send a message via AIM to EvilDeathCrab
Drive Programming

We're trying to implement three things. I think I've got a handle on one of them, and the two others I'm going to ask for input on.
All of this code is considering tank drive on one joystick, with PBASIC 2.5.

1) We have the wheel controlling a speed multiplier that gets added in to the calculation for the motor outputs.

2) We want to implement a "Regular drive" mode where the robot does not turn on a dime. This would involve one of the motors moving more slowly than the other.

3) We want to implement a gradual slowdown in the motor so that the robot does not come to a dead halt whenever the joystick is moved to the neutral position.

This is our current code, with #1 above enabled.

leftdrive=((p1_wheel/255)*(2000 + p1_y - p1_x + 127) Min 2000 Max 2254)-2000
rightdrive=((p1_wheel)/255)*(2000 + p1_y + p1_x - 127) Min 2000 Max 2254)-2000

For #2 I'm thinking something like this:
Wait a minute. I just had a stroke of genius... I think. Wouldn't it just be
if p1_x < 127 then
leftdrive = p1_x
rightdrive = p1_y
else
leftdrive = p1_y
rightdrive = p1_x
endif

as for #3, I'm drawing a blank. I cannot think of an easy way to code this. It would involve getting the difference between the drive (left? right? both?) and the joystick position. Maybe just a lot of IF statements.


Any input on any of the above three would be much appreciated. Thanks again!
__________________
This code works... in theory.