Go to Post Nah, I never crash or break anything... - Elgin Clock [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-01-2004, 16:59
Stormhammer's Avatar
Stormhammer Stormhammer is offline
Team 1183
AKA: Justin
#1183 (Eagle Executioner's)
Team Role: Driver
 
Join Date: Jan 2004
Location: Lawrenceville, GA
Posts: 52
Stormhammer can only hope to improve
Send a message via AIM to Stormhammer Send a message via Yahoo to Stormhammer
Question tank drive

just wondering if anyone has or knows of a site that has the programming code for a single joystick tank drive... if not, can someone give us an example one ( preferably one that worked )
__________________
1-2-3 EXE... prepare to be executed - Eagle Executioners ( no more Eagle Engineers ) #1183

Its either a Mopar or no car

Dude, WHY ARE YOU SO SLOW?!?!
  #2   Spotlight this post!  
Unread 28-01-2004, 17:03
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,571
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: tank drive

see line 224 of the user_routines.c in the default code

Last edited by Joe Ross : 28-01-2004 at 17:09.
  #3   Spotlight this post!  
Unread 28-01-2004, 21:12
Stormhammer's Avatar
Stormhammer Stormhammer is offline
Team 1183
AKA: Justin
#1183 (Eagle Executioner's)
Team Role: Driver
 
Join Date: Jan 2004
Location: Lawrenceville, GA
Posts: 52
Stormhammer can only hope to improve
Send a message via AIM to Stormhammer Send a message via Yahoo to Stormhammer
Re: tank drive

Quote:
Originally Posted by Joe Ross
see line 224 of the user_routines.c in the default code
your gonna have to explain that. The guy thats programming is a new guy on the team, he knows C and that, but yeah, just want to make sure there aren't any confusions anywhere. Thanks
__________________
1-2-3 EXE... prepare to be executed - Eagle Executioners ( no more Eagle Engineers ) #1183

Its either a Mopar or no car

Dude, WHY ARE YOU SO SLOW?!?!
  #4   Spotlight this post!  
Unread 28-01-2004, 21:31
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: tank drive

Quote:
Originally Posted by Stormhammer
your gonna have to explain that. The guy thats programming is a new guy on the team, he knows C and that, but yeah, just want to make sure there aren't any confusions anywhere. Thanks
void Default_Routine(void)
Code:
void Default_Routine(void)
{
//...
 /*---------- 1 Joystick Drive --------------------------
  *----------------------------------------------------
  *  This code mixes the Y and X axis on Port 1 to allow one joystick drive. 
  *  Joystick forward  = Robot forward
  *  Joystick backward = Robot backward
  *  Joystick right    = Robot rotates right
  *  Joystick left     = Robot rotates left
  *  Connect the right drive motors to PWM13 and/or PWM14 on the RC.
  *  Connect the left  drive motors to PWM15 and/or PWM16 on the RC.
  */  
  pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
  pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
//...
}
Of course, my thought is to use X for left and Y for right. But that's counter-intuitve. Really counter-intuitive
  #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.
}
  #6   Spotlight this post!  
Unread 29-01-2004, 13:41
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: tank drive

Speaking of each, what is the difference in storage between signed and unsigned? is it if bit1=true then # is negetive, or is it an offset, like (Signed) 0=(unsigned) 127, as an example.
  #7   Spotlight this post!  
Unread 29-01-2004, 14:38
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

Signed math just tells the compiler to interpret the bits differently. Internally the CPU uses something called 2-complement to represent the negative numbers. A number in 2-complement form can be added to another number and you will get the right results without any special hardware. However, you can't generate a 2-complement number by simply flipping the sign bit (bit 8). For example: 0x01 2-complement is 0xFF. 0xFF is 255 in unsigned math.

So, to represent a negative 5 in binary, you would complement 00000101 to get 11111010 then add one to get 11111011

So, add -5 and, say, 7 (in binary):

11111011
00000111
---------
100000010

The 9th bit falls off the end of the earth (or into the "carry" bit) and the resulting number is just 2. When adding larger numbers (int, short long and long) the bytes are added sequentially and the carry from the previous add is added into the first bit of the next.

When converting shorter to longer (e.g. a byte to an int) you simply copy the 8th bit into all bits of the next higher byte and the value is preserved. This is all done for you by the compiler.
  #8   Spotlight this post!  
Unread 29-01-2004, 16:08
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: tank drive

so 5 = 00000101 and -5 = !5 + 1 = 11111011
Or did I mis-read that?

I'm just curious, so one has a vague idea what happens if you pass a signed to a unsigned.
  #9   Spotlight this post!  
Unread 29-01-2004, 22:19
Random Dude Random Dude is offline
Oregon State Head FTA
AKA: Chris
no team (Oregon Robotics Tournament & Outreach Program)
 
Join Date: Aug 2002
Rookie Year: 1998
Location: Oregon
Posts: 142
Random Dude will become famous soon enoughRandom Dude will become famous soon enough
Re: tank drive

Quote:
Originally Posted by Astronouth7303
so 5 = 00000101 and -5 = !5 + 1 = 11111011
Or did I mis-read that?

I'm just curious, so one has a vague idea what happens if you pass a signed to a unsigned.
Well, if you do something like this


unsigned char u_char;
signed char s_char;

.....

u_char = s_char;



The maping will be as follows:

s_char >= 0 : u_char = s_char
s_char <0 : u_char = 256 - s_char


Hope that answers your question... (Note I'm speaking in terms of this micro and this compiler, YMMV on other systems...)
  #10   Spotlight this post!  
Unread 29-01-2004, 22:53
JoshJ JoshJ is offline
Registered User
#0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Salem County
Posts: 44
JoshJ is on a distinguished road
Send a message via AIM to JoshJ
Re: tank drive

Speaking of programming tank drives, ours threw me for a loop tonight. We had run last saturday w/o problems, and then tonight, our x and y values got switched. basically, to drive straight, we had to move the stick left or right, and to turn move it up or down. To fix it, i just changed the order in the default program for one stick mixing. Does anyone know what caused this/ how to fix it? Im lost, thanks.
-Josh
  #11   Spotlight this post!  
Unread 29-01-2004, 23:02
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: tank drive

did one of your motors have its polarity reversed? that would cause the exact problem you are experiencing. (it happened the first time we tested the bot, we switched the polarity of one motor, which fixed it)
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #12   Spotlight this post!  
Unread 29-01-2004, 23:08
JoshJ JoshJ is offline
Registered User
#0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Salem County
Posts: 44
JoshJ is on a distinguished road
Send a message via AIM to JoshJ
Re: tank drive

Quote:
Originally Posted by deltacoder1020
did one of your motors have its polarity reversed? that would cause the exact problem you are experiencing. (it happened the first time we tested the bot, we switched the polarity of one motor, which fixed it)
Thanks for the quick response. Actually that also happened the first time we ran, but we changed polarity, not code. Ill check and see if someone switched it again.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
1 stick drive to 2 stick drive wayne 05 Programming 18 01-04-2004 16:41
Rookie team drive tream idea Max Lobovsky Technical Discussion 18 21-01-2004 03:36
2-wheel versus 4-wheel drive Ben Mitchell Technical Discussion 23 07-11-2003 00:50
Direct drive or Chain? Suneet Technical Discussion 32 27-03-2003 23:00
Quad- 1/2 track drive system Ben Mitchell Technical Discussion 24 30-01-2002 11:55


All times are GMT -5. The time now is 10:40.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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