Mechanical XOR Gate

This guide shall show you how to create a mechanical XOR gate.

Concept

A mechanical XOR gate will output ‘true’ if only one of its inputs is true, otherwise, ‘false.’
For a logic gate to be truly mechanical it should not use any blockcode, and for it to be actually worth making, it should consume less than 515g’s(15g’s for notifications, right?).

Practice

You’ll need 7 triggers(A, B, C, A A, D A, A B, D B) and one counter(you can make this more memory-efficient by using only one trigger for activating and deactivating each trigger, instead of A A and D A for A, you could have one trigger A | D A. That would mean you could save up to 80g’s). This contraption shall be worth 305g’s.

  1. A will activate on ‘A A’, and deactivate on ‘D A’. A will be triggered on ‘t’ and send out a signal on ‘a is a’ .
  2. B will activate on ‘A B’, and deactivate on ‘D B’. B will be triggered on ‘t’ and send out a signal on ‘b is a’.
  3. C will send on ‘t’(this is your way of performing the XOR gate).
  4. A A and A B will send on ‘A A’ and ‘A B’, respectively.
  5. D A and D B will send on ‘D A’ and ‘D B’, respectively.
  6. The counter will increment on ‘a is a’ and ‘b is a’. The counter will have a target value of 2 and will send a signal on channel ‘reset’ when it reaches its target. The counter will reset on ‘reset’.

Explanation

I used 7 triggers for these reasons:
2 for the input states(A and B), 1 for ‘running’ the gate(C), and 4 for setting the input states(A A, D A, A B, and D B. You don’t need all 4, you can make it using only two, but I did it for simplicity).

Why a counter? Counters are wonderful and it was a lot easier than using a trigger(I haven’t done it yet, but it’s hard just to think about it…). The counter is the ‘output’ where 0 represents ‘false’ and 1 represents ‘true.’

Why does it work? A trigger that is active will send out a signal when it is triggered, but if it’s inactive, it’ll send out no signal. When C sends out ‘t’ it’ll trigger A and B, but A and B will only send out their signals if they’re active(note: I believe you can use one channel instead of two individual ones for A and B to send out on). The counter will be incremented when it receives the signals from A and B, but if it receives two signals(meaning both are active) it’ll be reset to 0. This ensures that the output is 1 if and only if one trigger is active, otherwise, 0.

Finish

Another idea

Credits to @SlimExtraterrestrial for inspiring me to write this.

Instead of using up 305g’s of memory, why not as little as 125! This is possible using counters which are better booleans than triggers. This idea was pretty much explored by @getrithekd in Comparing Counter-Properties (Finished), but I’ll explain the exact steps to make that into an XOR gate:

  1. Make two counters(your inputs) that have target values of 0 and reset when target reached(when target reached broadcast on ‘counter=0’).
  2. Create a trigger that will activate and be triggered by ‘start XOR gate’(or whatever you want as your channel to run the gate). This trigger will send a message on channel ‘subtract’.
  3. Your previous two counters will decrement on ‘subtract’. Make sure your trigger deactivates on ‘counter=0’.
  4. Add a third counter(your output) that will increment on ‘counter=0’. Make sure it has a target value of 2, and have it reset on target reached(using channels, preferably).

And done!
Whether you prefer triggers, or counters, you can create an efficient mechanical XOR gate without block code.

5 Likes

:+1:
Nicely made

Although it would make it better if you add an explanation and maybe an example on how all those triggers work together, like why 7?

Still good job

2 Likes

Unfinished?

Also maybe format some key terms? I mean sometimes reading plain is kinda hard…

1 Like

Great suggestions. I kind of rushed through it(like most of my guides), but I’ll make sure to add some of that. Thanks!

2 Likes

Partly.

1 Like

How much memory does a checker cost? You could have one and check and one or check. It must fail the and check and pass the or check.

I haven’t actually tested this it was just an idea.

I feel like I’ve been drowning this guide with a more probable way but I’m not trying to haha. Great guide!

4 Likes

35g’s for a checker. Two checkers = 70g’s. You would need 2 properties(for the two inputs) so 90g’s.
Checkers don’t have AND or OR gates, but you could use counter-properties and check if two counters are equal, if so, then you output 0, if not equal, then output 1. (that would consume about 125g’s of memory; 3 counters and 1 trigger)
The reason I used triggers in this guide was because I wanted to provide a solution using trigger states, but you could make it using counters which is actually far more efficient.

They do? Look though the settings. Create two checks and make the first checker have the mode of “both have to be true to pass” simulating an AND gate, and the second one has a “only one required to be true to pass”. The second one is an OR gate, if it fails the AND gate and passes the second checker we know the following:

a. it failed the “both are true” test, so it’s either one true or both false

b. it passed the “at least one right”, so combined with the first checker it simulated an XOR gate. we know at least one of them are true but not both.

2 Likes

Oops, I overlooked that setting, sorry.
That sounds like a good idea. I believe it should only consume about 165g’s(2 checkers, 2 properties, and 3 counters), which makes it more efficient than the trigger version.