Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Tank Drive (http://www.chiefdelphi.com/forums/showthread.php?t=34660)

Idaman323 14-02-2005 21:29

Tank Drive
 
We need help with using two joysticks with a tank drive system. I do believe the default code is only one joystick. If there is code somewhere, documentation, or even your help, it would help greatly, thank you!

AIBob 14-02-2005 21:46

Re: Tank Drive
 
Tank drive is very simple to program, and I believe that it is included in the default code, as an option. but here is what you would use as the code:
Code:

pwm01 = p1_y;  //change 01 and 1 to appropriate joystick and pwm output
pwm02 = p2_y;  //change 02 and 2 to appropriate joystick and pwm output

Thats basically it...
You put that in the function 'User_Driver' in place of whtever code you used, and its tank drive.

Goobergunch 14-02-2005 21:49

Re: Tank Drive
 
In the version of the default code that we use (not sure which one it is), the above code is included under Default PWM Mappings.

Idaman323 14-02-2005 22:04

Re: Tank Drive
 
I got the default code off of innovation first's documentation part on their website.


Where is the User_Driver function within the code?

AIBob 14-02-2005 22:30

Re: Tank Drive
 
Quote:

Originally Posted by Idaman323
Where is the User_Driver function within the code?

It is located within "user_routines.c".

Idaman323 14-02-2005 22:41

Re: Tank Drive
 
AHHH I cant find it anywhere in the thing

there isnt any function it...

Orborde 14-02-2005 22:46

Re: Tank Drive
 
Er...it's in Default_Routine, not User_Driver

AIBob 14-02-2005 22:48

Re: Tank Drive
 
OK... my team renamed that too, I just do not remember what we changed from the default code from last year, sorry.
It should be 'Default_Routine()'

russell 14-02-2005 22:55

Re: Tank Drive
 
It is part of a long list which maps the joystick inputs to pwm outputs. Its about ten lines long, they all look about the same (number=number;), and its about half or 3/4 the way down user_routines.c

Idaman323 14-02-2005 23:05

Re: Tank Drive
 
So as long as I hav ethat included it should work?

probizzle 14-02-2005 23:14

Re: Tank Drive
 
Quote:

Originally Posted by Idaman323
So as long as I hav ethat included it should work?

Depends.

On our bot last year, the motors were placed such that we had to reverse motor output to one side.

So,
Code:

pwm01 = p1_y; //put the joystick input to motor output directly
pwm02 = 255-p2_y; //reverse this motor

worked. You might need this depending on how your gearboxes/motors are put in. I'm guessing you'll have to reverse one (try which one) of the motors.

And this is, of course, assuming you are using one motor for left drive and one motor for right drive (no more no less).

Goobergunch 14-02-2005 23:17

Re: Tank Drive
 
Quote:

Originally Posted by probizzle
And this is, of course, assuming you are using one motor for left drive and one motor for right drive (no more no less).

Or if you have two motors for each drive (four total) and the two motors on each side are connected via the yellow-red-black PWM cables to one PWM Output on the RC, like we did this year.

Idaman323 15-02-2005 06:20

Re: Tank Drive
 
Should I comment/delete (not sure what would be better) out the stuff i don't need, like p1_x and p2_x, or does that need to be there for the bot to run?


And Ive only had a little of coding experience but wouldn't making the one motor go backwards be pwm02 = p2_y-255; not pwm02 = 255-p2_y; or did he have it right before?

And one more thing, in Deafault_Routine, there is a section titled, 1 Joystick Drive, and it combines the x, y on one joystick port.. Should i take this out?

AIBob 15-02-2005 07:27

Re: Tank Drive
 
Quote:

Originally Posted by Idaman323

Should I comment/delete (not sure what would be better) out the stuff i don't need, like p1_x and p2_x, or does that need to be there for the bot to run?


And Ive only had a little of coding experience but wouldn't making the one motor go backwards be pwm02 = p2_y-255; not pwm02 = 255-p2_y; or did he have it right before?

And one more thing, in Deafault_Routine, there is a section titled, 1 Joystick Drive, and it combines the x, y on one joystick port.. Should i take this out?

No.... you should leave them, as long as you do not send them to the pwms
No.... if you put in 0, it would leave you with -255, which is not an unsigned char and will give you an error.
Maybe.... You should comment this section out for later use

Idaman323 15-02-2005 09:01

Re: Tank Drive
 
Okay I think I got it. Thanks for all of your help.


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

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