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

78,350

413

179

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

2 People Made This Project!

Recommendations

  • Potato Speed Challenge

    Potato Speed Challenge
  • Bikes Challenge

    Bikes Challenge
  • Remix Contest

    Remix Contest

179 Discussions

0
kitacatter
kitacatter

8 days ago

Hi there!

I've noted that you get a deflection on my joysticks whenever something uses power across the common ground circuit (i.e. - whenever the stage button flashes). Do you have any recommendations for fixing this?

0
clementcdt25
clementcdt25

3 months ago

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

1
hugopeeters
hugopeeters

Reply 2 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 2 months ago

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

0
hugopeeters
hugopeeters

Reply 2 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
clementcdt25
clementcdt25

Reply 2 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
clementcdt25
clementcdt25

2 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
Username_Goes_Here
Username_Goes_Here

Question 2 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
clementcdt25
clementcdt25

3 months ago

And i'm finishing my python code to use this Controller with kRCP so just ask me if you want it ^^
(i also completelty rewrite the arduino code :) )

0
philipkyriacopoulos
philipkyriacopoulos

Reply 3 months ago

Could you post a link to a google drive of it so I can try it? I have been having no luck with KSP Serial IO, probably because I am on windows 10 lol

0
clementcdt25
clementcdt25

Reply 3 months ago

I have more bugs than expected :/
the most complicated is the serial communication but i think i can finish that in less than a week

0
clementcdt25
clementcdt25

Reply 3 months ago

Yes Serial IO is not compatible for Win10, I still have some bug to resolve but when i've finish i will upload my code ;)

0
philipkyriacopoulos
philipkyriacopoulos

Question 3 months ago

I have no clue how to make the handshake between the arduino code and the KSP Serial IO mod. I have been trouble shooting for a few days and I am using the slide potentiometer for the throttle to test the input and I am having no luck. Any tips or suggestions?

0
ReadItAlready_
ReadItAlready_

5 months ago

Hi, I'm interested in building this and I'd like to verify that the SVG file for the laser cutting is sized correctly. When measured it reads 40.06 x 53.70 inches (in Inkscape) and this does not seem correct. Should I crop the design or resize it? Thanks in advance

0
hugopeeters
hugopeeters

Reply 5 months ago

The faceplate should be 300mm by 200mm. The file for the box contains a 10mm by 10mm red square for resizing.

0
ReadItAlready_
ReadItAlready_

Reply 5 months ago

Thanks, I'm looking foward to attempting this.

0
hugopeeters
hugopeeters

Reply 5 months ago

I wish you a lot of joy and perseverance. If you need help, let me know.

0
CommanderMAM
CommanderMAM

Question 9 months ago

How should I alter the LCD code since I am using a 20x4 LCD display with an I2C with it (uses SDA and SCL pins to communicate)? Also am I correct in coding the LED bar graphs as:
inputBytes[0] = powLF >> 8;
inputBytes[1] = (powLF << 2) | (powOX >> 8);
inputBytes[2] = powOX;
inputBytes[3] = powEL >> 8;
inputBytes[4] = (powEL << 2) | (powMP >> 8);
inputBytes[5] = (powMP << 2) | (powSF >> 8);
inputBytes[6] = powSF;

if I wired them from red to blue and in the order LF, OX, MP, EL, SF, skipping no pins and having 6 at the end to spare? Almost done with my modified version I'm working on as a project for my Engineering class and this is the one thing that's giving me trouble. Thank you!

0
hugopeeters
hugopeeters

Answer 9 months ago

For your LCD, check the manual for that type of LCD and update the LCD.ino file accordingly.
For the LED bar graphs: it looks sensible at first glance, but you can easily check it by setting some fixed values in the code and seeing which LEDs light up.

0
CommanderMAM
CommanderMAM

Reply 9 months ago

Managed to get the LCD working in time for the deadline, but my shift register array is acting funky since I used male to female adapters for each shift register so I wouldn't risk burning them out when soldering like I had with one of my LED bar graphs. Pressing on them causes some to light and others to go out, so I'm not sure where the issue lies. The controller is still unable to communicate with the game, but that has more to do with lack of time and OS issues than the controller itself. Made the faceplate out of clear acrylic plastic because it turns out trying to cut Lexan plastic can release toxic fumes that can also damage the laser itself, in addition to the material being hell to cut through.

20191219_224634.jpg20191219_224653.jpg