DC Motor Control via PS2 Controller - need help adding a dead zone.
Hey everybody, I need help adding a dead zone to spin code that was provided to me to control some DC motors wirelessly over Xbees. Sometimes the analog sticks on a PS2 controller don't go exactly back to zero, which causes slight movement from the motors even when you're not doing anything.
I've been working on this for a week now, and since I'm not a spin professional, I just can't crack it. Any help would be greatly appreciated. I believe something could be added to either "Xbee to Control Board 1.26.11" or "Servos_PEKIT", but I'm not one hundred percent sure. I've attached the files in a zip, there's five total. It should be pretty easy to understand for someone who knows what they're looking at.
Basically, I was thinking of somehow specifying a small range inside each axis' 0 to 255 such as 118 to 138, and the motors would only get the pulses if the axis is outside of that range, but if anyone has any better ideas, I'd love to hear them.
Thanks for looking.
I've been working on this for a week now, and since I'm not a spin professional, I just can't crack it. Any help would be greatly appreciated. I believe something could be added to either "Xbee to Control Board 1.26.11" or "Servos_PEKIT", but I'm not one hundred percent sure. I've attached the files in a zip, there's five total. It should be pretty easy to understand for someone who knows what they're looking at.
Basically, I was thinking of somehow specifying a small range inside each axis' 0 to 255 such as 118 to 138, and the motors would only get the pulses if the axis is outside of that range, but if anyone has any better ideas, I'd love to hear them.
Thanks for looking.
Comments
An "easy" way would be something like this:
JOY_MID and JOY_MAX are program constants based on your joystick/adc.
Apply the dead zone after running this method and you should get better results.