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

How to make a simple counter

Archive: 16 posts


http://i.imgur.com/PeQLy.jpg

Hurmurmur, hellur. Murmurmur. My name is Ram.. Kris and today I want to create some understanding of a simple counting mechanism that you can combine with some numbers and it will go up. And down. And you will be able to extend it easily.


http://i.imgur.com/5f0Ar.jpg

Here you see a basic setup. I turned the chip 90 degrees clockwise so the output of the chip will be facing down. It is a bit nicer to look at. There are two selectors on it, each with 10 ports. The right one represents the most right digit for your counter and will count from 0 to 9. The one to the left represents the next digit, 1x to 9x. You can continue this setup for hundreds, thousands and so on, but for now I'd like to keep it simple.

Channel #1 is value 0, while channel #10 is 9. You can connect the outputs of the selectors to numbers made out of holographic material and eventually stack them up per set. That is not displayed here, again for simplicity.

Now, what we want this basic setup to do is cycle from 0 to 9 on the rightmost selector and on each full cycle tell the selector next to it to jump one position. So you go from 00 to 09, then suddenly *boom* 10. And on and on it goes.


http://i.imgur.com/lCIXy.jpg

I hooked up a button to the cycle input of the rightmost selector. Each time I hit it, the selector goes up by one. When it goes full cycle and reaches 0 again, I want it to tell the next selector to go one up as well, so I connected ouput #1 to the cycle input of the left selector. This will work. Kind of...

Bare with me.


http://i.imgur.com/Y72zV.jpg

So now we have two buttons, one to count up and one to count down. I order to tell a selector to cycle up or down through one signal input, we place a signal combiner in front of the cycle input.

We have a slight problem now... How do we tell the left selector to either go up or down depending on which direction the right selector is going?

We can connect output #10 to the (-) input of a new signal combiner and hook output #1 to the (+) entrance. Then that new signal combiner goes into the cycle input of the left selector.

But wait, you say. When the right selector is counting up, it will also pass by output #10; when that happens it will tell the left selector to count down, so this doesn't work.


http://i.imgur.com/TpSIM.jpg

This. This does work, however... Kind of...

What this does is using the previous setup and instead of wiring output #1 and #10 directly into a signal combiner, they first get matched with another signal through an AND gate. If output #1 is activated AND there is a positive signal coming in, tell the left selector to count up. If output #10 is activated AND there is a negative signal coming in, tell the left selector to count down.

So, if this works, how come it "kind of" works?

Well, for two digits it works good enough, most of the time. As you move onto three, four, then five a curious phenomenon will occur that will not be visible when you use buttons, but does show up when other logic replaces the button and gives off a short pulse to count either up or down.

What happens is one signal on each AND gate arrives there instantly, while the other has to travel through a complex selector. Then at the third selector, one pulse also hits instantly, while the other has to have domino'd through two other selectors already. The routed signal will start to arrive at the AND gates with an increasing delay and it will cause the AND gate to fail.

What we would rather have is a setup in which only the selector tells the next selector in line whether he needs to go up or down and not having to depend on that original pulse. Enter the red chip!


http://i.imgur.com/s4GzA.jpg

I closed the red chip on purpose for now. You see there are two lines going in and one line going out. These lines going in are output #1 and #10 from the right selector; they get all mashed up inside and the result is either a positive or negative pulse going into the cycle input of the next selector in line. You can repeat this for every digit, in theory indefinitely; just place another selector to the left side with a red chip hooked to it, fed by gate #1 and #10 of the previous selector.

The red chip decides that when gate #10 is active first, followed by gate #1, the selector must have counted up. If the reverse happened, then it must have counted down. If neither happened, then the selector probably went from #10 to #9 or from #1 to #2 and nothing needs to happen to the next selector in line. This is what its guts look like:


http://i.imgur.com/M6iS8.jpg

You don't need to fully understand it in order to duplicate it and use it, but if you care for that:

the two incoming signals are combined at an inverted OR gate, which will pass an OR gate and reset two 1-shot counters. Meaning that when neither gate #1 or #10 is active, the memory of which output was active last can be forgotten. Such reset will also happen if either #1 was active (counter set) and #10 next, or #10 active (counter set) and #1 next. The latter two combinations are fed to a signal combiner that goes to the chip's output.

I hope this helps. Good luck!
2011-07-07 23:54:00

Author:
Antikris
Posts: 1340


I had the same problem, a continuous signal would behave different from a pulse signal due to the problems you mentioned here. My solution I remember, was more convoluted than yours, I had to convert the change signal to a pulse signal after I implemented the solution. Nice job!2011-07-08 00:06:00

Author:
hesido
Posts: 166


Hah, wow, I was JUST thinking about this. Like 5 seconds before I saw this thread! Epic timing. I need to make one for my level, so this should speed up the process quite a bit, thanks!2011-07-08 04:41:00

Author:
SSTAGG1
Posts: 1136


I had the same problem, a continuous signal would behave different from a pulse signal due to the problems you mentioned here. My solution I remember, was more convoluted than yours, I had to convert the change signal to a pulse signal after I implemented the solution. Nice job!

This tutorial basically shows the versions and the learning process I went through for the counters I use in my next level. Before reaching the red chip, there was another stage in which I was trying to delay the instant signal in order to time its arrival at every AND gate. Then tried 1-shot counters in order to 'store' the instant signal at the AND gate until the second signal arrived. All and all nothing really worked for the situation I was in: half a dozen or more pulses per second due to destroying waves and waves of enemies.

The red chip and the array of selectors still cause a tiny lag to echo through the counting system, but it no longer breaks the system.

Many thanks to shane_danger, btw, or I would still be muddling around with sequencers.
2011-07-08 07:15:00

Author:
Antikris
Posts: 1340


How funny! I was just yesterday messing about with trying to get a selector based counting system to count both ways and here's the solution! Brilliant2011-07-12 18:19:00

Author:
Epicurean Dreamer
Posts: 224


Erm, I'm not sure why you use a selector instead of a counter. If you want to get many outputs with a counter, just hook it to a selector with batteries on it, and set to position. Okay, perhaps it takes more logic then... Mmm - god I hate it, now I think about Mm when I type Mmm - Yep, I guess yours's faster (woot, can we say yours's in englsh? that was weird. Hum, sorry, lack of school makes brain think random... I speak French).2011-07-13 20:01:00

Author:
Unknown User


I can confirm that this is very useful, if people are still uncertain. I set up a 3 digit counter, and it takes almost nothing at all.

Something I want to note though, is that you need conditions for reducing the count when there is nothing left to reduce, else you will jump back up to 9.
2011-07-13 21:08:00

Author:
SSTAGG1
Posts: 1136


Something I want to note though, is that you need conditions for reducing the count when there is nothing left to reduce, else you will jump back up to 9.

Our own little Millenium Bug. I left that out on purpose, because people who have a use for this counter probably already have an action in mind to execute at a max or min value.
2011-07-14 10:21:00

Author:
Antikris
Posts: 1340


Selector-based counting logic has been around for yonks, being used in stopwatches and the like - but what I'm interested in is the circuit that determines whether the selector is counting up or down to cycle the next selector in the sequence correctly. I had the same issue 3-4 months ago and came up with a solution similar to yours, though less elegant:

http://i92.photobucket.com/albums/l37/Corporeal/022acb7d.jpg

If it's of interest this circuit detects whenever the selectors go above or below a set number and flip the counters appropriately. The two AND gates are just hooked up to the outputs of the tens and units selectors:

http://i92.photobucket.com/albums/l37/Corporeal/df365b51.jpg
2011-07-17 02:33:00

Author:
Ayneh
Posts: 2454


Cool! Thanks a lot!!!2011-07-23 15:32:00

Author:
TheGoldenFlash
Posts: 209


Do you know how to make adding and subtracting instantaneous or near it? For example, I have power ups that add 5 or 20 projectiles, and a move that subtracts 8. I have a way to add and subtract these, but it does it rather slowly and the person can continue emitting projectiles while these are still in the process of counting, which pretty much prevents it from adding/subtracting the full amount before it finishes.2011-08-11 00:44:00

Author:
Unknown User


Do you know how to make adding and subtracting instantaneous or near it? For example, I have power ups that add 5 or 20 projectiles, and a move that subtracts 8. I have a way to add and subtract these, but it does it rather slowly and the person can continue emitting projectiles while these are still in the process of counting, which pretty much prevents it from adding/subtracting the full amount before it finishes.

You cannot really do that with this setup. You can trigger a pulser that fires off 8 shots into the counter, but at best that will take 0.5 - 1 second before these are added. 20 shots is easier, though: just pulse the second selector twice. You may want to look into my buffering tutorial as well if you choose to go that route.

In general, though, if you want to add to or subtract chunks from a counter, analogue feedback loops are what you are really after. I am not aware of a FBL counter tutorial, but for a good introduction to loops, check out comphermc's tutorials (http://www.youtube.com/watch?v=c4GaCQ1eRVE).
2011-08-11 06:39:00

Author:
Antikris
Posts: 1340


You cannot really do that with this setup. You can trigger a pulser that fires off 8 shots into the counter, but at best that will take 0.5 - 1 second before these are added. 20 shots is easier, though: just pulse the second selector twice. You may want to look into my buffering tutorial as well if you choose to go that route.

In general, though, if you want to add to or subtract chunks from a counter, analogue feedback loops are what you are really after. I am not aware of a FBL counter tutorial, but for a good introduction to loops, check out comphermc's tutorials (http://www.youtube.com/watch?v=c4GaCQ1eRVE).

I used comphermc's feedback loop tutorial for the health bar, which works wonders. But I'd rather use your method for the projectiles since it allows for way more numbers in the status bar without having wires all over the place. I hadn't thought of just pulsing the tens counter, so thank you for that tip. The only reason I chose 8 was because I'm remaking a classic game and in it that certain move uses 8, but for convenience I'll just make it use 10.

I will also check out your other tutorial. Thanks a bunch! I'll be sure to credit you once my stage is complete.
2011-08-12 02:25:00

Author:
Unknown User


very neat. It's pretty similar to what I did here https://lbpcentral.lbp-hub.com/index.php?t=45133-Scalable-digital-counter-UPDATED-with-level, except we wired the chips slightly differently. Where you used the notted OR, I used the #2 and #9 outputs from the selector.2011-08-16 16:17:00

Author:
tdarb
Posts: 689


i have a 20 digit counter and its simpler than this >.>, i use a selector with 12 inputs, each selector is for 1 digit, inputs #1-#10 correspond for 0-9, 11th is for +1 to next digit and it resets selector back to zero, 12th is for -1 to the next digit and it resets it to corresponding 9 (#10 on selector), my method is so easy, and u attach a direction combiner on the cycle part of the lowest digit only, it can be copied and pasted on top of each other and it will get longer + the connections affix themselves, little simple tweaking you can even pick to change a differt digit at a time2011-08-17 03:15:00

Author:
Unknown User


i have a 20 digit counter and its simpler than this >.>, i use a selector with 12 inputs, each selector is for 1 digit, inputs #1-#10 correspond for 0-9, 11th is for +1 to next digit and it resets selector back to zero, 12th is for -1 to the next digit and it resets it to corresponding 9 (#10 on selector), my method is so easy, and u attach a direction combiner on the cycle part of the lowest digit only, it can be copied and pasted on top of each other and it will get longer + the connections affix themselves, little simple tweaking you can even pick to change a differt digit at a time
Unless I read this wrong, that does indeed sound like a much simpler method for just counting. What Antikris made this for is to combine with the buffer system, which I don't think would work with your method.
2011-08-17 04:16:00

Author:
SSTAGG1
Posts: 1136


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.