Jump to content

[WIP] Elektronics - Logics and electronic circuits!


codefox

Recommended Posts

Current development state: planning development

(note: as the development of such a mod will require a quite big amount of work, I'd like to collect suggestions from you before I start anything)

Have you ever wanted to be able to control distant vessels, read values like fuel amount and dynamically interact with parts of your building/vehicle/station? Did you ever feel the need to build a trap for a friend on your DMP server which blows up as soon as he gets near? These dreams could now come true!

Elektronics is planned to be a mod which enables you to create electronic circuits which are able to interact with parts. You will be able to toggle actions, read values like resource amounts, transfer resources, transfer values and commands to distant vessels and much more.


But what would I need it for?

Here are a few examples on what you could do using Elektronics:

Autopilot and refueling

You have two space stations, a habitated space station (station A) and a unhabitated storage space station (station B).

You're using TAC life support, so station A needs food, oxygen and water. Station B holds these supplies so they can be distributed without having to launch from Kerbin.

There's a sensor (one from Elektronics) on station A which continuously checks the resource amounts. As soon as a value is lower than it should be, the sensor will dispatch a signal to a radio transmitter (from Elektronics) which will use an antenna to send a command to station B. This command tells station B to refuel a cargo ship which is already docked to station B. After refueling it, the cargo ship will be sent to station A. As it arrives there, it will dock to station A, refill the supplies, undock and go back to station B for further transports.

Traps

You're playing together with someone on a DMP server who likes to mess up your stuff. Time to mess up his stuff! You can take an explosive (e.g. the ones from KIS), wire it to a beacon and wait for someone to approach your trap. As soon as the beacon detects someone who gets near to it, the explosive will be triggered. Boom. He sure didn't expect that!

Timed events

You want to start your engine for 10 seconds every 10 minutes? Nothing easier than that. Just take two Elektronics timers, set one to 10 seconds and one to 10 minutes. Then, wire the 10 seconds timer to the 10 minutes timer, so it gets resetted every 10 minutes (causing it to run again) and wire the 10 seconds timer to the engine, so it gets started/shutdown for 10 seconds.

Whatever you can imagine!

It's up to you, really. You could probably even create KSP in KSP, although I wouldn't suggest you to do that.


Isn't that a bit too hard?

Nah, why should it be too hard? Actually, it's pretty simple as soon as you understand what's it about. If you don't like wiring together logic gates but rather develop "applications", you can also do that. It will be much like kOS, it will just give you much more possibilities.

But that's not KSP!

Why not? KSP is a sandbox game about creating stuff. We have mods which add robotics, inventories, weapons, automation and much more. Why not adding logics?

In real life, for example, vessel to vessel communications including sensors to monitor stuff are very important. I think things like this might be great for KSP as well.


Planned parts

  • Logic gates (AND/OR/NAND/NOT/XOR etc.)

    Has N inputs and 1 output. Compares values and returns the result.

    e.g. AND-gate:



    • [*=1]Input: Value1, Value2
      [*=1]Operation: Compares whether or not Value1 and Value2 are equal
      [*=1]Output: 1 if equal, 0 if not equal

    [*]Memory blocks

    Has N inputs and N outputs. Receives a value and stores it for later use.

    Example:


    • [*=1]Input: Value1
      [*=1]Operation: Stores Value1
      [*=1]Output: Stored value

    [*]Radio transmitters

    Is connected to an antenna. Transmits the input value (or values) to a specific target

    [*]Radio receivers

    Is connected to an antenna. Outputs a received value (or values).

    [*]Buttons

    Can be either toggleable or not. Outputs a value as soon as the button is triggered (can be triggered on EVA for example).

    Example:


    • [*=1]Value off: 0
      [*=1]Value on: 1
      [*=1]Operation: outputs value "on" when triggered, "off" when not
      [*=1]Output: value "on" (1) or "off" (0)

    [*]Constant values

    Stores N constant values.

    Example:


    • [*=1]Value1: 1
      [*=1]Value2: 200
      [*=1]Value3: 50
      [*=1]Operation: outputs the given values
      [*=1]Output: Value1, Value2, Value3

    [*]Beacons

    Measures distances between a beacon and a beacon receiver.

    Example:


    • [*=1]Operation: output coordinates and distance to a beacon
      [*=1]Output: X, Y, Z, distance

    [*]Timers

    Outputs a value after a given timespan.

    Example:


    • [*=1]Value (on): 1
      [*=1]Value (off): 0
      [*=1]Time: 1000ms
      [*=1]Output: 1 after 1000ms, 0 after it's done

    (can be resetted so it runs again)

    [*]Sensors

    Can be attached to parts containing resources and outputs the resource amounts.

    [*]CPU

    Pretty much like kOS but for interaction with other Elektronics parts.

    Provides as many outputs and inputs as you wish and is able to use them within a script. These scripts can be written using either an in-game code editor or a conventional text editor.

    The CPU will however only be available on later tech stages. It will probably use Python for scripting.

    [*][.. and more]


Do you expect me to do complex stuff just using logic gates?

No, of course not. Logic gates are meant to be used for basic things like comparison of two values. Of course, you could also create more complex stuff with that but that's totally up to you. If you don't like to use logic gates, go with the CPU. It will be much easier to use for big things but it would be overkill for simple things like 'check if value 1 is greater than value 2'.

When can I expect to see anything going on here?

I will keep this thread updated. Right now I'm working out the concept of this mod and I'll start the development within the next few days. Keep in mind that a mod like this requires a quite big amount of work. However, you can always ask me on how it's going.

Does it work with stock parts

I aim to support as many parts as possible. Every action which can be toggled using action groups can also be toggled using Elektronics, so it would already work with most of the things.

Any suggestions/critics/questions?

Please, go ahead and let me know!


Source code: GitHub (empty as of now, I'll add basic code soon)

License: MIT

Edited by codefox
Link to comment
Share on other sites

I took a look at it when I saw it in your signature already. That looks pretty neat, I wanted to add something like this to Elektronics as well! :)

If you feel like helping me with development of my mod, just let me know. Maybe you could help me on a few things if you like to. :P

Link to comment
Share on other sites

I can't code, don't know the syntax. But I can help with the program structure. I was already writing some (in plain English with some words from Commodore 64 BASIC, haha) on my phone while sitting in the train this morning.

Link to comment
Share on other sites

You appear to be lacking one of the most useful pieces of logic there is: If-Then statements. You could have a part that could, say, detect "If" a tank is empty of fuel, and "Then" refuel it with fuel from another tank.

Link to comment
Share on other sites

You appear to be lacking one of the most useful pieces of logic there is: If-Then statements. You could have a part that could, say, detect "If" a tank is empty of fuel, and "Then" refuel it with fuel from another tank.

That's what I described with the first example. This will of course be part of the mod.

If you'd like to go with the logic gates, you could take one which checks whether value1 (fuel amount) is greater than a specified value. Then, when this logic gate outputs "0", you can trigger the events needed to refuel the tank.

You could also do this with the CPU which supports scripting (probably using Python). There you'll probably have everything you'll ever need.

Edited by codefox
Link to comment
Share on other sites

Is it your goal to do this with a bunch of small surface-mounted parts you can hook together? (i.e. pick up a NAND gate from the parts bin, stick it to the side of the rocket, then pick up an OR Gate and stick it under that, and drag a line from the output of the NAND to the left input of the OR, then..... etc).

That would be a neat teaching tool for basic electronics logic.

Link to comment
Share on other sites

Is it your goal to do this with a bunch of small surface-mounted parts you can hook together? (i.e. pick up a NAND gate from the parts bin, stick it to the side of the rocket, then pick up an OR Gate and stick it under that, and drag a line from the output of the NAND to the left input of the OR, then..... etc).

That would be a neat teaching tool for basic electronics logic.

Yep, thats what I've planned. A few small surface-mounted parts which can handle logics, arithmetics etc. However, I will probably just create one part for this basic stuff so you can just place it and right-click on it to configure the part. Like some kind of selectable sub-parts. :)

Although you could also write scripts for it which won't require you to use any other parts than the CPU (and everything you want to use together with it, for example sensors).

Edited by codefox
Link to comment
Share on other sites

You could also maybe simulate the sorts of chips often used by small homebrew projects that contain an array of NAND gates inside them, so that each set of 3 pins maps to one of the internal gates, and you might get a dozen or so gates in one chip.

And if you have switches you "turn on" with action groups or rightclick menus, then you automatically get kOS script support "for free" that way. (i.e you can design a system made of a hybrid mix of software and hardware to do tasks - by having a kOS script "trip" one of the switches built with this mod.)

I like this. Good luck with it - I'd like to see it work.

Link to comment
Share on other sites

You could also maybe simulate the sorts of chips often used by small homebrew projects that contain an array of NAND gates inside them, so that each set of 3 pins maps to one of the internal gates, and you might get a dozen or so gates in one chip.

Thats a great idea! Maybe you'll see this feature in the mod, I'll just have to find out how I should realize this.

Regarding the action groups - the switches can be turned on by action groups, as well as by using the right-click menu. So compatibility with other mods should be no issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...