Jump to content

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


zitronen

Recommended Posts

[quote name='zitronen']Huh... Anyone else have the same problem with 0.17.6?

Oh just making sure... you have the handshakedisable set to 1 right?[/QUOTE]

Yes I did ... but i have a feeling that my arduino is a bit bonkers, it seems to keep rebooting/resetting every 10-60 seconds (abit somewhat random)... Gonna test with another chip :D
Link to comment
Share on other sites

[quote name='zitronen']Do you have a link to your project?


Not yet I am with family for the U.S. holiday weekend. They do not have internet and I am tethered to my phone. I have interfaced the serial and ethernet Data providers. I need to wait until mondayish to get my own arduino to test the serial portion to make sure I didn't break anything in it.



After I can test the original serial code in the new ISerialProvider interface code I wrote I will write an ethernet bridge that bridges an ethernet port to a physical com port, written and compiled with Visual C# against .net 4.5 so that it will run on windows 10 and get around the whole mono.net serial issue. So wednesdayish if work doesn't get in the way. There may exist a program that will forward a com port to a TCP/IP socket already, if there is that would be awesome because then I wouldn't need to write it, so if anyone can find one that would be awesome and I will test against it.
Link to comment
Share on other sites

3 hours ago, Scoppio said:

I'd like to thank you Zitronen, with your plugin I was able to create my TV-avionics.

This small gadget was a central piece for me to showoff my skills and get a job as a hardware developer in a new startup! :kiss:

Wow, awesome. Congratulations on the job, hope you get succesful on the startup.

Link to comment
Share on other sites

On 29/11/2015, 15:39:20, Freshmeat said:

A belated reply to 17.6 fixing SAS: It works, as long as you have SAS control in your controller instead of on keyboard. Turns the indicator of on the navball as well. It seems my problems came from not updating my code from17.3 or so :blush:

OK that's good I guess. I don't remember changing anything in the arduino code for SAS though...

On 30/11/2015, 12:58:44, Scoppio said:

I'd like to thank you Zitronen, with your plugin I was able to create my TV-avionics.

This small gadget was a central piece for me to showoff my skills and get a job as a hardware developer in a new startup! :kiss:

Nice, I am waiting for my 10% share of all your future income. Wait what do you mean you didn't read the contract?

14 hours ago, Keith Young said:

I am trying to use this with Raster Prop Monitor.

I'm having trouble since this is .NET 4.5 rather than 3.5

Is there a way to get this to work in 3.5? Is there a way to get this to work with MechJeb2 and/or Raster Prop Monitor?

Ah.. which version of the plugin are you using? I can recompile it for you or you can do it yourself. I don't intend on adding support for MJ or anything else because it's hard enough debugging hardware firmware and software problems over the interwebs. The best option is to try to fork the plugin to do you own thing, which a quite a few people have done.

Link to comment
Share on other sites

3 hours ago, zitronen said:

Ah.. which version of the plugin are you using? I can recompile it for you or you can do it yourself. I don't intend on adding support for MJ or anything else because it's hard enough debugging hardware firmware and software problems over the interwebs. The best option is to try to fork the plugin to do you own thing, which a quite a few people have done.

I'm currently using 1.04 but will be upgrading to 1.05 probably soon.

I'm not sure but I think the problem is in the SerialPort.dll.

Link to comment
Share on other sites

On 04/12/2015, 07:23:38, Freshmeat said:

Just making sure: Latitude and longitude are in degrees with decimal fractions, not degrees-minutes-seconds, right? Toying with ILS for my experiments with airplanes.

Yeah I'm pretty sure it is.

Link to comment
Share on other sites

https://github.com/tjandearl/KSPSerialIOOverEthernet

 

 

I have been busy moving, my wife and I just got our first house.  I got this working over ethernet.  I think that you can always use system.Threading in a mono/unity environment, just that unity is not thread safe.  The original code will probably work if you spin up a new thread and just loop while true with a break clause cleanup, and then you just read all the available data and work through it.

 

 

I separated some code into files and made the read routine which was apparently borrowed a bit easier to grok.  The current state of the code only uses the SerialOverEthernetProvider and I don't have the settings hooked back up yet.  I tested the TCP/IP stuff over a program called TCP-Com which may work for you windows 10 users.  If you build the code as is and set up TCP-Com as a server that listens on port 5000 connected to the Com port of your arduino it will work.  TCP-Com has a 30-day trial.  I have to go to bed soon and get to work but I will post binaries tomorrow.  I have all of next week off and we're all moved already (just unpacking woo!).

 

 

I need someone with windows 10 to confirm it works, and maybe you guys can be golden again.

 

@djnekkid    My arduino does the same as yours does with the app.  Look up this: http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection   Newer arduinos auto-reset on a new serial connection DTS high or low.  The Arduino IDE uses this to program the arduino without manual reset.  Disabling auto-reset should fix your issue with the arduino resetting.

Link to comment
Share on other sites

Very nice! Have you looked at some of the free TCP-Serial software on sourceforge (yeah I know SF is **** now)?

If you can't get them to work would you be able to forward the data as a simple UDP thing? I might be able to reuse some old code to go from UDP to serial. This way you don't have to depend on the ridicules $199 shareware thing.

Edited by zitronen
Link to comment
Share on other sites

  • 3 weeks later...

Newbie question here. I cant seem to make my LCD display for the arduino update the Pitch, Heading and Yaw values at all. The display simply shows "0.00"

 

Here is my code. Please bear in mind that im very new to Arduino and C in general. I have experience with C# and VB so im still getting my head around a code change.

 

void loop()
{
    input();
    output();
  
  lcd.clear();
  lcd.setCursor(0,2);
  lcd.print(VData.Pitch);   //PITCH
  lcd.setCursor(0,0);
  lcd.print("PITCH");    
  
  lcd.setCursor(6,2);
  lcd.print(VData.Heading);
  lcd.setCursor(6,0);
  lcd.print("YAW");    //YAW
  
  lcd.setCursor(12,2);
  lcd.print(VData.Roll);
  lcd.setCursor(12,0);
  lcd.print("ROLL");    //ROLL
  
  delay(500);


}

 

Further Info: 

  • running KSP 1.0.5 (issue?), all stock, except plugin. 
  • Windows 7.
  • Arduino Mega.
  • Demo example from tutorial, wish LCD libraries imported and configured.
Edited by JoeKickAss
Link to comment
Share on other sites

Can you get the LED demos working? Try that first to make sure there are no other weird issues.

The most obvious problem with your code is the delay(500). Unlike high level languages that deals with the OS, manages threads, n'stuff, all the code on the arduino is in a single thread. So when you do delay(), you are stopping everything, including send/receive from serial port.The loop() function needs to run as fast as possible, so to make this work you need to move your code inside the input() function, where there is a if statement checking when a complete packet has been received. This way your code is only ran when needed rather than all the time.

Link to comment
Share on other sites

On 1/5/2016 at 9:34 PM, zitronen said:

Can you get the LED demos working? Try that first to make sure there are no other weird issues.

The most obvious problem with your code is the delay(500). Unlike high level languages that deals with the OS, manages threads, n'stuff, all the code on the arduino is in a single thread. So when you do delay(), you are stopping everything, including send/receive from serial port.The loop() function needs to run as fast as possible, so to make this work you need to move your code inside the input() function, where there is a if statement checking when a complete packet has been received. This way your code is only ran when needed rather than all the time.

Thanks mate, got it sorted! Really appreciate the help! I have a 4 gimbal nav ball project in the works. I have all the gimbal conversion maths downpat, and arduino/KSP integration was the last foundation bit. Now to actually build the thing!

I hope to put a full tutorial and write up including code and maths behind it when its done. Fingers crossed!

Link to comment
Share on other sites

Hi everyone,

I am curently trying to make serial communication work between ksp and an arduino/ftdi usb...

I am on windows 10 and use the last version of the mod with disabled handshake.

Until now I can receive data on serial but only strange signs like a lot of <?>.

If anyone have an idea on what could cause that I would be pleased to read it ^^

Thanks for all your work ;)

Link to comment
Share on other sites

27 minutes ago, zitronen said:

Are you using your own arduino code? Have you tried the tutorial code?

I tried both, my own with a software serial in order to see the data received. 

With the tutorial code I get nothing from pin 5 6 7 or 11 12 13 but the rx pin blink.

Link to comment
Share on other sites

16 hours ago, hitmeifu said:

I tried both, my own with a software serial in order to see the data received. 

With the tutorial code I get nothing from pin 5 6 7 or 11 12 13 but the rx pin blink.

Good morning hitmeifu,

I was having troubles as well but I ended up modifying the arduino code to set the idle time to longer and it looks like it works.  Using just the regular code, I found out that when the ship would load on the launch pad I was getting data for a very short amount of time (like 20 seconds in total) by expanding the idle time numbers I havent lost connection between the board and KSP.  Also, are you using the most updated code? I know in the OP it has KSPdemo12, but here's the link to the most recent one

 

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

 

Safe flying!

Link to comment
Share on other sites

okies so I was kinda messing with some stuff and I was able to RX with the handshake enabled on Windows 10.  I could only RX and not TX....but my TX light is flashing very very slowly.

I dont know if it matters but I adjusted the Arduino code to this.

void Handshake(){
  digitalWrite(CONNECTEDLED,HIGH); 

  HPacket.id = 0;
  HPacket.M1 = 1;
  HPacket.M2 = 2;
  HPacket.M3 = 3;

 

i hope this helps a little bit....now i'm off to solder all the LEDS!

Link to comment
Share on other sites

On 15/1/2016 at 3:07 PM, Colray said:

Good morning hitmeifu,

I was having troubles as well but I ended up modifying the arduino code to set the idle time to longer and it looks like it works.  Using just the regular code, I found out that when the ship would load on the launch pad I was getting data for a very short amount of time (like 20 seconds in total) by expanding the idle time numbers I havent lost connection between the board and KSP.  Also, are you using the most updated code? I know in the OP it has KSPdemo12, but here's the link to the most recent one

 

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

 

Safe flying!

I was using the demo 12 thanks for the links to the newest one.

Now I am getting a constant tx led on and it is working for 20s like you.

I changed idle time both in kspIO mod and in arduino program but serial communication stop after this time.

I also tried while disabling or enabling handshake but I get the same result.

Link to comment
Share on other sites

On 1/16/2016 at 1:12 PM, hitmeifu said:

I was using the demo 12 thanks for the links to the newest one.

Now I am getting a constant tx led on and it is working for 20s like you.

I changed idle time both in kspIO mod and in arduino program but serial communication stop after this time.

I also tried while disabling or enabling handshake but I get the same result.

what did you end up adjusting your time to? I ended up pushing my idle timers out to like 20 mins or something like that (I smoke, and I know there is no way I could smoke an entire cig in 2 mins).  The only time I adjusted was the time in the Arduino program and I haven't had any problems.  This is what my code looks like. I only changed time on the KSPIO13 tab.

//if no message received from KSP for more than 20mins, go idle
#define IDLETIMER 1200000
#define CONTROLREFRESH 2000

I hope this helps some.

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