Thread: tank drive
View Single Post
  #5   Spotlight this post!  
Unread 28-01-2004, 23:06
Larry Barello Larry Barello is offline
http://www.barello.net
#0492 (Titan Robotics Club)
Team Role: Mentor
 
Join Date: Jan 2002
Location: Bellevue, WA
Posts: 85
Larry Barello has a spectacular aura aboutLarry Barello has a spectacular aura about
Re: tank drive

Another way to think of this is to convert the IFI joystick values into signed values (e.g. -127 to 127) then simple math to mix, then simple math to limit and finally simple math to convert back to 0-255 for the Victor. The IFI example code was lifted right out of the Pbasic code from last year. Pbasic didn't understand negative numbers (it was truely wretched...) hence the bizzare mixing code.
-------

char limit(int val)
{
if (val > 127) return 127;
if (val < -127) return -127;
return val;
}

void user_routine(void)
{
int Left = p1_y - 127; // Convert to signed #
int Right = p1_x - 127;

pwm01 = limit (Left + Right) + 127;
pwm02 = limit(Left - Right) + 127;

etc.
}