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.
<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.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.