Joystick Realisations

Yesterday I had extreme difficulty in doing air-to-air refueling in DCS World.

The obvious reason for that would be that it is an extremely difficult thing to do and I am just not good enough yet.

Not being happy admitting my own lack of ability, I decided to blame my homemade joystick.

To be fair, my joystick was built by a numpty (me), so there could easily have been something screwy with it.

When researching more expensive potentiometers, I discovered that 'linear' potentiometers do not necessarily give a linear response to changes in angle.  It depends on potentiometer model, temperature, and all sorts of other things.

Seeing as the potentiometers I used were the cheapest I could possibly find, their quality is questionable at best.  So I figured I'd have to measure the response curve, then hard-code a calibration fudge.

I was genuinely surprised with the results:

There is a beautiful linear section for part of the response, but the bit from 55-75 degrees is just shockingly awful.  This dodgy non-linear response even occurs after running the calibration in js-test, so I'm pretty confident it's because of the hardware.

Lesson: Measure the response curves for potentiometers before fixing them in a controller.  If I had done so for the joystick, I might have been able to get the whole axis range covered by that linear region, perhaps obviating the need for a calibration fudge at all.

To fix it properly, I'd have to take the joystick apart and re-mount the potentiometer so the movement range was in the linear section.  EFFORT.

So instead I used the measured data to estimate what ADC value (from 0 to 1023) I would get for each angle, along with what the output value (-127 to 127) should be for each angle.  Then I could find which section of the calibration line the ADC value was in and linearly interpolate to produce an output value.

Whilst this still leaves a nasty sensitivity issue in the forward-half of the y-axis, it does at least allow the OS calibrator to do its thing without getting horribly confused.



Comments

Popular posts from this blog

Micro:Bit and SPI display

DCS World with TrackIR under Ubuntu

Cardboard Mock-up of USB Joystick