Jump to content

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


zitronen

Recommended Posts

Thanks Zitronen. I got it working.

SO COOL!!!

Can you think of a way to control other things, such as picking SAS modes (retro, maneuver, etc) without using the mouse? I'm in the process of making a simpit/Apollo-ish module.

Stibbons, that is awesome. I've been looking at how to handle Navballs. I ended up changing Enhanced Navball so I can move it horizontally and vertically and I just treat is as a Navball HUD.

How much latency are you getting with the Navball? Have you found a way yet to show at least your Pro/Retro vectors?

This thread is amazing. Thanks for all the hard work Zitronen making this happen. This is more exciting than when I got N64/Goldeneye for Christmas. All my wife can do is roll her eyes.

Link to comment
Share on other sites

Nice one! Yeah I was looking at adding the SAS modes awhile ago, but unfortunately the windows 10 problems derailed that for a bit.

****

For people with windows 10 problems

I added a new config option:


<int name="HandshakeDisable">0</int>

Set it to "1" to disable the handshake stuff and it will just try the ports and send data without requiring handshake. Make sure you set the correct default port:

Download the new version here:

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

Link to comment
Share on other sites

How much latency are you getting with the Navball? Have you found a way yet to show at least your Pro/Retro vectors?

I'm trying to decide if the plugin should be trying to control the velocity display mode (Orbital, Surface or Target) of the in-game HUD. A nice side effect of doing that is that we can then save some space in the data packet by only sending the data the arduino requests. On the other hand, that's only really a saving of 16 bytes, plus "navball mode" would add a couple more bits to packets in both directions. And it's definitely possible that somebody would be interested in having, say, both orbital and target data available.

But once I've figured that out, yes, I do have code in the plugin to send that data, so I'll be able to show prograde, maneuver, target etc data on the navball. It's not finished yet because I spent a full day yesterday drawing and rendering the tiny icons to do it. :)

Haven't yet hooked this rig up to the rest of my controller. But it's currently capable of doing arbitrary rotations at >40 fps, and there's no other major delays getting packets between the different elements in my controller. So no, I'm not anticipating any noticeable lag beyond that generated by only getting data from the game every 80ms.

Link to comment
Share on other sites

Looking forward to seeing how this turns out.

I'm currently making as complete an Apollo styled simulator as possible. I'm currently using a modified version of EnhancedNavball to move the Navball vertically and sort of pretending it's a hud, which is less than great.

I was looking for a way to put a low latency Navball on a small OLED and decided that wasn't realistic for me to do.

Link to comment
Share on other sites

I gave up with the whole windows 10 thing. I tried for too long to get it to work. So I just dual booted my PC with ubuntu since I had to do this for work anyway.

However, I am having another problem. It will do a handshake but then not transmit any data over.

Changing the Buadrate makes KSP freeze when loading into the ship as well.

Is there anything I can do about this? My logs are as below. They don't seem that helpful.


[LOG 16:20:02.223] KSPSerialIO: Version 0.17.4
[LOG 16:20:02.223] KSPSerialIO: Getting serial ports...
[LOG 16:20:02.223] KSPSerialIO: Output packet size: 191/255
[LOG 16:20:02.224] KSPSerialIO: Baud: 38400
[LOG 16:20:02.224] KSPSerialIO: Parity None
[LOG 16:20:02.224] KSPSerialIO: DataBits 8
[LOG 16:20:02.224] KSPSerialIO: StopBits One
[LOG 16:20:02.225] KSPSerialIO: Found 34 serial ports
[LOG 16:20:02.225] KSPSerialIO: trying default port /dev/ttyACM0
[LOG 16:20:02.225] KSPSerialIO: Opening port...
[LOG 16:20:02.930] KSPSerialIO: found KSP Display at /dev/ttyACM0
[LOG 16:20:02.930] AddonLoader: Instantiating addon 'KSPSerialIO' from assembly 'KSPSerialIO'

--SNIP--

[LOG 16:20:05.412] KSPSerialIO: Handshake received - 314
[LOG 16:20:05.412] KSPSerialIO: Handshake received - 314
[LOG 16:20:05.413] KSPSerialIO: Handshake received - 314

Link to comment
Share on other sites

Hello, everybody!

I just registered to post this because I discovered that the newest version of the mod isn't compatible with 0.90.0.0 as it reports that there is no ".Vessel.mach Field" ([Exception] MissingFieldException Field '.Vessel.mach' not found).

To solve this I downloaded version 0.17.1 but this version is unfortunately not compatible with the given arduino-script "KSPIODemo12".

So i just wanted to ask wether anybody could help me rescripting it as I don't know what data this version of the plugin sends over the serial port or OP to post the code for 0.17.1.

EDIT: just found out that KSPIODemo10 suits perfect for 0.17.1 - works ootb!

Edited by ljonka
Link to comment
Share on other sites

Good news! From my quick tests, it seems to work with 1.0.5. They changed the thermal stuff again, will see if there are any problems. Also they removed intake air because "it make no sense", I will remove it from the vessel data to save some bytes.

Link to comment
Share on other sites

  • 2 weeks later...
can anyone with win10 confirm that this disablehandshake work?

I "just" started my project, and tried to connect my arduino (to a usb3 port, should not matter right?), uploaded the "KSPIOdemo12", connected a LED to pin 11 (SASLED) and a button to pin 8 (SASPIN).

changed the mentioned disablehandshake to 1, and set the comport to COM3 (as indicated in the arduino IDE(1.6.6)).

Started KSP (1.0.5), loaded a default ship on the runway, and neither "T" on the keyboard or the button on the arduino made the LED turn on.

Just to doublecheck my LED and button i loaded up a "LED"-program to the arduino (after quitting KSP), and _it_ worked as intended.


Thanx in advance :D

Edit: Arduino Mega 2560

Edit2: The LED (connected to pin 11 and 13) flashes occationally when when im the the VAB/Hangar :D

Edit3: Its also version 0.17.6 of this plugin, and when loading the craft to the runway, it _DOES_ say "initiated connection to com3" or somthing like that :D Edited by djnekkid
Link to comment
Share on other sites

Hi Zitronen

Thanks again for such an amazing mod. This is really helping me build my simpit.

I am currently trying to make a better autopilot. I can already turn on my basic autopilot using your additional byte.

To improve my autopilot I need to know the current available thrust of my vessel.

I currently see this chunk of code:

[CODE]
// this recursive stage look up stuff stolen and modified from KOS and others
public static List<Part> GetListOfActivatedEngines(Vessel vessel)
{
var retList = new List<Part>();

foreach (var part in vessel.Parts)
{
foreach (PartModule module in part.Modules)
{
var engineModule = module as ModuleEngines;
if (engineModule != null)
{
if (engineModule.getIgnitionState)
{
retList.Add(part);
}
}

var engineModuleFx = module as ModuleEnginesFX;
if (engineModuleFx != null)
{
var engineMod = engineModuleFx;
if (engineModuleFx.getIgnitionState)
{
retList.Add(part);
}
}
}
}

return retList;
}
[/CODE]

And there are some other methods as well.

I was wondering if you know how I can find the maximum available throttle? I don't think I see anywhere where you are utilizing retList. I'm pretty new to this, so I don't see where/how I can find the maximum available throttle, or the current mass flow, etc.

Do you know how to do this? Is there something I'm overlooking in your code you can point me to?

Thanks again!
Link to comment
Share on other sites

While I can't help you on current mass flow (actually, not even sure what this is?), I've dealt with the engine stuff myself.

[url=https://github.com/SirDiazo/TWR1/blob/master/TWR1/TWR1Module.cs#L223-L318]Here's the code where I pretty much do that.[/url]

Look for the TWR1MaxThrustVertical variable, that is what you are looking for I think. Ignore the offsetMultipler, that's a compensation for thrust not being perfectly vertical and I don't think it applies to your question.

D.
Link to comment
Share on other sites

Just the Rx-LED is flashing :)

I just tried the RCSLED, but to no avail :/
I also connected GLED and YLED, but still nothing :/

Thanx the the awnser tho ...



Just to be clear, I do not need to add any kind of libaries before compiling?
I could not find any #Include's, so I would not think so :D
Link to comment
Share on other sites

I am trying to get this to work in a MechJeb fork. However using OpenNETCF.IO.Ports; isn't working.

Error 9 The type or namespace name 'OpenNETCF' could not be found (are you missing a using directive or an assembly reference?)

I copied SerialPort.dll over, and added as a reference.

Was there a trick you did? For example I see a lot of references they don't have, such as System.Data.DataSetExtensions.

Is there something in particular I need to do to get this to compile, based on this error?

It's strange. I even opened SerialPort.dll in the browser, and copied OpenNETCF.IO.Ports in to the code.
Link to comment
Share on other sites

[quote name='djnekkid']Just the Rx-LED is flashing :)

I just tried the RCSLED, but to no avail :/
I also connected GLED and YLED, but still nothing :/

Thanx the the awnser tho ...



Just to be clear, I do not need to add any kind of libaries before compiling?
I could not find any #Include's, so I would not think so :D[/QUOTE]

No libraries needs, which version of the Arduino code are you using? You need version 13.

[COLOR="silver"][SIZE=1]- - - Updated - - -[/SIZE][/COLOR]

[quote name='Keith Young']I am trying to get this to work in a MechJeb fork. However using OpenNETCF.IO.Ports; isn't working.

Error 9 The type or namespace name 'OpenNETCF' could not be found (are you missing a using directive or an assembly reference?)

I copied SerialPort.dll over, and added as a reference.

Was there a trick you did? For example I see a lot of references they don't have, such as System.Data.DataSetExtensions.

Is there something in particular I need to do to get this to compile, based on this error?

It's strange. I even opened SerialPort.dll in the browser, and copied OpenNETCF.IO.Ports in to the code.[/QUOTE]

I don't understand what you are trying to do? The whole VS project is on github, if you just open the solution everything should compile?
Link to comment
Share on other sites

It does compile fine.

The problem is when I try to make a fork of MechJeb. So I copy the MechJeb source, and put the cs files in from your mod.

I add them as existing.

I also bring in SerialPort.dll

I include SerialPort.dll as a reference

When I try to build my copy of MechJeb it says in the KSPIO.cs that on the line using OpenNETCF.IO.Ports; that OpenNETCF can't be found.

It's very strange since I can even type Ope... which results in Visual Studio finding OpenNETCF so all I have to do is hit "." at which point it finds IO, so I hit "." again and it has Ports.

So somehow Visual Studio is finding the namespace of OpenNETCF and yet when I build, it gives the error I copied in.

I've had no problem with your code. This is outside something you caused. I just wonder if you know what might be causing this behavior. It seems strange that I'm including SerialPort.dll as a reference and it's still doing this.

I was wondering if you had another step besides adding it as a reference in order to get the namespace of OpenNETCF to hold up when building.

Basically what I'm trying to do is get Microcontroller buttons to launch MechJeb autopilot functions.

Thanks for such an awesome mod! I couldn't make this simulator without it.
Link to comment
Share on other sites

[quote name='zitronen']No libraries needs, which version of the Arduino code are you using? You need version 13.

[/quote]

Oh, I did not realize there were a version 13, as version 12 were in the OP :D
I guess i need to backtrack somewhat :D

edit: Happy to confirm that with v13 works :D (LEDS)

edit2: Well, not so happy to confirm that it works with v13, but just for a few seconds... i.e. i launch a craft with sas enabled, and then i 'spam' the 'r' (rcs) key, and after a few seconds, the LED stops turning on and off :/

even just standing on the launch pad, and the boards _seems_ to stop getting data, as the Rx light stops blinking... Edited by djnekkid
Link to comment
Share on other sites

I am working on a simple KSPSerialPort implementation that uses TCP/IP serial socket connections instead of using a standard COM port. I have gotten it working in a preliminary phase but if you would like to include it in the mainline library I can interface the serial port out and add the appropriate configuration parameters and upload it to the git repo.




I wonder if there is any interest in this.




My main reason for writing this is I currently don't have an arduino or any micro currently but I am working in Virtual Breadboard and windows 7 and Com0Com with VBB and .Net serial running from KSP didn't get a long together very well. So I decided to use the ethernet com bridge built into Virtual Breadboard instead. With the serial over TCPIP it gives you access to using a raspberry pi via ethernet or wifi, or interfacing with an arduino or other micro via one of these guys: [url]https://www.sparkfun.com/products/9476[/url] which may soothe some of the windows 10 woes.




Once I get a VBB project working well I am willing to share that as well, for those of you who are willing to shell out the $40 for VBB and the arduino + comm licenses. I like having VBB because it's great for experimenting without toasting your arduino (i've finally killed my first mega I bought 5 years ago, RIP).
Link to comment
Share on other sites

I'd be interested if you can get it to work for Windows 10, and this plugin doesn't work for Windows 10.

I'm just really hoping this can be made to work with Windows 10 since I'm in need of a new computer and Microsoft is pushing 10 like crack cocaine.

Hard to find good new computers with anything but 10, and I don't know anything about building computers.
Link to comment
Share on other sites

[quote name='Keith Young']Do you have any ideas why this doesn't work with Windows 10?[/QUOTE]

The full details are several pages back now, but the short version is that the serial connector library is supposed to fire a callback when data is received. That has never worked properly in Linux or OSX, and has stopped working in Windows 10. That means the plugin is able to send serial data out, but never gets notified of data being sent back by the arduino, so it never tries to read it.

There's been a fair bit of effort put in to trying to figure out why, but nobody's been able to get a handle on it. So there's a handful of attempts at working around it, with varying levels of success.

The workaround zitronen just released in the latest update is an option to put the plugin in send-only mode. With the plugin sending data, and using an Arduino's USB HID emulation to generate keyboard and joystick events you can recreate the same functionality.

My personal theory is that these issues are related to the version of Mono that Unity is running on. Still holding out hope that the Unity upgrade in KSP 1.1 will improve the situation for serial ports. Edited by stibbons
Link to comment
Share on other sites

[quote name='compy286']I am working on a simple KSPSerialPort implementation that uses TCP/IP serial socket connections instead of using a standard COM port. I have gotten it working in a preliminary phase but if you would like to include it in the mainline library I can interface the serial port out and add the appropriate configuration parameters and upload it to the git repo.

I wonder if there is any interest in this.
[/QUOTE]

Do you have a link to your project?

[quote name='Keith Young']I'd be interested if you can get it to work for Windows 10, and this plugin doesn't work for Windows 10.

I'm just really hoping this can be made to work with Windows 10 since I'm in need of a new computer and Microsoft is pushing 10 like crack cocaine.

Hard to find good new computers with anything but 10, and I don't know anything about building computers.[/QUOTE]

Yeah that really annoys me too. For now have you tried the latest version with send only mode?

[quote name='stibbons']The full details are several pages back now, but the short version is that the serial connector library is supposed to fire a callback when data is received. That has never worked properly in Linux or OSX, and has stopped working in Windows 10. That means the plugin is able to send serial data out, but never gets notified of data being sent back by the arduino, so it never tries to read it.

There's been a fair bit of effort put in to trying to figure out why, but nobody's been able to get a handle on it. So there's a handful of attempts at working around it, with varying levels of success.

The workaround zitronen just released in the latest update is an option to put the plugin in send-only mode. With the plugin sending data, and using an Arduino's USB HID emulation to generate keyboard and joystick events you can recreate the same functionality.

My personal theory is that these issues are related to the version of Mono that Unity is running on. Still holding out hope that the Unity upgrade in KSP 1.1 will improve the situation for serial ports.[/QUOTE]

Great summery, I will point people to this post in the future.
Link to comment
Share on other sites

Nope, I haven't tried that yet.

My main computer is 8.1 but I'm looking to buy a new computer for my simpit since I want 3 monitors at 1080 and I currently only have a 2GB graphics card in my 8.1 machine.

All these new XPS affordable rigs seem to be 10 these days. Unfortunately the sales on these to make them affordable are coming up in a few days.

It's going to be crucial to get the ship data to the microcontroller.
Link to comment
Share on other sites

[quote name='djnekkid']Oh, I did not realize there were a version 13, as version 12 were in the OP :D
I guess i need to backtrack somewhat :D

edit: Happy to confirm that with v13 works :D (LEDS)

edit2: Well, not so happy to confirm that it works with v13, but just for a few seconds... i.e. i launch a craft with sas enabled, and then i 'spam' the 'r' (rcs) key, and after a few seconds, the LED stops turning on and off :/

even just standing on the launch pad, and the boards _seems_ to stop getting data, as the Rx light stops blinking...[/QUOTE]

Huh... Anyone else have the same problem with 0.17.6?

Oh just making sure... you have the handshakedisable set to 1 right? Edited by zitronen
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...