2015-11-21

K-42 The hardware, part 2: Joystick controls

This post is a repost of a blog entry from 31th August 2015 on Kerbal Space Program forum (soon to be defunct).

As I had a tight budget for this build my first thought was to reuse my Saitek joystick and just mount it to the right inside the enclosure and jack it into the USB hub. When sketching on the layout I realized that it was a bad idea. It would either increase the size of the control board to much or, which was much worse, limit the space available for adding ludicrous amounts of switches.

The Saitek had to go. (Well, I might as well admit that part of me wanted to keep the Saitek as a stand alone joystick in case I wanted to do the unthinkable and play other games than KSP once in a while)

What I decided instead was to use small PS2 joystick modules that was available from China for less than $2 apiece. I ordered a couple and they functioned well but had two serious drawbacks. First of all, they looked too much like gamepad thingies, which they of course were. Secondly, the precision was abyssmal for fine control as the original thumbstick was too short and the spring that centered the stick was a bit stiff.

Time for reconstruction: Digging trough my boxes of Needful Things and found a couple of spare knobs for my IKEA book shelves. The threading of those were standard M4 so I got two M4 bolts and had a plan to Make Stuff Better(tm).



Step one: Rip the thumbstick from the PS2 controller.
Step two: Cut the hexagonal head off the bolt.
Step three: Drill a 2 mm hole in the unthreaded end of the bolt.
Step four: Screw on the knob on the once bolt but now joystick shaft.




Step five: Mount the new joystick shaft on the controller.



Step six: Screw the joystick to the back of the module and jack it into the Arduino Pro Mini.



Step seven: Mount into enclosure.



Result: A joystick that is long enough to enable me to make small smooth adjustments when flying.

As these are only two-axis joysticks I need two of them to get three-axis control. This means that I have one control for each hand. Not very Apollo like, but financially sound compared to getting a three-axis stick or (sigh!) the real thing.

The right joystick module also have a few switches to change how the sticks are mapped to controls.



The rover/flight switch selects between wheel steering and aerodynamic surfaces.

The second switch swaps the roll axis between the two joysticks. In rocket mode the right joystick controls yaw and pitch and the left controls roll. Plane mode swaps the roll and pitch between the sticks to be more similar to flight sticks.

The third switch selects whether the joysticks are used for translation och turns. In translation mode they control the RCS system with the right stick being up/down and left/right. The left stick is forward/backward and roll.

The last switch engages precision control. This means that control inputs are divided by four to make it easier to make small adjustments, for example when docking big heavy ginormous stuff in orbit.

The source code for the joystick modules. Totally Copyleft.
https://drive.google.com/file/d/0B5F...ew?usp=sharing

No comments:

Post a Comment