![]() |
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!
|
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 outputYou put that in the function 'User_Driver' in place of whtever code you used, and its tank drive. |
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.
|
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? |
Re: Tank Drive
Quote:
|
Re: Tank Drive
AHHH I cant find it anywhere in the thing
there isnt any function it... |
Re: Tank Drive
Er...it's in Default_Routine, not User_Driver
|
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()' |
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
|
Re: Tank Drive
So as long as I hav ethat included it should work?
|
Re: Tank Drive
Quote:
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 directlyAnd this is, of course, assuming you are using one motor for left drive and one motor for right drive (no more no less). |
Re: Tank Drive
Quote:
|
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? |
Re: Tank Drive
Quote:
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 |
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