Jump to content

Custom Control and Display


cm2227

Recommended Posts

Hello KSP community,

I decided to move my thread here as it is not about plug-in development anymore.

After christmas 2013 I started my own hardware project. I began with thoughts about using a USB interface board to connect my own buttons and gauges to the game.

Then I realized I can do bigger. In this forum thread I would like to share the history, accomplishments and failiures of this project.

Project overview

I'll keep this overview updated, although I'm not sure wether I should write all updates in the title post. Nevertheless, here is what I'm working on.

I'm building my own cockpit with custom controls and displays.

The cockpit consists of two parts, which I call the control panel and the console. It can be operated by a crew of two or a single pilot. The control panel houses buttons, switches and in the future a single LCD. The console part has a X-52 flight joystick and throttle, translation joysticks, keyboard, a trackball (to be added) and several switches, buttons, gauges and displays - LCD and 7-Segment.

The digital backbone and design requirement is a single USB connection to the PC. Logic units inside (apart from the obvious USB devices) a USB keyboard controller managing the buttons and switches (via another microcontroller) acting directly on action groups or KSP keyboard controls, an Arduino Mega for managing the displays (which I call luminous) and a second Arduino Mega called colossus for entering command codes remotely similar to the DSKY unit in Apollo spacecraft but acting on MechJeb.

May 5th, 2015

I continued my work through the winter, but only recently I achieved some serious progress. As described before I switched to Polystyrene modular panels. Now I can work on individual modules or the whole console just like I want.

Quick overview of improvements: New instrument panels, way more switches, new power supply with contrast and brightness for all instruments and LCDs.

Jump to the end of this thread for detailed progress description.

o5MjOxF.jpg

November 25th, 2014

Well I did probably almost nothing all Summer long. But I picked up my work and reworked the hardware side. I ripped away the dashboard and the wooden structure on the back, which became too heavy. I rebuilt the dashboard support structure from riveted aluminum profiles, and all the dashboard instruments and switch units will be mounted on modular panels so they can be modified or moved. I abandoned the principle of using a single-piece dashboard, because I simply had one chance to cut the matching hole for one instrument, and if I made a mistake I had to start over. There will be pictures soon.

Just take a look at the picture. I waste several centimeters on each side of the panel. Can't wait to fit some instruments to the new structure.

May 16th, 2014

I'm proud as a duck because I reached a major milestone today. For the first time ever I was able to display real-time vessel data from KSP. This would not have been possible without the plug-in from Zitronen, which at the moment I use without changes on the KSP side. The arduino software incorporates Zitronens example code.

VNHCOKnl.jpg

May 9th, 2014

I was able to repeat yesterdays success. For the last two weeks I've been working occasionally on the colossus hardware, but the software was not really functional. Today I finished the primary loops. Now it can ask the pilot for the next command, look up how many arguments the command needs and send all this information on a serial line.

Have a look at the colossus setup while running. All inputs are numerical and entered with the # key, whereas * acts as decimal point. Nothing spectacular, but I'm proud of it. The array of 10k pull-down resistors is present because I only recently realised I could have used INPUT_PULLUP instead.

jNMEajKl.jpg

The LCD is not the final one, which will be 16x2 as well but white on blue like luminous. I also intend to use a single potentiometer like the one shown for adjusting all LCD contrast voltages at once (and a second one for brightness). Of course that means the LCDs have to be identical.

On the luminous side I also made progress. Alarms are triggered properly now. If any value triggers a master alarm, the master alarm and buzzer will definitely tell you. Also each alarm (like monopropellant or battery level has its own dedicated LED. You can then quit master alarm with the right button, but the individual alarm LED remains illuminated as long as the alarm condition persists. During that time no master alarm can be triggered by the same alarm. Only when a value returns to normal and then back to alarm level it can trigger another master alarm. The master alarm buzzer happens to be cheap and sounds pleasantly unpleasant. :D

May 8th, 2014

The past two weeks have brought progress in several field. I split software development into three different projects. The actual KSP plugin, arduino software for display and for data input.

I suspended my work on the plugin (I actually havent't played KSP in weeks, all my free time for KSP goes into the project), but I intend to modify zitronens plug-in. I need communication with my display system on one serial port, and command interpretation on a second. Maybe I can extend zitronens plug-in to support two open connections and MechJeb commands.

In all due decency I named the software part for displays "luminous" and the one for data input and command interpretation "colossus".

Here I have a quick pic of the current luminous setup in running state.

lDrxFaYl.jpg

It shows two LCDs with various information, the flight mode switch, voltmeter for battery level and an LED column. At the moment I'm working on proper master alarm detection and the warning LEDs. I want a useful logic which allows the pilot to quit a master alarm and the same source of alarm can only trigger the alarm again after it has returned to normal condition.

That means you would get a master alarm for low battery level and quit it. The master alarm would only be triggered again after battery level has returned to normal and then to low again.

Next update will probably be about the colossus part.

April 24th, 2014

I'm actually making huge progress in the last days. I owe that to my lack of work at work and the incredible support of my wife, who treats this project as if it were her own.

I decided on ordering a second Mega µC, this one being a clone from SaintSmart.

kVpsbgD.jpg

This pic shows the current state. I'm working on several things currently. This time I focus on the instrument panel alone. That is the angled board with the lcd and the meter etc.

Best is to describe it from left to right.

The LCD to the left will be the consumables and EECOM display. It is currently connected directly to Mega#1 for test purposes. Later it will be driven by its own RS232 controller, which I still try to build myself. If that doesn't work all LCDs will be wired to the Mega with I2C LCD drivers. But I intend to reduce workload on Mega#1.

Below a group of LCDs will indicate alarms, warnings and status. The master alarm LED will be joined by an ugly-sounding beeper which came in the mail yesterday.

Next is a voltmeter, connected to Mega#1 for monitoring battery level in %. The scale is already adjusted, meaning 1mV equals 1% batt level.

The little black joysticks have been discussed on reddit and are described in my imgur gallery. If you don't know either of them, here are the links:

http://www.reddit.com/u/cm2227

http://cm2227.imgur.com

Newest addition to the panel is the numeric display. Three 8-digit and four 4-digit seven segment displays will show various figures depending on display mode.

There will be a selector switch for lift-off, flight and descent mode, each having its own set of display modes and alarm conditions.

For example flight mode will show apoapsis and periapsis on 8-digit displays, which is pretty much useless during powered or unpowered descent.

April 17th, 2014

After I gave up entirely on USB LCD controllers I also suspended my work on RS232 LCD controllers. I made my own circuit boards (layout and etching) but I just couldn't get them to work properly.

u5cEOj0l.jpg

UtZYQgdl.jpg

March 2014

I gradually expanded the wooden structure to house more parts and circuitry.This state shows the instrument panel installed, and also a wooden structure behind it to support power supply and future PCBs.

tbs3pRrl.jpg

Mid-February 2014

I threw away the first button assembly and started over. A wooden case houses 20 buttons and 6 switches. The hole is for a LCD to be added.

V0xtAaNl.jpg

Inside, a PIC microcontroller converts the switch states to key strokes.

meyO226l.jpg

Together with the console it looks like this.

yPk2jyol.jpg

Not much circuitry is installed yet, apart from a USB hub and a prototype USB LCD controller, which I discontinued after finding out that the corresponding USB library only supports one device. I was not yet into Arduino or similar microcontrollers and actualle tried to avoid them. The coordinate switches for translation control are just standing there unconnected to check their placement.

January 9th, 2014

This is where I started. A USB keyboard controller and some buttons. The USB interface I bought never got to use.

SWD9040l.jpg

And I put some joysticks on a board.

sQDh5x4l.jpg

Edited by cm2227
progress update
Link to comment
Share on other sites

Further not yet visible plans are:

Adding 5 MAX7219 ICs to control the 7-segment displays

Second LCD right of the center line (centered on the cross indicated with pencil right to the numeric displays)

Second Mega handling non time-critical tasks, i.e. not updating any displays based on serial communications

Second Mega receiving own 2x16 display and acting as input system similar to DSKY with its own keypad

Additional switches for flight modes, power supply and test circuits

Link to comment
Share on other sites

Looking good, I think that you would be interested in this thread.

http://forum.kerbalspaceprogram.com/threads/66763-Custom-hardware-simpit-repository-For-people-who-take-KSP-a-little-too-far

It's basically what you are doing.

You will see my project is the third in the thread you linked :sticktongue:

- - - Updated - - -

What I want to accomplish in the near future is controlling MechJeb in DSKY-style (not NOUN and VERB based, but similar). I already assembled a field of 12 buttons for direct mechjeb Smart-A.S.S. commands like PRO, RETRO, TARGET+ etc. that don't require numeric input. But I dream of a sequence like this:

The LCD reads "Ready for input. Enter command:"

You press *11# on the keypad like your cue card told you to load MechJeb ascent guidance.

The LCD reads "Ascent guidance was requested. Please provide desired orbit altitude in km: "

You press 125# on the keypad

This goes on for inclination and other details (auto-staging has its own switch)

Finally the LCD reports "Ascent guidance active and ready for lift-off. Press * any time for disengage."

Automated landing would work similar. Interplanetary transfer is more complex, but feasible.

I guess the C# coding for the KSP plugin interacting with MechJeb poses the largest obstacle to me.

Link to comment
Share on other sites

I guess the C# coding for the KSP plugin interacting with MechJeb poses the largest obstacle to me.

Hmmm, maybe ask one of the MJ coders for advice on that? sure they have a thread somewhere around here :wink:

Awesome work though, I plan on maybe building something similar (but different) at some point...

Link to comment
Share on other sites

  • 2 weeks later...

Ignore this if you like, but I must caution you. That's a beautiful X52 throttle you've got there. I have the X52 Pro, which is essentially the same thing, but black.

And it does NOT function as intended.

The throttle curve is really messed up in KSP for this particular device. No one seems to know why. Just thought I'd give you a heads-up in case you didn't know.

Link to comment
Share on other sites

Thanks for the advices. Yes, I intend to use a font without serifs, like on the Apollo CSM panel. And I haven't played much with the X-52 throttle yet. But I will watch closely for irregularities in the throttle curve.

Link to comment
Share on other sites

  • 2 weeks later...

Guys, just a quick heads-up from me. I'm currently working on the seven segment displays, and I'm pretty sure I'll accomplish what I've planned. And there are people out there who don't know much about digital electronics. Yes, it is definitely possible to use a Max 7219 IC with common anode displays.

Link to comment
Share on other sites

  • 4 months later...

So, how goes the project? I recently started work on my own controller, but have run into issues using LCD displays to output the data from Zitronen's Plugin. Could I see a working version of the code you used? An example would make things far easier. Thanks!

Link to comment
Share on other sites

  • 1 month later...

Oh, I only now realized you replied to that thread.

Well, there you go. The Arduino software version running on the photos is luminous04a. See https://github.com/cm2227/Arduino/tree/master/luminous04a for source code.

Just a little bit of explanation on the code. It does much more than just display some numbers on an LCD. It reads switches and controls some status LEDs, as well as an analog output.

Basically you can just run take Zitronens code https://github.com/zitron-git/KSPSerialIO and add the LCD Library.

In the header of my main file I include the LiquidCrystal library and initialize 2 LCDs (eecom and pilot) in 4bit mode:


// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal eecom(23, 25, 27, 29, 31, 33);
LiquidCrystal pilot(22, 24, 26, 28, 30, 32);

Now some lines from my void setup(), I left out some less important lines. It sets up the serial connection and starts to write a Title, Monopropellant and electric charge as static text to the EECOM LCD.



void setup(){
Serial.begin(9600);

// set up the LCD's number of columns and rows:
eecom.begin(20, 4);
// Print a message to the LCD.
eecom.setCursor(0,0);
eecom.print("Luminous04a EECOM");

eecom.setCursor(0,1);
eecom.print("ECharge ");
eecom.setCursor(0,2);
eecom.print("MProp ");
}

In the loop() section I show you as an example how I update the EECOM LCD in every cycle:

 // update EECOM display
eecom.setCursor(8,1);
eecom.print(VData.ECharge);
eecom.print("/");
eecom.print(VData.EChargeTot,0);
eecom.setCursor(6,2);
eecom.print(VData.MonoProp);
eecom.print("/");
eecom.print(VData.MonoPropTot,0);

eecom.setCursor(0, 3);
eecom.print("MET: ");
eecom.print(VData.MissionTime,0);

And yes, the "MET:" text can be moved to the static text in the setup() routine, as it doesnt't have to be refreshed but stays the same throughout the mission.

For the pilot LCD I have different routines, where the displayed information depends on switch states where the pilot selects between different sets of data.

Does this help?

Link to comment
Share on other sites

  • 5 months later...

So, here's my update "soon" - five months later.

I made a new EECOM panel with consumables LCD, switches and voltmeter as battery and generation/drain gauge.

BtqrEBa.jpg

The right most switch will toggle between battery level and power generation or drain.

Link to comment
Share on other sites

I really love what you are doing!

I also have the same X52 controller, and I am planning on creating a similar setup to yours. Although, I have a raspberry pi that I'd like to incorporate somehow.

Minus the cost of the X52, how much money would you say you have put into this project?

Any thoughts of disassembling the X52 to make a sleeker setup? I do like the fact that Saitek put through holes that you can use to mount the joystick/throttle; however, I wonder how difficult it would be to disassemble it without breaking anything...

Also, have you found a way to incorporate the MFD on the throttle controller to display KSP related data? I haven't found any great documentation that describes how to modify the MFD to output whatever you want, but I am sure it can be done.

Keep up the good work!

Link to comment
Share on other sites

Thank you for the compliment.

I thought about disassembling the X-52 but I probably won't do it. You see, I started this project without a plan. I just but my joysticks on a board, and I left the joysticks intact because I didn't know how it would turn out - I expected me to take it apart after a few days. No its been 18 months that I'm working on this console, and my plans and specifications still change every time I lay my hands on the project.

I didn't even find out about the holes for mounting the joystick until after I encased them in wood.

And I don't see much potential for a sleeker setup. I could gain area or depth, if you know what I mean. Area doesn't help me much, as I still have space free on the level part of the panel. More switches there would take up arm rest space. And I don't think I could gain more than a few millimeters of installation depth, and then? The distance between the base board and the wooden panel is already fixed.

Hardware cost is not that much, I'd say 150€ without the X-52. Of course I spent more on materials wasted, tools and components never installed. I bought extensive collections of resistors, capacitors and other components because I need the variety.

Oh and for the MFD, that only works with the X-52 pro which I don't own. So it's just a clock and a stopwatch. But a good pilot needs a stopwatch and track of time on his home planet :cool:

Link to comment
Share on other sites

  • 11 months later...

April 14th, 2016

As I'm a Dad since November I have even less time for my project. Still I managed to do some progress, which I'd like to show you.

Last Summer I got my hands on a collection of different analog gauges, mostly ampmeters for 0-20mA signals but also some voltmeters. So I had to find a way to add a lot of gauges to my console, because I just love gauges! My solution was to build a separate enclosure which can be placed anywhere near or on top of the main console. My cockpit is supposed to be suitable for one or two pilots - some time when it's finished.

Anyway take a look at the progress pics and feel free to ask if you have questions.

Of course I will add a faceplate with labels and stuff, the massive board is for stability reasons only. Next update will be soon I hope. I'm working on my 16 LED caution & warning display. My next goal is having a few basic functions (gauges, LEDs, switches, Joysticks) ready to actually fly a mission with this thing.

Link to comment
Share on other sites

  • 3 weeks later...

Nice project! Keep that up. Have you any progress on DSKY-MechJeb interface or you abadon that idea completly?  Just wondering, since I got exactly same idea to make that in my project too, not while ago :D 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...