May 01 2012

XOR gate

Category: Lego,TechnicsSpiller @ 09:08

As I mentioned in Mechanic NOR gate I was working on extending the NOR-gate to a compact XOR-gate and I finally succeeded in making a prototype of it.

My original idea to make it smaller failed, however after trying to think outside the box for a bit I finally made a breakthrough. Keshav Saharia made an AND-gate by surrounding an OR-gate with NOT-gates. I realized that this can be achieved by modifying an OR-gate slightly. Instead of enforcing the output to be true when one input is, you can get the AND-gate result by enforcing that the output is false when at least one input is too. Instead of pushing the output beam on true inputs, you pull it on false input like shown in the example AND-gate design below:

AND gate

With this much smaller AND-gate it becomes a whole lot easier to create a compact XOR-gate. My prototype as shown below contains two layers, one layer contains 2 AND-gates and one OR-gate while the bottom layer is a single NOT-gate.

Top view of XOR gate Bottom view of XOR gate

The reason I call this a prototype is that it contains the same flaw as Keshav Saharia’s XOR-gate, it does not reset its internal gates when a state updates. This could be solved by using rubber-bands like I did with my NOR-gate design. However I believe this approach to logic gate design is flawed and since it is difficult to do add this without increasing the size (and work well) I wouldn’t even bother.

The issue is that friction will continue to build up in the system when you start combining the gates, and those rubber bands makes it much worse. (I also fear that the rubber bands in one gate might affect another gate.) It is limited how much force these gates can function with. Small inaccuracies in how much the axles extend will also propagate throughout the system.

All those issues limits the amount of gates you can chain together and I don’t think it would perform well enough to complete a 4-bit adder (using half/full-adders).

So I want to try a completely different approach using continually rotational power as inputs and using gears to create the gates. One of the advantages is that gears can handle much much larger power throughput than the axle-beams approach. Secondly, by making it continuous you can more easily supply more power by embedding motors in the gates. The big disadvantage however is that it will use much more space and therefore also pieces. However if I can get it to work and I believe it will scale well I will try to get the gears/parts required.

7 Responses to “XOR gate”

  1. Jack F. says:

    Hey spiller, thats really cool! The AND gate is an amazing breakthrough! Not to mention you some how managed to cram two of your AND gates and an OR gate into what looks like a 4×10 space and manage a NOT gate in the same ammount of space! Incredible! A fix for your elastic bands problem: I was thinking you might be able to use technic springs or shocks, possibly even just a spring from a mechanicle pencil or pen. Just like with electromechanic logic, you don’t have to use ONLY legos. Also you could make a verticle model and let gravity reset the gate. Finally, I understand that the people who make these awesome creations are quite inteligent and consequentaly (not to intelligence is a bad thing, because it most certainly is not) always preoccupied. But I am extremely interested in these amazing creations people make, but then I’m disappointed to see that the creator

    • Jack F. says:

      Couldn’t find the time to create or post a guide on how to build it. I, for one, would be very appreciative if you could try to find the time to create a guide for your gates. Once again I understand your buisy, and I understand if you can’t. I’ll enjoy your work all the same. I don’t have much to offer in the way of tips, techniques or tricks with legos, but It’d be awesome to get in contact with you some time via email. I doubt I helped much if any, but you never know. I had to share. Best of luck!

      • Spiller says:

        The Lego springs that I know of are too large or too strong which is why I have been using elastic bands. Using non-Lego springs is possible, but I’m a Lego purist (for the extra challenge) so I’m not going to do that.
        Using gravity is a very nice idea though. Not sure how well it will work out, but it is worth a shot.

        About instructions, I can make a stepped LDraw file easily (as the gates are small) and I think I already made one (without steps) for the NOR gate. I might not convert it to something like PDF, but you should be able to see each step using a LDraw viewer in that case. I’m at my parents place currently though, so it will have to wait till I get home.

        I have email accounts at both Hotmail and Gmail with the username ‘spillerrec’, you (and anyone else) are free to contact me there.

        • ErnWong says:

          Springs/elastic bands may cause a bit too much resistive force.
          Keshav Saharia’s idea was having two parts to an AND gate on the shaft. On one end is a bit like the “AND-ing end” which sets the output and the other is like the “OR-ing end” which resets it.
          It is made such that when the inputs are both 1, then it pushes the AND part, which pushes the output to 1. But when one of the inputs is pulled back to 0, it pushes the OR part back, which resets the output to 0. I know, I’m bad at explaining.
          However one downside to that is that the input needed to be “multiplied by two” when pushing the AND part (which is made out of a lever-like thing where it simply turns when only one input is pushed). Keshav’s version didn’t multiply it by two so it may be a bit inaccurate, but multiplying by two (ie by converting it into rotational motion, using a 2:1 gear, and then converting it back to linear motion) takes a bit more space.
          Springs/elastic bands may work for small “circuits” though. One way to decrease the spring’s force is to put it on an angle, but that uses too much space too!

  2. santi says:

    Super cool!

    I’ve been working on lego gates for a while ( ). I’m trying to build gates that do not require rubber bands, and thus my gates are rather bulky. However, they have the advantage that they can be combined easily with one another (I build a logical machine that combines 8 of them ). But I’m very intrigued by your designs. I’m going to try to reproduce them tomorrow, and see if I they can be of use in a new project I’m working on. Great work!

Leave a Reply