Home    LittleBigPlanet 1 - PSP - Tearaway -Run Sackboy Run    LittleBigPlanet 1    [LBP1] Everything Else LittleBigPlanet 1 [Archive]
#1

AND gate design challenge

Archive: 48 posts


This is from a different thread and it seemed to cause some head scratching amongst a couple of members:



I don't like that "pistons in series" method of AND gating, you can make a 16 input (poss more) AND gate with only one moving part.

Thought I'd post this as a challenge for anyone who is interested:
Design a 16 input AND gate with only one moving part.

To clarify, I'm counting a block of material that moves as a "moving part", connectors don't count.


Here is a hint if you get stuck:
My n-input AND gate consists of:

a rectangle of dark matter,
a rectangle of some other material,
1 mag switch,
1 mag key,
1 other switch,
a number of connectors.


Here is a solution:
(4 inputs shown, but should work with any number)


Dark Matter moving Part
|------| |------|
| gS |ccccccccccc| gK |
| | | |
| |ccccccccccc| |
| | | |
| |ccccccccccc| |
| | | |
| |ccccccccccc| |
| | | |
| gr |ppppppppppp| |
|------| |------|

where:
ccccc is a chain, set to strength 10,
ppppp is a piston set to stiff / strength 5
gK is a green mag key
gS is a green mag switch (set to invert)
gr is a grab switch (set to direction / inverted) and connected to the piston.

Set your inputs to directional and connect them to the chains. gS is your output.


And here is a better solution (edited in waaaaay after the thread died):
(4 inputs shown, but will work with any number)


Dark Matter moving Part
|------| |------|
| gS |ccccccccccc| gK |
| | | |
| |ccccccccccc| |
| | | |
| |ccccccccccc| |
| | | |
| |ppppppppppp| |
|------| |------|

where:
ccccc is a chain, set to strength 10,
ppppp is a piston set to stiff / strength 5
gK is a green mag key
gS is a green mag switch (set to invert)

Set your inputs to directional and connect them to the chains and the piston. gS is your output.



And if that's too easy for you, design a n-input AND gate with no moving parts - no hints this time.
Edit - if you want to have a go at challenge #2, don't read on, the solution is further pown the posts!


P.S. I couldn't work out where this should go, I didn't think it fitted into any of the forums.
2009-04-16 12:22:00

Author:
rtm223
Posts: 6497


I like the last challenge.

Maybe try and get someone to "sponsor" you for the n-input no parts (ie to donate XP) and put it in contests.
2009-04-16 12:42:00

Author:
dawesbr
Posts: 3280


Quite a nice idea, rtm!2009-04-16 13:21:00

Author:
tameturtle
Posts: 150


Just a permanent switch with lots of dissolve blocks?
Or are you looking for a reversable one?

Could you possibly explain how the diagram works?
2009-04-16 19:44:00

Author:
Pinchanzee
Posts: 805


Probably for most levels a disolve based one would work, but the design I have in mind is fully reversible.

How the diagram works:

Green mag key is inverted so if the moving bar is pulled in, output is false; bar pushed out, output is true.

The weak piston is always pushing out (it's switch is inverted direction).

If all of the chains are set to out, then none of them affect the moving bar and the piston pushes it away.

Otherwise, the chain(s) that are set to "in" will pull in the bar setting output false. A single chain is enough because it's stronger than the piston.

You could always replace the piston with gravity, but I prefer having the movement a bit more controlled.
2009-04-16 21:10:00

Author:
rtm223
Posts: 6497


Hm, the only way i could think of to make an AND-switch with no moveable parts would be to bend something. But bending materials is something i don't want my logics to be depending on. :/2009-04-16 21:18:00

Author:
Vanemiera
Posts: 329


Emitters aren't moving parts, are they?2009-04-16 21:23:00

Author:
dawesbr
Posts: 3280


Nope, but what they emmit may or may not be...2009-04-16 21:29:00

Author:
rtm223
Posts: 6497


Well I'm thinking emitters then, that place keys. When the input is activated, the emitter gets turned off, meaning the key, which has a lifetime of 0.1 seconds, is destroyed (until the input is released, of course). Then, when all blocks are gone, an inverted key detects this and activates. n-input, non-moving and gate!

EDIT: This method could be used to make almost any type! Just change the different emitters to inverted or not to get it right, or the magnetic switch to normal.

Eg, n-input or, have the switch as normal, then the emitters as normally off. As soon as one input is made, the switch is active, et voil?, n-input or!
2009-04-16 21:42:00

Author:
dawesbr
Posts: 3280


You forgot to mention the keys are on dark matter, but yeah. I'm actually using this as an OR gate at the moment, I like the fact you can change the lifetimes and swap between on and one-shot for various timing effects bult into the gate.

Problem with both of these solutions is you can't invert individual inputs inside the gate, you have to do it at the switch. I don't understand why winches don't have a backwards mode. Actually... just checked, looks like thats new in yarg as well

PS, turning OR gates into AND gates and vice versa like this is De Morgan's theorem.
2009-04-16 21:51:00

Author:
rtm223
Posts: 6497


Well isn't there something about any gate can be made with a combination of nands?2009-04-16 23:04:00

Author:
dawesbr
Posts: 3280


i would like to know how the hell u lot figure this stuff out...2009-04-16 23:07:00

Author:
CreateNPlay
Posts: 1266


2 hours of Logic Gate DT lessons that got us up to XORs and a lot of forehead-rubbing.

I enjoy making ones that are slightly physics-based. I basically accidentally taught myself logic gates before I was taught them in DT, thanks to LBP.
2009-04-16 23:11:00

Author:
dawesbr
Posts: 3280


Good old-fashioned forehead rubbing - brilliant! The elements of digital logic are soo simple, once you get your head round it. dawesbr just worked out a REALLY important piece of electronics theory from first principles and that's the beauty of it.

I believe there were some early computers where the logic was entirely 3-input NAND gates, probably for cost reasons, but doing that in LBP wouldn't pay off. I do have a plan for something far more useful for LBP, but need to test it first.


Also, now you mention XOR gates, I don't have a good solution beyone 2 inputs
2009-04-16 23:55:00

Author:
rtm223
Posts: 6497


Is this more thermo efficient than nesting piston ANDs?

Also, can you put the chains to 0.1 sec timings without it breaking?
2009-04-17 03:51:00

Author:
dcf
Posts: 468


Who here still does/did electronics? I'm currently studying electrionics (Year 10) just finished 555's and are doing a lot of gates at the moment. It great, because as I learn more about gates in electrionics, I can apply my knowledge to LBP and replicate the idea.2009-04-17 09:00:00

Author:
DanC
Posts: 433


Is this more thermo efficient than nesting piston ANDs?

I guess so (less edges, less objects, less movement etc) though that depends how the lbp engine handles multiple connectors on the same object. Would need some experimentation to know for sure.


Also, can you put the chains to 0.1 sec timings without it breaking? The no moving parts one definately can. I'm pretty sure the one in the OP can too. As I was drifting off to bed I thought up an idea for a single gate that could OR a whole bunch of ANDs, something like:

(abc' + a'b + acd), or if you prefer:

(a AND b AND NOT c) OR (NOT a AND b) OR (a AND c AND d)

And make the whole thing switch in 0.1s. Which would be nice.

trickster - I did four years of it at university. TBH, not much outside of the first year is directly applicable to LBP
2009-04-17 09:56:00

Author:
rtm223
Posts: 6497


I'd be very surprised if the piston+multichain AND gate is not much more thermo-friendly than the traditional stacked pistons.

The former only requires simple addition of the forces exerted by the winches and the piston. The latter requires additional collision detection, constraint resolution and movement calculations for every moving object in the piston stack. That's far more complicated to solve, and will thus require a lot more computational resources.

Now I only have to confirm it actually works as an AND gate, too ...
2009-04-17 10:16:00

Author:
tameturtle
Posts: 150


I'd be very surprised if the piston+multichain AND gate is not much more thermo-friendly than the traditional stacked pistons.
...
That's far more complicated to solve, and will thus require a lot more computational resources.
That was my assumption during design and the theory of it is sound...



Now I only have to confirm it actually works as an AND gate, too ...

Oh, ye of little faith! I've lost the original apparently, but unless there are any typos on the settings to use, it's a pretty sound AND. And as dawesbr sort of pointed out, with chains set to backwards and the mag key uninverted, you get an OR gate.

PLUS a bonus feature I just thought of - if you make one with lots of inputs, during develeopment any unused input chains can be hooked up to the grab switch (permenantly on) and you can swap these for "proper" inputs as and when you need them. Once you are done, cut the darm matter and moving part down to size and unused inputs disappear
2009-04-17 13:48:00

Author:
rtm223
Posts: 6497


Yeah, this seems to be the most efficient multiple OR/AND gate I've seen in this game. If this is low thermo then that is quite exciting. The biggest thermo drain on normal piston OR/AND gates is the piston timing. As you make a piston timing shorter, you can actually see the thermo increasing below a certain time. It's actually fairly significant at 0.1 seconds. However, this might not be caused by the piston, but rather the predicted movement of the object the piston is attached to. If this is the case it is possible that this gate uses less thermo. However, it is also possible, that having multiple pistons and chains on one object makes it more complex for the engine and therefore increases the thermo. The only way to know for sure is to experiment. One can make a large number of both types and see how many they can copy before the thermo is filled.2009-04-17 14:31:00

Author:
dcf
Posts: 468


The biggest thermo drain on normal piston OR/AND gates is the piston timing. As you make a piston timing shorter, you can actually see the thermo increasing below a certain time. It's actually fairly significant at 0.1 seconds.
I did not know this, thanks.


However, this might not be caused by the piston, but rather the predicted movement of the object the piston is attached to. If this is the case it is possible that this gate uses less thermo. However, it is also possible, that having multiple pistons and chains on one object makes it more complex for the engine and therefore increases the thermo.
2D vector addition of the multiple forces (or speeds) is a really simple calculation. Plus you would need to add these up anyway to do the pistons in series... Collision detection on multiple objects is far more complex. however:


The only way to know for sure is to experiment
Agreed. Are you volunteering?
2009-04-17 15:30:00

Author:
rtm223
Posts: 6497


Wow triple post

rtm, I was kinda actually referring to my design for NO moving parts at all, in case you didn't notice.

trickster, year 10 DT here as well 741 op-amps woo!
2009-04-17 15:35:00

Author:
dawesbr
Posts: 3280


I did not know this, thanks.

you're welcome.



2D vector addition of the multiple forces (or speeds) is a really simple calculation. Plus you would need to add these up anyway to do the pistons in series... Collision detection on multiple objects is far more complex. however:

True, although we don't know the algorithm LBP uses to calculate thermo, which is the real issue, not the actual computation time. Also, for nested ANDs/ORs I have not placed pistons in series. I use a simple, two input AND/OR and link multiple together, rather than making a single device. The advantage to this is that there is no weird piston problems from placing pistons in series. Each object is directly hooked to dark matter. This is obviously less efficient because, for example, to have 4 inputs, one has 6 moving parts (2n-2). However, in LBP it might be more thermo friendly because of the assumptions that are made when something is directly linked to dark matter.

I haven't really considered any of these things with my first tool set. I came at the problem from the 'programmer time more valuable than computation time' mindset, which may be wrong for LBP engineering.


Agreed. Are you volunteering?

Yeah, I'll give it a shot. As someone who puts ~100-200 logic gates in a level this is a big deal for me. If this is much more thermo friendly it has huge implications.
2009-04-17 16:46:00

Author:
dcf
Posts: 468


Tested a configuration with six winches against one piston, all set to 0.1s. Confirmed working. Great!2009-04-17 17:39:00

Author:
tameturtle
Posts: 150


Still can't think of an n-input XOR. I was thinking maybe something to do with a rotating circle with an angled switch, surrounded by emitted keys. One emitter off, circle spots it and stops. But this would work as an OR. Perhaps by linking my previous idea to this one, or...2009-04-17 17:48:00

Author:
dawesbr
Posts: 3280


thanks dcf, I'm looking to see how that turns out - would be funny if it's horrendously inefficient lol.

dawesbr, as an xor with multiple inputs will be true is any odd number of inputs is true, it's gonna need some really funky contraption, which probably would be less easy than just stacking lots of 2 input ones. I don't intend to try and solve that one, because I don't have any use for it yet!
2009-04-17 17:59:00

Author:
rtm223
Posts: 6497


XOR might actually be pretty straight forward.

Traditional two input XOR is AND(OR,NOT(AND)). Nesting them together means one and only one.

In order to do this we need to use the multi-input OR. Instead of using a multiple input AND we need one that activates if any two are active. This might be doable by setting the winch strength on the multiple input AND to 5. This way when only one winch is triggered it can't overcome the piston. If two or more are triggered then the combined strength might overcome the piston. If this works you only need to put these two together with a traditional two input AND to complete a very simple XOR switch. It's not quite as simple as these multiple input ANDs/ORs but XORs rarely are.
2009-04-17 19:07:00

Author:
dcf
Posts: 468


Probably for most levels a disolve based one would work, but the design I have in mind is fully reversible.

How the diagram works:

Green mag key is inverted so if the moving bar is pulled in, output is false; bar pushed out, output is true.

The weak piston is always pushing out (it's switch is inverted direction).

If all of the chains are set to out, then none of them affect the moving bar and the piston pushes it away.

Otherwise, the chain(s) that are set to "in" will pull in the bar setting output false. A single chain is enough because it's stronger than the piston.

You could always replace the piston with gravity, but I prefer having the movement a bit more controlled.


This sounds like all chains have to be activated at once though?
What if you wanted a reversable gate, that the effect was permanent, but reversable if one of the AND inputs were changed??
2009-04-17 19:20:00

Author:
Pinchanzee
Posts: 805


Pinchanzee, a single chain set to input is enough to pull the moving part back in. It's a fully working combinatorial AND gate.

[quote=dcf]Traditional two input XOR is AND(OR,NOT(AND)). Nesting them together means one and only one.[quote]
This is wrong. (a XOR b XOR c XOR d) will be true if 1 or 3 of the inputs are true.
2009-04-18 01:30:00

Author:
rtm223
Posts: 6497


Pinchanzee, a single chain set to input is enough to pull the moving part back in. It's a fully working combinatorial AND gate.

[quote=dcf]Traditional two input XOR is AND(OR,NOT(AND)). Nesting them together means one and only one.[quote]
This is wrong. (a XOR b XOR c XOR d) will be true if 1 or 3 of the inputs are true.

Bah, you're right
2009-04-18 01:45:00

Author:
dcf
Posts: 468


I'd be curious about you memory test results.

While I understand the piston based idea can be more "complex" engine wise, I know that emitters simply take alot more memory than connectors though. There's definetely a interesting test to be made in this case because it can go either way really. I would even bet the pistons wins memory wise since emitters are taking so **** much in my exp.

.
2009-04-18 05:31:00

Author:
RangerZero
Posts: 3901


I was thinking the memory test would be for traditional AND gates vs the multiple chains one. I'm not really convinced the emmiters AND gate is that great, simply because you can't negate the inputs internally to the switch. Plus it's so noisey! I'd use it for timing requirements only I think.2009-04-18 08:58:00

Author:
rtm223
Posts: 6497


It has no moving parts though - that was the challenge xD2009-04-18 16:05:00

Author:
dawesbr
Posts: 3280


Test Procedure: Gates built and tested in blank level. Captured as object and placed into new blank level once. Object copied 100 times with dark matter aligned to big grid. Thermo rounded to nearest 1/2 bar and recorded.

Additional notes: Only dark matter and white wood used for all tests. Starting gate left in level. No other objects in level.

AND Gates 2 Inputs
Parallel Config: 6 bars
Normal Config: 4.5 bars

AND Gates 3 Inputs
Parallel Config: 7 bars
Normal Config: 9.5 bars

AND Gates 4 Inputs
Parallel Config: 8 bars
Normal Config: 14.5

**************************************

The results speak for themselves. If you are using even 3 inputs there is an enormous thermo advantage to using the parallel gate. In addition, the parallel gate should have a faster response time compared to the series configuration.

***************************

I have also run an additional test. I took a captured 4 input AND gate, placed it in a level and deleted one input. I then copied it so there were 100 of them and measured the thermo. It appears identical to the thermo for the 3 input gate. Therefore, it does not appear necessary to clutter your profile with parallel gates for each input. Just make one for the highest number of inputs you will use and capture it. If you need less inputs just delete the chains.
2009-04-18 16:22:00

Author:
dcf
Posts: 468


Nice work dcf, I was hoping this would be one of those things where the more inputs you have the better the payoff.2009-04-19 12:08:00

Author:
rtm223
Posts: 6497


good stuff! great challenge! It's a shame I haven't picked up a new PS3 since moving (left mine to a friend). I found that winches have many interesting uses since they don't exert force when extending.2009-04-19 13:05:00

Author:
snowflakecat
Posts: 102


Oh, if anyone wants the 4 input AND/OR gates let me know and I'll send them to you. You must be careful with the lengths (2.5 instead of zero, etc) or else the thing oscillates.2009-04-19 13:11:00

Author:
dcf
Posts: 468


Hmm.. I'm still not really understanding how this idea works..
Has anybody made a level?
Or would somebody be able to make a tutorial level?
I'm sure many people would benefit from it, not just the members here
2009-04-19 15:44:00

Author:
Pinchanzee
Posts: 805


Think about it like this. Each chain is worth, say an arbitrary unit of 2. The piston is worth 7. Only when all the chains are on, and their total worth is 8, can they overcome the 7 that the piston has. If only 3 are on, they amount to 6, so the piston overpowers them.

Also, the piston can act as an override
2009-04-19 16:44:00

Author:
dawesbr
Posts: 3280


Ahh.. I see.. great idea!
I'll be sure to try it out
Thanks
2009-04-19 18:27:00

Author:
Pinchanzee
Posts: 805


Think about it like this. Each chain is worth, say an arbitrary unit of 2. The piston is worth 7. Only when all the chains are on, and their total worth is 8, can they overcome the 7 that the piston has. If only 3 are on, they amount to 6, so the piston overpowers them.

Also, the piston can act as an override

It's actually a little different than that. The piston is weakened so even a single chain overpowers it. When none of the chains are activated, the piston forces the material away. When any one or more chains are activated the material is pulled towards the dark matter.
2009-04-19 19:07:00

Author:
dcf
Posts: 468


Snowflakecat - yeah I found it quite a subtle but useful tool in many ways.

Pinchanzee, Consider the following:

assume pushing is a positive force, and pulling is a negative force.
When the forces of all connectors are combined:

Overall positive force makes the output of the gate TRUE,
Overall negative force makes output FALSE

The piston is always pushing, so always exerts a force of +5
The chains can pull or be passive, so exert a force of -10 or 0


Example cases:

If all chains are out, you get a total force of 5+0+0+0+0+...+0 = 5
If a single chain is pulling, total force = 5+0+0+0...+0 -10 = -5
2 chains pulling gives 5+0+0+0... -10 -10 = -15
Any more chains pulling gives a greater negative force.


The only way to get a positive force, TRUE is if all chains out is . Hence AND.

The problem with a tutorial level, is that you can't actually "see" the inner workings of this gate, only the output, so seeing it in action won't explain HOW it works, only that it does work...
2009-04-19 19:34:00

Author:
rtm223
Posts: 6497


My way would work too, wouldn't it?

Where n is number of winches.
Where p is piston strength.
Where w is winch strength.

w=(p+1/n)

Should do the trick each time, without the inversion of the gate.

Oh well.

Anywho, with my method (is it possible with yours too) you could have, say, piston of 7, three winches of 3, two winches of 5. It is like multiple inputs...to an n-input and. If you know what I mean?
2009-04-20 08:38:00

Author:
dawesbr
Posts: 3280


dawesbr, I like the fact you can put the different weightings (strengths) on the inputs, you can have some quite complex behaviour, could be really useful for some specialist application. But for a stright AND, you limit yourself to 5 inputs, with the assumption force of 1 is enough to move the object. Also you have to re-tune it to add / remove inputs.2009-04-20 13:07:00

Author:
rtm223
Posts: 6497


dawesbr: As rtm223 said, your method can work but it is different than the one described in the OP. I think Pinchanzee was asking about the method described by the OP. I was just pointing out that your explanation was an inaccurate description of the OP's contraption. I was not commenting on whether it would or would not work.2009-04-20 13:49:00

Author:
dcf
Posts: 468


Maybe I have my definitions mixed up, but isn't the first example an OR gate, not and AND gate?

I never studied electronics or anything so feel free to tell me I'm wrong, but logically, an OR gate would activate if it gets an input from any of it's multiple inputs (input 1 OR input2), where as an AND gate would activate if it gets inputs from ALL its inputs (input 1 AND input 2), wouldn't it?
2009-06-19 01:38:00

Author:
chillum007
Posts: 228


Maybe I have my definitions mixed up, but isn't the first example an OR gate, not and AND gate?

I never studied electronics or anything so feel free to tell me I'm wrong, but logically, an OR gate would activate if it gets an input from any of it's multiple inputs (input 1 OR input2), where as an AND gate would activate if it gets inputs from ALL its inputs (input 1 AND input 2), wouldn't it?

Your definitions are fine. However, you are misreading the device schematic. (LBP device schematics are very difficult to read!) The output is inverted in the AND gate while the chains are backwards in the OR gate. Each input chain begins contracted. When all the chains are extended, the piston pushes the key away, activating the inverted switch. For the OR gate the output isn't inverted but the chains are all set to backwards. So at the beginning all the chains are extended and the piston pushes the key away from the switch. When any chain is activated it contracts, overriding the piston and bringing the key to the switch, activating it.
2009-06-19 13:35:00

Author:
dcf
Posts: 468


Yeah it's a little hard to undertand because of the inversions. It's easier to understand if you imagine the output mag switch on a separate piece of dark matter and not inverted:


Dark Matter moving Part
|------| |------| |-----|
| |ccccccccccc| gK | | gS |
| | | | |-----|
| |ccccccccccc| |
| | | |
| |ccccccccccc| |
| | | |
| |ccccccccccc| |
| | | |
| gr |ppppppppppp| |
|------| |------|

When all of the chains (inputs) are TRUE (outwards), only the piston exerts a force and pushes the moving part out so the green key and switch come together, giving TRUE output.

If you want to have a play with them, there are examples of the AND and OR variants of this design as collectables in a level of mine (logic giveaway or something, not sure).
2009-06-19 14:00:00

Author:
rtm223
Posts: 6497


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.