Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Thanks for all your help...and a question (http://www.chiefdelphi.com/forums/showthread.php?t=51341)

seanl 13-06-2007 15:47

Re: Thanks for all your help...and a question
 
Quote:

Originally Posted by fimmel (Post 631652)
that would work for "tank style" drive, i think he meant using a single stick drive.

oh.. i dont really have experience with single. personally i prefer tank.
although reducing speed with a button is a nice idea. i might try that out.

fimmel 13-06-2007 18:01

Re: Thanks for all your help...and a question
 
just make sure to test the code with the robot up on blocks or something. just to make sure it wont do any damage
...forest

Quzarx 13-06-2007 20:39

Re: Thanks for all your help...and a question
 
Another way to do it would be to make a few lookup tables. We set up custom curves, so we had a large area that was slow for fine adjustments, and an area of full speed. This also makes so no calculations are needed on the fly, you just load them into the ram.

You would toss something like this (what we used) under the #include's in user_routines.c
Code:

rom unsigned short int Joystick_Array[] = {0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,61,62,63,63,64,65,66,67,68,69,69,70,71,72,73,74,75,75,
76,77,78,79,80,81,81,82,83,84,85,86,87,87,88,89,90,90,91,91,92,92,93,93,94,94,94,95,95,96,96,97,97,98,98,99,99,99,100,100,101,101,102,102,103,
103,103,104,104,105,105,106,106,107,107,107,108,108,109,109,110,110,111,111,111,112,112,113,113,114,114,115,115,116,116,116,117,117,118,
118,119,119,120,120,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,135,135,136,136,136,136,137,137,137,138,
138,138,139,139,139,139,140,140,140,141,141,141,141,142,142,142,143,143,143,144,144,144,144,145,145,145,146,146,146,146,147,147,147,148,
148,148,149,149,149,149,150,150,150,151,151,151,151,152,152,152,153,153,153,154,154,154,154,155,155,156,157,158,158,159,160,161,162,163,
164,164,165,166,167,168,169,170,170,171,172,173,174,175,176,176,177,178,179,180,181,182,182,183,184,185,190,194,199,204,208,213,218,222,
227,232,236,241,246,250,255,};

Then to call it:
Code:

Left_Drive = Joystick_Array[p1_y];
Right_Drive = Joystick_Array[p3_y];

(Again, here we use tank style, and used p1 and p3 due to custom control systems (p2 and p4 have all of the button outputs)

That makes so the variable "Left_Drive" and "Right_Drive" are modified pwm values, but not assigned to the pwm yet.

To go with one joystick:
Code:

if (p1_sw_trig == 0)
{
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
}
else
{
pwm13 = pwm14 = Limit_Mix(2000 + Joystick_Array[p1_y] + Joystick_Array[p1_x] - 127);
pwm15 = pwm16 = Limit_Mix(2000 + Joystick_Array[p1_y] - Joystick_Array[p1_x + 127);
}

In this case, you would make an array with new values (halves if you want). the joystick gives a value of 0 to 255, so it looks in spot 0, if full reverse in the array, and in this example, would grab a value of 0. 127 points to the 127th. Remember, the first one is spot 0, not 1 in the array. Doing it this way allows you to have multiple curves for drivers, or just change the values completely so you have a larger slow area so you do not need to cut it in half at all.

lukevanoort 13-06-2007 21:31

Re: Thanks for all your help...and a question
 
(This is in regard to the post above mine, which I will not quote, for space considerations)

We do essentially the same thing, the only differences are, we use a slightly different equation, and our lookup table uses unsigned chars instead of short ints (although, in theory both should work, unsigned chars just take up less space). However, instead of just using ours for only our drive system, ours is used for every single joystick controlled movement on our robot. We have found that this greatly increases usability and driveability of our robot and its mechaisms by allowing fine control when necessary (like positioning the wrist for a ringer) and fast control when you need the speed (like driving across the field to a ringer). I would highly recommend at least trying exponential lookup tables, you may be amazed by the improvement such a small change can make.


All times are GMT -5. The time now is 23:34.

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