Home    LBP Showcase / Reviews / Recommendations    Object Showcase
#1

Zero-Latency Set-Reset and Toggle Switch

Archive: 10 posts


This object showcase serves two purposes. One, to show off the new set-reset toggle set-reset and toggle switch that I just came up with; two, to rub it in rtm's comphermc's rtm's and comphermc's face.


Background

Just after the release of the LBPC Logic Pack (https://lbpcentral.lbp-hub.com/index.php?t=18649-LBPCentral-Logic-Pack!), in a post on LBW (http://forums.littlebigworkshop.com/lbp/board/message?board.id=pod&message.id=105115#M105115), rtm challenged me to come up with a "lower thermo, faster swiching implementation" of his beloved winch logic (http://www.lbpcentral.com/forums/entry.php?842-Welcome-To-the-Wonderful-World-of-Wenches!!).

Coming up with a more thermo-efficient switch seemed almost impossible - how could I improve on a switch with only one moving part? The answer seemed to point towards a switch with no moving parts, and in exploring that possibility, I also came across the fastest-switching switch that's possible to produce in LBP - a switch that switches in zero time. Sounds insane, but here it is, in each of its four possible states...

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13874
'Raw' State

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13872
'Reset' State

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13873
'Set' State

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13875
'Unstable' State


Settings

Emitters
Lifetime: infinite
Max Emitted At Once: 1

Magnetic Switches
Behaviour: One-Shot


How it works

Each of the two emitters is configured to fire a block of dissolve into the hole directly to its right. Each block of dissolve contains one magnetic key and one magnetic switch, where the switch is connected to the dissolve. In this configuration, they will mutually annihilate one another.

Firing a one-shot input into top emitter will cause the switch to enter the 'reset' state, which causes a one-shot output from the topmost red magnetic switch, and firing a one-shot input into the bottom emitter will cause the switch to enter the 'set' state, which causes a one-shot output from the bottommost green magnetic switch.

Sounds pretty obvious, but due to the way that emitters work, the output magnetic switch fires on exactly the same simulation clock tick as the input fires - meaning that if you chain several of these together, they will all switch state at exactly the same time.

To make a toggle switch, simply trigger both emitters at the same time when you're in the 'set' or 'reset' state - one hole will always be blocked, so only the other emitter will fire, annihilating the existing block. You can use this fact to chain several toggle switches together to create a ripple counter which acts in the same way as a synchronous counter...

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13871
One of my favourite numbers in binary

As for my claim of 'no moving parts', thanks to a 'feature' of LBP whereby static objects can be emitted into the same space as other static objects (see rtm's latest blog post (http://www.lbpcentral.com/forums/entry.php?1041-Emitter-Blocking-Theory) for the details), each emitted dissolve piece can have a piece of dark matter glued to it, and still be emitted into the hole, which should score this switch a zero on the moving parts thermo. The downside is that it scores much higher on the collected objects thermo than its winchier counterparts, but I guess you can't have everything.

I also have a two-input AND/OR/NAND/NOR which works on a similar principle, but I'm hoping to improve the design somewhat before I post about it.
2010-03-02 23:19:00

Author:
Aya042
Posts: 2870


I made something very similar to that a while back but Im guessing yours is better 2010-03-02 23:27:00

Author:
Kern
Posts: 5078


OK, this is close to what I came up with, but I assumed, that the dissolve triggering would add latency. So the switching off (of the dissolve) will not actually happen instantatiously.

I assume you are working on the basis that you can get an instantaneous switch off from not-q switching on? Which would mean that you can only have the equivalent of single-edge triggered outputs (in the form of a rising edge and falling edge 1-shot) from this? You can't actually output and instantly switching directional signal, for example?

Note all my statements have question marks
2010-03-02 23:44:00

Author:
rtm223
Posts: 6497


...I assumed, that the dissolve triggering would add latency. So the switching off (of the dissolve) will not actually happen instantatiously.

What dissolve triggering?

Bear in mind that the outputs are one-shot, so they only fire when the key appears - they do nothing when the key disappears. That's why each input and output in directional logic requires two connections in one-shot logic. My one-shot two-input NAND gate has four one-shot inputs and two one-shot outputs. As long as all the gates in your chain work on this principle, then all those gates will switch instantly. You will get latency every time you convert from directional to one-shot, and vice versa, but that's generally going to be a fixed overhead, and won't depend on the number of gates in the chain.



I assume you are working on the basis that you can get an instantaneous switch off from not-q switching on?

Correct.



Which would mean that you can only have the equivalent of single-edge triggered outputs (in the form of a rising edge and falling edge 1-shot) from this?

Correct.



You can't actually output and instantly switching directional signal, for example?

Not sure. I'd have to think about it, but I don't think the game engine can support an instant switch in both directions from the same mag switch.

The switch is only instant when a mag key is emitted in the radius of an extant mag switch, and since a switch can either be inverted or not, but not both at the same time, then it would seem reasonable that a single switch could never make both transitions instantaneously.
2010-03-03 00:30:00

Author:
Aya042
Posts: 2870


Sounds interesting. Before, I never did fancy the idea of using emitters in my logic devices, but it seems all that has changed. Kudos to the zero moving parts.2010-03-03 00:49:00

Author:
M_R_Enigma
Posts: 161


Can you look at my tech showcase and see if the two logiks are similiar?2010-03-03 07:14:00

Author:
Kern
Posts: 5078


If I remember right, your device is like half of AYA's. You don't have the inverted output that would be required for the zero latency in both directions.

So I can see how you could take this and turn it into an AND gate, but it would be really quite a complex system (kinda 3x the size of this), maybe you've got something better going on.

What is interesting about this is that the newly emitted piece of dissolve does not dissolve itself, using the old piece of dissolve. I've been curious recently about the ordering in which magnetic switches and emitters and suchlike are triggered when all things should be happening at the same time. Would this be evidence that emitted mag switches will trigger in the order of which one was emitted first? I think that's how it works when you place mag switches into a level, so it would make sense. I'm just suprised it works with dissolve as there is latency so you'd think all of the switches would have time to trigger....
2010-03-03 09:05:00

Author:
rtm223
Posts: 6497


Death to all winches! Long live the emitter! 2010-03-03 09:44:00

Author:
Rogar
Posts: 2284


Can you look at my tech showcase and see if the two logiks are similiar?


If I remember right, your device is like half of AYA's. You don't have the inverted output that would be required for the zero latency in both directions.

I assume you're referring to this gizmo...

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13880
Can you spot the switch that moves the piston?

Without seeing it in create mode, I'm not 100% sure how it works. My guess is that there's a hidden directional mag switch somewhere which is connected to the piston, and it's actived by the presence (of lack thereof) of the tiny mag key on the block of dissolve.

If so, then rtm is correct, your switch-on should be instant, but switch-off will not be. Simple test is to chain many switches together, and look for any obvious rippling. I made a similar mistake in my first two-input implementation (an OR gate in this case)...

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13879
Don't try this at home!

It looks a lot like a doubled version of the set-reset - the problem is that using two green switches at the bottom (both one-shot, one inverted), the transition from 'on' to 'off' is only operating at the speed of dissolve, and as I previously mentioned...


FWIW, I just hooked up a 500 unit dissolve chain which took 17.2 seconds to fully dissolve. Allowing for a 500ms margin of error (which is quite high), that would place dissolve latency somewhere between 33.4ms and 35.4ms. Slightly higher than my initial estimate, but still well below the 50ms average of moving connectors.

...so it's still faster on average than it's winchy counterparts, but not instant.




So I can see how you could take this and turn it into an AND gate, but it would be really quite a complex system (kinda 3x the size of this), maybe you've got something better going on.

After my first failed attempt, I had to start thinking in terms of state transitions rather than the states themselves, since when one input of an AND gate changes from 'off' to 'on', in order to know whether we should emit the mag key activating the 'on' output, we need to know what the last state transition of the other input was.

My best attempt so far (and bear in mind I'm more interested in latency than thermo-efficiency at this stage), is as follows (an AND gate this time)...

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13876
!A AND !B

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13878
A AND !B

http://www.lbpcentral.com/forums/attachment.php?attachmentid=13877
A AND B

It has the same output configuration as the set-reset, in the sense that the red output fires instantly when the output changes from 'on' to 'off', and the green output fires instantly when the output changes from 'off' to 'on'.

This time, however, I have an intermediate state with blue switches and keys where we don't know if the green output should trigger or not. The presence of both intermediate blocks triggers the final 'on' output, and as long as only one input changes at a time, this also provides zero-latency switching.

However, as I said previously...


As far as I can tell, as long as the mag switch exists at the point where a key is emitted into its radius (i.e. you can't emit the key and the switch at the same time), then it switches in the same simulation tick as the key's emission. Similarly, if that switch is attached to an emitter in a one-shot configuration, then the emitter will fire on that same tick.

...so if both inputs were to switch from 'off' to 'on' in the same simulation tick, then, since the blue switch on the intermediate block doesn't yet exist, it can't produce the final 'on' state in that same tick.

Frankly, this is very unlikely to occur in practical use, since, although it's quite common in feedback circuits, I'd pretty much deemed them useless in those cases, since they rely on switching latency in order to function correctly.

However, there's probably a way to translate some circuits in a way which would be compatible. Take this D-type latch, for example...

http://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/D-Type_Transparent_Latch.svg/300px-D-Type_Transparent_Latch.svg.png

Since the two NAND gates on the right are effectively in an SR-type latch (set-reset switch) configuration anyway, I don't need to use feedback for that part, since I already have a zero-latency SR-type latch. As for the bottom-left NAND gate, which could encounter a simultaneous state-change when 'E' changes, that's really just a cheat to cut down on the number of gates. The alternative configuration...

http://upload.wikimedia.org/wikipedia/commons/thumb/c/cb/D-type_Transparent_Latch_%28NOR%29.svg/300px-D-type_Transparent_Latch_%28NOR%29.svg.png

...does exactly the same thing, but avoids the feedback to the left of the SR-type latch.

If you're not using them in a feedback configuration, then it's much less likely that a situation would occur where both inputs would change in the same clock tick. If they are, you're probably doing something wrong. However, feel free to point out a suitable counterexample.




Would this be evidence that emitted mag switches will trigger in the order of which one was emitted first? I think that's how it works when you place mag switches into a level, so it would make sense. I'm just suprised it works with dissolve as there is latency so you'd think all of the switches would have time to trigger....

I think what actually happens is that the dissolved block, or at least the components stuck on it, are removed from the simulation on the same clock tick as its mutually-annihilating partner is emitted. The reason why it then takes another 35(ish)ms to cause any switches relying on it to change state is less obvious.


I now challenge the community to come up with a better AND gate (or OR/NAND/NOR since they're all equivalent), which is capable of making every possible state transition in zero time. The winner will receive compensation in the form of an air of intolerable smugness.
2010-03-03 17:14:00

Author:
Aya042
Posts: 2870


Oh sorry i didn't realize that mag switch was hidden, but your reputation precedes you as you assumed correctly2010-03-03 17:27:00

Author:
Kern
Posts: 5078


LBPCentral Archive Statistics
Posts: 1077139    Threads: 69970    Members: 9661    Archive-Date: 2019-01-19

Datenschutz
Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.