Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet 2    [LBP2] Help!
#1

How to detect what order two signals were activate in

Archive: 20 posts


*activated

There are two signals: A and B.

When signal A and then B activates I want to generate signal Y.

When signal B and then A activates I want to generate signal Z.

Been trying to figure this out for a while now and I just can't get it to work.
2011-03-28 03:21:00

Author:
Ayneh
Posts: 2454


This is a bit confusing. I could probably work this out somewhat easily in create mode, but it's really complicated when I try to do it in my head. Try experimenting with counters set to 1 and selectors to save the signals.2011-03-28 03:31:00

Author:
Joey9898
Posts: 131


Did you mean to delete both of those posts or just one?

I'm thinking something with microchips that get enabled/disabled (circuit breakers). Like when signal A turns on, it triggers a 1-shot counter that turns off a circuit breaker on the B signal. This will prevent signal B's signal from propagating to whatever receives the "first" signal. There will also need to be secondary connections from A and B so that you can detect that the signal has triggered second.

So like signal A hits a 1shot counter, which sends a signal to a node on a sub-chip (the A sub-chip). That node hooks into a NOT gate outside the chip, which then feeds into the activate input of another sub-chip (the B sub-chip). The node will also feed into one input of an AND gate (the A AND gate). The second input of the AND will be fed from the 1shot counter on the B side (you'll need to duplicate everything I've said to this point for the B side). The end result is that whichever signal is triggered first will disable the signal from the other side from getting through to its AND gate, so only the first signal can trigger its AND gate. Then you can feed whatever resets the system into the reset inputs of the 1shot counters.

I think that should work, but I haven't built it myself, so I can't say for sure.
2011-03-28 06:58:00

Author:
Sehven
Posts: 2188


A couple of things that could work, depending on what exactly you're trying to accomplish.

If Event A and Event B could happen over and over back and forth, you could do this:
Signal A increments 1-Counter Z and resets 1-Counter Y.
Signal B increments 1-Counter Y and resets 1-Counter Z.
The most recent event determines whether the activated output is output Y or output Z.

If Events A & B are one time events, it may be best to go old school LBP1 low tech:
An empty dark matter chamber is large enough to hold two key sponges, one on top of the other. Key sponges spawn at the top of the chamber and stack in chronological order.
The bottom of the chamber has key sensors Y and Z with radius set low, so they can only see the sponge at the bottom of the stack.
If A then B, Key A will be the only key detected, generating output Y.
If B then A, Key B will be the only key detected, generating output Z.
2011-03-28 07:35:00

Author:
discokrakken
Posts: 108


i was thinking along the same lines as you sehven, but I think there is something I am missing.

I drew out three different circuits that could show which was activated first. The simplest is am RS nand latch with NOT gates coming off of it.

essentially, signal A and signal B feed into inverted AND gates. the output of the A AND gate goes into the input of the one for B, and vise versa. these both feed out into NOT gates. this works with a constant signal but will shut off when the signals are cut, or will toggle if the input feeding the currently active signal is shut off.

i made another using a selector where A and b are both fed into the same XOR gate and separate AND gates, the XOR is then fed into both AND gates as well, and this into inputs 1 and two of a selector. The outputs are run through NOT gates, ad run into the third input of the AND gate attached to the opposite signal. Node three on the selector is used as a reset signal. This works really well for establishing which was first with pulsed inputs, but can be sketchy if not reset properly.
2011-03-28 08:16:00

Author:
tdarb
Posts: 689


Actually, since a selector gives precedence to the lowest port, I would think this could be accomplished with just two three port selectors, two AND gates, and a battery.

Take the two selectors and hook the battery up to port one on both. Take input A and hook it into the second port of one of the selectors (call this selector A), and input B into the second port of the second selector (call this selector B). Take the output of the second port of selector A and hook it into the third port of selector B. Take the output of the second port of selector B and hook it into the third port of selector A.

Take the output of the second port of selector A, and input B, and feed them into an AND gate. This output is Y.
Take the output of the second port of selector B, and input A, and feed them into an AND gate. This output is Z.

So what happens is this:

When input A happens first, it selects port two of selector A, which in turn selects port 3 of selector B. When input B comes online, it can't change selector B, since port 3 has precedence and is already selected. So you get output Y. The reverse occurs for when B comes online first.

Only when both ports go off is the circuit reset.

There is one caveat. If both inputs (A and B) come online in the same frame, both will select port 2, which will select port 3 on both. Unfortunately, you'll get no output since port 2 will not be selected for either.
2011-03-28 15:05:00

Author:
Shanghaidilly
Posts: 153


I had an horrendous time trying to sort this out for a racing type game and my logic became incredibly complex. So complex that there's a few of tenths of a second delay between the initial trigger and the result... where moving objects are concerned that is quite a large distance your object could have moved and I have a massive problem where if two players cross the line relatively close, the whole system fails. Though for some reason when I read your question I've thought of something much simplar. I haven't tested it so let's see if I can explain.

My issue is that it take a frame of movement for a piece of logic to activate I believe? Therefore if you have 5 logic components between your trigger and action that's one sixth of a second delay. Logic needs to be kept at a minimum and be in sync:

Ok, so you have sensor A and B each hooked up to their own self resetting counter with max value 1. Have two 3 way selectors and hook up a battery to input 1, counter A to input 2 and counter B to input 3 of one of the selectors. Also connect counter A and B to the inputs of an XOR gate. For the second selector hook up a battery to input 1 and the XOR output to the cycle input.

That's all you need to set up the basic detection logic, though if I'm right to believe the 1 frame per logic aspect, I'd suggest adding a double self resetting counter as then you have the same amount of components between the sensors and both selectors:

Sensor → counter 1 → counter 2 → selector 1.
Sensor → counter 1 → XOR gate → selector 2.

Now you just need to set up AND gates to determine the result: if output 2 of selector 1 and output 2 of selector 2 are lit, then object A has came first. If output 3 of selector 1 and output 3 of selector 2 are lit, you know object B came second etc. The added bonus though is that you also have a way of detecting when both activate at the same time due to the XOR gate. If they do, selector 1 will have output 3 lit, but selector 2 will still have output 1 lit as the XOR gate will have stopped any signal getting through, so it's a tie.

I'm aware this is similar to the setup posted by Shanghaidilly above, but this setup has the beauty of detecting when both cross at the same time, and I think it would be pretty straight forward to expand this to 4 objects (something I need for my race level) or even more. This setup has 3 components between trigger and result - one tenth of a second, I can't see any way of getting that lower unless a new logic component is released where it does this job for us.

That's if it works... like I say I haven't tested it so I could be overlooking something here.
2011-03-28 17:17:00

Author:
Xaif
Posts: 365


My issue is that it take a frame of movement for a piece of logic to activate I believe? Therefore if you have 5 logic components between your trigger and action that's one sixth of a second delay.

Actually, this is not true. The simulation optimizes the results on each frame. You can hook up 30 OR gates together in series and the result will be returned in 1 frame. My 7-bit signed register and adders have probably 50-60 components in them, yet I can take a stored value in the register, add a number to it, and store it back into the register in one frame (it takes one more frame to cool down before you can repeat the process).

Some things do have latency (sequencers for example which require an extra frame to output the result and the activation switch on microchips). You have to be careful hooking these up in series. Selectors have no latency, but one could contest that if you take the output of one port on the sequencer and hook it into another port on the selector. In this case, the first port is selected on the first frame, then whatever port it is hooked into is selected on the next frame. However, this latency ONLY occurs on selectors where you loop them in this fashion. Plus, this is extremely useful for creating complicated pulsers or for triggering frame by frame animations.

I
2011-03-28 20:13:00

Author:
Shanghaidilly
Posts: 153


I've been able to do this.

Basically I have 2 puzzles. Completion of either puzzle opens up the next one. The two puzzles also have their own rewards. When you complete puzzle 1, the camera swoops past it's reward, onto the opening of puzzle 3. If you want to complete the 2nd puzzle after it, I didn't want the camera to swoop across the the opening of puzzle 3, since it has already been done, so instead it goes to a different camera which just focuses on puzzle 2's reward. I'll take a photo of my logic now, if you wish?

And, yes.... it took me a while to work out too

EDIT:

http://img863.imageshack.us/img863/2976/aphoto.jpg (http://img863.imageshack.us/i/aphoto.jpg/)

Uploaded with ImageShack.us (http://imageshack.us)

Basically, (1) and (2) are the puzzles, the neon lights (they're out btw ) are the cameras. I think you only need the areas that AREN'T covered by green. The areas that are covered by green, I like to call the "Selective XOR gate". I'm sure others will have come up with it before and called it something else..... but anyway.... it works.

If you complete (1) 1st, you activate the 1st camera, if you then complete (2), you activate the 4th camera. If you complete (2) first, you activate the 3rd camera.... completing (1) after that will activate the 2nd camera.
2011-03-28 21:28:00

Author:
Ali_Star
Posts: 4085


http://i51.tinypic.com/eslrir.png

The inputs are A and B, and the outputs are C and D. If the A signal arrives first, C is active. If the B signal arrives first, D is active. If no signals arrive, C and D are both inactive. Both Counters have a maximum value of 1. You may remove the circuitry in red if you know that both signals will always stay on once activated.
2011-03-29 02:16:00

Author:
Unknown User


I have tested out my logic suggestion and while a blatant mistake was to use batteries (instead a seperate reset trigger should be used) it still doesn't work. Yet it should.


Actually, this is not true. The simulation optimizes the results on each frame. You can hook up 30 OR gates together in series and the result will be returned in 1 frame. My 7-bit signed register and adders have probably 50-60 components in them, yet I can take a stored value in the register, add a number to it, and store it back into the register in one frame (it takes one more frame to cool down before you can repeat the process).

Some things do have latency (sequencers for example which require an extra frame to output the result and the activation switch on microchips). You have to be careful hooking these up in series. Selectors have no latency, but one could contest that if you take the output of one port on the sequencer and hook it into another port on the selector. In this case, the first port is selected on the first frame, then whatever port it is hooked into is selected on the next frame. However, this latency ONLY occurs on selectors where you loop them in this fashion. Plus, this is extremely useful for creating complicated pulsers or for triggering frame by frame animations

There seems to be some form of latency with selectors. In my setup when the first object passes it records that as coming first, however when the second passes it records that as coming both first and second... This seems to be due to the selectors overlapping somehow, do they turn on the new output in one frame, then turn off the old one in the next frame? That's the only way I can think it is messing up, because like I say, it SHOULD work.

Another issue is the XOR gate, when both objects pass at the same time sometimes it triggers... sometimes it doesn't. It's highly inaccurate for some reason, and I have made it so that both objects are exactly lined up with the grid, yet it gives inconsistent results.

I'm baffled and quite annoyed by it. =|
2011-03-29 14:00:00

Author:
Xaif
Posts: 365


http://i51.tinypic.com/eslrir.png

The inputs are A and B, and the outputs are C and D. If the A signal arrives first, C is active. If the B signal arrives first, D is active. If no signals arrive, C and D are both inactive. Both Counters have a maximum value of 1. You may remove the circuitry in red if you know that both signals will always stay on once activated.

That's the RS NAND latch I was describing earlier. awesome

there's a good description of it here (http://www.play-hookey.com/digital/rs_nand_latch.html). That site is also a great resource for exploring digital and analogue logic.
2011-03-29 14:21:00

Author:
tdarb
Posts: 689


http://i51.tinypic.com/eslrir.png

The inputs are A and B, and the outputs are C and D. If the A signal arrives first, C is active. If the B signal arrives first, D is active. If no signals arrive, C and D are both inactive. Both Counters have a maximum value of 1. You may remove the circuitry in red if you know that both signals will always stay on once activated.

At first I didn't see how this could work, but one thing you didn't tell us. Those are inverted AND gates. Correct? Otherwise, with standard AND gates, both C and D would be on in it's initial state and a catch-22 condition would be created for the AND gates.
2011-03-29 15:16:00

Author:
Shanghaidilly
Posts: 153


Shanghaidilly, the circle after the gate means the output is inverted. That's common logic notation. 2011-03-29 15:27:00

Author:
Linque
Posts: 607


yup, the circle at the end of it means the output is inverted. It really denotes a NOT gate on the end, hence the name NAND gates (Not AND).

http://www.play-hookey.com/digital/derived_gates.html
2011-03-29 15:31:00

Author:
tdarb
Posts: 689


You can also use the circle at the input of the gate to denote that the signal is inverted right before the input. This can be useful when drawing pictures if you have multiple paths of the same signal and some but not all are inverted.2011-03-29 15:37:00

Author:
Linque
Posts: 607


Shanghaidilly, the circle after the gate means the output is inverted. That's common logic notation.


yup, the circle at the end of it means the output is inverted. It really denotes a NOT gate on the end, hence the name NAND gates (Not AND).

http://www.play-hookey.com/digital/derived_gates.html


Thanks for setting me straight folks. I totally missed that.

Anyone tested this to see how the simulation handles both A and B signaling in the same frame? I'm just not sure how the simulation will handle the precedence.
2011-03-29 17:41:00

Author:
Shanghaidilly
Posts: 153


Well, that will cause a race condition, unfortunately. Ideally, I would recognize when this condition occurs and route the output elsewhere. Let me see if I can draw up an alternate schematic.

http://i53.tinypic.com/fthcuo.png

I modified the original schematic to account for this race condition. A and B are fed into two counters that reset themselves. This means they activate for only one frame. If they're both active in the same frame, this means there's a race condition so the output goes to bottom of the next set of counters. Otherwise, the inputs go into the original circuit, which is in its own microchip.
2011-03-29 19:48:00

Author:
Unknown User


It wouldn't handle it well. I listed an alternate circuit that will work in an earlier post.

Another solution would be to run your AB inputs into AND gates, and then into 1 & 2 on a sequencer. run output 1 of the sequencer out to a NOT gate and into AND B, do the same with output 2 but into AND A. You would just need a third input/output on the sequencer to put a reset signal into it to clear the outputs. This will only work with pulsed inputs though.

With a sequencer the highest active input takes precedence. so if hit at the exact same time, B should activate disabling A. When you activate input three, it goes out to nothing so represents a neutral state.
2011-03-29 20:37:00

Author:
tdarb
Posts: 689


Hi, sorry I couldn't respond sooner. Thanks to all the thoughtful replies I got it working. It uses a couple of counters plus some and gates as per a few of the suggestions here.

It's reassuring others had the same problem when it came to puzzles or races and that there are a number of applications for this kind of logic. Cheers.
2011-03-30 23:24:00

Author:
Ayneh
Posts: 2454


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.