Go to Post While money can create fancy-looking robots, it does not always create game-winning ideas. - Karibou [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 17-02-2008, 07:43
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
reducing sensativity of joystick for precision?

Hi, we are using a joystick to act as a throttle. We realize that we don't need to move the joystick far to get the bot moving fast. I'm trying to reduce the sensativty of the joystick near the beginning of the swing for precise control. We could just scale the output down, but I would like to limit the max speed at the top of the swing. Does anyone have any suggestions? I heard of using a cubic equation, but I'm not sure how to impiment this in code. I was also think about using a sine or cos function to multiply to the throttle raw output, but then that would start getting floating point math involved in which i want to try to stay away from.

Thanks,
windell
  #2   Spotlight this post!  
Unread 17-02-2008, 08:25
BigJ BigJ is offline
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 947
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Re: reducing sensativity of joystick for precision?

An easy way to stay away from the floating-point math is to do the calculations yourself, round to integers, and make a lookup table. There are way to accomplish these ideas in code though, through using bigger numbers to save precision while making calculations.
  #3   Spotlight this post!  
Unread 17-02-2008, 10:34
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Mentor, LRI, MN RPC
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,835
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: reducing sensativity of joystick for precision?

The cubic equation is actually fairly easy to use. It looks something like this:

Code:
long temp;
long answer;
long divisor = 127;
temp =((int)p1_y) - 127; //this centers the input range between -127 and 127
answer = (temp*temp*temp) / (divisor*divisor);
answer = answer + 127; //shift the answer back over to the range 0-255
Just make sure you use longs, because you'll overflow an int! The basic idea is that you have a very shallow curve near 0, and a steeper curve near the extremes (-127 and 127). You get all the way to the extremes because 127^3/127^2 is 127. Throw in a couple of more values, and you see that moving the joystick 30 away from center gives you an answer that's only 3 or 4 away, and it can really help.
  #4   Spotlight this post!  
Unread 17-02-2008, 11:44
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: reducing sensativity of joystick for precision?

Quote:
Originally Posted by BigJ View Post
An easy way to stay away from the floating-point math is to do the calculations yourself, round to integers, and make a lookup table. There are way to accomplish these ideas in code though, through using bigger numbers to save precision while making calculations.
The disadvantage of a look-up table is that it is extremely difficult to change if the function doesn't work well. Imagine having to change 256 array entries! You can use the cubic code that Eagle gives above or your own quadratic code (which our team uses), while still staying away from floating-point math.

As long as you put all your division at the end of the line, everything will be integer operations and shouldn't take much longer than a LUT.
  #5   Spotlight this post!  
Unread 17-02-2008, 15:40
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: reducing sensativity of joystick for precision?

Thanks guys! I think ill use the cubic function since its startup time seems to be the lowest. Although I do like the lookup table idea as it is great for motor control! anyways thanks a lot! you're a life saver

windell
  #6   Spotlight this post!  
Unread 17-02-2008, 16:39
m3t4w0rm m3t4w0rm is offline
Junior Member
no team
 
Join Date: Feb 2008
Rookie Year: 1990
Location: r00t
Posts: 1
m3t4w0rm is an unknown quantity at this point
Re: reducing sensativity of joystick for precision?

just write a prog to write out the table then copy paste into code its really easy to change.
  #7   Spotlight this post!  
Unread 18-02-2008, 09:55
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: reducing sensativity of joystick for precision?

Attached is a EasyC program that has been used in various forms to build mapping tables for the robot in the past. You change the UserInclude.h to match the pwm/encoder pins you are using on the robot and then run the program with the robot up on chocks so the wheels are free to spin.

The program builds C rom data tables for unmapped, linear, two stage linear and a 4th user defined (whatever you want to add) mapping table. You capture the tables from hyperterminal and plug them back into your build environment. Yeah, this is done under no-load conditions, but it gets close enough.

The code determines slowest speed at which the wheels reliably turn, max speed and then derates that to 90% and then tries to match left/right wheel to the current formula with the least difference between left/right and desired mapping point.

The doc file shows uncompensated and linear mapping that results from the program. The program also generates a two step mapping with 80% of joystick travel covering 60% of the robot velocity. The mappings can be changed to whatever is desired.


An example of how the map tables are used.
Code:
<wheels.h - data from mapping program>


/* ***** Vector Motor Map 'map0' ***** */
/* ***** linear velocity mapping **** */
rom const unsigned char wheel_lft_map0[256] = 
{
    /* 0-15 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 28, 37, 46, 55, 64, 
    /* 16-31 */ 74, 83, 92, 101, 110, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 
    /* 32-47 */ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 
    /* 48-63 */ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 
    /* 64-79 */ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 
    /* 80-95 */ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 
    /* 96-111 */ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 
    /* 112-127 */ 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 114, 115, 116, 127, 
    /* 128-143 */ 138, 139, 140, 148, 148, 149, 149, 150, 150, 151, 151, 151, 152, 152, 152, 152, 
    /* 144-159 */ 153, 153, 153, 154, 155, 156, 157, 157, 157, 158, 158, 159, 160, 160, 161, 161, 
    /* 160-175 */ 162, 162, 163, 164, 165, 165, 166, 168, 169, 170, 171, 171, 173, 174, 175, 176, 
    /* 176-191 */ 177, 180, 181, 183, 184, 186, 188, 192, 194, 198, 203, 208, 215, 221, 229, 232, 
    /* 192-207 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    /* 208-223 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
    /* 224-239 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 252, 
    /* 240-255 */ 251, 250, 249, 249, 248, 247, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255  
};
:
.

<wheels.c - program uses currently selected mapping table>

void WheelLft_Set( unsigned char joystick )
{

    if (_wheel_map_selected       == 0)
        _wheel_lft_pwm = wheel_lft_map0[ joystick ];
    else if (_wheel_map_selected == 1)
        _wheel_lft_pwm = wheel_lft_map1[ joystick ];
    else if (_wheel_map_selected ==2)
        _wheel_lft_pwm = wheel_lft_map2[ joystick ];
    else
        _wheel_lft_pwm = joystick;

    SetPWM( WHEEL_LFT_PWM, _wheel_lft_pwm );
    return;
}
Just something to play with.
Attached Files
File Type: doc temp.doc (110.0 KB, 55 views)
File Type: zip ProfileMotors-2007-007.zip (48.3 KB, 58 views)
  #8   Spotlight this post!  
Unread 18-02-2008, 10:10
Tom Line's Avatar
Tom Line Tom Line is online now
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,554
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: reducing sensativity of joystick for precision?

Actually, you can create the lookup table in excel in a matter of seconds and copy and paste it over into your code. There's no disadvantage to using a LUT over the formula, other than memory, and since the LUT should be placed in ROM that's not much of an issue either.
  #9   Spotlight this post!  
Unread 18-02-2008, 10:15
Kev Kev is offline
The Greatest
FRC #0614 (Nighthawks)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Fairfax County
Posts: 16
Kev is an unknown quantity at this point
Send a message via AIM to Kev
Re: reducing sensativity of joystick for precision?

PHP Code:
pwm01 pwm03 =(unsigned char)(((((((int)(p1_y) - NEUTRAL) * ((int)(p1_y) - NEUTRAL)) >> 8)*((int)(p1_y) - NEUTRAL))>>6) + NEUTRAL); 

__________________
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
Reducing the sentivity of the joystick in easyC Pro Neurovirus Programming 9 19-01-2008 09:30
Precision of Shooting Nitroxextreme Robot Showcase 0 10-02-2006 07:39
Reducing wheel traction dude__hi General Forum 18 29-03-2004 18:43
Goal Drawings Precision petrrj OCCRA 1 23-09-2003 21:01
reducing gear box weight mickjagger Technical Discussion 16 23-01-2003 20:35


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

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