Jump to content

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


zitronen

Recommended Posts

1 hour ago, ryan00793 said:

What drivers did you use (I just ordered the module that you linked)

None (or W10 found some on its own, not sure now). I didnt instal anything related to CH340. Plug n Play :wink: 

1 hour ago, Freshmeat said:

Just to clarify: You get a USB-TTL converter, plug it to GND, TX and RX pins on your Arduino, short VCC and +5V on the module, and run the code as usual?

Yup, exactly as you said. I just dont used arduinos usb as power source. Idk what happen if both Atmega16U2 and CH340 will be present during handshake.  For code, there are no modification at all. Technicaly this is only hardware change.

Link to comment
Share on other sites

2 hours ago, Mattew said:

Yup, exactly as you said. I just dont used arduinos usb as power source. Idk what happen if both Atmega16U2 and CH340 will be present during handshake.  For code, there are no modification at all. Technicaly this is only hardware change.

I have a PSU supplying power, and it has annoyed me to no end that the Arduino draws power from USB when i flick the power switch to 'off'. I might install a CH340 for that reason alone.

Link to comment
Share on other sites

16 hours ago, Mattew said:

Okaaay. Just finished tests with my control panel + CH340. I had no issues so far, everything works as expected. Connection is fine. Recived and transmited data are okay too.  I think we can say that problem is in Atmega16U2 chip or its drivers. That isn my expertise so I cant say why is that.

If anyone strugling in Win10 with his or hers custom control panel and dont want wait for fix (or maybe it wont be even possible to fix) you can get same USB-TTL-Thing as me. 

Interesting. That does indeed seem to indicate problems with the way the original Arduino driver plays with the current serial library.

I do have one more thing I want to try - recompiling the serial library on a Windows 10 system. And I'm currently standing up Visual Studio Community on my Windows install to try it out. But apart from that I don't have any suggestions apart from just trying another serial interface. :(

Link to comment
Share on other sites

GAH! Looking for a Mega 2560 that has the CH340G chip is excruciatingly annoying! All the listings on eBay seem to include BOTH 16U2 and CH340G, just to snag extra hits...
Makes searching a pain! :confused: Anyway, I need to give up my search and get some sleep... Getting up for work is rapidly approaching... and my being asleep is not... :huh:

I'm running on Mac OS, but I'd rather have a unit that CAN run on Windows 10. I'd like that incase I ever need to test with my Win 10 (dual boot), or if I travel to some event (like a maker faire, etc) with my controller and tablet... It's a dual core i5, and I can still launch small craft just fine)

Link to comment
Share on other sites

  • 2 weeks later...
5 hours ago, zitronen said:

Just waiting for 1.2 to release.

Don't we all :wink:

 

Answering @hawk_za: No, there is no difference between 32 and 64 bit installation. Unzip into gamedata. You might want to check the settings in the config file in the plugin folder, so KSP does not override your input.

Edited by Freshmeat
Link to comment
Share on other sites

If it helps anyone: I  was having the issue on Win10 where the Arduino worked for a few seconds then just stopped, 

I only need to use this to get data out for a display panel, so I've disabled handshake in the config.xml, and commented out //output() in the main loop in the example Arduino file and it seems to be stable.

 

The problema appears to be with the Arduino sending data, not KSP trying to read it;  I took all of the port.read() statements out of the KSP plugin and it made no difference.

 

Edit: and here's my prototype display!   I also modified MNDeltaV to show remaining deltav not total.  https://youtu.be/h_E09jtD0vg

 

Edited by JeffSergeant
Link to comment
Share on other sites

On 15.9.2016 at 11:37 PM, Mattew said:

Just sit tight with me and have fingers crossed. I ordered from ebay  that USB-TTL module with CH340 chip and REALY hoping it will work. I am guessing 10-14 days until it arrives so lets wait. 

 

EDIT:

So today i got a little surprise from ebay. That USB-TTL module actualy come TODAY! unbeliveable. But sadly i am not home and cant do serious testing. Buuuut i made quick test (Uno with KSPIODemo13) and comunication was handled by CH340 convertor insted of Uno`s on board Atmega16U2. And guess what? IT WORKS ABSOLUTLY PERFECT! Yes, KSP IO pluggin is working under Win10 with no issues (kind of). I got communication both ways, in and out. I got throttle from uno board even when there werent any controler (probably getting false signals on unconnected analog input) and it was seen in game on actual throttle. From those few short test I didnt lost comunication with board and seem absolutly fine. I will get home tomorow and ll be able to run some full test, especialy connect my full control panel using CH340 and see how it goes. Probably run some quick Mun mission and see if it will held up whole time with no issues (I guess it will be ok). 

So long story short, Win10 have issues comunicate over Atmega16U2 but CH340 run fine.  I hope it will some of you more experianced guys (or girls) some idea how to fix code insted of telling ppl to go buy CH340 TTL module. 

Sadly they don't ship to germany, so I tried one of them: http://www.ebay.de/itm/112103375411?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

avrdude: no programmer has been specified on the command line or the config file
         Specify a programmer using the -c option and try again

That's what the arduino ide says when I try uploading to the board. The internet refuses to help. Do you have any idea?

 

I think it's because I'm uploading on the mega2560 via the usb-ttl. What's the solution to this? NO, usb directly into the mega 2560 brings the same result.

Link to comment
Share on other sites

On 01/10/2016 at 11:53 AM, JeffSergeant said:

If it helps anyone: I  was having the issue on Win10 where the Arduino worked for a few seconds then just stopped, 

I only need to use this to get data out for a display panel, so I've disabled handshake in the config.xml, and commented out //output() in the main loop in the example Arduino file and it seems to be stable.

 

The problema appears to be with the Arduino sending data, not KSP trying to read it;  I took all of the port.read() statements out of the KSP plugin and it made no difference.

 

Edit: and here's my prototype display!   I also modified MNDeltaV to show remaining deltav not total.  https://youtu.be/h_E09jtD0vg

 

Hey can you share which variable from KSP gives you delta V remaining?

Link to comment
Share on other sites

20 hours ago, Freshmeat said:

If it does not work with either the CH130 nor the usb cable it must be something else. The error message sounds as if the IDE is set up wrong. Can you try on a win 7 machine?

I reinstalled the ide.

Now I can upload the code through the "normal usb connection delivered by the mega2560.

And it runs with the usb->ttl CH340. The serial monitor gets data from the board. So next step, let's see what KSP has to say about this.

Edited by Benji
Link to comment
Share on other sites

On 10/4/2016 at 4:54 PM, zitronen said:

Hey can you share which variable from KSP gives you delta V remaining?

sure, I found it by looking at the source for KRPC (https://github.com/krpc/krpc) , a goldmine for this sort of thing!  I made this change in the update() function of KSPSerialO, no idea if it's the right way of doing it but it seems to work

 

if (ActiveVessel.patchedConicSolver.maneuverNodes.Count > 0)
                            {
                                KSPSerialPort.VData.MNTime = (UInt32)Math.Round(ActiveVessel.patchedConicSolver.maneuverNodes[0].UT - Planetarium.GetUniversalTime());
                                //KSPSerialPort.VData.MNDeltaV = (float)ActiveVessel.patchedConicSolver.maneuverNodes[0].DeltaV.magnitude; //removed JS
                                KSPSerialPort.VData.MNDeltaV = (float)ActiveVessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(ActiveVessel.patchedConicSolver.maneuverNodes[0].patch).magnitude; //Added JS
                                
                            }

 

 

I've also since upgraded my instrument panel to a project box.  It's doing the job for now :)   http://i.imgur.com/TNvZcfM.jpg

 

Edited by JeffSergeant
Link to comment
Share on other sites

On 6. 10. 2016 at 4:11 PM, zitronen said:

is what everyone really wanted?

Oh yes, its someting realy missing :wink: But isnt we running out of space in data packet?

Edit: Anyone else already got CH340 module and test it? So we can finaly for 100% said where is issue with W10 and KSPIo

Edited by Mattew
Link to comment
Share on other sites

10 hours ago, zitronen said:

I would simply replace the old node delta V value with delta V remaining. I would also like to add target speed and distance though.

I must have missed a memo... What did node delta V even do? was it just a static value of the total of a maneuver node? I mean, that's really only useful when paired with remaining ∆V, to calculate the percentage of a burn remaining.

Seems to me like node ∆V and remaining ∆V could be used to recreate the analog "burn meter" that's on the left of the in game navball... Or am I missing something?
I was planning on constructing the assembly below. It displays maneuver node ∆V remaining, time to burn, and displays via mechanical positioning, the percentage of the total burn remaining. It's a steel bar and a threaded rod, in a mechanism much like that of a floppy drive or optical drive head assembly. It'd read out the ∆V remaining value, and I figured I'd have to manually set the node total ∆V with a manual button to "lock" the node in. Node remaining ∆V is definitely the important one.

Spoiler

KerbalCM_NodeDispaly.png

(Spoilered to reduce clutter)
Current method of operation would be to set up a maneuver node in the game. When it's where I want, I'd press a Maneuver Lock button on my controller, and the meter carriage would slide to the top position, and the maneuver node remaining ∆V would be stored in a total ∆V variable. The time to node and ∆V will display on the meter carriage. If remaining ∆V drops, it'll read the numeric value live, and the carriage will drop lower based on the percentage of the remaining ∆V out of the stored total ∆V, from when the Maneuver Lock button is pressed. When it gets to 0 ∆V, the meter carriage would be at the bottom of it's scale.

Target Speed and Distance is a big deal though. Most certainly need those... **Scratches head** Hmm... do we have maneuver and target vectors too? I don't recall.

Anyone else feel like Arduinos are sitting right at the edge of just barely performing all the stuff we want them to do... :confused:

Link to comment
Share on other sites

Hmm.. can you not just save the delta V remaining at the start of the burn for your meter? @stibbons was working on the vector stuff.

We definitely are getting to the limit of what arduinos can handle. And to think when I started this I thought surely 255 bytes should be enough for everybody...

My long term plan is to make KSP send packets through UDP, and have a C# program that converts these to serial and sends the different packets to different COM ports. This way you can have multiple arduinos plugged in the same computer and it should also solve the windows 10 problem. Seems like a lot of work though, probably will take a while I get around to doing it.

Link to comment
Share on other sites

6 hours ago, zitronen said:

Hmm.. can you not just save the delta V remaining at the start of the burn for your meter? ...

That's actually what I have planned... I'm just   confused   curious (naw, still confused :confused: ) what the old behavior of node ∆V was... Cause I'd always assumed it worked like ∆V remaining. As I said... Must have missed the memo, crossed the lines, etc, etc.

I look forward to whatever Stibbons figures out! :prograde:

I don't know how the software you described would work to split everything off, but if you ever achieve a piece of software that can indeed do just that, You'll have my respect and gratitude! :D

Link to comment
Share on other sites

6 hours ago, zitronen said:

 when I started this I thought surely 255 bytes should be enough for everybody...

Now littla noob question from me since I am not expert on these communications, we cant just add another 255 bytes? like send two packets ot something like that?

On that splitting data to diferent arduinos, I did and I am using kind of such thing. More hardware based. My Mega2560 is acting as main board and there is little instruction that take speed data, save it as unit_32 value and then send over RX1,TX1 to UNO board which is acting as control procesor for nixie tubes. I like that concept so much that Iy plan to create for each function (displays, nixies, controls) to have its own processor . Sound good. 

Link to comment
Share on other sites

7 hours ago, zitronen said:

@stibbons was working on the vector stuff.

Very, very slowly. Last update, I was trying to get a decent handle on how vectors and quaternions work in Unity3D. That's painful to my brain that rarely has to write code more complex than Puppet manifests, and it's been taking a back seat to Real Life lately.

7 hours ago, zitronen said:

My long term plan is to make KSP send packets through UDP, and have a C# program that converts these to serial and sends the different packets to different COM ports. This way you can have multiple arduinos plugged in the same computer and it should also solve the windows 10 problem. Seems like a lot of work though, probably will take a while I get around to doing it.

I'd been looking at how other flight sims implement their serial interfaces, particularly FlightGear and Objects in Space. On the one hand, I'm not especially fond of introducing more latency with a network hop, even if it's over the loopback interface. But on the other hand, pulling the serial code out of KSP itself should address all of the weird cross-platform woes we experience using the Unity version of mono.

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