KerbalController: a Custom Control Panel for Rocket Game Kerbal Space Program

87,190

448

190

Introduction: KerbalController: a Custom Control Panel for Rocket Game Kerbal Space Program

About: I always like to learn something new, but rarely finish what I start.

Why build a KerbalController?

Well, because pushing buttons and throwing physical switches feels so much more substantial than clicking your mouse. Especially when it's a big red safety switch, where you have to open the cover first, flick the switch to arm your rocket, start the countdown and 3 .. 2 .. 1 .. we have liftoff!

What is a KerbalController?

A KerbalController, also referred to as a Control Panel, Simpit (simulated cockpit), DSKY (display keyboard) or custom joystick, is a customized input device for controlling the popular rocket-building-and-flying-and-hopefully-not-exploding game Kerbal Space Program combined with optional output from the game, such as status lights, telemetry displays and/or fuel gauges.

This specific build includes inputs such as rotation and translation controls through joysticks, a throttle slider, loads of buttons with status lights, LED fuel gauges and a telemetry LCD display with multiple modes.

This guide will include everything you need to build an identical copy, or make adjustments and improvements along the way, as you see fit. Included are:

  • a parts list
  • digital design drawings ready for lasercutting
  • wiring instructions
  • Arduino code
  • Code for the accompanying KSP plugin
  • Lots of pictures

Ready for takeoff? Let's go!

Step 1: The Tools

The most important tool you need to have for this build is a soldering iron. That includes some solder, a metal cleaning sponge to clean the tip of the soldering iron and a "third hand".

Other tools are a wire stripper, a wire cutter, tweezers and some small size screwdrivers.

Step 2: Parts and Basic Layout

Making the best possible controller for you means selecting exactly which buttons and switches you want to implement. Because everybody plays the game differently. Some people fly planes and build SSTO's (single-stage-to-orbit). Others prefer rovers of space stations. And some just want things to spectacularly explode!

It helps to draw all the parts in their approximate size and drag them around in a vector drawing program (like Affinity Designer or Inkscape) or 3D drawing program (like SketchUp).

If you want an easier build, you can just copy my controller and get the parts listed on the attached parts list.

Step 3: Create a Prototype (optional)

If you are copying my controller, you can skip this step.

If you are going for a custom layout, I recommend using a shoe box first to create a working prototype with the main controls. It really helps to fine tune the position of the main controls. It's also nice to get the confidence you can get it to work before you continue to invest time and money in the final build. I actually played the game for quite a while with my shoe box controller. Isn't it the Kerbal way to use salvaged parts to hack something together?

Step 4: Tips on Wiring

When creating a prototype, don't solder all your buttons in unless you want to de-solder them when you get to the final enclosure. I soldered some wires to the buttons and used a solderless breadboard to make the temporary connections to the Arduino.

When connecting all electronics to the final faceplate, you can reduce clutter by creating loops for 5V and ground. You don't connect all ground pins directly to the Arduino, but rather connect ground on one button to ground on the next button and loop all around. Finally, you connect to the Arduino.

After creating loops for power and ground, all the connections to the Arduino pins remain. I recommend getting some strips of header pins and soldering the wires to those. You can use these as a big connector, so you can still unplug your Arduino for testing.

The length of the wires is a balancing act between short enough to keep the enclosure free of excess tangles of wire (which might prevent you from being able to close the box) and long enough to be able to move parts out of the way to solder other parts in, tighten screws and poke around with your multimeter while debugging.

Step 5: Getting the Faceplate Lasercut

Achieving a clean, professional look is very hard when sawing and painting by hand. Luckily, laser cutting is not very expensive any more. It allows for extreme precision, as long as your design is accurate.

Attached is my faceplate design, in formats appropriate for Affinity Designer and other vector drawing programs like the free InkScape.

I had the faceplate lasercut in The Netherlands at Lichtzwaard. They have since closed and activities have been taken over by Laserbeest, where I had the box laser cut. Every shop may have different requirements for the design, so check with your shop before submitting. They also almost always offer design help at an hourly rate.

Important things to keep in mind:

  • Everything must be vector based. That's why the logo in my faceplate design didn't get etched. Note this is not fixed in the designs attached.
  • Even text has the be vector based. So convert those letters into curves!
  • Measure. Measure. Measure. I failed to take into account the size required for mounting the joysticks and had to hack it. Turned out fine, luckily. Note this is fixed in the attached designs.

After checking everything thoroughly, send it to the lasercutting shop. Expect to pay 40-50 euros in The Netherlands and get this beautiful result in the mail the next day!

Step 6: Hooking Up Buttons and Switches

Most switches and buttons have the connectors labeled C, NO, NC, +, -. Here's how to hook them up to the Arduino.

Simple switch or pushbutton:

  • Ground --> C (common)
  • Arduino digital pin --> NO (normally open)

We will configure the digital pin as INPUT_PULLUP, which means the Arduino will keep the pin at 5V and detect when the pin gets grounded and treat that as an input. The NO connector on the switch or button is Normally Open, so the circuit is not connected. When you push the button or toggle the switch, the circuit gets closed and the pin gets grounded.

Pushbutton with LED:

The button part is the same as above. For the LED, you attach additional wires:

  • Ground --> - (negative)
  • Arduino digital pin --> + (positive)

This part is pretty straightforward. We will use the Arduino pin in normal OUTPUT mode.

Safety switches with LED:

These are a bit different and do not allow control over the LED independent from the switch position. The LED will always only light up when the switch is toggled on. They have a +, - and signal connector.

  • Ground --> - (negative)
  • 5V --> + (positive)
  • Arduino digital pin --> S (signal)

We will use the Arduino pin in INPUT mode. When the switch is toggled on, the LED lights up and the signal pin goes high.

Step 7: Hooking Up Joysticks and the LCD

LCD

The LCD is very simple. It just needs power, ground and serial.

  • 5V --> VDD
  • Ground --> GND
  • Arduino Tx PIN --> RX

You can use a JST connector or solder the wires to the board directly.

Joysticks

The joysticks might look daunting at first, but they are quite easy to connect. There are three axis that are connected in the same way. Two of them are using the connectors on the bottom of the joystick. The third uses some wires.

  • Ground
  • Wiper --> Arduino analog input pin
  • 5V

The connectors can be attached in this order. Don't worry about getting it backwards, the wiper is always the middle one. If power and ground are swapped, we can flip the axis around in the Arduino code later.

The wires might have a different colouring scheme on your joystick, but in general: the two wires with identical colours are for the button on top. Red or orange is 5V, Black or brown is Ground. The remaining wire is the wiper.

Step 8: LED Bar Fuel Gauges

Okay. This is the hardest part of the entire build. Feel free to skip this on your first build, or improve it and let me know!

I got these great LED bars I want to use as fuel gauges. The top LED is blue, then some green, then orange and finally red. If we can light one LED at a time, we can let it represent the fuel level on our spacecraft.

I initially ordered driver IC's with them. They work great! You can select dot mode or bar mode and it will display an analogue input voltage as a single LED (dot) or a range of LEDs (bar). But an Arduino does not output an analogue voltage! And the PWM feature that allows you to dim a LED by sort of emulating an analogue voltage, does not work with these driver IC's.

On to plan 2: shift registers. You get to work with these in every Arduino starter kit. And you can learn more about them here: https://www.arduino.cc/en/Tutorial/ShiftOut

The plan is to somehow convert the fuel levels into the proper string of bits that will represent the fuel levels on the LED bars. With 5 fuel gauges, all fuel levels filled up would need to be 10000000001000000000100000000010000000001000000000. With monopropellant empty, it would become: 10000000001000000000100000000010000000000000000001.

Sound simple enough. There are some complications. The shift registers have 8 pins, while the LED bars have 10 LEDs. I use 7 shift registers to get 56 outputs. When wiring them in, I skipped an IC pin somewhere (we'll fit that in code). And I wiring one LED bar in starting at the other end (we'll fix that in code). Oh and Arduino math that we need sometimes uses floating point arithmetic which causes rounding errors (we'll fix that in code). Note that I share the code in a later step.

My final build did not match the attached wiring diagram, so if you rebuild this controller, some updates are required to the code. Comment below if you need assistance.

Every LED requires it's own resistor. Try some different values in order to match the brightness. Green appears much brighter than red with the same resistors, so it helps to balance that out.

End result: instead of 50 digital pins required to power the 5 LED bars, that is reduced to 3: a clock signal, a latch signal and a data signal.

Step 9: Building the Enclosure

Time to get my revenge with those logo's!

I converted the logo's to proper vector drawings so they get etched just fine. This time, I have a different issue. The screw holes are not in the right places for proper assembly of the box. I used 6mm MDF for the box. Unfortunately, screwing of nailing into the edges causes them to split. I hacked it together with additional wood scraps and glue. Lot's of glue.

For those of you that are better with wood, glue and/or nails, I have attached a version of the designs without the screw holes altogether.

Despite the difficulties, the end result is quite slick.

Step 10: Software and Testing

Download the following software to make the controller work with Kerbal Space Program:

KSP plugin: https://github.com/hugopeeters/KSPSerialIO

The ZIP file is the compiled plugin. The rest is source code you can use to modify the plugin and compile your own version. Unpack the plugin into the GamaData directory.

Arduino Code: https://github.com/hugopeeters/KerbalController

Use the Arduino IDE to upload the code onto the Arduino Mega in your controller.

Look at the bottom right of the Arduino IDE to figure out which serial port the controller is on (e.g. /dev/cu.usbmodem1421). Open the config.xml file from the plugin directory and make sure your port is filled in. Now you are good to go!

You can use debug mode by putting the small on/off switch top left into the ON position. The LCD should display a string of letters. Each letter represents a button or switch and switches between lower and upper case when you press the button or toggle the switch. Setting the xyz switches into Xyz (on/off/off) will also display the throttle slider values. xYz displays joystick values for the Translation (left) joystick. xyZ for the Rotation (right) joystick.

LCD Modes

The following display modes can be selected for display on the LCD by using the x, y and z switches.

TakeOff Mode:     Suface Velocity / Acceleration (G)   
Orbit Mode:       Apoapsis + Time to Apoapsis / Periapsis + Time to Periapsis
Maneuver Mode:    Time to next maneuver node / Remaining Delta-V for next node
Rendezvous Mode:  Distance to target / Velocity relative to target
Re-Entry Mode:    Percentage overheating (max) /   Deceleration (G)
Flying Mode:      Altitude / Mach number
Landing Mode:     Radar Altitude / Vertical Velocity
Extra Mode:       not implemented (yet)

To see the different modes in action, look at the video at the end of the instructable.

Step 11: To the Moon!

Fire up KSP, load your favourite vessel, or build a new one and off you go!

Tips:

  • Use custom action group 5 for your ladders
  • Use custom action group 6 for your solar panels
  • Use custom action group 7 for parachutes or drogue chutes
  • Assign the launch escape system and the appropriate decouplers to the Abort action group
  • Don't forget you need to Arm the Staging button
Arduino Contest 2017

Runner Up in the
Arduino Contest 2017

First Time Author Contest 2018

Runner Up in the
First Time Author Contest 2018

Epilog Challenge 9

Participated in the
Epilog Challenge 9

3 People Made This Project!

Recommendations

  • Home Decor Challenge

    Home Decor Challenge
  • Explore Science Challenge

    Explore Science Challenge
  • Box Challenge

    Box Challenge

190 Comments

0
CobaltKyro
CobaltKyro

Question 11 days ago

Does the software side of things still work on the recent version of KSP? Also does the API plugin fork work on Windows?

0
Crowsjunker
Crowsjunker

2 years ago

HugoPeters! Incredible job with this. You (and the countless other KSP modders) inspired me make my own! I was working with the same joysticks you use in this and I was banging my head against the wall trying to figure out why the Z axis was eternally wonky! I took a step back and began sifting through your code and stumbled on this.

if(analogRead(pRZ) <= 40){CPacket.Roll = constrain(map(analogRead(pRZ),0,40,-1000,0),-1000,0);}
else if(analogRead(pRZ) >= 60){CPacket.Roll = constrain(map(analogRead(pRZ),60,500,0,1000),0,1000);}
else {CPacket.Roll = 0;}

Seeing this, I realized that the Z axis seems like it was just as wonky for you! I decided to test a second joystick and found the same thing. a wonky z-axis! I was doubtful that between you and I we had gotten 4 defective sticks.
I took stick apart, hoping that there was something impacting the Z-pot - but found nothing - UNTIL I realized that it was wired wrong! (read: I had it wired wrong). It goes against logic (at least in mind) - but the z axis pot is wired so that BLACK is the wiper, not white!

I changed my wiring and presto - my z-axis produces results just like X or Y!
It just so happens that I took a close up look at the pictures you posted and, like I did initially, you used white as the wiper (wiper--->analog input pin)! It looks like it's a pain to change, but FWIW, I'll bet if you make black the wiper - it will no longer be wonky for you!


TLDR: For those joysticks, black is the z-axis wiper, not white!

Love the controller! Thanks again for the inspiration!!!

0
hugopeeters
hugopeeters

Reply 2 years ago

Really?! Great find, thank you for sharing! Fly safe.

0
frankieorabona
frankieorabona

Reply 3 months ago

I'm not sure about this...by putting the black as a wiper, the roll is fixed all on the right and I have no travel on the left...
I still have the Z-axis completely crazy....

0
Kspmaker
Kspmaker

Question 3 months ago

Hi does this work with ps4

0
jinnylikestechystuff
jinnylikestechystuff

Question 4 months ago

Hello hugopeeters and everyone!
Numerous questions here: sorry if I take up your time!
I am someone who would love to build this controller.
I have purchased all the parts and am going to prototype them pretty soon.
I plan to do exactly the same as hugopeeter's but I wanted to add a few touches I felt would be useful to me in gameplay. Some of them include: A launch button (With an arm button and a key 'arm'; this is just an extra stage button for fun), a craft to map toggle switch and I wanted to add an additional abort button alongside the arm switch.
Your instructions were really helpful and useful to me. I am confident in wiring and breadboarding.
The only problem I am afraid of is programming. I have a little previous knowledge in Python, Java and Swift (I know the basics like loops, variables, functions and statements) and have watched a couple of videos on Arduino programming and read the code you provided. I understand about 50% of the code, I still seem a little discombobulated; do you have any tips or tricks for programming this for a beginner like myself?
The second question I have is that if it is ok to use a GND, VCC, SDA, SCL instead of GND, RX, VDD. And if so, how should I wire it?
Any help at all would be greatly appreciated!

0
Nicolem1234
Nicolem1234

5 months ago

I'm a mom who has been tasked with purchasing all of the items on this list so that my 13 year old can build this controller (with some help). I have NO knowledge of what all of these parts are, but I managed to load some of them into my cart...only to find that upon checkout on the Tinytronics website (for the billing address), I'm unable to put USA as my country. So I suppose I have to stop right there? Does this company not ship to the USA? I wish it was possible to purchase this controller...kiddo is a (what I consider) master KSP gamer. He thinks this controller looks great! Any help or suggestions are appreciated!

0
hugopeeters
hugopeeters

Reply 5 months ago

Hi Nicole,
Tinytronics is a local website I used to get my parts. There are different websites offering these parts in the USA. A quick google results in this overview: https://www.build-electronic-circuits.com/buy-elec...
AliExpress also has a lot of these parts, but shipping will take much more time. You can also copy/paste the name of the component into Google and find online shops.
Good luck!
Hugo

1
abelcheban
abelcheban

Question 7 months ago

Hi everyone and Hugo. I am trying to build a button box with dual joysticks just as shown here excluding the LCD screen and fuel gauges. Could anyone lend me a hand in coding it or lead me to someone that has shown how to do so? I want to make it so it can be swapped to other games such as flight sim. train sim, and practically any other game that can really read a controller input. Thanks for any help!

P.S. The main focus is on the dual joysticks. The buttons and encoders I believe I can figure out but if any help can be given for those as well I would very much appreciate it!

0
clementcdt25
clementcdt25

12 months ago

ani idea why when we turn the joystick too much clockwise, LCD screen and LED turn off ??

1
hugopeeters
hugopeeters

Reply 11 months ago

Yes, the resistance is becoming too low, so all the current flows through this path instead of other paths. Adding a resistor in serial might solve this.

0
clementcdt25
clementcdt25

Reply 11 months ago

ok and between what exactly did you put the resistor ? and which resistor ?

0
clementcdt25
clementcdt25

Reply 11 months ago

finnaly i discover that the white wire and the black wire are switched. So it just need to switch them, white on GND and black on the arduino pin.
Thanks chinese :/

0
Pocketrocket88
Pocketrocket88

Reply 7 months ago

Oh gotcha, I wired black to ground, red to hot, and white to Arduino, ended up adding a 2kOhm resistor between arduino and the pot, was wondering why things were so wonky with the rotation on the joysticks.

Guess I might need to rewire the joysticks now.

0
hugopeeters
hugopeeters

Reply 11 months ago

I didn't. Mine also dims when you turn the joystick too far. I expect it will be solvable by putting a 100 Ohm resistor in series with the joystick, so on one of the two leads that control that axis. Makes no difference which side. Your min/max/mid values for that axis will become different, so adjust the Arduino code accordingly.

0
Username_Goes_Here
Username_Goes_Here

Question 11 months ago

I'm thinking about making this, and do you think that 3d printed parts would work instead of the laser cutted wood?

0
Pocketrocket88
Pocketrocket88

Answer 7 months ago

I made the main body/case out of metal and then used 3d printed parts as the individual panels. Worked great for me, I liked the flexibility of being able to change the design however I wanted and not worry about getting parts laser cut.

20201016_140438.jpg20201016_140530.jpg
1
clementcdt25
clementcdt25

11 months ago

Hey It me again ^^ I have upload my python script and my arduino code on github so if some Windows 10 users want to download it, here is the link :
https://github.com/clemclem25/KerbalController_Ard...
I'm a newbie on github so if i did something wrong just tell me :)
And the code is absolutly not optimized but work for me with almost every features. I will upgrade it during this summer as much as i can ;)

0
Pocketrocket88
Pocketrocket88

Reply 7 months ago

I need some help, I am very new to this kind of stuff. I made my own controller, I wired everything and wrote my own basic code to control everything in the game that I could from keystrokes. I am using an arduino Mega 2560 that I have reconfigured as an HID to allow it to control the keyboard buffer. So everything works great except for the throttle (I have the slider just control the 'z' and 'x' key so I can control min and max throttle but no fidelity there), SAS mode selector switch (reference picture for the rotary switch to eventually select which SAS mode) and the LED Tank readouts (I currently just have my code outputting a loop to cycle through the LEDs to make sure everything is wired up correctly. So basically everything works except for the things I need to communicate with the game, that is beyond my understanding). I have downloaded your python script and your arduino code and can kind of reverse engineer it to try and figure out how to communicate with the game but am stuck there.

I'm a completely self taught programmer, so don't really understand some aspects. Is it possible to communicate with the game with my Arduino as an HID or did I start down the wrong path?

If you don't mind, is there anyway we could open up a communications path so I can ask you some more questions. If you don't have the time I completely understand. I've just put so much work into this and am failing at the final steps to make it work completely.

20201016_140438.jpg20201016_140517.jpg20201016_140530.jpg
0
Haru-Sama
Haru-Sama

8 months ago on Step 11

It's so cool, I really want that thing, so awesome but I will need help