Jump to content

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


zitronen

Recommended Posts

First of all: THANK YOU @zitronen for this amazing plugin. I'm waiting for some parts to arrive but i'm already playing around with your plugin and trying things out. I'm using:

  • Arduino Nano (eBay/China clone with a CH340 Chip)
  • KspSerialIO 0.18.7
  • KSP 1.2.2.1622
  • KSPIODemo16
  • Windows 10

Everything works like a charm so far with one exception. The same behaviour @Freshmeat mentioned before. 

On 2.4.2017 at 4:40 PM, Freshmeat said:

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

Furthermore: If SAS is enabled and i'll use the joystick SAS will be disabled. As soon as the joystick gets back to his null-position SAS is re-enabled. I can't toggle SAS while the joytick is used.

Any ideas?

Link to comment
Share on other sites

@Freshmeat & @#Pseudo Yeah the whole axis thing is a bit hacky. The only way I can get joystick to work is to temporarily disable SAS and turn it back on again.

Not being able to toggle SAS while using the stick is just how it works, but SAS engaging by itself does seem like a bug. If this is too annoying, the better way is to use a arduino leonardo or some other 32u4 to emulate a usb joystick (it's what I use right now), which will give you the normal operation.

 

I had a look around a while ago to see how other mods did axis control, couldn't find a better option. If someone can point me to a better solution I'll have a look.

Link to comment
Share on other sites

@zitronen How about checking the SAS bit in each controlpacket instead of checking when it changes? That would at least restore SAS to off immediately after it engages. As it is right now, you only can use the joystick when SAS is at stability assist anyway, so it will not cause any great disturbances in maneuvers.

I have a Leonardo around, but no time to redo my rig. Right now the plan is to disassemble, rewire and change a couple of panels during the summer holidays.

@JoshTheCoward Sorry for not getting back to you. If you want the LEDs driven by shift out register (75HC595), you assemble your variables into bytes. Try google bit masks to get an idea of how it works. Then you shift those bytes into the IC. While the tutorial recommends 220 ohm resistors for the LEDs, I would start testing how high I could go and still se the LED, IIRC I went with 1500 ohm or 2200 ohm for my first build. 74HC595 have the advantage of you being close to the design, it is very transparent what happens. On the other hand, 22 LEDs source a lot of current from the arduino, you might want to add a separate power source to be safe. I use an old PSU, but a tablet charger gives 5 V 2 A, and you might have a spare lying around. Just strip the end of a USB cable to get the power leads.

The MAX7219 sidesteps the problem of power by only turning 8 LEDs on at a time, rapidly switching so it looks like you get a steady signal. You use the LedControl library I linked last post. It requires a quite a bit of reading up, but if you try to make a simple system on a breadboard, we will be happy to help you debug it.

Link to comment
Share on other sites

I copied some code from here about "State Change Detection". I've got a button hooked up to my arduino and I spliced in the code from that wiki. In my serial output I get:

1
off
2
off
3
off
4
off
5
off
6
off
7

This is only from a single push of the button, I believe this is called bouncing? but i'm not sure. The program works perfectly fine when its not working together with this plugin. Any ideas what may be causing this issue?

Link to comment
Share on other sites

9 hours ago, happytor said:

I copied some code from here about "State Change Detection". I've got a button hooked up to my arduino and I spliced in the code from that wiki. In my serial output I get:


1
off
2
off
3
off
4
off
5
off
6
off
7

This is only from a single push of the button, I believe this is called bouncing? but i'm not sure. The program works perfectly fine when its not working together with this plugin. Any ideas what may be causing this issue?

If the code is an exact copy of the one referenced, it already has a delay(50) to deal with bounce, but if it is omitted bouncing might occur. Try adding it in and see if it solves the problem, or add a small capacitor (100 nf suggested here) in parallel to the button.

Another thing that might be off is the if the pull down resistor is faulty. If it is not connected the input can fluctuate wildly when the switch is not closed, giving a similar readout but without even pressing the button. I guess that it might be able to give problems as well is the resistance is to low, but then I would guess the power drain will make your arduino give in.

Finally, the button itself might have a bad connection. I have used a keypad from an old phone, and it gives me no end of trouble.

If nothing here helps, try posting your exact code and a picture of the circuit.

Edited by Freshmeat
Link to comment
Share on other sites

  • 4 weeks later...

Hi good afternoon.

i'am german.

My name is peter and i'm 69 years old.
I play with kerbal and arduino mega.

I have seen this interesting project and am thrilled.
I can run your programs but not to run because I do not have such a display as you.

I would simply times data with the arduino mega received from kerbal and evaluate as text.
How do I do this with KSPSerialIO?

How does the serial data stream from the kerbal comes?

Which program fit exactly together for a display, there are so many here for kerbal.

Thank you.

greeting
Peter

Link to comment
Share on other sites

Hi Peter, and welcome.

I am not exactly sure what you are asking, but the arduino code zitronen has provided creates a struct with several data fields as shown on first page of the thread. I think everyone around here has started downloading that code and modified from there.

As for how to exactly proceed, it depends a lot on what hardware you plan to connect in the other end. A few LEDs and gauges is simple enough, but the different displays run a multitude of different libraries. Further, I have not heard from zitronen since 1.3 came out, so I am not certain if the plugin works with that version.

Link to comment
Share on other sites

Oh yeah excrements, I've been peer pressured into playing too much Factorio lately. I'll check the 1.3 thing this weekend, not super hyped about the update...

Now KSP is owned by take two, I wonder what's going to happen with development, could be a good thing. Really miss the @HarvesteR days...

Link to comment
Share on other sites

Hi good afternoon.

I've changed to com32,
But does not work.

Message: port com32 failed

greeting

 

<?xml version="1.0" encoding="utf-8"?>
<config>
    <double name="refresh">0.2</double>
    <string name="DefaultPort">COM32</string>
    <int name="BaudRate">38400</int>
    <int name="HandshakeDelay">3000</int>
    <int name="HandshakeDisable">0</int>
    <int name="ThrottleEnable">2</int>
    <int name="PitchEnable">2</int>
    <int name="RollEnable">2</int>
    <int name="YawEnable">2</int>
    <int name="TXEnable">2</int>
    <int name="TYEnable">2</int>
    <int name="TZEnable">2</int>
    <int name="WheelSteerEnable">2</int>
    <int name="WheelThrottleEnable">2</int>
    <double name="SASTol">0.05</double>
</config>

Link to comment
Share on other sites

6 hours ago, funkheld said:

Hi good afternoon.
How can serial  a  "stage" send to rocket with the program KSPIODemo16?

Thank you.
greeting

Hi,

you just need to do this:

if (digitalRead(somepin))
      MainControls(STAGE, HIGH);
    else
      MainControls(STAGE, LOW);

You can also control RCS, SAS, LIGHTS, and other stuff this way.

Link to comment
Share on other sites

Update 0.19.0:

Changes:

  • Fixed broken axis/SAS control issues reported by @Freshmeat and @#Pseudo
  • Rebuilt against KSP 1.3 (previous version seem to work still, so this is just in case something changed)

Download link:

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

 

This now becomes the recommended version.

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