Simple logic guide for circuits. Latch, counter and Timer

Admins, I can’t post in guides so please move this to guides if it meets standards.

This is a guide to show how to create a simple latch and a counter. Then how to combine them to create a timer.

If none of that sounds interesting, trust me, digital circuit stuff (real or fake) is all about building a “library” of smaller designs, then figuring out how and when to use them.

This guide won’t cover input or output components, honestly input/output is what’s limiting circuits right now. I hope that by showing people what even basic logic gates can do, it’ll encourage devs to port some input/output components from /TG/

If you want to just see the designs please scroll to the bottom, if you want to understand what they’re doing read on.

Logic Gates and Truth Tables
The fundamental building block of all digital circuits and computers. Logic gates take inputs, and spit out outputs according to some rule.

Truth Tables are the written out example of this.
Ie. For an AND gate.

| A | B | O|
| 0 | 0 | 0 |
| 1 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 1 | 1 |

This means that only that last case of having A =1 AND B=1 will output a true.
Truth tables are incredibly useful and you can create them quite easily, or look them up.
You should try to understand and/or memorize the tables for AND, OR, and XOR
Note, that once you wire multiple gates together, you may have to create a truth table for your entire creation to help understand what it does.

States and triggers
So gates are cool and all but something has to trigger them.
In the real world gates start reacting the moment their inputs change. Here however, they are triggered.

The most common triggers you’ll use are the Clock, and a button. They send out pulses which will cause a component to do it’s job. IE an AND gate will not AND the inputs until it’s been triggered.

The clock component allows for your creation to keep going after you stop pressing the button. It’s important to think of clocks as having cycles, and in each cycle everything happens, then next cycle, it all happens again. This doesn’t have to be strictly true I don’t think, but start out with that assumption and learn where to bend the rules later is my opinion.

The button is for when you wanna initiate the event, or if you want to change what’s happening. This will become more obvious later when we use a button to stop a counter.

States are nastier. When a system acquires a state, everything gets more complicated. Luckily it’s pretty easy to know if you need a state. Basically, does it need to remember previous iterations?

Consider a roulette wheel vs a bingo ball dispenser. The roulette wheel doesn’t need to know previous spins to calculate it’s next spin. It’s just random. A bingo ball dispenser, however, has to keep track of what balls it’s dispensed. A physical one does this by physically sending the ball out. A digital one has to remember what was randomly rolled previously.

States will mostly be stored in RAM, but you could 100% create your own memory component out of just gates, so have fun. Fun fact, all logic gates, and thus digital devices, can be created using just NAND gates, which is an AND gate connected to a NOT gate.

States mean the inputs to gates will change, meaning you have to consider more rows of the truth table. Increasing difficulty and complexity.

A latch circuit
A latch circuit’s job is to hold a previous value, with the option to clear this latch. Below is a simple toggle latch.

To analyze it, first we see an XOR there, so let’s draw a table for it:
XOR is “Exclusive OR”, meaning that it will be true ONLY when both inputs are not the same.
In single bit binary, that means 1-1 or 0-0 will result in a 0 out.
| A | B | O|
| 0 | 0 | 0 |
| 1 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 1 | 0 |

So the A input is hard coded to be a 1. This means we can ignore all rows that have A=0.
So that leaves us with just B = 0 therefore O = 1. Or B = 1, and O = 0
It is essentially a NOT gate at this point. But you can make it from a Logic component.

The RAM component will initialize Null, which will feed back a 0 to the xor gate’s B node.
So, on the first press, look at the second row in the truth table. O = 1 so the XOR will trigger True, and set result = 1.

The signal sent from “True” to “Store” will cause the ram to store the 1 being sent from result.
“Stored Value” will now be stable at 1. It is also being looped back to B as you can see.

On the next button press, A = 1, but now B = 1. Meaning the XOR will trigger False and set result to 0. Triggering clear will set the output to null again. (Note, if you want output to reset to 0, then simply wire false up to store as well.) At this point, the looped back value to B will be 0 again. Meaning we’ve reached a previous state. A = 1, B = 0. The A can’t change, and B can only be 0 or 1 and we’ve seen what happens both times then. Thus this circuit can only ever toggle between 0 and 1.

Note you can clear the latch via any method. It doesn’t have to be a toggle.

Next is a counter. A counter counts up.
Question? Should a counter have a state?

Answer: Yes, it has to, how else can it remember what number it just had.
Go ahead and try to count without remembering your last number.

I’m using a clock here, but any pulse will work, it depends on what you want to count. Button presses? Time? number of deaths on station? Here we’re building a timer circuit, so it’s based on a clock. You can think of the clock as in game way to use “time has passed” as a repeatable input.

There’s no gates here, so no truth table, but it’s worth understanding Arithmetic components.
Every time the clock pulses, 1 will be added to B. Initially “Stored Value” on the ram will be Null so B = Null = 0 so “output” will be a 1 after the first pulse. This value is stored in ram and fed back, causing the next pulse to add to B =1, then B=2 and so on counting up.

I think it’s important to use ram here since the ram won’t update when the arithmetic component is triggered guaranteeing it won’t change while the arithmetic happens. I think it’s probably fine in the game, but direct feedback feels wrong to me and seems like it could go wonky. It also gives you a reset option by pulsing the clear signal on the ram.

You should use the arithmetic output directly, and not the RAM, since the ram doesn’t have a trigger output. The RAM exists just to hold the previous iteration’s number.

Here we add a comparer to our counter, when the counter goes above the set target number of cycles. Once you reach that number, you’ll get a radio signal sent. It will also clear the counter so it can start counting all over again.

Note, you can use one of the other buttons on the shell, create a list of speeds, then use a button connected to a counter, to count up and index the speed, then reset the count at the end. Or you could toy with multiplexers if you’re brave.

That’s enough for now though. Good luck and ignore that logic thing on the right. The station was on fire when I took the picture.

1 Like

To be honest, it is my belief that circuits are kneecapped intentionally so they don’t have to be dealt with IC or rulewise, but can’t be described as a “removed” feature.

I’ve made my opinion about this known in previous topics, and never particularly received any sort of rebuke towards this line of thought, which has led me to believe it is correct.

I hope it changes, but it probably won’t.

I’d at least like everything but drones brought back. I mean, use physical security to keep it balanced.

Yes, you can space the armory with this… if you can attach a remote signaller to all the doors between it and the airlock.

I don’t see a problem, for example, with like a doorjack shell that let’s you quickly wire up all the wires so your logic can auto hack the door. You’d just need to cycle each wire with a multiplexor while reading the test light then beep to indicate crowbar time. Or if the shell has cutters, identify ID with a sound analyzer then could cut ID, then pulse till OPEN.
It’s nothing you couldn’t do yourself. You just automated it.

The biggest advantage is remote activation, but that’s not that hard, give security/AI the ability easily see and trace repeated signal transmissions if they’re looking for them or something.

I dont think this is the case? I heard Dejaku was interested in porting the rest of them

if (exist):
play = honk.mp3
repeat inf

circuits died many years ago… this is but their rotting corpse.
im just beyond astounded how the most overpowered bullshit (xenobio/botany) remains but CIRCUITS got the boot for some stupid reasons

I dont think this is the case? I heard Dejaku was interested in porting the rest of them

ive been hearing people say that for quite a while… its been close to a year and we have gotten nothing

Bit of an unrelated question but you seem to know a lot about circuits.
How do I put a circuit into an airlock circuit shell?

hello. Someone said xenobio, so here I am

xenobio is still here because ??? (even i can’t justify this)

circuits got removed in pr #3969 because
“Numerous issues, and none of the coders/maints seem to really care to fix, so yeet it is. Improves compile times.”
this isn’t really an answer to the “numerous issues thing” so we can dig deeper

to figure this out we can go to this thread

and read some of the posts there

here’s cae, on why circuits died

xenobio (the given comparison) is very buff, but is a bunch of individually powerful effects. Sure, you can stack some, but to what end? Each does it’s own thing and can be (and probably is) logged individually. And while time is hardly one of those things you should gate things behind, circuits were gated behind less for more. You also can’t crash the server with xenobio, which is a plus.

Circuits compound their power, are very hard to log, and are very hard to tell apart without ripping them open. All because of their modular construction. This is why they got the boot.

As for the thing about the wiremod port… idk i don’t follow that.

1 Like


Xenobio adds in a lot of stuff that is fun to interact with and can’t be done any other way
Improve, don’t remove

But tbh, science having whack shit is fine, it’s meant to be fun, and it is.

They got the boot because of how many server crashing related bugs they had.


1 Like

yeah i can get behind this
like, replace the way you get this stuff sure
but don’t just excise it

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.