Jump to content

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


zitronen

Recommended Posts

Always <3

Oh wells, the science got done, I can do it again :)

...Is anyone else getting weird issues with steering via joystick? I've set up some thumbsticks, and even with SAS enabled, the ships are drifting off course. I've tested out the hardware, it's not a deadzone issue... any ideas? Maybe a floating point error or something? :/

I hate it when I can't figure out problems :/

EDIT:

This is in sandbox mode, with a pilot, and I am wondering if it's a conflict with the pilot auto-controls, as the prograde, retro, etc buttons do not work with axis enabled...

Edited by AmeliaEatyaheart
Link to comment
Share on other sites

Always <3

Oh wells, the science got done, I can do it again :)

For the Kerbals who are still alive...?

They added a bunch of new things to the controls, I might have to have a look at it. The controls will overwrite SAS/pilot if your input is more than 10% from centre (default setting), which will explain the drift. Did you calibrated your sticks? They can be quite inaccurate without calibrating.

Link to comment
Share on other sites

For the Kerbals that are still alive ;)

Yep, the sticks are calibrated - it's drifting even if I tell my code the joysticks are always at 0,0,0... I suspect it's how the new pilot SAS controls work in game :/

I know I talk about how much I prefer the Teensy 3.1 to the Arduino an awful lot on here, but this is another great example...I just got this in the mail a couple days ago:

http://imgur.com/lNCAkBk

A little pricey at $35, but it is a solid, compact, and spring return 3-axis stick with set screws to calibrate the resistances, perfect size for what I was after...Since the Teensy can simultaneously emulate serial, keyboard, mouse, and joystick across the USB connection, I have not needed to do anything with the MOD's control outputs and instead just rely on the built-in emulation...

Setting this thing up for KSP was MUCH simpler than I was expecting...The code is literally:

valueX = analogRead(2);

valueY = analogRead(1);

valueZ = analogRead(0);

Joystick.X(valueX);

Joystick.Y(valueY);

Joystick.Z(valueZ);

with no other effort required...The only other thing I needed to do was adjust the set screws so that my analogRead()s were fairly close to 512 (since from the factory all 3 were around 650-700) and then go into the control settings within the game and assign them as I would a normal joystick...I did not have to mess with software calibration or dead zone mapping at all to avoid drifting, things just worked perfectly with defaults.

I have not even gotten around to reinstalling the MOD after .90 because I have been working more on construction and controls rather than coding for the display (and, admittedly, I have been playing too much after the update to get as much work done as I should). Since the board I am using can handle all the input data directly and with a greater range of function than using the control packet within the MOD, it makes things much simpler.

Note: Not at ALL knocking the control features of the MOD of course :P, this just lets me go a little more overboard with my design.

Edited by harbingerx81
Link to comment
Share on other sites

I know I talk about how much I prefer the Teensy 3.1 to the Arduino an awful lot on here, but this is another great example...I just got this in the mail a couple days ago:

http://imgur.com/lNCAkBk

Nice... Makes me to want to redesign part of my controller once again :cool:

Note: Not at ALL knocking the control features of the MOD of course :P, this just lets me go a little more overboard with my design.

What's that overboard word you keep using?

Link to comment
Share on other sites

What's that overboard word you keep using?

Well, you have the footprint you plan to fit all of your lights, buttons, displays, etc on, that is the 'board'...You keep coming up with more and more things to add and eventually run out of space, pushing bits outside the limits of the original dimensions...So, you go over [the edge of the] board...

Good thing I am still waiting for my 3D printer, so all I have is a pile of electronics on my desk and can keep adding to that mess of wires without consequence for now...Instead, i just keep making more and more little circuit boards to wire into this monstrosity...

Link to comment
Share on other sites

Hi, i have a question about that mod that is pretty likely already answered but i'm to stupid to find it... So i looked through the thread and installed the mod. Now my problem is that i tryed to read the data from the Com-Port and here is already the problem. I have no Serial ports on my PC. I tried the Settings File but it only says "Com1". I dont use an Arduino board intead i want to use the Raspberry but for that i first want to read out the actual Values via a small C# programm. So my question is:

On what Com Port does the Plugin write the Values and how can i read them out.

Also ingame my whole console get spammed with "active vessel not found" messages.

Link to comment
Share on other sites

@masterdies:

The plugin comes with a config file in GameData\KSPSerialIO\PluginData\KSPSerialIO\config.xml. The COM port used by the KSP-side of the plugin is configured with the "DefaultPort" setting in there - default is COM1. Edit this value before starting KSP and it will expect the microcontroller to be present at that port.

Once KSP is running you're free to keep updating your code on the microcontroller until you get it right - just keep switching between the VAB and the launchpad (for example) to have the KSP-side of the plugin attempting a fresh handshake with the microcontroller

Link to comment
Share on other sites

Okay... i now have an virtual com-port COM1 and a Program which reads out the Values send over the port... but the values pretty much makes no sense. I've got 190,239,4,0,1,2,3,4...

I think i got the System totally wrong. Am i right. Science the Com Port is a serial Port with only 9 Pins it have to send the Values one after another. So in the end i must pick up 45 data packages.

Link to comment
Share on other sites

If you are using a RPi you will need to write your own code to talk to the plugin. There is a handshake + response process which is used to automatically find which com port is being used, that's the packet you got. You can have a look at the arduino code to see how that works.

Link to comment
Share on other sites

Made my own controller:

20141227_215928.small.jpg

Started with code based on KSPSerialIO. But quickly rewrote just about everything:

https://github.com/daid/KSPSerialIO

As I needed support for a lot of switches. Not all buttons do something yet. And I still need to build the dials.

But the top left switches control the 10 custom action groups.

The buttons below that do mostly nothing, except for 2 controlling the camera (with HullcamVDS) and 2 controlling timewarp.

Joystick controls pitch/yaw/roll (hold top button for roll).

The lever left of the joystick controls the throttle.

Next 6 switches control SAS, RCS, Lights, Gear, Breaks, Docking/Staging mode.

Covered switch controls staging.

Next 6 switches control the SAS mode (bit complex, but all 10 modes can be selected with the 6 switches)

But I wanted to place a thank you for this mod, as I could not have done it without your groundwork.

Edited by Daid
Link to comment
Share on other sites

Made my own controller:

http://daid.eu/~daid/20141227_215928.small.jpg

Started with code based on KSPSerialIO. But quickly rewrote just about everything:

https://github.com/daid/KSPSerialIO

As I needed support for a lot of switches. Not all buttons do something yet. And I still need to build the dials.

But the top left switches control the 10 custom action groups.

The buttons below that do mostly nothing, except for 2 controlling the camera (with HullcamVDS) and 2 controlling timewarp.

Joystick controls pitch/yaw/roll (hold top button for roll).

The lever left of the joystick controls the throttle.

Next 6 switches control SAS, RCS, Lights, Gear, Breaks, Docking/Staging mode.

Covered switch controls staging.

Next 6 switches control the SAS mode (bit complex, but all 10 modes can be selected with the 6 switches)

But I wanted to place a thank you for this mod, as I could not have done it without your groundwork.

Very nice, I like to get a one-liner description from you to add to the list of related projects in first post if possible! Will probably also steal some code from you!

Link to comment
Share on other sites

I have been wanting a pair of these for rotation and translation, but the price tag is rather scary for now. How does it handle?

I think it is well worth price tag personally...The only downside is that it hits its max/min resistance pretty close to the center, about 50% of its range of motion is outside the range where it really has any effect. For me, this is just fine because I wanted full control with minimal movement, but it might make precise control a little difficult on small ships with quick turning speed. It is very solid on build quality though and the springs are the perfect stiffness to be able to move X-Y without accidentally twisting the Z axis. I'd call it a 9/10.

Link to comment
Share on other sites

Very nice, I like to get a one-liner description from you to add to the list of related projects in first post if possible! Will probably also steal some code from you!

Feel free to steal code. I'll push updates as soon as I make them. I'm also changing the Hullcam mod, so I can have telescope cameras pointing at the rocket.

Call it a "Kerbal control panel with many buttons and switches, allowing you to fly your rocket without a keyboard", as that's pretty much what it is.

Edited by Daid
Link to comment
Share on other sites

Zitronen, once you get around to it and back from holidays, would it be possible to look into how the plugin checks for change of vessel? When I undock, my fuel gauge hits zero. Also, when I board a ship, it would be nice if you could push a control packet update, so it registered the state of SAS, etc. I have had some hairy situations caused by looking at my indicator light and believing SAS was active when it was not. A few cases of loosing control as well when shifting around using [ and ].

I am not certain to what extend these bugs are interrelated, and for loss of control a trip to the tracking station solves it.

Link to comment
Share on other sites

Feel free to steal code. I'll push updates as soon as I make them. I'm also changing the Hullcam mod, so I can have telescope cameras pointing at the rocket.

Call it a "Kerbal control panel with many buttons and switches, allowing you to fly your rocket without a keyboard", as that's pretty much what it is.

Added to first post!

Zitronen, once you get around to it and back from holidays, would it be possible to look into how the plugin checks for change of vessel? When I undock, my fuel gauge hits zero. Also, when I board a ship, it would be nice if you could push a control packet update, so it registered the state of SAS, etc. I have had some hairy situations caused by looking at my indicator light and believing SAS was active when it was not. A few cases of loosing control as well when shifting around using [ and ].

I am not certain to what extend these bugs are interrelated, and for loss of control a trip to the tracking station solves it.

Yeah there might be some problems. When I get back I will look at:

1. The new autopilot stuff added in 0.90, which hopefully will allow better axes controls and not have the plugin override the keyboard, and fix some of the problems AmeliaEatyaheart is having

2. Implement sending of the the indicator status (SAS, RCS, etc.)

Right now the controls are only "Synced" during scene changes (going back to VAB, tracking station), I can make it sync on vessel switching, but that can cause other problems like on ship A you have control group 10 set to solar panels and you switch to ship B which has it set to jettison engines, so when you switch vessel, well you get the idea... Docking, EVA adds even more complexity so I don't think sync on vessel switching will be a good idea. Once you have the status information your LEDs will reflect the actual states in the game, this will be less of a problem I hope.

Link to comment
Share on other sites

Excellent setup @Daid, you should set up your own thread too and have it added to the master index.

Continuing this way, we will need a subsection of the forum just for our controller setups :)

I tried asking for one, it was mostly ignored. :( All this work being shared (and code along with it) certainly seems to be a completely different topic than one single "mod"

Link to comment
Share on other sites

Right now the controls are only "Synced" during scene changes (going back to VAB, tracking station), I can make it sync on vessel switching, but that can cause other problems like on ship A you have control group 10 set to solar panels and you switch to ship B which has it set to jettison engines, so when you switch vessel, well you get the idea... Docking, EVA adds even more complexity so I don't think sync on vessel switching will be a good idea. Once you have the status information your LEDs will reflect the actual states in the game, this will be less of a problem I hope.

I was thinking about the same problem. But you could solve it by adding a "pre-flight-check" procedure. Where, when you switch vessels, all controls are disabled until your controls match the actual ship status. With a message on the screen saying "Waiting for pre-flight-check of: Action group X"

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