Our robot this year is geared 3:1, and because it is so fast, we hoping to use a logarithmic speed tank-drive system for much more control at low speeds and less control at high speeds. We use the formula:
((((input-127)/127)^3)127) + 127
Unfortunately, this really cool function seems to be complicated long for our PIC to solve quickly. If someone has a Cortex, it might work. Let me know what you think.
Sample values:
0 ----> 0
32 —> 74
64 —> 111
96 —> 125
128 -->127
255 --> 257
If you have the room on your microcontroller, you could use an array to control the values sent to the motors. Fill the array before the while loop where your operator code is so that you don’t constantly populate it with the same values. This is a lot easier computation wise for the microcontroller because instead of doing a bunch of calculations each time the code is run, it just has to fetch one value.
Sample array (you would need to fill in all of the values):
v[0] = 0
v[32] = 74
v[64] = 111
v[96] = 125
v[128] = 127
v[255] = 255
motor = v[input];
If you don’t want to store an array of length 256 on the microcontroller, you can do something like this (again you would need to fill in all of the values for the array):
newinput = input/10;
v[0] = 0
v[3] = 74
v[6] = 111
v[10] = 125
v[13] = 127
v[25] = 255
motor = v[newinput];