Jump to content

My unnamed Command Console


Captain_Hair

Recommended Posts

Howdy folks :) I've been working on plans for my own Kerbal Control Panel, but wanted to hold off on posting until I was closer to a working prototype.

Prototype goals
1: Cover all of the basics required to complete the final project. Such as learning how shift registers work, getting analog and digital input into the game, along with getting data back out.
2: Stay within the budget of £30
3: Be fun to use and at least equally as functional as using keyboard/mouse.
4: Entire panel must fit A4 paper size.
5: Be capable of getting to the Mun and back with, using only the Console.

xImjw8M.jpg

Haven't quite finished, but it's almost there. I've got the LCDs still to fit, still waiting on button covers and need to do a bunch of soldering and finalise my code. But so far it meets all my design goals.

The two LCDs, Analog Guage and (hopefully) Annunciator powered through an Arduino uno (the "output" unit). The buttons and analog inputs are handled by a Pro Micro (32u4) to take advantage of its HID Abilities. The result of this is that all inputs register as a keyboard/joystick over usb, so it's very quick and very simple, ensuring all the important inputs are registered quickly and do not require any 3rd party mods or software. This also allows me to experiment with different mods for the outputs (currently using ksp simpit) without interfering with the control aspect of the panel. I only had 3 shift registers to hand, so my button limit is 24. I've managed to eek out a few more though due to the he same keypress having multiple functions, such as on the EVA panel where many of the EVA buttons are also connected to another button elsewhere as they share the same keypress. Analogs each get their own input too, since the analog demux chips haven't arrived yet.

I should be updating this weekly, though obviously some updates will be more exciting than others.

Things on my to do list, if anyone has any suggestions here I'd greatly appreciate it :)
1: I have a 128 x 128 pixel LCD that I'd like to getting running as my navball over SPI. I've seen a few people post these, so if anyone could point me toward some code I'd be much obliged! I don't mind if it's not pretty and doesn't have all the Nav markers, I'd just like to be able to get a rough guide to the direction I'm pointing.
2: Decide if I want full analog inputs for control and rotation. I feel like analog input for X/Y rotation is a must, but what about Z? Is it worth going analog on that too, they're not used as often. Similarly I can't decide if I want the Translation x/y/z to be digital or analog, both have their merits.
3: Figure out which mod to use to get data from the game. I'm currently using Kerbal Simpit which, while a little fresh and lacking in features, provides a lot of data very quickly and easily. I've also heard good things about KRPC.

And finally just wanted to say thanks to all of those who are also posting their builds as it's helped me a great deal :)

Link to comment
Share on other sites

First, grats on your project. It looks slick.

Second, hardware suggestions:

  • I made a single-axis joystick out of a small wooden pin attached to a potentiometer. It worked pretty alright on a budget for rotation. For forward-reverse translation, I just use a stick between two microswitches.
  • The best enhancement of my second controller was the ability to switch between airplane and rocket control schemes: A selector that switches the roll and yaw axes in code. It was only after that I could fly spaceplanes.
  • You could improve above idea by mapping a joystick to EVA movements in a third option, freeing space and switches on your panel.
  • For your momentary switches, you can set them up as a keypad and save tons of input pins. It can be done with toggles as well, if you put in a diode after each switch to prevent ghosting.

The only guy I know of that has a working navball is @stibbons, the author of Kerbal Simpit. Check his rather large source. Word of warning: I recall him taking a very long time to get the navball correctly done, and IIRC has a Teensy devoted just to doing that. This puts the price tag somewhat above £30.

On the I/O plugin, I find myself very much on the fence. Look closely to your needs. The most versatile is kRPC, but it runs slower and is more complicated to write programs for. Kerbal Simpit has a cleaner way of interfacing than KSPSerialIO, but my requirements are better aligned with the latter due to familiarity.

Ask around, there a lot of people more knowledgable than me that will love to answer. Even more so if you do it in the relevant plugin thread, where more people look ;) And be sure to post pictures so we can applaud your progress.

Link to comment
Share on other sites

7 hours ago, Freshmeat said:

*useful stuff*

Thanks very much for your reply :) I think I recall seeing your project, with the wooden dowels. I REALLY like your idea of aircraft flight mode, thats an excellent idea. After some thinking, I'm considering having 1 fully analog joystick and 1 fully digital, with some way of selecting a mode. Perhaps a rotary encoder for each to toggle EVA/Rotation/Translation/Flight/Rover, each mode could then have slightly different controls and allow me to use whichever I want for the task at hand. I'm definaltly going to have a "Flight" mode though. I also like how you've got an autopilot, thats something I'd like to dabble with but I'm leaving that till much later.

I was going to go with a button matrix, even ordered 200 diodes to make a large 128 button matrix, but decided against it. Since space inside the panel isn't an issue, I can afford to fit as many shift registers as I want. So rather than (as an examlple) 2 shift registers in a row/column matrix (8 input, 8 output) for a total of 64 buttons, I could just have a large cascade of 8 shift registers in a row to get 64 buttons. Disadvantages are requires more physical space and being slighly inefficient. Advantages are simpler coding and hardware (no diodes or row/column polling needed) and each button will have a common wire so I can more easily use things like rotary encoders and toggle switches that are single pole. Its almost literally a "6 and two 3s" decision, but in my case it should work out less effort this way.

I think I've seen @stibbons navball, he mentioned it worked with an arduino but was slow, however his was a much bigger LCD if I recall, so my hope is that by driving fewer pixels It''ll be a bit quicker. To be honest I'd be happy with a very low-quality navball for now so I can do away with the screen GUI, then upgrade to a more powerful navball later if/when I have a finished panel to put it in. The pro micro and lcd only cost £5 combined so if I can get any navball working out of it, it'll be worth the cost. Either way, navball is low on my priorities for now, I just figured Id have a dabble with it :)

I'm currently using Kerbalsimpit and finding it excellent, just a little sparse on features currently. But assuming stibbons picks up on it again after moving I'll stick with it as it is really nice to use. Since I'm mostly separating my inputs and outputs over 2 arduinos, I'm going to work on inputs first then see what stage the various plugins are at when I come to outputs.

 

I've been holding off posting an update till I had more, was hoping to have all the hardware fitted but not had time to do all the soldering, so here is a small update.

 

KtXLqUn.jpg

Thats the button boards soldered up (though I cant fit them till button covers have turned up grrr) and almost all the mounting holes drilled. Slow but steady progress.

 

UxhoeYR.jpg

 

Heres my current spaghetti of a breadboard, with 16 buttons over 2 shift registers. Once I've gotten the button boards soldered I''ll hook them up to this working example (along with a 3rd shift register) and check they all work. Then I'll move the shift register over to its own circuitboard and free up the breadboard for more experimenting.

O1bsNwz.jpg

 

Goodies started turning up in the post! Heres 20 shift registers of various types, 200 diodes and 20 assorted transistors.

 

Pcx8mdj.jpg

 

And here are the analog sticks I'll be using for the prototype. I chose these as the total cost was £2, so for the budget prototype they were ideal. Final project will have a proper 3 axis stick and 4 way digital joystick as inputs.

 

9dFjSVU.jpg

 

2 LCDs recovered from another project. A nice round analog gauge (along with resistors to convert it from 300v to 5v) and an indicator from a classic mini, which I thought might make for a neat "big alarm warning" type lamp.

 

Ik24tZK.jpg

 

Left to right: A key-operated locking switch for master control. A 4-way HAT style button, a 2 axis PSP analog stick (thought this might be ideal for camera/mouse) and a 10 position rotary encoder that I plan to use for Custom Action Group activation.

SY3CKn1.jpg

 

Another pro micro (or 32u4 rather) and a tiny 1:1 ratio LCD screen, which will hopefully become my "navball for under £5".

 

SPZRxJQ.jpg

 

And lastly, a whole bunch of ON/OFF/ON toggle switches, 50 5mm LED holders alongside coloured LEDs, and 3 very nice heavy duty covered toggle switches for Stage/Abort/Throttle(?) locking.

So the majority of this update is really just photos of parts that won't even be on this prototype... but still. Its coming along and I'm narrowing down my final hardware requirements for the main project, which is exactly what I wanted from the prototype.

Edited by Captain_Hair
Link to comment
Share on other sites

7 hours ago, Freshmeat said:

The only guy I know of that has a working navball is @stibbons, the author of Kerbal Simpit. Check his rather large source. Word of warning: I recall him taking a very long time to get the navball correctly done, and IIRC has a Teensy devoted just to doing that. This puts the price tag somewhat above £30.

 

And by "working" it's still a case of rendering the navball but none of the assorted velocity markers one expects to see on it.

The teensy is useful, and can comfortably render my ball at 30fps. My earlier tests were on an Arduino Uno, with lower quality, and it seemed to cope quite well at the 12.5fps I push packets out of the game (that's sending a packet every 80ms).

1 hour ago, Captain_Hair said:

however his was a much bigger LCD if I recall, so my hope is that by driving fewer pixels It''ll be a bit quicker

Mine is a larger display, but also has a much smarter display driver. I only have to send a command to "draw a line between these two points" to the driver, and it's responsible for flipping individual pixels. Doing a lot more of the rendering work in your Arduino is going to be a bit more taxing.

Can't wait to hear how you go with it though! :D

1 hour ago, Captain_Hair said:

I'm currently using Kerbalsimpit and finding it excellent, just a little sparse on features currently. But assuming stibbons picks up on it again after moving I'll stick with it as it is really nice to use.

<3

What would you like to see that's missing? I'm easing back in to writing code by rejigging the serial backend, but would love to get back in to doing fun things with the KSP API too.

Link to comment
Share on other sites

Oh wow thanks for replying stibbons :)

My goal was for something like this:

https://youtu.be/haSRLkled_A

Gah, pasting that link erased the rest of my post... so, yeah my goal was something similar to that link above. I'm willing to compromise where required, I'd be happy with even a handful of frames per second, just something to get me going without the UI :)

 

As far as Simpit goes, I'm still getting a hang of it, mostly been spending time on parsing the information once I've got it, into nicely displaying it on the lcd. I'm also aware there's features it has that I haven't fully uncovered. As an example I know you can subscribe to resource information, but not sure on the specific code to call a specific resource type, though the wiki documentation says it's possible.

Link to comment
Share on other sites

Oh yep. catmacey posted a link to their github repo with that code, and I'm using a modified version of it to drive my navball. A Uno will let you do similar at an acceptable rate. Biggest advantage to the teensy and better controller in my setup is that I'm able to drop in a higher quality model with a bunch more vertices.

11 hours ago, Captain_Hair said:

As an example I know you can subscribe to resource information, but not sure on the specific code to call a specific resource type, though the wiki documentation says it's possible.

Yep yep. All of the stock resource types are accessible. Working from memory, and haven't tried this code, but you want to do something like this:

#include "KerbalSimpit.h"

KerbalSimpit mySimpit(Serial);

void setup() {
  // Initialise the serial connection
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  while (!mySimpit.init()) {
    delay(100);
  }
  digitalWrite(LED_BUILTIN, LOW);
  
  // Register a message handler
  mySimpit.inboundHandler(messageHandler);
  // Request data about total available liquid fuel
  mySimpit.registerChannel(LF_MESSAGE);
}

void loop() {
  mySimpit.update();
}

void messageHandler(byte messageType, byte msg[], byte msgSize) {
  switch(messageType) {
    case LF_MESSAGE:
      if (if msgSize == sizeof(resourceMessage)) {
        resourceMessage myLF;
        myLF parseResource(msg);
        // myLF now contains a resource message, with
        // total capacity and current available amounts
        float totalLF = myLF.total;
        float availableLF = myLF.available;
        // etc
      }
  }
}

There should be message types for all of the stock resources (including EVA fuel). They all are standard resourceMessages, and can be processed in the same way.

Link to comment
Share on other sites

Oh well then it bodes well for me if you're using a modified version of his code, my screen is twice the pixels of his, but there's ways and means around fps issues. And I've always got the option to throw in a beefier board like you have with the teensy for more fps at a later date.

Thinking ahead (waaaay ahead) if I can't get other navball markers to show on it, I might also consider a physical navball, though those are their own can of worms from what I've seen in other people's projects :p

 

Regarding kerbal simpit, my problem is i dont know where in the documentation "LF_MESSAGE" and other messages are for me to call them. The ones I've been using were found from examples and other people's code. I'm sure there's a list somewhere, just that I haven't found it yet. :)

Link to comment
Share on other sites

  • 2 weeks later...

Apologies for double post, but I've got a small update with my prototype.

 

1yhAIlc.jpg

Finally some of the fixings arrived, so I've fitted the button boards, lcds and analog sticks. Considering I didn't even have any of the components in hand when I designed and printed the panel template everything fits surprisingly well!

Worst offender is the analog sticks, which by design have basically no extra space for clearance on either the stick or its mounting holes, so I'm going to have to do a loft of careful filing and sanding of the wood for them to fit correctly without rubbing on anything.

I also noticed the throttle panel is much bigger than needed so I might see if I can budge it over to one side and fit something else, maybe more buttons, in that space. I'm also not sure what to do with the Annunciator panel, so I'll consider putting something else in its place, perhaps more buttons.

 

A6Xnvc1.jpg

 

Also the mounting bolts are a little large and certainly aren't aligned in any way, but I'm with with the prototype being a little messy. This is most noticeable on the save/load label which has ended up with a bolt head stuck right in the middle of it.

Oy2hgTZ.jpg

One nice feature is that I can easily set the height of the button boards. So I've got the EVA buttons raised as much as possible for ease of mashing, with the time/space buttons almost flush to prevent accidental pressing.

hNJUnW4.jpg

Quick pic of the rear of the board, not particularly interesting as nothing is connected.

MfVChbU.jpg

And the in - progress shift register board. Given that I had space on the board and more shift registers and resistors on the way I figured out I might as well solder it up with 4 sockets rather than 3. That way I've got 8 extra spots for buttons if I need them for anything.

G2pgRsf.jpg

And a sneak peek of the big board I'll be using on the final project. 15 shift registers for a total of 120 buttons. The idea being to make adding a new physical button as simple as possible. All I need to do is hook the "new" button upto the common 5v rail on one side and the other runs to this shift register board.

 

So not the most exciting update, but still slow and steady progress. And of course it's all good experience for building the mk2 version later. I could really do with spending and afternoon getting it all connected again and having a test flight.

Link to comment
Share on other sites

7 hours ago, Captain_Hair said:

So not the most exciting update, but still slow and steady progress. And of course it's all good experience for building the mk2 version later. I could really do with spending and afternoon getting it all connected again and having a test flight.

Progress is good, and potential for expansion is really nice. I recall just wanting to be over with the thing and start flying again as well, and it sort of inhibits my ideas for making improvements to my rig now.

Link to comment
Share on other sites

6 hours ago, Freshmeat said:

Progress is good, and potential for expansion is really nice. I recall just wanting to be over with the thing and start flying again as well, and it sort of inhibits my ideas for making improvements to my rig now.

Hah yeah, in every single other project I've done the quality has suffered near the end in a dash to get it finished. That's another good reason for the prototype I guess, I don't think I need any parts back from it once it's done so I can play freely whilst building the bigger version.

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...