3

I need a flip flop that takes input from a single source. I need it to have three states (3-cycle) instead of the usual two. I want an output on every third input, but not on the other two. It is easy to make a simple flipflop with two states, but I did not find any mentioning of more states.

6
  • What output should it give at each state? Commented Mar 12, 2020 at 23:32
  • A similar question is here: gaming.stackexchange.com/q/339812/171580 But it's not exactly the same and there are only two answers there, one by me that is not very easy to modify for three outputs and one that I find pretty hard to understand. Commented Mar 13, 2020 at 6:42
  • @Baskakov_Dmitriy actually need only the first signal. Next two could be dumbed. To be clear. I have an observer and I need to use only the first impulse and ignore the two others. Also it would be great that thefirst impulsewould be as fast a possible Commented Mar 13, 2020 at 6:44
  • @FabianRöling Suddenly that looks like a 4-state contraption. I have ideas how to build my own with 4 (and actually every even number). But it is a challenge for 3-states Commented Mar 13, 2020 at 6:49
  • You should put that information about only needing the first output into the question. Commented Mar 13, 2020 at 10:46

6 Answers 6

2

enter image description here

Two sticky pistons pulsed simultaneously with 1-tick pulse (like from an observer or a monostable) handing a redstone block to each other. The two comparators on the sides could be replaced with repeaters, but the middle one is needed to filter out the moment the redstone block transitions back from one side to the other stopping just for 1 tick.

Obviously this only works in Java Edition.

10
  • Does this work in all locations, rotations and world quadrants? I think there are even some redstone contraptions that work differently with different Java versions, but that's not easy to test. Commented Mar 13, 2020 at 10:49
  • 1
    It works in all locations, any x/z orientation and all world quadrants, won't work rotated vertically due to QC. The ORDER in which outputs are triggered is highly directional though.
    – SF.
    Commented Mar 13, 2020 at 13:07
  • Thats genius. And fast indeed. It tottaly mathes my needs Commented Mar 13, 2020 at 16:05
  • 3
    The problem with this is that it depends on a bug that might be fixed any day and also on redstone update order, which might change at any time as well. Commented Mar 13, 2020 at 17:07
  • @FabianRöling: Absolutely not. It depends on Java Edition's consistent update order. If anything, one could expect BE adopting this behavior.
    – SF.
    Commented Mar 13, 2020 at 19:47
4

This circuit can be used to get an output every 1, 2, 3, … up to 320 inputs, depending on how many items you put into the dropper:

The dropper points into the hopper and the hopper into the dropper.
Here is a structure file: https://drive.google.com/file/d/1471ikFq5PrcBcpdfpolioXI3gfxvwt3t

This circuit is actually much more complex than it looks:
When you press the button, the comparator receives a signal strength of 15 from the button, which is higher than whatever it gets from measuring the dropper, so its effective input signal strength is 15. Note that this might change in the next snapshot, because this report is marked as "fixed" in 20w11a, even though I am pretty sure that it reports an intended game mechanic. I don't know how it's supposed to be "fixed" in the next snapshot.
The input signal strength of 15 is equal to the side signal strength of 15, which means that the comparator turns on its output. That turns off the redstone torch and redstone wire in the bottom of the picture.
The button also activates the dropper, which drops one item into the hopper.
The comparator also turns on the redstone dust in the top of the picture and the repeater, which locks the hopper. When the button turns off, the comparator outputs a power level of at most 8, which is still enough to lock the hopper, so the item that got dropped into it does not get pushed back.

When you press the button a second time, the comparator shortly outputs a signal strength of 15, then goes back to whatever it measures from the dropper. Not much happens in the rest of the circuit.

When you have pressed the button as many times as there were items in the dropper, the comparator shortly outputs a signal strength of 15, then 0. That turns on the redstone torch and bottom redstone wire and turns off the top redstone wire and repeater. The hopper gets unlocked and pushes back all its items into the dropper. The comparator does not activate from that, because the comparator still gets a side input signal of strength 15. That way, the circuit is back to the state in the screenshot.


You can take an output signal from any component of this circuit (except the button) and invert and/or shorten it, if you need that.

This circuit has a size of 4×2×3, not counting the button, which can be any input (or a button on the side of the block).
In theory you should be able to remove the column with the repeater and button, move the right column one to the left and put the button on the dropper, but for some reason the comparator does not receive the signal from the button. That is probably a bug, but I will wait until 20w11a is out before I report it.

You need 2 redstone, 1 repeater, 1 comparator, 1 redstone torch, 1 dropper, 1 hopper and 7 blocks, of which the higher 3 need to be solid, the other just need to have a solid top surface. You also need items inside the dropper.
The button can be replaced with any input downwards, upwards or from the one remaining side into the block, as long as it powers the dropper and comparator from there.
Any input length should work, but if you use only one item in the dropper (which would make the circuit useless, but do whatever you like) and toggle the input very fast many times, the redstone torch can burn out. That should only delay putting back the items from the hopper to the dropper, but if you give more inputs into the circuit in the meantime, that might break something, if you depend a lot on outputting on every input.
No input speed (of on/off cycles) completely breaks the circuit (except for the case mentioned above), but if the off phase after the last input is less than 3 redstone ticks times the number of items, then the hopper cannot put the items back into the dropper in time, so you do not get the wanted output.

The delay from input to output is one tick, if you take an output from the block on the right or the redstone wire on top.

11
  • This is a unique build. Wow. Suddenly, it did not handles my needs, because it cycles 3 states more slow than the 3-state-only build. I have a very fast line, and the hopper-> dropper return is to slow in my case. But I will surely use this in my builds. I am happy you posted it here Commented Mar 14, 2020 at 9:12
  • I am making an automatic 3-hight wall builder, that randomizes between cobble and stone. For my superflat server, to surround my village with walls Commented Mar 14, 2020 at 9:17
  • And the stone/cobble comes pretty fast Commented Mar 14, 2020 at 9:17
  • 1
    Do you mean the reset is not fast enough? That seems to indeed be an issue, I'll add it to the answer. Commented Mar 14, 2020 at 11:03
  • 1
    Basically we can set two identical n-flipflops following your design. And in the time one is reseting the other is working. Commented Mar 14, 2020 at 11:46
2

enter image description here enter image description here

This is both fairly fast, and quite safe to stay unchanged, plus will work in BE as well. One item in a hopper-dropper loop. Positive edge ejects the item switching the signal off, negative edge activates next one. If you prefer this reversed you can attach outputs to hoppers, and in this case using a non-stackable item you'll be getting signal strength 3, meaning in many cases you can omit the repeaters, increasing reaction speed. You still need to allow enough time for the comparator to grab the signal.

2
  • That looks really interesting. I will try it out at my serv later. Thanks. Commented Mar 14, 2020 at 12:25
  • Your piston based solution deals actually amazing with speed. And is really stable. Tested variaty of speeds. No issues so far. Commented Mar 14, 2020 at 12:27
1

I found a much better solution than in my previous answer, much better than all of the existing answers even (in my opinion). And what gave me the idea for it was a video about astrophysics: https://www.youtube.com/watch?v=F1CddzgVW14

Whenever you have a problem and want to solve it with redstone, it's always a good idea to try an Etho hopper clock. They are insanely versatile.

The right part of this circuit is just an Etho hopper clock, with an inverted output coming from both pieces of redstone dust. The left part is just a generator for quick off pulses, leading into both hoppers.
Whenever you press one of those many buttons (doesn't matter which one), one item goes from one hopper to the other. If you for example put 3 items in, then every 3 button presses, one of the lamps will light up. You can just combine those two outputs into one to get an output on every third input. Alternatively, you can just use only one of them to get an output on every sixth input, which works better, but only for even numbers.

Here is the structure file: https://drive.google.com/file/d/1YM_EyIYJZupriuereG3I5lf7b30nzcAM

This circuit has no reset time and a delay of 5 redstone ticks (10 game ticks), which could be rewired for just 3 redstone ticks/6 game ticks delay.

Turning the input on and off very quickly many times would make the torch burn out.

The circuit has a size of 5×3×6, but it can also be rewired easily to be 3×3×6 or even 6×2×6, of which the bottom of the two layers is just the ground.
The materials in the screenshot are 4 solid blocks, 7 more blocks with a solid top surface, 5 redstone, 3 redstone torches, 3 repeaters, 2 comparators, 2 sticky pistons, 1 redstone block, 2 redstone lamps and 2 hoppers (with 3 items inside) and some buttons. Of course much of this changes if you rewire some parts, this can change a lot.

This circuit can be used every number of input pulses per output pulse from 1 to 320 and every even number from there to 640. And of course you can combine multiple of these for bigger numbers.

1

The following DLPD - Dropper Latch Pulse Divider circuit design outputs a pulse for every Nth input pulse with N={1,2,3,...,9*64=576}. Depending on how many items one puts in one dropper.

DLPD - Dropper Latch Pulse Divider / Counter

The input triggers both droppers but one is alwyas locked until the other one is empty and vice versa. = Every time all items have been moved from one dropper to the other the RSD in front of the observer flips between power levels 0 and 15, triggering it once every cycle.

Notes:

  1. No cool-down (just the circuit delay).
  2. Without the observer you get a latching switch that flips on/off every Nth input pulse and has an inverted output too.
  3. The circuit delays for both cycles differ by one RS-tick (one has an extra RS-torch to go through)(I think).
  4. This is the flat version (3x2x5=30). Some other configurations are possible (eg. 3x3x4=36, 3x4x3=36, all including the floor but without the output observer).
  5. The input pulses can't be too close to each other or the output won't trigger(?) and some pulses may not be counted(?).
  6. Its kinda similar too / derived from the MHLC and SHLC

@Predicate - I'm a bit pedantic here but: Flip-flops by definition 'are' binary logic. Tri-state logic exists but doesn't make sense here. You've only got one output and it has only two states. The one input only has two states too. If I'm not mistaken "x-state logic" always refers to all in/outputs only. Not the number of internal states of a circuit.

0

This is a flip-flop, using two of Fabian Röling's N-flip-flops with no reset downtime. On the top left and right are unaltered flips flops from Fabian. Each of them needs to be fed with the same "N" amount of items in the dropper.

Between them is a switch that is triggered when one of the flipflops end its cycle: the comparator takes output from the dropper permanently and inverts the signal. When the dropper spills out the last item, the comparator turns off, then inverted that gives a small pulse.

This pulse goes into a RS-latch (two droppers facing each other). This part decides to wich n-flipflop the initial signal would be sent.

The algorithm is: 1. Initial pulse sent 2. RS-latch decides where to sent the signal 3. Current flipflop receives signal and does one step of the n-cycle.

After Repeating these steps n times. The dropper fires into the RS-latch causing it to switch. Now the latch will direct the initial input in the other flipflop. Cycle repeats for the second flipflop, in that time the first resets itself.

No downtime achived.) Thank toFabian for the great n-flipflop.

enter image description here enter image description here

7
  • Can you please explain what the added part does? It looks very complicated and I don't know how it works. Commented Mar 15, 2020 at 14:51
  • Sure, i will. just doing some more improvements. maybe i will get it 1 tick faster Commented Mar 15, 2020 at 15:15
  • If you want, you can join and play around with the system now on my serv. 77.2.53.149 Commented Mar 15, 2020 at 15:15
  • 1
    Added description @FabianRöling Commented Mar 15, 2020 at 18:50
  • Oh, you're using two droppers as another flip-flop! I was experimenting a lot with two pistons, as seen in my screenshot, but that was very complex to use in other places. Really good idea! And the last part is just two AND gates. I'll see later whether I can compact this. Commented Mar 16, 2020 at 0:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .