Jump to content

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


zitronen

Recommended Posts

On 10/9/2018 at 1:16 AM, ohMorrissey said:

I have my simpit finished and functional, control and all (windows 10 btw!) 

Is there anything that could cause intermittent connection drops? 

The code multi tasks to read 5 ICs and write to one screen but it doesn't stop talking to KSP while it does so, was wondering if there is anything else? 

First of all, it is a sick setup you have. Very cool looking, and from the looks of it highly functional.

Second, when I had dropouts, I had some more demanding tasks only run once or twice per second. It is quite sufficient to know for instance your fuel level to that timescale. And as zitronen said, increase your buffer. A Mega has a ton of ram compared to an Uno.

Link to comment
Share on other sites

On 10/10/2018 at 8:34 PM, zitronen said:

You can try increasing the size of the rx buffer in HardwareSerial.h in your Arduino install.  If that doesn't work or if you are very low on SRAM you can turn down the refresh rate in the plugin config file.

I'll give both a try individually then together if it doesn't help enough, Ill let you know

 

On 10/11/2018 at 12:29 AM, Freshmeat said:

Second, when I had dropouts, I had some more demanding tasks only run once or twice per second. It is quite sufficient to know for instance your fuel level to that timescale. And as zitronen said, increase your buffer. A Mega has a ton of ram compared to an Uno.

My more demanding functions are run once over about 60 loops, I use a global timer, 

Originally when I used my IC's the shift in and shift out functions caused SerialIO to drop out (They use bout 30ms worth of the delay function), so now it runs over multiple loops, eg: 

int GlobalTimer = 1;

void loop(){

input();

if (GlobalTimer == 1) {
// Pulse latch pin
}

if (GlobalTimer == 20) {
 // Read first pulse from ICs
}

if (GlobalTimer == 23) {
 // Read Second pulse from ICs, etc for all 8 pulses, 3 ms apart
}

if (GlobalTimer == 60){
// Run HUD functions 
GlobalTimer = 0;
}

GlobalTimer++;
delay(1);
}

 

Link to comment
Share on other sites

Yeah don't use delay(), since it stops everything, really bad.

instead of

GlobalTimer++;
delay(1);

Do it this way

now = micros();
dt = now - dtOld;
if (dt >= 1000) {
  dtOld = now;
  GlobalTimer++;
}

Also do you really need to update stuff every 60ms?

Link to comment
Share on other sites

btw.   my Board runs well at  KSP  V1.5.1 / Serial IO V1.4 / Arduino V18.4 (?  i have the *.ino-base with just 54 attributes to TargetdV) / Win7

 

PS:  Dez. 2018  -> KSP    V 1.6.0  works well. 

Edited by sec3
Link to comment
Share on other sites

  • 3 months later...

So, with the fuel data work right now, there is no way to detect if an side booster/engine has run out of fuel, should something be done about it?

 

Also should I fix the stupid thing where you can only target Vessels and not celestial bodies?

Edited by c4ooo
Link to comment
Share on other sites

Question for people using Teensys - did you get it working in Win10?

I ask as I was able to connect the Teensy to the debugging tool with a bit of tweaking. Messages are sent back and forth no prob. However, if I try to connect with KSP, it gives the "no display found" error. I'm not sure why it would work for the debugger tool and not KSP.

I'm using Teensy 3.6,  Arduino 1.8.7, KSP 1.6.1

I can get it working no probs with Arduino - just having some issue getting Teensy up and running with KSP. Any help would be greatly... ummm... helpful and appreciated.

Edit: (FIXED!)
Checking the specific reason of my failed connection the log file give this error: "CreateFile Failed: 2" - this led me to search way back in this thread and I found a suggestion to change the port name to something lower than COM10 might work, and it did.
So for WIn10, if you're getting "CreateFile Failed: 2" errors AND have a COM port higher than COM9, try change to a lower COM port.

So I'm back up and running again. :) This time on a Teensy 3.6!

Edited by wile1411
Link to comment
Share on other sites

Ok - follow up query for @zitronen regarding the issues I experienced. Just curious - was there a reason (maybe KSP limitation) on why the mod used "OpenNETCF.IO.Ports" instead of "System.IO.Ports" that is in the Debug tool?

It seems that the KSPSERIALIO debugtool doesn't require the serialport.dll and is a little more robust with COM ports > COM9. However, the OpenNETCF SerialPort.dll included with this mod seems to be unable to utilize higher COM ports for some reason. At least that is the comments I see in this thread and with my own experience.

Saw the OP issues notes (sorry! :blush:)
 

 

 

 

Edited by wile1411
Link to comment
Share on other sites

  • 4 weeks later...

Hi guys, I've just started to play some KSP again, realised I forgot to actually put the new version out.

 

Update 0.19.1:

Changes:

  • Added pro-grade, maneuver, and target pitch and heading angles, as well as normal vector, thanks to @c4ooo
  • Recompiled against KSP version 1.6.1, seems to work OK

Plugin download link:

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

Arduino code dowload:

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

 

If you were using a previous version (demo 16), just add the following to your arduino code data structure:

int16_t ProgradePitch;   //56 Pitch   Of the Prograde Vector;  int_16 ranging from (-0x8000(-360 degrees) to 0x7FFF(359.99ish degrees)); 
int16_t ProgradeHeading; //57 Heading Of the Prograde Vector;  see above for range   (Prograde vector depends on navball mode, eg Surface/Orbit/Target)
int16_t ManeuverPitch;   //58 Pitch   Of the Maneuver Vector;  see above for range;  (0 if no Maneuver node)
int16_t ManeuverHeading; //59 Heading Of the Maneuver Vector;  see above for range;  (0 if no Maneuver node)
int16_t TargetPitch;     //60 Pitch   Of the Target   Vector;  see above for range;  (0 if no Target)
int16_t TargetHeading;   //61 Heading Of the Target   Vector;  see above for range;  (0 if no Target)
int16_t NormalHeading;   //62 Heading Of the Prograde Vector;  see above for range;  (Pitch of the Heading Vector is always 0)       

 

Edited by zitronen
Link to comment
Share on other sites

First of all, thank you for keeping the mod alive. I have spent literally hundreds of hours building control panels, and learned everything I know about electronics and microcontrollers due to this plugin, knowledge that turned out handy in my job as well.

Second, just to be sure: When you are flying prograde, your VData.ProgradePitch will have same value as VData.Pitch, right? Then you have just solved a thorn in my code as the data I could get from kRPC was troublesome.

Third, I am not certain what you mean by NormalHeading value. How does it differ from Heading?

Fourth: Welcome back to the explody rockets.

Edited by Freshmeat
Link to comment
Share on other sites

On 4/2/2019 at 10:56 AM, Freshmeat said:

Second, just to be sure: When you are flying prograde, your VData.ProgradePitch will have same value as VData.Pitch, right? Then you have just solved a thorn in my code as the data I could get from kRPC was troublesome.

Third, I am not certain what you mean by NormalHeading value. How does it differ from Heading?

Yep pretty much, although of course if you pull up sharply, VData.ProgradePitch will lag behind VData.Pitch (changing your pitch doesn't immediately change vertical velocity).

 

As for the NormalHeading value, this should be the Heading of the Normal vector. There is no Pitch for the Normal vector becouse it always sits on the orbital plane (Pitch = 0).

I didn't know this at the time of my pull request, but sending this isn't necessary - the NormalHeading should always be ProgradeHeading + 90. Thus it probz wont hurt to remove it.

Also you can easily get the Radial vector pitch/heading from the the Prograde and Normal vectors, so no need to send that either.

Edited by c4ooo
Link to comment
Share on other sites

@c4ooo: Thanks for clarifying. I want to have an alarm going off whenever I deviate to much from prograde as my constructions are not always that aerodynamically stable.

BTW @zitronen: Why in the range from -360 to 360 instead of -180 to 180? I can perfectly live with it, but it seems like a strange choice.

The word normal is a funny one. In math, it is the perpendicular, but in everyday use, it is what is expected, hence my confusion.

Link to comment
Share on other sites

5 hours ago, Freshmeat said:

BTW @zitronen: Why in the range from -360 to 360 instead of -180 to 180? I can perfectly live with it, but it seems like a strange choice.

IIRC I didn't like the idea of negative headings. Otherwise, the range -180 to 180 could have been used :)

Link to comment
Share on other sites

I Love that this thread is still alive, I have a bit of a bug that I was wondering if you guys have seen before. 

When I load up a rocket so going from the V.A.B. to the launch pad occasionally ~30-40% of the time its seems like things don't load right. I have no control over the rocket and the stages on the left hand side are all missing. the work around that I found is just to return to the V.A.B. and just reload the rocket and most of the time that fixes it.

I'm not sure if this has to do  with me changing the baud rate in the config file and code to 115200. Or if this is a handshake issue where I just need to increase the handshake wait time.

I'm also using an arduino mega with almost every IO being used (yes it's a big control panel) and I'm not sure if having so many IO's is causing a delay.

Link to comment
Share on other sites

On 4/5/2019 at 10:31 AM, Freshmeat said:

@c4ooo: Thanks for clarifying. I want to have an alarm going off whenever I deviate to much from prograde as my constructions are not always that aerodynamically stable.

 

Yeah this should work. Just divide the raw prograde pitch/heading value by 50.0 to get heading in degrees.

 

On 4/5/2019 at 8:30 PM, EccentricTea said:

I Love that this thread is still alive, I have a bit of a bug that I was wondering if you guys have seen before. 

When I load up a rocket so going from the V.A.B. to the launch pad occasionally ~30-40% of the time its seems like things don't load right. I have no control over the rocket and the stages on the left hand side are all missing. the work around that I found is just to return to the V.A.B. and just reload the rocket and most of the time that fixes it.

I'm not sure if this has to do  with me changing the baud rate in the config file and code to 115200. Or if this is a handshake issue where I just need to increase the handshake wait time.

I'm also using an arduino mega with almost every IO being used (yes it's a big control panel) and I'm not sure if having so many IO's is causing a delay.

If what freshmeat said doesn't work, can you post the debug log? It can be either the plugin not detecting your arduino or something wrong in the arduino code.

Link to comment
Share on other sites

well I think I figured it out, and it a bit specific to my setup since I'm using almost every I/O on the arduino mega and I'm running 8 max7219 Ledcontrol chips so its controlling over 512 leds and that is taking so long the code freezes up so I'm decreasing how many are getting updated each time through the code and so far thats working.

Link to comment
Share on other sites

@EccentricTea Same happened to me, should have thought about that as well when I tried to help. A lot of functions only need updating every second,. I used to do it on 250ms rolling updates, spreading the computationally expensive updates even (Arduinos are not exactly found of trigonometry). BTW, do you have any pictures of your console? I am rather intrigued by now.

Link to comment
Share on other sites

14 hours ago, EccentricTea said:

Do I have to upload the photos to another site first just to point a URL at it to get the photo in my post or is there a better way?

You will need to upload to somewhere else. The forum used to play well with Imgur, but you can use whatever you fancy. If you make a thread over at Fan Works, we can all chime in with our applause.

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