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.
- 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’ .
- 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’.
- C will send on ‘t’(this is your way of performing the XOR gate).
- A A and A B will send on ‘A A’ and ‘A B’, respectively.
- D A and D B will send on ‘D A’ and ‘D B’, respectively.
- 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:
- Make two counters(your inputs) that have target values of 0 and reset when target reached(when target reached broadcast on ‘counter=0’).
- 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’.
- Your previous two counters will decrement on ‘subtract’. Make sure your trigger deactivates on ‘counter=0’.
- 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.