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

Addition using toggle logic switches

Archive: 26 posts


I have a bunch of toggle switches that I want to connect to a counter, but I want the counter to only display how many are active as apposed to how many times they've been toggled. Any advice would be much appreciated. Let me know if my question isn't clear.2011-02-09 18:33:00

Author:
Kraznoff
Posts: 26


Question: is something "triggering" the count of the enabled toggle switches? Or do you want the counter to keep up with them in real time?2011-02-09 19:48:00

Author:
Shanghaidilly
Posts: 153


Does it have to still be 'displayed'?

Try having it so the counter activates 2 NOT switches, one the opposite to the other. One resets the counter. The other one makes it go up. This one has to be the one that is off when it's actually OFF. So when the toggle witch is on, the counter is up. When not, it is reset. Each counter must have to have a target of 1.

Hope that helps.
2011-02-09 19:55:00

Author:
mutant_red_peas
Posts: 516


When you say counter, do you mean like the counter that is in the LBP2 tools? Or do you mean a counter like on a calculator that displays the number?2011-02-09 20:11:00

Author:
Shanghaidilly
Posts: 153


I mean counter as in the one in the Tools Bag. 2011-02-09 20:25:00

Author:
mutant_red_peas
Posts: 516


Sorry for the confusion, I'm using a calculator display type counter, not the one in tools. I tried spreading out the toggle logic switches on a sequencer and activating the sequencer at the end to count "active" signals, but when you put the toggle into a sequencer it removes the input. So in the end I want the display to show how many times toggles have been flipped minus redundant moves.2011-02-09 20:41:00

Author:
Kraznoff
Posts: 26


Why don't you have it so 2 numbers together in an AND switch make the answer (when they're added together) light up on the calculator display.

Example using tag sensors:

Light Green = 1
Green = 2
Yellow = 3
Light Blue = 4
Blue = 5
Pink = 6
Purple = 7
Red = 8

When the light green and blue tag sensors are activated they go into their AND switch and make the number when they're added together (6 in this case) appear on the display.

Then make something else logicy for a different operation. There's only 4 operations

Then you can use a selector and each AND switch with an extra port (for the selector output, which feeds into it when the operation is selected) so the selector chooses the operation.

Sorry if that's too much...
2011-02-09 20:47:00

Author:
mutant_red_peas
Posts: 516


Whoa, now I'm really confused. In your original post, you said you wanted to just count the enabled toggles. Now you want to know how many times each of them were toggled on and off? Aren't those two different things? Also, what does your counter work off of? I mean, what type of input does it expect let's say if 5 toggles are on.2011-02-09 20:49:00

Author:
Shanghaidilly
Posts: 153


The original one worked off counters from tools bag. But then you said it's counters off the calculator.

The second thing is powered by the numbers selected on either side of the operation sign. If the player selects 4 and 6, the 2 numbers power an AND switch which lights up the number 10.

Every number should be in invisible holo on the display, I think.
2011-02-09 21:07:00

Author:
mutant_red_peas
Posts: 516


I thought it meant the same thing, counting enabled toggles is the goal. I'm using this counter if that helps http://lbp.me/v/x94vgt . I'm gonna see what i can make of mutant's suggestion.2011-02-09 21:07:00

Author:
Kraznoff
Posts: 26


Thanks, I like seeing if what I say works. Post what happens on my Visitor Messages page.

Also I don't like people calling me 'mutant'. FourteenInchGaz calls me Mr. Peas, I like that name
2011-02-09 21:11:00

Author:
mutant_red_peas
Posts: 516


I think i understand what your saying but i think i have a slightly different situation, let me clarify a bit further. I have 25 toggles in a grid and you can switch them on and off. I want the counter to display how many of those toggles are on, either in real time or at the end, doesn't matter which. I think your way might work but with a ton of wiring, i feel like there may be an easier way.2011-02-09 21:31:00

Author:
Kraznoff
Posts: 26


Kraznoff - can more than one toggle switch be enabled or disabled at a time? What I mean is that whatever is turning them on or off, does it occur one toggle switch at a time, or can two toggle switches be turned on simultaneously? If not, then it's actually quite simple. Otherwise, I have a solution but will need to test it before trying to explain it off the top of my head (you'll still have to do a bit of wiring since you have 25 toggle switches to deal with).2011-02-09 21:40:00

Author:
Shanghaidilly
Posts: 153


Unfortunately from 3 to 5 can be toggled at a time.2011-02-09 21:43:00

Author:
Kraznoff
Posts: 26


That means that you're going to have to "work through" all the toggles switches and count them as you go. It should take approx. 1.5 seconds to "count" the switches. Is this acceptable?2011-02-09 21:53:00

Author:
Shanghaidilly
Posts: 153


What do you mean? And yes, 1.5 seconds is fine.2011-02-09 21:59:00

Author:
Kraznoff
Posts: 26


It's probably not the optimum solution here, but one way to do it would be to make a MC like the following.

Place a NOT gate on there. Have that run into a pulser (counter set to one and set to reset itself). Then run that out to the minus pole of a direction combiner.
Above that place a pulser, that runs into the positive pole of the direction combiner.

Run your toggle output to the NOT gate, and the pulser connected to the positive pole of the combiner.

Now every time your toggle flips, you should get a positive or negative signal you can send to the counter.
2011-02-09 22:02:00

Author:
tdarb
Posts: 689


It's probably not the optimum solution here, but one way to do it would be to make a MC like the following.

Place a NOT gate on there. Have that run into a pulser (counter set to one and set to reset itself). Then run that out to the minus pole of a direction combiner.
Above that place a pulser, that runs into the positive pole of the direction combiner.

Run your toggle output to the NOT gate, and the pulser connected to the positive pole of the combiner.

Now every time your toggle flips, you should get a positive or negative signal you can send to the counter.

If two or more toggle switches are turned on at exactly the same time, then you'll only see one of them since you'll probably be ORing the outputs from all this together to go into the counter. So the counter would only go up by 1 instead of 2 (or 3 or more).
2011-02-09 22:37:00

Author:
Shanghaidilly
Posts: 153


Ok, so i have it set up now so only one toggle is toggled at a time, any ideas from here?2011-02-09 22:47:00

Author:
Kraznoff
Posts: 26


If two or more toggle switches are turned on at exactly the same time, then you'll only see one of them since you'll probably be ORing the outputs from all this together to go into the counter. So the counter would only go up by 1 instead of 2 (or 3 or more).

yes, but you are talking about .03 seconds per pulse to update the counter.

Aside from that, the only real downside is that it outputs to the counter directly. You would need a buffer object of some sort to hold the "sum" in, in order to output it to the display when the add condition is met.
2011-02-09 22:56:00

Author:
tdarb
Posts: 689


I think that will work tdarb, i'll go try it out. I'll make sure to credit your counter, it's very handy.2011-02-09 23:03:00

Author:
Kraznoff
Posts: 26


OK, so your goal is just to have a display of the number of toggles activated, right? Not necessarily to have the total number of "on" switches be the value of one of LBP2's built-in "counter" objects?

Probably the easiest way to count the toggles is to combine them to create an analog signal. Set up a battery at 1%, and wire each input switch to an AND gate with that battery on the other terminal. Then get a battery at 100% and hook it to the positive side of a direction combiner, and hook the output of one of those AND gates to the negative side. The output of the direction combiner will be an analog signal that's either 100 or 99 depending on whether the switch was active. Keep doing this, chaining the output of a direction combiner to the positive input of another direction combiner, and the output of one of the AND gates to the negative side. Ultimately you'll get an analog signal that's (100% - (number of switches active)%) - pass that through a NOT gate and the analog signal will just be (number of switches active)%. Then feed that into a logic meter (build your own or find one online) and you'll have a display of the number of active switches.

Alternately you could build a big binary adder: take the switches in groups of two and turn the inputs into two-bit counts (A AND B -> value 2, A XOR B -> value 1, else value 0) - then take pairs of values, add them together with a binary adder until you've reduced the whole thing to a single binary sum. (Then you'll need to display the binary sum - you could do that by turning it into an analog value and displaying it with a logic probe, or you could create a binary-to-decimal decoder and do it that way...)
2011-02-09 23:06:00

Author:
tetsujin
Posts: 187


Wow, I can't say this is how I was expecting to play this game.

Works perfectly, thanks tdarb and everyone else.

Here is the final product for anyone following along: http://lbp.me/v/xmqpfj .
2011-02-09 23:19:00

Author:
Kraznoff
Posts: 26


I added it to my queue. I made a somewhat more primitive Lights Out game in LBP1, so i can't wait to see it!!

Mine is still uploaded too I think, if you would like to have a look
2011-02-10 08:10:00

Author:
tdarb
Posts: 689


Probably the easiest way to count the toggles is to combine them to create an analog signal. Set up a battery at 1%, and wire each input switch to an AND gate with that battery on the other terminal. Then get a battery at 100% and hook it to the positive side of a direction combiner, and hook the output of one of those AND gates to the negative side. The output of the direction combiner will be an analog signal that's either 100 or 99 depending on whether the switch was active. Keep doing this, chaining the output of a direction combiner to the positive input of another direction combiner, and the output of one of the AND gates to the negative side. Ultimately you'll get an analog signal that's (100% - (number of switches active)%) - pass that through a NOT gate and the analog signal will just be (number of switches active)%. Then feed that into a logic meter (build your own or find one online) and you'll have a display of the number of active switches.


This, IMHO, is absolutely brilliant. It doesn't even care if more than one toggle switch is modified during the same clock tick.

BTW, it's not too tough to put this analog signal through an ADC microchip to convert it to a pulse stream. This could feed the counter he is already using.
2011-02-10 15:57:00

Author:
Shanghaidilly
Posts: 153


Queued!

I had another suggestion but I guess you don't need it now.....
2011-02-10 19:49:00

Author:
mutant_red_peas
Posts: 516


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.