Jump to content

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


zitronen

Recommended Posts

Update 0.18.4:

Changes:

  • Changed MNDeltaV from node delta V required to deltaV remaining (thanks @JeffSergeant)
  • Added float TargetDist: Distance to targeted vessel (m)
  • Added float TargetV: Target vessel relative velocity (m/s)

Download link:

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

Arduino code:

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

Edited by zitronen
Link to comment
Share on other sites

3 hours ago, zitronen said:

Update 0.18.4:

Changes:

  • Changed MNTime from node delta V required to deltaV remaining (thanks @JeffSergeant)
  • Added float TargetDist: Distance to targeted vessel (m)
  • Added float TargetV: Target vessel relative velocity (m/s)

:D

The target stuff is SO incredibly useful!!!

I'm confused... I had this up on my computer:

        public UInt32 MNTime;       //41*Dt Time to next node (s) [0 when no node]

        public float MNDeltaV;      //42 D  Delta V for next node (m/s) [0 when no node]

So... Wouldn't MNDeltaV make more sense to read deltaV remaining... Knowing the time to a maneuver node (MNTime) seems pretty important? Why would MNTime be changed to deltaV remaining? Or am I grossly misunderstanding something here? :confused:

Edited by richfiles
Link to comment
Share on other sites

Hey guys.

 

I have been testing this mod for some days, but I can't manage to make it work.

 

Could you please help me having it working ?

 

I'm running plugin V18.4 and game 1.2. 

 

Here are the logs : 

[LOG 07:35:09.065] KSPSerialIO: Version 0.18.4
[LOG 07:35:09.065] KSPSerialIO: Getting serial ports...
[LOG 07:35:09.066] KSPSerialIO: Output packet size: 199/255
[LOG 07:35:09.068] KSPSerialIO: Found 3 serial ports
[LOG 07:35:09.068] KSPSerialIO: trying default port COM5
[LOG 07:35:12.087] KSPSerialIO: KSP Display not found
[LOG 07:35:12.091] KSPSerialIO: trying port \Device\Serial0 - COM1
[LOG 07:35:15.093] KSPSerialIO: KSP Display not found
[LOG 07:35:15.094] KSPSerialIO: trying port \Device\Serial2 - COM5
[LOG 07:35:18.097] KSPSerialIO: KSP Display not found
[LOG 07:35:18.098] [AddonLoader]: Instantiating addon 'KSPSerialIO' from assembly 'KSPSerialIO'
[LOG 07:35:18.101] [PlanetariumCamera]: Focus: Kerbin
[LOG 07:35:18.102] [UIMasterController]: HideUI

 

And here is my config.xml :

 

<?xml version="1.0" encoding="utf-8"?>
<config>
    <double name="refresh">0.2</double>
    <string name="DefaultPort">COM5</string>
    <int name="BaudRate">19200</int>
    <int name="HandshakeDelay">1500</int>
    <int name="HandshakeDisable">0</int>
    <int name="ThrottleEnable">2</int>
    <int name="PitchEnable">2</int>
    <int name="RollEnable">2</int>
    <int name="YawEnable">2</int>
    <int name="TXEnable">2</int>
    <int name="TYEnable">2</int>
    <int name="TZEnable">2</int>
    <int name="WheelSteerEnable">2</int>
    <int name="WheelThrottleEnable">2</int>
    <double name="SASTol">0.05</double>
</config>

(BaudRate is at 19200 in the code too.)

I'm testing the demo code n°2 with the LEDs. In game, it displays " IOawake, no displays found".

 

I'm uploading the code into the adruino with com5, so I assumed this is what i had to set up in the config.xml ? The mod tries all coms port anyway.

 

I also tried game 1.1.3 / 1.1.1 with mod V17 etc, same issue.

 

Thx !

 

Edited by hiwa37
Link to comment
Share on other sites

44 minutes ago, hiwa37 said:

Hey guys.

I have been testing this mod for some days, but I can't manage to make it work.
Could you please help me having it working ?

I'm running plugin V18.4 and game 1.2. 

 

Here are the logs : 

[LOG 07:35:09.065] KSPSerialIO: Version 0.18.4
[LOG 07:35:09.065] KSPSerialIO: Getting serial ports...
[LOG 07:35:09.066] KSPSerialIO: Output packet size: 199/255
[LOG 07:35:09.068] KSPSerialIO: Found 3 serial ports
[LOG 07:35:09.068] KSPSerialIO: trying default port COM5
[LOG 07:35:12.087] KSPSerialIO: KSP Display not found
[LOG 07:35:12.091] KSPSerialIO: trying port \Device\Serial0 - COM1
[LOG 07:35:15.093] KSPSerialIO: KSP Display not found
[LOG 07:35:15.094] KSPSerialIO: trying port \Device\Serial2 - COM5
[LOG 07:35:18.097] KSPSerialIO: KSP Display not found
[LOG 07:35:18.098] [AddonLoader]: Instantiating addon 'KSPSerialIO' from assembly 'KSPSerialIO'
[LOG 07:35:18.101] [PlanetariumCamera]: Focus: Kerbin
[LOG 07:35:18.102] [UIMasterController]: HideUI

 

And here is my config.xml :

 

<?xml version="1.0" encoding="utf-8"?>
<config>
    <double name="refresh">0.2</double>
    <string name="DefaultPort">COM5</string>
    <int name="BaudRate">19200</int>
    <int name="HandshakeDelay">1500</int>
    <int name="HandshakeDisable">0</int>
    <int name="ThrottleEnable">2</int>
    <int name="PitchEnable">2</int>
    <int name="RollEnable">2</int>
    <int name="YawEnable">2</int>
    <int name="TXEnable">2</int>
    <int name="TYEnable">2</int>
    <int name="TZEnable">2</int>
    <int name="WheelSteerEnable">2</int>
    <int name="WheelThrottleEnable">2</int>
    <double name="SASTol">0.05</double>
</config>

(BaudRate is at 19200 in the code too.)

I'm testing the demo code n°2 with the LEDs. In game, it displays " IOawake, no displays found".

I'm uploading the code into the adruino with com5, so I assumed this is what i had to set up in the config.xml ? The mod tries all coms.

I also tried game 1.1.3 / 1.1.1 with mod V17 etc, same issue.

 

Thx !

 

Heya

Welcome!

What version of windows are you running?

Link to comment
Share on other sites

4 minutes ago, Sputnix said:

No; only issues seem to be with 10.

You should be using demo13 (https://sites.google.com/site/zitronfiles/KSPIODemo13.zip ).
Is that the one you're using? (I ask only 'cos you mentioned demo No2)

No, I'm actually using the n°1, mentionned one the first page :

"Source code for arduino - There may be newer versions posted in the thread, but this is the current recommended "stable" version.

1. Warning LED demo: https://sites.google.com/site/zitronfiles/KSPIODemo.zip use code from demo 4  <============  this one

2. Input demo: https://sites.google.com/site/zitronfiles/KSPIODemo2.zip use code from demo 4

3. Action groups: https://sites.google.com/site/zitronfiles/KSPIODemo3.zip use code from demo 4

4. Input Axes: https://sites.google.com/site/zitronfiles/KSPIODemo13.zip"

I'll try the one you said, KSPDemo13.zip, after work, and let you know how it's going on.

Thank you for your answers! Can't wait having it working and to build my controller :D 

 

 

Link to comment
Share on other sites

35 minutes ago, hiwa37 said:

I'll try the one you said, KSPDemo13.zip, after work, and let you know how it's going on.

Thank you for your answers! Can't wait having it working and to build my controller :D 

 

 

No problems :)

Feel free to send me a PM for assistance if you'd like.

Link to comment
Share on other sites

So I just got a mega 2560 and I seem to be having an issue with reliability. For example I'm finding that I'm having issues getting it to "sync" up at launch or on a resume. And by sync up I mean that I'm getting issues where the wrong data is displayed and doesn't update at all (I would occasionally get this on an uno but very rarely and pressing the reset button on the arduino uno fixed it [reset doesn't fix on mega 2560]) on launch but when resuming from the tracking station it has a different issue (didn't notice this on the uno) but it has the correct data sometimes but other wise the data is static (might have updating data for a minute or two). Both arduinos are using the same code so I don't really understand what's the deal.

I am using win 10 but the mega I got has a ch340g (looks identical to the ch340g on the uno).

Link to comment
Share on other sites

3 hours ago, ryan00793 said:

I am using win 10 but the mega I got has a ch340g (looks identical to the ch340g on the uno).

Heya,

The only way I know of KSPSerialIO working under Windows 10 is with the weird workaround that @KingLuxor mentioned here.

I'm not sure of the ins and outs, but they mention:

Quote

using a proxy app to receive UDP from KSP and relay that out the serial port using System.IO.Ports

Are you doing that? 

If not, straight serial connection to the arduino (via USB) and thru the plugin won't work. 

Link to comment
Share on other sites

It looks like code desync to me as it happed several ppl (include me) here. In short term, arduino is taking to much time to do stuff and cant keep up with data input and thus it stop talk to KSPIo. What do you have connected to your Arduino? Only 3 leds as demo? You may try increase bound rate or lower refresh rate at least for test purpose. Also I recomend for this kind of testing awesome  TOOL HERE by   @KingLuxor 

Link to comment
Share on other sites

18.4 needs arduino code demo14, current "stable" version on the first page is 18.3, which needs demo13. If you are just testing you should try stable version.

If you are getting intermittent problems, try increase serial buffer as well,  see "known issues" in first post.

 

Unrelated: there is a issue with 18.4 which gives null reference error when you target a planet, I think I found a fix, I'll do some more tests before releasing an update.

Edited by zitronen
Link to comment
Share on other sites

8 hours ago, Sputnix said:

Heya,

The only way I know of KSPSerialIO working under Windows 10 is with the weird workaround that @KingLuxor mentioned here.

I'm not sure of the ins and outs, but they mention:

Are you doing that? 

If not, straight serial connection to the arduino (via USB) and thru the plugin won't work. 

There is a work around posted not too long ago where Mattew posted that a different serial chip will make it work since it's not using the arduino chips. Work around here

7 hours ago, Mattew said:

It looks like code desync to me as it happed several ppl (include me) here. In short term, arduino is taking to much time to do stuff and cant keep up with data input and thus it stop talk to KSPIo. What do you have connected to your Arduino? Only 3 leds as demo? You may try increase bound rate or lower refresh rate at least for test purpose. Also I recomend for this kind of testing awesome  TOOL HERE by   @KingLuxor 

That's frankly disappointing I bought the mega hoping it would be "better" 16Mhz vs 8Mhz but I guess it doesn't directly translate to performance. That tool doesn't actually change refresh rate as seen here I can update it but I don't exactly know what the refresh rate number represents. If no one actually knows I can just open an issue on github and be like "WHY IT NO WORKKK?"

3 hours ago, zitronen said:

18.4 needs arduino code demo14, current "stable" version on the first page is 18.3, which needs demo13. If you are just testing you should try stable version.

If you are getting intermittent problems, try increase serial buffer as well,  see "known issues" in first post.

 

Unrelated: there is a issue with 18.4 which gives null reference error when you target a planet, I think I found a fix, I'll do some more tests before releasing an update.

I'm using a modified one of 13 i think? But the actual thing works it's just as mattew said i guess going to fast.

Link to comment
Share on other sites

That is weird. Unmodifed Demo and without any more hardware should work and not lag behind. I am using Mega as "The Gateway" for whole control panel and main process unit and I fixed lag issue long before and far away.  Try increase that buffer (mentioned in first post) and for testing purpose you can change refresh rate to something crazy like 1 second or more. 1sec is loooooots of time for any mCU to do stuff. My guess KSPDemo get executed like 10,000,000 per second :D   I think increasing speed of Gateway mCU is kind of pointless atm for purpose faster data transfer PC <--> Arduino. 

EDIT: About that Test tool. I forgot that normaly you  cant change bound rate within program itself. If you want change it, you must find config file in source files of tool, change value and recompile tool again

Edited by Mattew
Adding stuff
Link to comment
Share on other sites

Update 0.18.4a:

Changes:

  • Fixed a null reference bug when targeting a planet

Download link:

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

 

Also if you are still having intermittent connection issues, try changing

boolean KSPBoardReceiveData() {
  if ((rx_len == 0)&&(Serial.available()>3)){

To

boolean KSPBoardReceiveData() {
  if ((rx_len == 0)&&(Serial.available()>6)){

In SerialCOMS tab

 

Edited by zitronen
Link to comment
Share on other sites

@zitronen My bad I thought for some reason that the uno had an 8Mhz cpu. Also thanks for pointing out that it's explained in the first post.

@Mattew That link I included shows that the refresh rate is actually hard coded. You can just replace that line with what's below to make it not hard coded (watch the rx light on your arduino to confirm). I've now made an issue on the repo with it so that the guy can fix it.

_udTimer = new Timer {Interval = (int)(refreshrate * 1000)};

However it's kinda weird since it works at a faster rate than what I have in game, and maybe it's because it's the same data??? But I just saw the update I'll try it and see if that fixes my issue.

Link to comment
Share on other sites

First off thanks for the great plugin, super cool. 

I am having a problem however getting the throttle to work. I am on windows 10, which may be causing problems, but everything else is working so far (SAS controls, LED warning lights, staging), so i'm not totally sure. I did try the debug tool that KingLuxor made and that wouldn't connect to the serial port. 

Has anyone else had any problems like this? It seems like things mostly work, except for the throttle and debug tool.

Link to comment
Share on other sites

Nice! :D

I recently ordered some arduinos, so hopefully i'll be able to make a mini control panel or something :) (Unfortunately shipping from china takes ages :( )

To make sure i understand correctly, the arduinos and computer is linked via a USB cable, right? In the posts above there was a mention of a " usb->ttl adapter", not sure what that is :( 

Anyways, please do continue to work on this! I would love to see stuff added like time warp controls, the new 1.2 kerbnet icons (or whatever they are called) etc. :)

Link to comment
Share on other sites

2 hours ago, c4ooo said:

Nice! :D

I recently ordered some arduinos, so hopefully i'll be able to make a mini control panel or something :) (Unfortunately shipping from china takes ages :( )

To make sure i understand correctly, the arduinos and computer is linked via a USB cable, right? In the posts above there was a mention of a " usb->ttl adapter", not sure what that is :( 

Anyways, please do continue to work on this! I would love to see stuff added like time warp controls, the new 1.2 kerbnet icons (or whatever they are called) etc. :)

What operating system are you using (for playing the game, etc)?
The plugin communicates thru the USB, yes, and talks to the programmed Arduino board.

What icons are you referring to? That's not related to this plugin :P:wink: 

As for additional controls - I don't think 'time warp' is really an important controller thing. The best thing would be to program an Arduino as a keyboard, and do key-mappings to buttons (which has been discussed at various stages throughout this thread). Good luck! :)  

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