Desensitizing Joysticks

We are trying to desensitize our joysticks and we know what to add to the code but we don’t know where to add it. Whether to add it to User Routines Fast or User Routines. Where do we add it.

Whenever you want to do processing on operator input (filtering, desensitizing, delta-coding, etc.), it makes the most sense to do it only when new values are available. I would definitely put it in user_routines.c, in the Process_Data_From_Master_uP() function.

What i would do is make a function that adjusts the value of the joystick depending on the input…

unsigned char Dead_Band(unsigned char input_value)
{
	unsigned char Output = 127;
	if (input_value < Dead_Band_Forward)
	{
		if(input_value > Dead_Band_Reverse)
		{
			Output = 127;
		}
		else
		{	
		Output = input_value;
		}
	}
	else if(input_value > Dead_Band_Forward)
	{	
	Output = input_value;
	}

	return Output;
}

Then i would use that in the user_routines.c file under the Default_Routine() function as your output value to whatever PWM you want it to output in.

void Default_Routine(void)..........

pwm01 = Dead_Band(p1_y);
pwm02 = Dead_Band(p2_y);

I know you said you already solved the coding part, but this thread extensively covers this topic.

Edit:
If you want to take a look at the low pass filter I mention, PM me. The version in the papers contains a slight bug. (Well, ok, it’s fatal… but only if you push the joystick all the way forward. ;))