I have a usb game pad that I've managed to get into and I've found a way to apply voltage to the joystick potentiometer in a way that tricks Windows into thinking the joystick is being moved. I've also managed to rig this up to an arduino which I have put inside the controller along with a single axis gyro sensor.
The aim of this was to create a motion controller such that the gamepad could be held up and steered left or right like a steering wheel for driving video games. I had this working great , the only problem was the large drift I would get over a short amount of time. I assumed that if I used a 3-axis accelerometer in conjunction with the single axis gyro, I would get a better result.
However, I have tried this and am struggling to find a way in which I can use the accelerometer for the desired function. I am able to get the roll and pitch angle of the accelerometer, but I am unsure how to apply these to my end result. I have the gyro set up in the plane of the controller, so that rolling the controller to the left produces a negative angle (until -90 degrees), and rolling right produces positive angle (until +90 degrees). This works no matter which way up the controller is, so long as I zero the angle initially while holding the controller level.
I can use the accelerometer roll angle, but it only remains usable when the controller is held vertically with no pitch. If the controller is leaned away or towards me, the accelerometer roll angle reading changes largely and becomes unusable.
Does anyone know the maths I need to apply to the accelerometer angles to make them behave in the same way as the gyro sensor?
Sorry for the long text, and thanks for reading.