Minecraft – Synchronize two redstone pulse inputs

minecraft-java-editionminecraft-redstone

I'm making a goldfarm in minecraft. I'm making an automatic collection system. I have a hopper minecart run in an unloading loop.

I have an issue with the unloading loop. I want to use the same hopper mine-cart to collect and unload the items. I need a way to keep the cart in the unload loop until the cart is empty, then release it to the collection loop.

To switch between loops i have a switch that turns the track. I activate this switch automatically. The default OFF state of the switch is to stay in the unloading loop. If an empty hopper-cart is detected, the switch is activated for a couple seconds and the hopper-cart is switched to the collection loop.

I'm sending an ON pulse only when the cart is empty and otherwise having the output be OFF. I used a detector rail as one output and a comparator measurement as another output. The comparator is ON when the cart is over the detector rail and it has items and the detector rail is ON when the cart is over the rail. Thus if the detector rail is ON but the comparator is OFF I know the hopper-cart is empty. There are three states:

State          Detector rail        Comparator        Desired output                                
Cart full      ON                   ON                OFF
Cart empty     ON                   OFF               ON
No cart        OFF                  OFF               OFF

This is XOR behavior. I fed both outputs to an XOR gate. Here is the problem, one of my inputs has a 1 tick delay (game ticks not red-stone ticks). I think this causes my XOR gate to have transition states because the two inputs are not synchronized. This causes undesired behavior which I will give an example of:

Here is how my inputs are wired:

Detector-rail -> repeater(2 tick delay) -> comparator(2 tick delay) -> input to XOR.

Comparator reading detector-rail(2 tick delay) -> repeater(2 tick delay) -> input to XOR.

Everything else is redstone wire.

From my understanding of the above, both inputs should have exactly the same delay, reach the XOR gate at the same time and keep the output of the XOR gate OFF. When I run a full hopper-cart over the detector-rail, my XOR gate sends a 1 tick ON output pulse to the track switcher.

I suspect one of the inputs has a different delay and I think its because the comparator has to read the hopper-cart contents when it is on the detector rail. I'm unsure of the true cause.

What I want: when a full cart passes over the rail, the XOR gate gets both inputs ON ON at the exact same tick and the output stays OFF. How do I synchronize these signals so I don't get 1 tick ON pulses?

What I've tried:

  • I searched extensively on the internet and mine-craft forums for
    information on how to synchronize pulses. I couldn't find anything on
    pulse synchronization.

  • I tried asking friends on minecraft servers for help but none of them
    have gone this in depth with redstone.

  • I also tried adding a comparator to the XOR output to see if that
    would cause it to ignore 1 tick outputs because according to The
    official Minecraft wiki
    "Redstone comparators usually do not respond
    to 1-tick fluctuations of power or signal strength".

For clarification purposes:

Here are the inputs to the XOr gate:
two inputs to an XOR gate using a detector rail and a comparator

Here is the XOR gate itself:
a standard XOR gate receiving two inputs, the output is connected to a sticky piston below a diamond block

Here is what happens when A hopper-cart with items runs over the track (inputs are ON ON output should be OFF at all times)

the whole circuit viewed from the side. The hopper cart can be seen on top of the detector rail. The two torches showing the inputs of the XOR gate show that the gate has both inputs ON. The sticky piston can be seen extending the diamond block

Best Answer

Try the circuit given below (attach to the output of the XOR gate). You can adjust the delay using the repeater connected to the sticky piston. The component behind the moving block is a comparator. It worked for me on 1.14.4

enter image description here

Without the other repeater, a pulse would leak out when the piston is pulling back the block.