Hello fellow programmers!
I am currently working on finding a solution to a probable bug which in being a programmer for the last 2 years never occurred. The base joystick to motor control has a bug in it.
It preforms the funtion, but one wheel always continues to spin even when the joystick may only be giving a output of 1 or 2. How do you implement dead bands on your analog sticks to control the motor power output.
I dont have it right here, but ours is something like:
// since joysticks return -127 to 127 values, and since motors react in a
// rance of -100 to 100, this function adds a midpoint deadband and
// adjusts the speed to be within the expected range.
int deadband(int invalue)
{
// if the value is between -27 and 27 then use
// that as the deadband and return 0
if (abs(invalue) < 27) return 0;
// if the value is negative, add 27 to bring the (-27 to -127) to (0 to -100)
if (invalue < 0) return invalue + 27;
// if the value is not > 27 then it already exited, so - 27 and return
return invalue - 27;
}
task main()
{
motor[motorA] = deadband(joystick.joy1_y1);
motor[motorB] = deadband(joystick.joy1_x1);
motor[motorC] = deadband(joystick.joy1_y2);
motor[motorD] = deadband(joystick.joy1_x2);
}
haha that looks exactly like what I am trying today thanks:D
I’ll just see what works best I may end up going with the other idea too but thank you for your help.
John Fogarty
GForce 3864