Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy 3.6 Beta project - Simpit for Kerbal Space Program

  1. #1
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,938

    Teensy 3.6 Beta project - Simpit for Kerbal Space Program

    I was looking for something to stretch my Teensy 3.6 Beta board and set to on hard panel for the game Kerbal Space Program (build a rocket badly, try to reach space). The game is extensively modable and a mod intended for Arduino exists that streams game state information to serial, but input was limited and currently non functional under windows. This is no big deal for a Teensy since it can also be a keyboard, joystick and mouse to close the control loop and having spare serial ports could use an FTDI adapter to keep serial port static while I reprogrammed the Teensy.

    So built out a panel to provide:
    Multi function digital Readout with matrix showing icon for current mode
    Artificial Horizon
    Assorted analog gauges
    Hard switches and buttons
    Analog controls for docking
    Indicator lights - lots of indicator lights
    Click image for larger version. 

Name:	Simpit.jpg 
Views:	540 
Size:	100.4 KB 
ID:	8062

    A number of features that should be there are currently on the cutting room floor including the still in shipping RGB LCD in place of the under size B/W one that was on the bench when this started.
    What it is doing however is running a beta 3.6 unit with:
    SPI for LCD
    rotary encoder
    Keybord matrix library with 12 buttons
    two toggle switches
    Two Analog reads for joystick
    I2C for matrix and 7 segment displays in top row
    4 analog outputs driving gauges
    software SPI for LED strip making up indicators (hardware SPI supported by layout but not smart enough to have it working yet)
    Hardware Serial for game state data
    USB HMI code sending to game (has lock switch to disable HMI sends when coding, and also disables when game pause detected)
    Assorted glue logic to drive all of the above
    Plenty of pins left over for expansion
    And because of the limited data coming from the game it's not only doing floating point math for rendering the artificial horizon but it has to extract the vectors for actual flight direction first.

    All of this 'just worked' software wise by just throwing libraries together and have plenty of cycles left over yet to add more features without needing to do any optimisation yet.

    Compile report:
    Sketch uses 60,296 bytes (5%) of program storage space. Maximum is 1,048,576 bytes.
    Global variables use 8,620 bytes (3%) of dynamic memory, leaving 253,524 bytes for local variables. Maximum is 262,144 bytes.

    Because it can both get game state information and send inputs it can automatically do things like send keypresses to match in game toggles to hard switches, and intelligently control warning lights (vertical speed back light goes amber for negative climb rate, red where remaining AGL/rate <10 seconds of flight.

    Lots of room for more features like audio,fly by wire and a second LCD as a MFD, but that has to go on hold for the moment to rebuild the physical parts of the panel to sort out boring things like LEDs and buttons needing to ocupy the same space and excess of tape holding things together.

    Thanks to Paul for making the hardware that could do all of this in one go, and the software that made doing it all 'just work' together.

  2. #2
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Awesome! I'm a Kerbonaut myself, this game taught me more about orbital mechanics than any physics course I ever took
    How does it "feel" flying with the panel? Took it to Mun or Minmus yet? Is there any noticeable lag between on-screen and hardware indicators?

    I'd really love to see a few more pictures of your panel, especially of the docking control (six analog axes for full manual RCS control?). And can you point me to the mod that allows serial output of game stats?

  3. #3
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,938
    The Mod is:
    http://forum.kerbalspaceprogram.com/...-april/&page=1

    if you are using it to talk to a 32bit micro you need to drop in
    __attribute__((__packed__)) into the struct definition on the arudino example so it looks like:

    struct __attribute__((__packed__)) VesselData

    For things to work out. My docking control isn't that clever yet, just the left/right/up/down analog control and button in/out on bottom of left hand panel. So far only flying on it has been planes, to get the navball working and cross check the various indicators and buttons. Partly because I'm missing the planned MFD that would be showing my orbital information, though guess I probably have enough data on the single multi purpose LED to munshot with... Cue madly twiddly selection knob during landing.

    If building your own really important that you interlock any keyboard commands, since as I found out it's tedious getting rid of several thousand 'gear up, gear down' cycles when I made an effective 'if (1==1)' error.

    Lag is present but low, since mod is running a 10hz update rate and Teensy is keeping pace. Navball orientation is ok, but vector pointing is sloppy since I'm extracting the vectors from a mix of other data, where I'd be better of recompiling the mod to include the required data directly. Means for example my current code needs to swap constants depend on which body you are around, which isn't a good look.

  4. #4
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Thanks, this looks very nice. I wish I had the time to build a panel myself, but at the moment I don't see this happening until at least February

    I'd love to have a physical, tangible full manual docking control, as i'm docking using the keyboard right now (Or mechjeb...), and that's really a pain in the... well.

    Ben

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •