|
Re: Help with Joystick Axes and Sensitivity
A good way to decrease the sensitivity feel of the joysticks is to output to the PWMs as a non-linear function of the joystick inputs.
For example, instead of:
PWM = joystick input (or pwm01 = p1_y or y = x)
Try:
PWM = 128/(1+127*EXP(-k*joystick in))-1 (<- this is a logistic function)
(find a k value that works
probably around .075)
Of course it is not a good idea to have the RC evaluate this complex floating point expression every loop. Instead try using excel to generate a list of what you wish every joystick input values to map to in PWM outputs and save the excel file as a coma delimited list. You want a file that looks like:
0,0,1,1,2,2
Except instead of 0, 1, and 2 you want the values generated from your function. You also want either 127 or 244 numbers instead of six.
Creating a file in this format allows you do store this information in a ROM table on the RC:
[Please note that I have not actually tested this on the RC. I have no way to verify if it will actually work or not, but this bit of code does compile successfully. If someone notices a mistake please correct me.]
const rom unsigned char pwm_outputs[128] = {
#include "name_of_file.csv"
};
Now you can access the data you put in your name_of_file.cvs file as you would any other unsigned char array in your program. IE, pwm_output[1] would return 0 if your file looked like my example above does.
So, pwm01 = pwm_output[p1_y], will set pwm01 based on the excel table you generated.
This is the way I feel is best to decrease the sensitive feel of the joysticks. Another way Ive heard suggested is to implement piecewise functions instead of a ROM table. Instead of a switch controlling a high and low sensitivity, the position of the joystick axis would. In other words, when the joystick is between 0 and 30 (in absolute difference from 127), the rate of change of the PWM output would be 2 PMW per joystick (a line of slope 2). From 30 to 60 you could use a steeper line (slope 2 maybe), and so on. This would allow your robot to feel less sensitive at low ranges but still reach full output at full joystick throw.
Greg
__________________
The above was my opinion. I'm wrong a lot. I'm sarcastic a lot. Try not to take me too seriously.
Last edited by GregT : 05-02-2005 at 00:58.
|