Jump to content

[Hardware, Plugin] Arduino based physical display + serial port io+ tutorial (24-11-19)


zitronen

Recommended Posts

Should be possible, though limited to 255 characters per packet for now, so 10 lines of 20 char each or something. The main issue will be testing and debugging, since only people who have displays can test it.

You are getting 10 of those displays? That will be expensive!

Link to comment
Share on other sites

Should be possible, though limited to 255 characters per packet for now, so 10 lines of 20 char each or something. The main issue will be testing and debugging, since only people who have displays can test it.

You are getting 10 of those displays? That will be expensive!

Thats what I figured, thing is the text does not need to be updated very often. Don't know if you can devise a specific packet for it that only gets sent once in a while? Still limited to 255 chars then?

As for price, I'd love to find cheapers ones. At $20 a pop I might grab only one or two, but I wouldn't mind grabbing 10 if they could be had for $10 or less. I'm not partial to the OLED, I just liked the compact size of them. If someone knows of similarly sized ~20 char displays with SPI or I2C interface than I'm all ears.

Link to comment
Share on other sites

Thats what I figured, thing is the text does not need to be updated very often. Don't know if you can devise a specific packet for it that only gets sent once in a while? Still limited to 255 chars then?

That's exactly what I will need to do. It will need to be run on launch and vessel switch.

Link to comment
Share on other sites

I'm going to go ahead and copy and paste something that I posted on reddit. Thank you so much for the plugin zitronen! The album I posted is all static images, I'll show you some of my working displays in a bit.

Okay I'm kinda cheating here because this is something for a "flight simulator". I wanted some cool control systems for Kerbal Space Program, but was disappointed with what the game had to offer. I'm also a sucker for cool hardware, so I decided to put my electrical and programming skills to the test and make my own hardware controller for Kerbal Space Program.

Album of current status is located here: http://imgur.com/a/nd92X[1] All input devices work perfectly with the game right now. Grabbing info from the game also is working thanks to a plugin for KSP located here: http://forum.kerbalspaceprogram.com/threads/66393-Hardware-Plugin-Arduino-based-physical-display-serial-port-io-tutorial-(15-Mar)[2]

On the larger display are all the fuel readouts, as well as distance to AP. and Pa. Smaller seven segment display shows current altitude altitude (or velocity, can't decide which). Third LCD displays shows information about the status of the craft and flight to the user. There are two Arduinos powering this whole setup. An Arduino Leonardo receives serial info from the game, parses it, and then sends it to an Arduino Mega 2560, which then displays the information on the individual displays. The Leonardo is also responsible for sending input information to the game.

One of the ideas I have been developing and programming is an automated launch system. You punch in a time to launch, and the game runs through the setup for you, starting from when you pull up the red cover and flick the big switch. I already have added functions such as keeping the controls locked out until an access code has been typed into the keypad.

If you want to know how I have accomplished this so far or are interested in seeing a video just let me know and I will see what I can do.

Link to comment
Share on other sites

I'm going to go ahead and copy and paste something that I posted on reddit. Thank you so much for the plugin zitronen! The album I posted is all static images, I'll show you some of my working displays in a bit.

Great stuff! Here is the repository thread for builds... get a post up here and I'll add your project onto the main post.

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

Link to comment
Share on other sites

So I'm sitting down and digging into this for the first time in weeks. I'm going to forgo the 8-seg displays because they're beyond my ability at the moment.

In the meantime, what does this section do in the main tab?

#define SAS 7

#define RCS 6

#define LIGHTS 5

#define GEAR 4

#define BRAKES 3

#define PRECISION 2

#define ABORT 1

#define STAGE 0

Only RCS and SAS are needed to for the sketch to compile, but they don't seem to be using pins as either inputs or outputs. My guess is this is this is something to do with the packet?

Also, I ran into the same problem Mulbin did with his inputs, that is the HIGH/LOW state was backwards for how I logically expected things to work. Putting a button on an input resulted in the input being ON by default, and off when the button was pushed.

Link to comment
Share on other sites

Thats what I figured, thing is the text does not need to be updated very often. Don't know if you can devise a specific packet for it that only gets sent once in a while? Still limited to 255 chars then?

As for price, I'd love to find cheapers ones. At $20 a pop I might grab only one or two, but I wouldn't mind grabbing 10 if they could be had for $10 or less. I'm not partial to the OLED, I just liked the compact size of them. If someone knows of similarly sized ~20 char displays with SPI or I2C interface than I'm all ears.

I have had some excellent success finding components (especially in larger quantities) on aliexpress. Just from a quick look, you could easily get those displays (with controller chips) for under $10 each shipped, and if you scoured around a bit more, I bet you could go even lower. I don't know if I've just been lucky, but I've done probably close to a dozen orders through them, and despite the slow-ish shipping, never had a serious problem. (for example this might work: http://www.aliexpress.com/item/IIC-I2C-1602-blue-LCD-module-provides-libraries-For-Arduino/1062018842.html )

Link to comment
Share on other sites

So I'm sitting down and digging into this for the first time in weeks. I'm going to forgo the 8-seg displays because they're beyond my ability at the moment.

In the meantime, what does this section do in the main tab?

Only RCS and SAS are needed to for the sketch to compile, but they don't seem to be using pins as either inputs or outputs. My guess is this is this is something to do with the packet?

Also, I ran into the same problem Mulbin did with his inputs, that is the HIGH/LOW state was backwards for how I logically expected things to work. Putting a button on an input resulted in the input being ON by default, and off when the button was pushed.

It's exactly what you guessed - it just tells which part of the packet to put each setting into before sending it back to the computer.

Link to comment
Share on other sites

@katton:

Thank you for that LCD. While the backpack for it is much smaller than the ones available from adafruit (I have a couple) the LCD itself is still enormous, compared to that OLED. My goal was to have a small ~10-20Char display under each action group button with a short description of what it is. Pretty much a straight rip-off of the ALCOR IVA, except in meat-space.

I'll look at the displays I have (they all seem to be clones/copies) and see if it'll work in the panel taking shape in my head.

@zitronen:

The action group buttons are not working how I expected them to. It's the same behavior as the SAS and RCS, which is fine there. Example: I have a light assigned to group 1. If I press #1 on my keyboard, that light turns on and stays on until I press #1 again. With a physical button, the light is only on so long as the button is pressed. Is this by design? I'd like to have buttons for AG1-10, so I just need to know if I need to get momentary buttons (this is bug), or toggle buttons (this is by design).

Link to comment
Share on other sites

Top of my wish list for things to be included is definitely MET/game world time. At present I can't program my charge/drain rate dial without it. I can't use real time to calculate it as KSP often runs at slightly slower than 1 game second per real second depending on graphics and memory load.

Link to comment
Share on other sites

Mulbin, did you ever sort the issue you had with your Mega board? While not the cheapest solution, I think grabbing a Mega will be much simpler than trying to deal with a port expander for additional I/O pins.

Yes, it works fine on the Mega now. It was only the early version of the plugin that had an issue where for some reason the mega only worked if you launched from the VAB, not from the launchpad.

Over this side of the pond you can pick up a clone mega (I have a "Funduino") for £15 (about $20-$25)

Edited by Mulbin
Link to comment
Share on other sites

@zitronen:

The action group buttons are not working how I expected them to. It's the same behavior as the SAS and RCS, which is fine there. Example: I have a light assigned to group 1. If I press #1 on my keyboard, that light turns on and stays on until I press #1 again. With a physical button, the light is only on so long as the button is pressed. Is this by design? I'd like to have buttons for AG1-10, so I just need to know if I need to get momentary buttons (this is bug), or toggle buttons (this is by design).

It is by design, to facilitate toggle switches. If you are using buttons, assign "activate" and "deactivate" instead of "toggle" in VAB/SPH, or just writes some simple arduino code to turn your button to a switch.

Link to comment
Share on other sites

A good way to handle this is to treat the button as a switch with a var to act as a status, something close to http://www.instructables.com/id/Beginner-Arduino/step15/Button-As-Toggle-Switch/ . I would suggest putting in some code to debounce the button.

@katton:

The action group buttons are not working how I expected them to. It's the same behavior as the SAS and RCS, which is fine there. Example: I have a light assigned to group 1. If I press #1 on my keyboard, that light turns on and stays on until I press #1 again. With a physical button, the light is only on so long as the button is pressed. Is this by design? I'd like to have buttons for AG1-10, so I just need to know if I need to get momentary buttons (this is bug), or toggle buttons (this is by design).

Link to comment
Share on other sites

"Weekly" update 9: 0.14.2

Added roll, pitch, yaw, translate x, translate y, translate z axes. Similar to throttle, you will need to enable the axes in the settings file. Also added is a tolerance setting for roll pitch and yaw, by default when you turn on SAS the SAS will override the attitude axes until you move one of the axes beyond SASTol (10% travel default), then the axis will override the SAS.

Plugin:

https://sites.google.com/site/zitronfiles/KSPSerialIO_014_2.zip

Link to comment
Share on other sites

How do pitch, roll etc work? Is it like a joystick where you are feeding it a rate of turn/movement in each direction? Or is it digital - so for instance you could tell it to turn 30 degrees along the X axis and hold that angle?

Looking forward to time, will be the last part needed for my first panel. Will there be values for world time and MET? Or just MET?

Link to comment
Share on other sites

This is for those who are adding LCD / OLEDs to there builds.

Are you using refresh timers between updates to your display? Or just driving the LCD's updates out with every loop? My current alpha build is using an i2C controlled 2x16 LCD panel on a 200 millis refresh timer. its a little slow about 3 or 4 times a second. What are other people seeing. And yes, I know i2C can be slow, but I'm attempting to save pins.

15zwar.jpg10qz0va.jpg

Sorry about the rotated image. Not sure why tinypic did that..

Link to comment
Share on other sites

Ok, I need a bit of Arduino advice. Not sure why but all of my switches and dials have stopped working, all I get is on light which turns on while the scene loads.

The plugin is detecting the COM port perfectly.

I am able to upload sketches to the arduino without problems.

I have run various test sketches and I know the dials work (and the pins work).

I have tested the serial.

I have checked all the wiring.

I have tried a fresh install of the game and plugin.

I have reloaded the plugin.

I have reset the board.

I have tried on both windows 7 and XP.

Still my control panel is completely dead.... any thoughts? It worked fine on .23.5 yesterday.

EDIT - "Starting serial port COM 2" (the correct port), RX light is constantly flickering as usual... not a single switch, light or dial does anything.... Although I know they all work.

Edited by Mulbin
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...