Jump to content

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


zitronen

Recommended Posts

Does this still hold true with things like Real Solar System? (checks wiki) You are lucky, even Mercury and Neptune are only 7 characters :sticktongue:

This is another reason for the sending the name instead of an index, if squad adds more planets or if you use mods there's no need to change the code and add multiple look up tables.

Link to comment
Share on other sites

@zitronen, on a different tangent:

Is is possible to share the serial port between multiple plugins? And if so, could you add a "Z" or something at the beginning of your data stream?

I want to control additional stuff on my controller, like the brightness of the 7-segment displays, and control this (in the best case) through a GUI element on the PC.

The easiest way would be via a potentiometer on the controller, but who in this thread goes with "easy" solutions? :sticktongue:

Link to comment
Share on other sites

That will save a couple of bytes in the data stream (we still have like 80 left), but you will need lots more to store the look up table on your micro..

That is true if I need the name for display purposes. In case I only need to know which one it is for lookup purposes (air pressure, atmospheric scale height, ...) I don't.

But yeah let's try Strings, I'll report back when AVR C throws us a funny ;)

Link to comment
Share on other sites

@zitronen, on a different tangent:

Is is possible to share the serial port between multiple plugins? And if so, could you add a "Z" or something at the beginning of your data stream?

Hmm, I'm not sure whether it can or can not be done but I doubt it can and out of the box it doesn't work: You can't "snoop" the Serial connection while KSP and the Arduino talk to each other with a serial terminal, for example.

Maybe someone with a bit more lowlevel knowledge on Serial comms can shed some light if it's possible at all.

Link to comment
Share on other sites

Is is possible to share the serial port between multiple plugins? And if so, could you add a "Z" or something at the beginning of your data stream?

It's not impossible, but almost certainly impractical.

I want to control additional stuff on my controller, like the brightness of the 7-segment displays, and control this (in the best case) through a GUI element on the PC.

I will admit to taking the easy way out on this one, with a pot on the panel. :) But honestly, I think your best solution would be a second arduino, communicating with the PC over a second serial connection (stick a USB hub in your enclosure) and with your primary arduino over SPI or similar.

Advantage of that is that talking to your second serial port is very simple with whatever you like.

Link to comment
Share on other sites

That is a negative confirmation on the original plugin. All systems nonfunctional. Mayday Mayday Mayday.

Alright pilot! You've trained for this!

Here's procedure:

- ensure stable orbit, correct if necessary

- disengage RCS and SAS

- switch off external lights

- emergency beacon to program FFS.

- shut off all auxiliary systems

- break comm silence only in emergencies

- Reduce cabin pressure to 0.7

- reduce cabin temperature to 18

- Disengage fuses 0x32, 0x74 and 0x92

- Grab the snacks from F5 and rest in your cabin

hang in there boy, help is on the way

...and remember, it could be worse

4312.jpg

:D

Link to comment
Share on other sites

If I get some time over the holiday break there's a good chance I'll get myself a small OLED display for my controller for Christmas. That will definitely end up using a second arduino as a dedicated display driver.

This is what I am doing already, probably 2 x LCD displays and a second microcontroller dedicated to them...My suggestion is that you go with something beefier than an Arduino though, for a couple reasons...I would heavily suggest the Teensy 3.1:

https://www.pjrc.com/teensy/teensy31.html

A quick break down:

ARM-Cortex-M4 running at 72 MHz (vs the Uno and Mega's 16 MHz)

256 KB Flash (Same as the Mega, much more than the Uno's 32 KB)

64 KB RAM (8x the Mega 32x the Uno)

About $20

Fully compatible with the Arduino IDE and almost every library via an Addon downloaded from their website.

**For one, updating an LCD/OLED is a relatively slow process depending on how many pixels are involved with the change and the Arduino can't really keep up...I have used several different screens on previous projects and it is always an issue, even when using something with a 128x128 resolution and what I am using in my KSP controller has a 240x320 res...Testing THAT display with an Arduino vrs The Teensy updates 3-4 times faster.

**It has 3 Serial ports, so if you don't want to screw around dealing with SPI/I2C libraries to communicate between boards, the Teensy makes the process fast and easy.

**You can emulate Keyboard, mouse, and joystick functionality over the same USB connection you use to read the serial data from KSP...This means that with very simple, out of the box code, you can control pretty much everything.

**Cost/function they can't be beat if you want to stick with the Arduio IDE.

Cons: They only come in a 'mini' profile, so they are not going to fit Arduino shields...Also, unless Zitronen has changed the packet structure since the last version I downloaded, you might have to modify things a little bit to account for the fact that the Teensy is 32-bit and some variable sizes may be different than the Arduino's.

Edited by harbingerx81
Link to comment
Share on other sites

@zitronen, on a different tangent:

Is is possible to share the serial port between multiple plugins? And if so, could you add a "Z" or something at the beginning of your data stream?

I want to control additional stuff on my controller, like the brightness of the 7-segment displays, and control this (in the best case) through a GUI element on the PC.

The easiest way would be via a potentiometer on the controller, but who in this thread goes with "easy" solutions? :sticktongue:

Since you desire a GUI, have your computer organize the data from the multiple plugins and just use the arduino as a display driver.

Link to comment
Share on other sites

Can you add a variable to the output stream for X rot torque, Y rot torque, and Z rot torque? I'm making a simulator cockpit thing and want to have XYZ torque indicators like inside the game cockpits or the bottom left corner of the screen that shows trim. The problem I have is the arduino can output the joystick input but if I turn on SAS, the indicators will stay blank.

Just a request; Ignore it if have better things to do.

Link to comment
Share on other sites

OK, seems to be working again... They probably changed lots of things, can you guys test please: https://sites.google.com/site/zitronfiles/KSPSerialIO_016_0.zip

The passive parts (reading the values etc) works perfectly fine. No idea about active control though, I can't test this with the setup I have with me during the week. Good job with the quick fix :)

Link to comment
Share on other sites

<transmission lost>

Cmdr Freshmeat, please come in.

Systems have been patched, you should be ready to go.

Protocols for reactivation as follows:

- stow those snacks. hover up the crumbs, you know how much the open circuits on panel F9 love crumbs.

- Re-engage fuses and 0x92, 0x74 and 0x32, in that order

- restart auxiliary systems, wait for warning light 0x37 to go dark

- engage SAS and verify attitude control

- ensure valve pressure on SE to be above 0.8

Once confirmed, you're good to set temperature and cabin pressure to nominal levels, break comms silence and proceed with the mission plan.

Confirm when ready.

Link to comment
Share on other sites

Since you desire a GUI, have your computer organize the data from the multiple plugins and just use the arduino as a display driver.

Not really, I desire a User Interface. Not necesarily Graphical User Interface. I just want to inject additional data into the stream between KSP and the Arduino...

Link to comment
Share on other sites

<cracle>

Flight panel responsive after system update. Initiate testing procedure

RCS enable: Check

SAS enable: Check

Light: Check

Landing gear: Check

Brakes: Check

Roll: Check

RCS forward/rear: Check

Displays:

Monopropellant: Check

Battery: Check

Fuel: Check

Radar altitude: Check

All systems operational. thanks a lot, zitronen, for the fast and efficient emergency response.

Link to comment
Share on other sites

Not really, I desire a User Interface. Not necesarily Graphical User Interface. I just want to inject additional data into the stream between KSP and the Arduino...

There have been discussions earlier in the thread about using the ship descriptions to send some configuration data to the controller. If you want to do more then you are better off just forking the code and doing it yourself (like cm2227 and MrOnak), since it would be impossible for me to support all the possible things people want to do with their custom display/controller. Debugging software + firmware + hardware problems over the intarwebs is hard enough already!

Link to comment
Share on other sites

I am afraid I jumped the gun. I checked out in sandbox, as I had no save in career yet. No problems. In carrer, however, I got the error:

[Exception]: NullReferenceException: Object reference not set to an instance of an object

Repeating over and over. Ship was a capsule, decoupler, couple of FT-L tanks and a LV-T30

Link to comment
Share on other sites

I tried it in Career, works fine. Not sure what happened there @Freshmeat.

@Zitronen: No hassles, I'll manage ;). You keep steering your project the way you see fit. Till now you've done a fabulous job of it and I trust that won't seize suddenly.

If there will be a time where I want to fork to add more telemetry data to the KSP -> microcontroller downlink I might do so but I've got my schedule so busy with other projects (*cough* PCB mill *cough*) that that's far off. All is good :)

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