Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Where is tank drive in 2005 code? (http://www.chiefdelphi.com/forums/showthread.php?t=43529)

scottmso 08-02-2006 09:31

Where is tank drive in 2005 code?
 
I am still trying to understand the 2005 default code (my programming team is currently using the 2005 robot because they are currently working on the new one.) What I want to do right now is try to modify the tank drive so it is less sensitive. I can find where the 1-joystick drive is but I cannot find where the 2-joystick (tank drive) is. Is there a particular place that it is in in the code? thanks

ForgottenSalad 08-02-2006 09:38

Re: Where is tank drive in 2005 code?
 
EDIT: Just noticed your edit - They're located in user_routines.c in the default routine.

They should look something like this.

pwm01 = p1_y;
pwm02 = p2_y;
pwm03 = p3_y;
pwm04 = p4_y;
etc....

scottmso 08-02-2006 09:51

Re: Where is tank drive in 2005 code?
 
Quote:

Originally Posted by ForgottenSalad
EDIT: Just noticed your edit - They're located in user_routines.c in the default routine.

They should look something like this.

pwm01 = p1_y;
pwm02 = p2_y;
pwm03 = p3_y;
pwm04 = p4_y;
etc....

Now I understand, thanks.

Unholy 08-02-2006 10:09

Re: Where is tank drive in 2005 code?
 
also, if you want to limit response to the joystick, you can multiply the joystick value by a decimal value less than 1. For example, one of the robot components in our robot requires small movements, but we found it complicated to just move it slightly, so we multiplied the joystick input by .20, so even when the joystick is fully deflected it will move slowly.
-Unholy

Matt Krass 08-02-2006 14:16

Re: Where is tank drive in 2005 code?
 
Be careful, it's very easy to accidentally make it multiply by 0, the PIC has no dedicated floating point processor and does weird things to decimals. It would make your motors constantly run full reverse. Which is also bad :)

I recommend multiplying up then dividing down. For example instead of

Code:

pwm01 = p1_y * 0.2; //Error Prone! BAD!
Use this

Code:

pwm01 = (unsigned int)(p1_y * 2) / 10;
Try them both on your calculator, you'll get the same result, but the PIC is more likely to work with the second method...practically guaranteed to work better than the first.

Good luck!

ForgottenSalad 08-02-2006 20:56

Re: Where is tank drive in 2005 code?
 
Quote:

Originally Posted by Matt Krass
Be careful, it's very easy to accidentally make it multiply by 0, the PIC has no dedicated floating point processor and does weird things to decimals.

We found that out yesterday. If we went forward on the joystick, no matter how little, it'd run full forward... If we went backwards, we'd get gradually faster as you pulled back, but then at 3/4ths of the way it'd reverse and go full forward...

Stephen Kowski 08-02-2006 21:16

Re: Where is tank drive in 2005 code?
 
Quote:

Originally Posted by ForgottenSalad
We found that out yesterday. If we went forward on the joystick, no matter how little, it'd run full forward... If we went backwards, we'd get gradually faster as you pulled back, but then at 3/4ths of the way it'd reverse and go full forward...

never heard of 3/4 of the way there, but when you max out the speed controllers sometimes it goes to 255 there is a problem with, i think, the speed controller that it can differentiate well between 255 and 0 so it goes forward or doesn't act properly....wierd thing, but that is the first place id look and just set the max PWM value possible to 254.

DanDon 08-02-2006 22:03

Re: Where is tank drive in 2005 code?
 
Quote:

Originally Posted by ForgottenSalad
We found that out yesterday. If we went forward on the joystick, no matter how little, it'd run full forward... If we went backwards, we'd get gradually faster as you pulled back, but then at 3/4ths of the way it'd reverse and go full forward...

In order to stop the full forward when moving the joystick forward just a bit, you can try putting a deadband into the drive code.

You can try something like this:

Code:

if(p1_y>117 && p1_y<137) //+-10 unit deadband around 127 neutral
          pwm01=127;
else
          pwm01=p1_y;

then just experiment with the deadband size to see which range feels best for you driver(s).

Hope this helps,


All times are GMT -5. The time now is 01:36.

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