Jump to content

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


zitronen

Recommended Posts

Does anyone know if the SASTol can be removed from the plugin, and I bought a 20x4 lcd screen what digital pins do i use for it to display the data in the sdisplay thanks, Iove this code is amazing.And thanks for the help. 

Link to comment
Share on other sites

Why do you need to remove it? You can set it to zero or change the control input settings, see first post.

For the LCD, just look up arduino LCD tutorials, it's pretty easy to hook up.

Link to comment
Share on other sites

hi folks,

I'm looking for some guidance on getting this program to work. Here's what I've done so far;

- purchased an Genuino Uno
- wired LEDs as per OP's instructions+picture (analong pin 5/6/7 > led > resistor > ground) (this is correct, right?)
- installed plugin folder to both "gamedata" and "plugin" folders
- downloaded and then uploaded OP's demo code to my board
- launched a ship in KSP

Unfortunately, nothing happened. I'm wondering if my wiring is incorrect, or if I've installed the plugin incorrectly. Thanks in advance for any help you guys can offer.

One more thing; in the OP, we have " You will need to go to settings file and set ThrottleEnable to 1, by default throttle is not enabled (same with all other axes) " to enable throttle control via a slide potentiometer or other. Where is this settings file? Never mind, I think I found my answer

Cheers

Edited by QQuMADbrah
I think I found the answer to my second question
Link to comment
Share on other sites

7 hours ago, QQuMADbrah said:

- wired LEDs as per OP's instructions+picture (analong pin 5/6/7 > led > resistor > ground) (this is correct, right?)

- installed plugin folder to both "gamedata" and "plugin" folders

Hi, and welcome.

You need to connect to digital pins,not analog ones. If this is your first arduino project, I recommend starting with a few simple tutorials. Try things like turning a LED on and off, using the code from http://arduino.cc, before starting with KSP. It helped me tremendously.

The plugin goes in Gamedata, in a subdirectory KSPSerialIO, the way it is zipped.

Hope this helps, otherwise feel free to ask more questions. Try to keep them as specific as possible, and tell what you have done and what code you have used, like you just did above. It makes it a lot easier to help. Looking forward to see your project.

-Freshmeat

Edited by Freshmeat
Link to comment
Share on other sites

Thanks for the prompt reply.

I did some further testing last night and managed to generate an error code which should help to pinpoint the problem:

"IO awake
Starting serial port COM3
Error opening serial port COM3
Access to the requested resource is not authorized."

This appears on the launchpad, just after I load my vessel. For what it's worth, I'm running Windows 10 (unhappily). I know that this mod has had some issues with Windows 10. I'm running the most recent version of Kerbal available, vanilla. I saw another user had some issues with their COM port and zitronen suggested turning it on manually. My handshakedisable setting is set to "1" but I'm unsure if I've configured my COM port correctly.

I've done some circuitry and basic coding before, I understand most of what his code does besides communicating with Kerbal. Any assistance trying to get this going would be appreciated.

(also, yes, I promise that I had my LEDs plugged into the digital pins, not analog. that's not the issue!)

Link to comment
Share on other sites

it very well could be. Is closing my IDE enough to keep it from using it?

I used the UnoJoy firmware fix and it is working beautifully. I would love to use this plugin in the future to get information from KSP but as it appears now, Win10 is not supported :/

Link to comment
Share on other sites

On 28/5/2016 at 9:35 AM, zitronen said:

Why do you need to remove it? You can set it to zero or change the control input settings, see first post.

For the LCD, just look up arduino LCD tutorials, it's pretty easy to hook up.

Thanks zitronen i will keep trying with the lcd, I like to use the SAS for small rockets when I'm using the joystick so the movement is softer when I put it to cero it just deactivate the sas control immediately. Thank you very much. 

Link to comment
Share on other sites

Oh yeah it's unfortunately not possible to have the SAS on and still have axis control over the plugin. Either SAS is controlling the craft or you are. My code simply turns off SAS when your input > SAStol and gives you control. You can mess with the SAStol value and see what's comfortable for you. If you must have SAS on with your axis controls, you can use a leonardo for a proper USB HID joystick.

Link to comment
Share on other sites

Thanks, I use this way to  plug the screen is a 20x4

 The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

But nothing appears in the screen while im inside ksp.

You have to add something in the demo code or the pluggin to make it work?

Thanks

Link to comment
Share on other sites

15 hours ago, daddy1988 said:

Thanks, I use this way to  plug the screen is a 20x4

 The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

But nothing appears in the screen while im inside ksp.

You have to add something in the demo code or the pluggin to make it work?

Thanks

Heya!

Normally what I do is work out the code to get a single thing working (in this case the LCD). Program it up, make sure it's working with sample code either from official Arduino site or from another geek/arduino site.

Then, take that code, and transfer it into the kspSerialio 'demo' program. If the demo is working fine with the bare-bones configuration that @zitronen posted / explained, then you shouldn't have any problems adding the additional code for the LCD.

Link to comment
Share on other sites

Thanks Sputnix, I'm new at arduino code what I don't understand is where should i put the code: LiquidCrystal lcd(12, 11, 5, 4, 3, 2)

for the arduino to recognize the lcd, Is the KSPDemo 13 the code used on the first video?

 

 

Link to comment
Share on other sites

Oh...

The demo code is just a simple template for writing your own code. It has nothing for LCDs in it. If you want to use LCDs, you should first figure out how to use it, follow the arduino tutorials to print numbers and stuff. Then you can put the same code into the demo, change the print value to something useful (say VData.Alt). I would put it just below "Indicators();"

Link to comment
Share on other sites

On 10/6/2016 at 5:31 PM, zitronen said:

Oh...

The demo code is just a simple template for writing your own code. It has nothing for LCDs in it. If you want to use LCDs, you should first figure out how to use it, follow the arduino tutorials to print numbers and stuff. Then you can put the same code into the demo, change the print value to something useful (say VData.Alt). I would put it just below "Indicators();"

I finally did It I will upload the code so newbies like me can make it without knowing just the basics. 

 

Thank you for all the help

Edited by daddy1988
Link to comment
Share on other sites

Has anyone has time to test this on 1.1.3? My code is still not ported to functionality on my new hardware.

And while where at it: How is ControlGroup in the ControlPacket struct organized? Is it 1-8 in one byte and 9-10 in another, or 1-5, 5-10?

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

I've been (*gasp*) playing without this for the last little while, my controller is partially disassembled waiting for me to rebuild chunks of it.

On 6/24/2016 at 5:07 AM, Freshmeat said:

And while where at it: How is ControlGroup in the ControlPacket struct organized? Is it 1-8 in one byte and 9-10 in another, or 1-5, 5-10?

The former. Treat it as a single uint16_t (because that's literally what it is) and iterate through bits 0-9.

Link to comment
Share on other sites

You shouldn't need to do anything with the bits, if you want turn on say group 1 just use:

ControlGroups(1, HIGH);

The function is in demo13:

void ControlGroups(byte n, boolean s) {
  if (s)
    CPacket.ControlGroup |= (1 << n);       // forces nth bit of x to be 1.  all other bits left alone.
  else
    CPacket.ControlGroup &= ~(1 << n);      // forces nth bit of x to be 0.  all other bits left alone.
}

 

Link to comment
Share on other sites

@zitronen: I know, but since I use a shift register, it is easier to reorder the bytes and write them in one go instead of masking out the bits and write them one by one.

In other news, have done most of the controls, the gauges and the LCDs, so I would be able to take off on my current rig. But all my LEDs are yet to do, and right now the software is as much fun to write as the game is to play. I also have the keypad and TFT installed, but as of yet not entirely sure how to make the most of them. Well, the holidays are here, so it all depends on the rain.

Link to comment
Share on other sites

Hi, i followed OP's tutorial and got it to kinda work. When i hit launch and get to the launchpad the leds will light up and preform correctly for about 10 seconds, then the lights will cut out and stop working. If i revert to launchpad it will work again but only for 10 seconds. Any ideas on how to fix? Thanks.

Edited by aaronata
Link to comment
Share on other sites

@aaronata Welcome to the forums.

First of all, are you using Windows 10? The plugin has refused all attempts to get it to work properly. You can use HandshakeDisable 1 in the config to make KSP send data you can display, but you cannot send anything from the Arduino to KSP.

Second, try to post your KSP log. There might be some useful information there.

Link to comment
Share on other sites

@Freshmeat I am using windows 10 but i did have HandshakeDisable set to 1. As for the logs, i didnt really find anything that could be useful but here. From KSP.log:

[WRN 13:47:35.467] [HighLogic]: =========================== Scene Change : From EDITOR to FLIGHT (Async) =====================
[LOG 13:47:35.608] [UIApp] OnDestroy: EngineersReport
[LOG 13:47:35.610] [UIApp] OnDestroy: ContractsApp
[LOG 13:47:35.612] [UIApp] OnDestroy: KSPedia
[LOG 13:47:35.678] UIMasterController: HideUI
[WRN 13:47:36.226] The referenced script on this Behaviour is missing!
[WRN 13:47:36.245] The referenced script on this Behaviour is missing!
[WRN 13:47:36.249] The referenced script on this Behaviour is missing!
[WRN 13:47:36.250] The referenced script on this Behaviour is missing!
[LOG 13:47:36.553] UICanvasPrefabSpawner FlightUI spawning Flight
[WRN 13:47:36.570] [UiApp] Awake: ResourceDisplay
[LOG 13:47:36.624] UIMasterController: HideUI
[LOG 13:47:36.629] AddonLoader: Instantiating addon 'AeroGUI' from assembly 'KSP'
[LOG 13:47:36.632] AddonLoader: Instantiating addon 'KSPSerialPort' from assembly 'KSPSerialIO'
[LOG 13:47:36.634] KSPSerialIO: Version 0.18.2
[LOG 13:47:36.635] KSPSerialIO: Getting serial ports...
[LOG 13:47:36.635] KSPSerialIO: Output packet size: 191/255
[LOG 13:47:36.638] KSPSerialIO: Found 5 serial ports
[LOG 13:47:36.638] KSPSerialIO: trying default port COM5
[LOG 13:47:36.653] KSPSerialIO: Handshake disabled, using COM5
[LOG 13:47:36.654] AddonLoader: Instantiating addon 'KSPSerialIO' from assembly 'KSPSerialIO'
[LOG 13:47:36.684] ------------------- initializing flight mode... ------------------

KSPSerialIO or anything related to it is not mentioned after initializing flight mode. 

Edited by aaronata
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...