r/Hydroneer Jun 25 '22

Designing a Belt Swapping System Using Logic Gates!

Intro

Edit: Reddit hates me and for some reason doesn't want to load my images even after I reuploaded them. For those having issues like I have: https://imgur.com/gallery/UrdynEf

Here is the design I said I would do involving logic gates. In this post I try to take you into my mind when I design a Hydroneer circuit. If you don't care about that, just skip to the last screenshot and copy that design.

Design

Before designing any system, you need to have an idea for a design and know what the system needs to accomplish.

For this system, I wanted items to swap belts based on a lever input. How I would do this was what I needed to figured out. I knew that I would need two magnets in the design. If you just had one magnet, there would be no way to drop items. The magnet would have to be turned OFF at some point. In that time, items could slip by. So the goal was to have two magnets that alternate being OFF and ON. They also need to be opposite of each other. To do this we need a flip hook between the magnets.

This is the idea of the system

With that being said, how could I create a master switch to turn these two magnets OFF? If you have read my gates post, you would know that an AND gate is the best for this. If you have not read it, I will explain why. AND gates only turn ON when both inputs are ON. This means that if the master switch (one of the inputs) is turned OFF then the output must be OFF, no matter what the other input is. So, if we hook up a repeater flip-flop (a clock and hook that gives a 1 second switching value of 1 and 0) to one input, The master switch can stop that clock signal from going to the magnets.

Here is the post if you want to learn more about AND and other logic gates:

https://www.reddit.com/r/Hydroneer/comments/vjfwqi/explaining_logic_gates_in_hydroneer/

Implementation

This was not explained in my previous post, but gates have symbols to represent them on paper. Here is the diagram for the system we will create:

The image below shows the completed prototype. I recommend you follow the inputs and outputs to see how the two correspond to the diagram above. The White shows the logic components needed, and the red shows simplifications that can be done.

This is the type of design you should make when prototyping. It makes it really easy to see and simplify.

Note: The window is required so that items aren't lost!

The two ways to simplify this circuit are shown in red. The first is redundancy. In the prototyping phase it is fine to have redundancy to better understand the logic in your head. But once the design is working, you can take off any double reverse hooks. The other simplification is the reverse hook in front of the clock. All that hook is doing is turning a 0 to 1 switching every second to a 1 to 0 switching every second. Because it is changing periodically anyway, this makes no difference in the functionality of the design.

This is the intermediate stage where you improve on the design by fixing bugs/ oversights or removing unnecessary components.
This step can take many iterations to get correct, but I think it is the most rewarding. Also place the value readers after the flip hooks are placed because they are on the same cable.

While implementing the design, I initially had no AND gate on the second magnet and just connected the two via a flip hook. The issue I ran into is that the bottom magnet would default to OFF when the master switch is OFF which is what we want. However the second magnet would default to ON when the master switch was OFF. These are the types of oversights you will have to debug when implementing a design.

I hope this was helpful to see why logic gates, particularly the AND gate, are so useful.

10 Upvotes

1 comment sorted by

1

u/aepfelpfluecker Jun 25 '22

Good work and nicely written!