Jump to content

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


zitronen

Recommended Posts

Okay. Windows 8.1 64bit, KSP 1.3 in 64bit mode (also tried in 32bit mode, nothing different), plugin version 0.19.0. I also have KerbalEngineer installed.

 

Here's the log:

[LOG 11:03:29.314] [AddonLoader]: Instantiating addon 'KSPSerialPort' from assembly 'KSPSerialIO'
[LOG 11:03:29.316] KSPSerialIO: Version 0.19.0
[LOG 11:03:29.316] KSPSerialIO: Getting serial ports...
[LOG 11:03:29.317] KSPSerialIO: Output packet size: 200/255
[LOG 11:03:29.320] KSPSerialIO: Found 2 serial ports
[LOG 11:03:29.320] KSPSerialIO: trying default port 
[LOG 11:03:29.321] Error opening serial port : Object reference not set to an instance of an object
[LOG 11:03:29.323] KSPSerialIO: trying port \Device\USBSER000 - COM9
[LOG 11:03:30.845] KSPSerialIO: KSP Display not found
[LOG 11:03:30.848] [AddonLoader]: Instantiating addon 'KSPSerialIO' from assembly 'KSPSerialIO'
[LOG 11:03:30.856] [AddonLoader]: Instantiating addon 'FlightAppLauncher' from assembly 'KerbalEngineer'
[LOG 11:03:30.885] [AddonLoader]: Instantiating addon 'DisplayStack' from assembly 'KerbalEngineer'
[LOG 11:03:30.912] [AddonLoader]: Instantiating addon 'FlightEngineerCore' from assembly 'KerbalEngineer'
[LOG 11:03:30.917] [AddonLoader]: Instantiating addon 'KSPSerialPort' from assembly 'KSPSerialIO'
[LOG 11:03:30.918] KSPSerialIO: Version 0.19.0
[LOG 11:03:30.918] KSPSerialIO: Getting serial ports...
[LOG 11:03:30.919] KSPSerialIO: Output packet size: 200/255
[LOG 11:03:30.919] KSPSerialIO: Found 2 serial ports
[LOG 11:03:30.920] KSPSerialIO: trying default port 
[LOG 11:03:30.921] Error opening serial port : Object reference not set to an instance of an object
[LOG 11:03:30.922] KSPSerialIO: trying port \Device\USBSER000 - COM9
[LOG 11:03:32.426] KSPSerialIO: KSP Display not found
[LOG 11:03:32.428] [AddonLoader]: Instantiating addon 'KSPSerialIO' from assembly 'KSPSerialIO'
[LOG 11:03:32.432] [PlanetariumCamera]: Focus: Kerbin

Link to comment
Share on other sites

Just to confirm you are using COM9 for your arduino and you are using the demo16 arduino code? Do you see any serial rx tx lights flash on your arduino when you go to launch?  I could be either your arduino is not receiving anything from the plugin or for some reason it's not sending the handshake packet. Maybe increase handshake from 2500 to 5000 in the settings file?

"KSP Display" is just referring to your arduino. I called it a "display" because originally I made a display with mine. Maybe I should change it to something generic.

Oh I just checked the first post, the "tutorial" still linked to the older demo13 version of the arduino code, you need demo16 for the current 0.19 plugin. No sure if this is the problem but I fixed the link now.

Edited by zitronen
Link to comment
Share on other sites

Yes i confirm i use the COM9 port. I downloaded the demo16 code, and increased the handshake delay to 5000ms. Still, nothing. At launch neither the TX nor the RX lights would flash. The L light flashed twice, only while the launch screen was loading. Just to be sure, i'll try a fresh KSP/arduino code install.

Link to comment
Share on other sites

Hello again.  So I'm trying to speed up the code a little, since my TFT display is apparently so slow at drawing text that once I try to draw more than 100 characters or so after every data update, the serial connection fails.

Can I remove the output(); section from the loop() since I am only wanting my display to read values from KSP, and I am not using any switches or anything for KSP to read data from my Arduino?  Should that speed things up?  I tried removing output() but it actually seemed to slow things down for some reason, like the dll on the KSP side was waiting for data and timing out after every packet or something.

Or what about setting the serial baud rate higher?  What sort of effect does that have on things?

Edited by moeburn
Link to comment
Share on other sites

@moeburn The quick and dirty way of getting time to do everything is to raise your refresh rate in the init file. I use a refresh of 0.125 instead of 0.08, a value gotten by raising it until the disconnect problem went away. Further, consider if you can live with the display updating every half second instead: I have a counter that updates every 250 ms by comparing to a timer. When the counter is 0 and 2, LCDs are updated. When its is 1 and 3, indicator lights are updated. Additionally, on 1 real time clock and all resource gauges are updated, and on 3, some floating point operations for navigation happens. Every beat updates my terrain altitude gauge. Thus I manage to not get my Mega swamped.

Setting the baud rate higher would transfer more information to the Arduino, swamping it earlier. If you have a larger board (Mega), you can increase the serial buffer, but beware that the tutorials on how to do it are all outdated. I think I managed to do it but I am not really certain. In fact, the larger memory is the real reason the Mega is preferable, I only use a fraction of its pins.

Link to comment
Share on other sites

Hi guys, I'll Preface with a Thank you for all your work and help.

I just wanted to let you know I am running windows 10 on my computer and so far I can controll Pitch, Yaw, Staging, Throttling so it seems like there might have been some kind of update that helps with the compatibility of windows 10 (I could be an idiot it could have been your update) but I just wanted to let you know. I'm now starting to try and figure out how to display some spacecraft data, wish me luck ^.^

I have 1 fun little question as I was tinkering. do you think it's possible to design and build a controller that would support 2 players, similar to a Pilot, Co-Pilot situation

Link to comment
Share on other sites

12 hours ago, EccentricTea said:

Hi guys, I'll Preface with a Thank you for all your work and help.

I just wanted to let you know I am running windows 10 on my computer and so far I can controll Pitch, Yaw, Staging, Throttling so it seems like there might have been some kind of update that helps with the compatibility of windows 10 (I could be an idiot it could have been your update) but I just wanted to let you know. I'm now starting to try and figure out how to display some spacecraft data, wish me luck ^.^

I have 1 fun little question as I was tinkering. do you think it's possible to design and build a controller that would support 2 players, similar to a Pilot, Co-Pilot situation

Hi there's no reason why throttle wouldn't work if you can control all the other things. Did you check the config file? You may want to try setting throttleenable = 1 or 3. see first post for details.

Link to comment
Share on other sites

  • 3 weeks later...
On 8/1/2017 at 4:33 PM, Pvt. KASA said:

Hi there! I dont know if this has been answered yet but how many digits after the comma are there for the Rol, Pitch and Heading variables?

They are 32 bit floats; 8 bits store an exponent and 24 bits store the number, giving roughly 7 digits of precision. Note that there could be 7 digits to the left of decimal point and zero to the left, or 2 to the left and 5 to the right. (This is determined by the exponent.)

But since degrees can't be higher then 360, this means that there should only be 3 digits to the left of the decimal, thus leaving 4 on the right side. However I don't see why you would need more then 1 digit to the right of the decimal point unless you where running a space program in real life :)

 

Side note: since the arduinos don't have FPUs, would it be possible to use fixed point instead of floating point? This would increase speed, and could decrees memory usage.

Edited by c4ooo
Link to comment
Share on other sites

I spent some time working on these, so I thought I'd share.

KSP Serial IO Debug Tool - A fork of the original tool, but updated for the current version. Source only. May extend to properly send/receive SAS Mode, but I just wanted something that didn't require restarting KSP all the time...

KSP Controller Arduino Code - Modified to use 74LS595 Shift registers to handle I/O (yes, I know there are better input solutions, but it's what I have). WIP, need to add stage and abort locking logic as well as LCD support.

 

Edit: I ended up turning off the CRC check to avoid connection issues.

Edited by madlemur
Link to comment
Share on other sites

@zitronen 

 - I changed my code to V016 with adding the new codeparts but i can´t get the switches of RCS / SAS and 1 AG working, although the LED have the correct state on keypressing. 
- example V16Demo->  switches were ok. 
     - i copied my codeparts to the Demo,  i didn´t wanted actually  do all the work again -> functions perfectly ... but goes sometimes "offline" ... checked twice... basicly same code but the switches weren´t recognised. ???    I have no glue...  wrong bracket-loop? 

  - now i´m running the old 018.x IOSerial with the 0.14b code ... standbymode while typing this in flight...    no problems;  

PS: yes i know, without the code you can´t check and explain. but i dont want to release here, cause not to get laughed... ;-)
PPS: by the way now realized after (1 (!) year coding),  6 LEDpins from the original Code were occupied... so stupid i am. 

win7 64; Uno; KSP1.3
LCD i2C / WS2812 strip / 5 switches 

Edited by sec3
Link to comment
Share on other sites

On 19.8.2017 at 7:16 PM, zitronen said:

Sounds like your plugin and arduino code versions are not compatible? I'm not quite sure what exactly you want to do, but check page 68 for the example SAS code.

thanx.  Is the compatibility checked by somewhat else as the missing defines (from the PlugIn) ?  

I just wanna refresh/update the Version, nothing special.  maybe monitor the SAS state or so on the LCD/ RGBs,  or cycle-switch them on an 4D-Video-Mixer-Poti. 

 

Link to comment
Share on other sites

Most of the time you just need to compare the new arduino demo code with yours. Most importantly, check "struct VesselData" and "struct ControlPacket" are the same, and see if you are missing any #defines. If it's not the same, copy to new code to your old code.

Edited by zitronen
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

I've been trying to figure this out for several days with no success. Maybe it's a limitation of the plugin?

Just downloaded and installed the latest plugin, and have it working with both the game and the debug tool (which is WAY easier!). I can throw physical switches to affect the game, and this turns on/off LEDs. Great success.

I've got a 4D systems uLCD-43 LCD screen that I want to use to create a display. I've coded up the display to look like the old Apollo DSKY and want to send parameter values like Radar Altimeter to the screen. I have Serial2 started up, and can send data to the screen (example: just write "1234" to one of the fields on the screen) but doing so breaks the communication with the game. Using the debug tool confirms that it is no longer receiving my switch inputs from the arduino, nor can I send commands back to it. Starting up the serial port and attaching the screen doesn't seem to cause the problem. It's when I actually tell it to "genie.WriteObject()" that issue arises. The logs show it is connecting to COM5, which is my arduino mega, but nothing is happening after that.

Datasheet for the screen can be found here: http://www.4dsystems.com.au/product/uLCD_43/

I don't mind buying a different LCD since others seem to have had luck with those (though I cannot find any source code examples for displays like Zitronen's). I'd prefer to make this display work since I've got it laying around. Any help would be appreciated, thanks!

[LOG 13:58:09.485] [UIApp] OnDestroy: KSPedia
[LOG 13:58:09.500] [PlanetariumCamera]: Focus: Kerbin
[LOG 13:58:09.501] [UIMasterController]: HideUI
[LOG 13:58:10.166] UICanvasPrefabSpawner FlightUI spawning Flight
[LOG 13:58:10.188] UICanvasPrefabSpawner FlightUI spawning VesselLabels
[LOG 13:58:10.190] [UiApp] Awake: ResourceDisplay
[LOG 13:58:10.195] [AddonLoader]: Instantiating addon 'AeroGUI' from assembly 'KSP'
[LOG 13:58:10.198] [AddonLoader]: Instantiating addon 'KSPSerialPort' from assembly 'KSPSerialIO'
[LOG 13:58:10.200] KSPSerialIO: Version 0.19.0
[LOG 13:58:10.201] KSPSerialIO: Getting serial ports...
[LOG 13:58:10.202] KSPSerialIO: Output packet size: 200/255
[LOG 13:58:10.204] KSPSerialIO: Found 3 serial ports
[LOG 13:58:10.205] KSPSerialIO: trying default port COM1
[LOG 13:58:14.729] KSPSerialIO: KSP Display not found
[LOG 13:58:14.732] KSPSerialIO: trying port \Device\Serial0 - COM1
[LOG 13:58:19.238] KSPSerialIO: KSP Display not found
[LOG 13:58:19.240] KSPSerialIO: trying port \Device\USBSER001 - COM5
[LOG 13:58:23.749] KSPSerialIO: found KSP Display at COM5
[LOG 13:58:23.750] [AddonLoader]: Instantiating addon 'KSPSerialIO' from assembly 'KSPSerialIO'
[LOG 13:58:23.754] [PlanetariumCamera]: Focus: Kerbin
[LOG 13:58:23.756] [UIMasterController]: HideUI

Edited by ajden
edit to add debug log
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...