Dead zone for RC control

I’m using the arcade drive controls through Easy C, but the current controller the drivers want to use doesn’t center itself very well, so I need to know if there is anyway to put a dead zone into the code. Thanks for the help.

I think you have two choices:

  1. See this Post and use the drive ( ); function. “built in deadband”.

  2. Make your own “arcade” control by mixing the port1_x and port1_y with a SETPWM. Then using IF statements so that the mixed values from the joystick have to be greater than your deadband, else SetPWM 127.

I figured out a really easy way to do it. Turns out I just didn’t think it through. I made a simple If-Else statement. If the joystick values are between then set pwms as 127 else tank drive. Worked well enough.

A very readable way to do it is to make an inline function like this:

#define STOP 127
#define DEAD_ZONE 15 // or any other number, fool around with this to make it work as you want it to
#define IN_DEAD_ZONE(x) (x <= DEAD_ZONE + STOP && x>= STOP - DEAD_ZONE)

This would work with something like this:

if (IN_DEAD_ZONE(p1_y))
p1_y = STOP;