Jump to content

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


zitronen

Recommended Posts

Ok, weird bug...
I built a spaceplane, launch it... when i end up on the runway, the action groups (and gear, lights etc) all work every time, but the analog controls are all not responding...
If I 'revert to launch', about half the time, the analog controls kick in... O_o

Got NO clue what's going on! O_O
Running: 0.18.3, off demo 13 as basecode, on win7 & 64-bit kerbal, if that's any help?

Any assistance would be appreciated :)

Link to comment
Share on other sites

Hmm.. when you say "end up on the runway", is that a euphemism for "after it exploded" or did you actually land on the runway and it suddenly stops working? 

It seems like axis control hooks are not working properly, but I thought I fixed this. What happens if you switch vessel?

The latest version is 0.18.6, but I have not changed anything with the axis controls since 0.18.3.

 

Also for teensy people:

I'm not 100% sure, but If you are on a teensy you should be able to run some insanely fast serial speeds with USB serial right? (if you are not using it for debugging) You should be able to crank the refresh speed up by a lot.

Edited by zitronen
Link to comment
Share on other sites

LOL! :D I should have said 'started in SPH and launched from runway' - this is a new instance of a vehicle :)
Though landing with joysticks does get a bit... interesting, this is a problem with intact vehicles, rather than Jeb's scrapyard :wink:

Switching vessels seems to work; quicksave & quickload does not. Loading a vehicle already in orbit does not work.

Launching from VAB seems to work; launching from SPH seems to not work - but sometimes kicks in if 'revert to launch' chosen.


 

Link to comment
Share on other sites

I can confirm the problem from both VAB and SPH. Revert to launch rarely fixes it, revert to VAB/SPH often does, as well as going to space center if it is a previously launched craft I return to. I am running last version before the option for selecting SAS mode was introduced (no time for hardware upgrade yet). I have not found anything in logs. If SAS stability is chosen as SAS mode, you can see it disengages when joystick is moved, but pitch/yaw/roll indicator (the one in left lower corner) does not register anything.

Link to comment
Share on other sites

That seems to have fixed the analogue control issue - TY!!!!! :D

New prob: occasionally I'm getting a message like 'no permission to access resource' when attempting to handshake - it knows what COM port is my controller, but it's acting like the handshake is failing?
If I unplug the USB cable and replug it in, it will work again.

This one is being sporadic, and after getting hit with it 5 times in a row I can't replicate it, so ¯\_(ツ)_/¯

Seems to happen if I fly a ship, go back to space centre (or pause), change my code, then return to ship.
When it first happened in pause I figured it was just breaking the handshake / connection, but it's also happened while the game has been in space centre view / tracking station view O_o

/brain splodes

Link to comment
Share on other sites

I can confirm that things seem to work as well, thank you for taking your time :) The problem was very sporadic, though, so I cannot ensure you that it is totally gone. Will write if something comes up.

The SAS controllers are a treat, I really need to get an upgrade. Control a la DSKY on a wonky keypad is not recommended for time critical commands :confused:

Another thing: I do not know whether it is my programming skills or lack thereof making a mess of things, but if I disengage SAS and then use my joystick, SAS reengages. Does anyone else experience this?

Edited by Freshmeat
More bugs
Link to comment
Share on other sites

  • 3 weeks later...

I use CD4021 shift-in IC's to get more digital inputs, tutorial here. An alternative is 74HC165. For digital outputs, you can use 75HC595, and specifically for LEDs you are best off with a dedicated multiplexer like MAX7219. All of these IC's can be had very cheap off ebay. I know analogue expanders exist as well, but I have no experience in using them.

Alternatively, if you are using a lot of buttons (not toggle switches), you can run current to different sets of buttons at a time, then a single input can be shared from one button from each set. It is a bit better explained here.

Hope this helps, I am at work and my brain is busted so the last one might not make sense.

And I promised to tell @zitronen if his hotfix for the issue above worked. It does, without fail.

Edited by Freshmeat
Link to comment
Share on other sites

1 hour ago, JoshTheCoward said:

I am about 3 pins short on a mega board. Is there a module you can buy to give you more pins? 

Jesus, how many wires are you.. you know what I don't even want to know :0.0:.

 

24 minutes ago, Freshmeat said:

I use CD4021 shift-in IC's to get more digital inputs, tutorial here. An alternative is 74HC165. For digital outputs, you can use 75HC595, and specifically for LEDs you are best off with a dedicated multiplexer like MAX7219. All of these IC's can be had very cheap off ebay. I know analogue expanders exist as well, but I have no experience in using them.

Alternatively, if you are using a lot of buttons (not toggle switches), you can run current to different sets of buttons at a time, then a single input can be shared from one button from each set. It is a bit better explained here.

Hope this helps, I am at work and my brain is busted so the last one might not make sense.

And I promised to tell @zitronen if his hotfix for the issue above worked. It does, without fail.

Thanks, I'll update the the recommended version to this one this weekend.

Edited by zitronen
Link to comment
Share on other sites

Thanks for the tips, I will do some research. 

 

I have 46 wires right now. I bought digital joystick with out know whick killed me. Now need 2 inputs per axis so 12 just for attitude and translation. 22 for anuciator LEDs and 6 for switches, 10 for was buttons, 3 for speed selector, 1 throttle, 1 abort, 1 stage. So need 56 in total. Also thinking of adding a few readouts.

 

Yes a lot of wires. Is there a better way of doing it?

Link to comment
Share on other sites

2 hours ago, JoshTheCoward said:

Thanks for the tips, I will do some research. 

 

I have 46 wires right now. I bought digital joystick with out know whick killed me. Now need 2 inputs per axis so 12 just for attitude and translation. 22 for anuciator LEDs and 6 for switches, 10 for was buttons, 3 for speed selector, 1 throttle, 1 abort, 1 stage. So need 56 in total. Also thinking of adding a few readouts.

 

Yes a lot of wires. Is there a better way of doing it?

The IC's I mentioned will bring that down to two for LEDS and three for the digital inputs.

Link to comment
Share on other sites

6 hours ago, Freshmeat said:

Alternatively, if you are using a lot of buttons (not toggle switches), you can run current to different sets of buttons at a time, then a single input can be shared from one button from each set. It is a bit better explained here.

Toggle switches would work too. Just use an binary-> 5v analog converter, and map the arduino's analog input onto the range [0,255]. Then, to test if switch n is on, check to see if bit n of the input is set one.

Link to comment
Share on other sites

Re excessive wiring I like using the keypad library http://playground.arduino.cc/Code/Keypad

Or more precisely it's teensy equivalent - unsure if the linked library has any gotchas on a mega. Especially good if my buttons will be in a physical grid, just screw them in on a 45 degree angle and run wires vertically and horizontally. It's way less fun when you want to wire 12 buttons in a row as a 3*4 matrix.

I've also moved to LED strips/pixels for my panel LEDs, see adafruits neopixels/dotstars and the ebay generics they are branded from (WS2812/AP102 I think). I just make my indicators and switches round numbers of pixels apart, and glue the strip behind the panel in one go. Even if I'm 'wasting' every other pixel (where buttons are bigger than normal) it's still way fewer wires to keep track of, and I'm ok trade money for time and reliability in a case like this.

Similar to the serial chips mentioned above you could also buy a 'bare' Arduino of choice and use it as a port expander, say dedicated just to capturing all the inputs from the joystick and spitting them out on a serial port or i2C

 

Link to comment
Share on other sites

7 minutes ago, gremlinWrangler said:

I've also moved to LED strips/pixels for my panel LEDs, see adafruits neopixels/dotstars and the ebay generics they are branded from (WS2812/AP102 I think).

You know you can buy addressable LEDs in regular PTH housings as well, right? I've been using a bunch of these Adafruit ones in my build, but cheaper varieties are undoubtedly available.

Link to comment
Share on other sites

On 4/21/2017 at 2:49 PM, stibbons said:

You know you can buy addressable LEDs in regular PTH housings as well, right? I've been using a bunch of these Adafruit ones in my build, but cheaper varieties are undoubtedly available.

Yep, but I've already got left over square pixels, and options to  fab precisely spaced square holes. So it's working for me. That said, if I was starting over I'm thinking those strands you've got would be the way to go for a bullet proof build that allows round holes and less critical spacing. Those spots where they join strips often produce a step in the length which can be fun if you don't plan ahead.

What I want now is a similar strip of serial addressable inputs, so you run one behind your panel as a snake, jumper your buttons to it, and clock all your inputs in as SPI on a couple of pins. At least for things like gear select or action buttons that don't need really low latency but you do want a simple wiring harness.

Link to comment
Share on other sites

Sorry for the Newbie post, but Im trying to get the demo16 to work just to show me some warning LED indicators, But I cant get it to work, 
I added a line to turn on an LED when KSPBoardReceiveData() returns false, as a no connection indicator

This added LED turns off and the GLED flickers then in on for a moment when ever the game is loading into a vessel. As soon as its finished loading the GLED turns off and my no connection LED turns back on.

Sorry if its been talked about already but a 74 page thread is impressively long. Thankyou in advance

im running: Windows 10, KSP 1.2.2, KerbalIO 0.18.7, and using the code from demo16 on a Arduino Due (using the Programming port)

Link to comment
Share on other sites

3 hours ago, ohMorrissey said:

Sorry for the Newbie post, but Im trying to get the demo16 to work just to show me some warning LED indicators, But I cant get it to work, 
I added a line to turn on an LED when KSPBoardReceiveData() returns false, as a no connection indicator

This added LED turns off and the GLED flickers then in on for a moment when ever the game is loading into a vessel. As soon as its finished loading the GLED turns off and my no connection LED turns back on.

Sorry if its been talked about already but a 74 page thread is impressively long. Thankyou in advance

im running: Windows 10, KSP 1.2.2, KerbalIO 0.18.7, and using the code from demo16 on a Arduino Due (using the Programming port)

The problem is Windows 10. I am not qualified to explain exactly what goes wrong, but KSPSerialIO is hit and miss on that platform. Some people have had good success using an external USB->TTL chip like this one. The one I got includes a 3.3 V pin, but I have not gotten around to make the switch to either 3.3V nor Win10.

Link to comment
Share on other sites

11 minutes ago, Freshmeat said:

The problem is Windows 10. I am not qualified to explain exactly what goes wrong, but KSPSerialIO is hit and miss on that platform. Some people have had good success using an external USB->TTL chip like this one. The one I got includes a 3.3 V pin, but I have not gotten around to make the switch to either 3.3V nor Win10.

Even getting data from KSP? I've seen a few posts, including other threads where it says you can still get data from KSP, you just cant control anything.

My board is definitely recieving data, it just isn't doing what it is supposed to do with said data

Link to comment
Share on other sites

In the config file (\GameData\KSPSerialIO\PluginData\KSPSerialIO\config.xml), have you changed HandshakeDisable from 0 to 1? This is needed on Win10 because the plugin does not register anything from the Arduino, and then shuts down the stream. If HandshakeDisable=1, it just spams data and the scetch on the Arduino does not time out and register disconnect.

Hope above made sense.

Link to comment
Share on other sites

15 hours ago, Freshmeat said:

In the config file (\GameData\KSPSerialIO\PluginData\KSPSerialIO\config.xml), have you changed HandshakeDisable from 0 to 1? This is needed on Win10 because the plugin does not register anything from the Arduino, and then shuts down the stream. If HandshakeDisable=1, it just spams data and the scetch on the Arduino does not time out and register disconnect.

Hope above made sense.

I have just tried that, with no luck, 

However, I have just tried the code on an old Uno knockoff and am currently printing Apogee and Velocity to an LCD screen, 
Really appreciate the help!  

Link to comment
Share on other sites

@Freshmeat Thanks for the help before but I'm stuck again, I'm trying to run the demo16 code to get the green yellow and red lights to flicker on

I am using an 

-Arduino Mega

-KspSerialIO 0.18.7

-KSPv 1.0.5.1028

-KSPIOdemo16

-Windows 10

before I was using demo13 and I had a very slightly older KSPSerialIO (by like a version or 2)  and when I loaded a craft I would get a quick flicker of the lights and then the green light would go on for a second but then nothing would happen when I launched my craft. Now I moved onto demo16 and updated to the latest Mod version and now when I load the craft I get the very fast flicker but nothing else but a warning message that says 

"Access to the requested resource is not authorized

                Error opening serial port COM3

                       Starting serial port COM3"

 

I also went in and changed the HandshakeDisable from 0 to 1. and that caused the 1 second green light blink to not happen but when i put it back to 0 and used demo16 it blinked twice for 1 second when it was loading the craft.

Do you have any idea what I'm missing? Please and thank you, Also should I get the most recent game?

 

UPDATE: I figured it out (for reasons to long to explain I couldn't update my game) I just rebought the game to get the most up to date game and it fixed it all

Edited by EccentricTea
Link to comment
Share on other sites

On 4/20/2017 at 2:36 PM, Freshmeat said:

The IC's I mentioned will bring that down to two for LEDS and three for the digital inputs.

I have been reading up on this but may be a little over my head. Do I make an array and send it through the shift register as a binary number?

or do I keep it as the variables I already have? but how do I send those through the register?

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