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

How to make your own addtion calculator useing BCD calculator,basics of numeral logic

Archive: 18 posts


Road to build your own LittleBigCalculator
Well at least addition using BCD-based calculator

This article is part of Project CALTRON that also includes:

CALTRON the addition quiz machine - https://lbpcentral.lbp-hub.com/index.php?t=35152-CALTRON-Addition-Quiz-Machine
Numeral-logic components objects - https://lbpcentral.lbp-hub.com/index.php?t=35153-Shadowriver-s-numeral-logic-components&p=610167

Inroduction

First of all i'm not good article writer and i'm not native english speaker, so if you find any gramma errors and fact that article is not well formed... plz dont mind it^^'

This article describe step-by-step idea of bringing much thermo economic addition calculator in to LBP1, i have no idea how original LittleBigCalculator (at least addition part of it) is build, but it might in this way. My article can be read in 2 ways:

1.By reading whole article and see whole idea, you will see basics of numeral logic and most likly you will understand my LBP BCD calculator more
2. In simple way if you want to learn how to use numeral logic components in LBP, by reading only "Explanation of interpretation of LBP logic", "Numeral Systems" and "Bring all together sections"

I recommend to do way number 1 So let's get started

Explanation of my interpretation LBP logic

I made this section after writing whole article and i notice that i lose to enplane some terms that use in it the way i describe LBP logic... its mix of real-life electronics and what we have in LBP. If you fell lost you can read this section again

-Digital electronic in real world uses is 2 states 0 and 1, same as LBP in there wire (except speed), in this article we gonna use Winch based gates invented by rtm233 described in his article:

http://www.lbpcentral.com/forums/entry.php?842-Welcome-To-the-Wonderful-World-of-Wenches!!

-As you will see in it pistons and winches work as "Inputs" and and switches functions as "Outputs" of logic gates... but not only them, but in all components that we build pistons/winches gonna be inputs and mag switches are outputs, this is very impotent to understand my article, i think used word "Input" and "Outputs" over hundred times in it

-We gonna use directional output in switches since it's only way to control pistons/winches as signal in wires as we said before 0 and 1 are states that ruling LBP, here how element react on specific tates:
State 0: When mag switch is not reacting (now mag key near it's range) makes winch and piston to go to minimal length
State 1: When mag switch is reacting (mag key is near it's range) makes winch and piston go to maximal length
Of corse everything can be inverted here at any point

-I also gonna use word "bit" and "digit" lot, bit is as single 0 and 1, it's a state that we got wired to inputs and show of in output, also it's a single digit of binary numeral system. BCD digit is representation of decimal digit in 4 bits of binary numeral system 1-0000, 2-0001 etc.

I think thats it what you need at the beginning, if you want to understand my article, you need to see LBP1 logic in this way. You don't understand something more, reply with question?

Now let's get to real deal

Numeral Systems

So lets start with the beginning as you should know logic is based on 2 states (excluding speed) on and off, 0 and 1, true and false, light and darkness, nothingness and omniverse, whatever you like to call it. So how we gonna use only 2 digits to describe full numbers? Well... we just can let say 10 is 2 and 11 is 3, 100 is 4, 101 is 5 and so on and so on, we can use limited number of digits, or even more then we usually use to describe numbers. Group of symbols forming a digits is called numeral system, in real life we use numeral system that uses digits 0,1,2,3,4,5,6,7,8 and 9, this system is called "Decimal", system that we gonna use in LBP (and is used in all digital electronics) that have only 0 and 1 digits is called "Binary". What is so magical about 0 and 1? Well they 2 things:

1.They are easy interpret in world of electricity, we got power in the wire or simply not, same as in LBP wires
2. They are very abstract, it's easy to make numeral operation on it, and you will see that soon

So in LBP, we have can only only binary numeral system (in fact it's same limit in real life electronics ;]), how we gonna bring in decimal digits in this 2 stated world?... it's not simple as it look like at first, you might counted that maximal digit of Decimal system (aka 9) in Binary is 1001, look ok, right? well not fully, think how you gonna describe number 10, you can't go simply 10000 yet, since there other combinations of Binary digits 1010, 1011, 1100, 1101,1110, 1111 that can also describe numbers, skipping then would be nothing but waste of space. This is why in electronics there 3rd numeral system used, that uses those those extract combinations as digits and have 16 digits in disposal, it's called "Hexadecimal", Hex in short, not only it has digits 0-9 but also letters A, B, C, D, E, F. Even so we still can't get number described in Decimal system out of Binary system, so we need to workaround it a little bit... but how? We gonna talk about this later, let's use binary system for a little bit since it's only system we have in disposal in world of LBP logic

As summery, we gonna met 3 numeral systems

Binary - 01
Decimal - 0123456789
Hexadecimal - 0123456789ABCDEF

Heres example of conversation:


Dec Hex Bin BCD
0 0 0 0000
1 1 1 0001
2 2 10 0010
3 3 11 0011
4 4 100 0100
5 5 101 0101
6 6 110 0110
7 7 111 0111
8 8 1000 1000
9 9 1001 1001
10 A 1010 0001 0000
11 B 1011 0001 0001
12 C 1100 0001 0010
13 D 1101 0001 0011
14 E 1110 0001 0100
15 F 1111 0001 0101
16 10 10000 0001 0110
17 11 10001 0001 0111
18 12 10010 0001 1000
19 13 10011 0001 1001
30 14 10100 0010 0000

And so on and so on, i hope you get the idea of those numeral systems

Art of Addition

So we need to make adder and we have only binary system in disposal... so we have no other why then learn adding in binary system.You should know columnar addition method right? they learn that in 3rd class primary school, heres example:

1
7
+14
---
21

Addition each number of single column (4+7 in first column for example) and everything that is over digit size will be added in next column addition if form of so called "Carry" (in this example it's 1, +1 of our 2nd number it makes 2, and result is 21). This method works perfectly with binary numeral system and it's basis of addition and (as you will see in future) essens of calculation in logic circuitry. So lets try the same on binary system, 7 is 111 and 14 is 1101

1111
111
+1101
-----
10100

Reminding that 1s above is carry from last column. Now lets analyze, in this method we repeat same operation of addition on each column, in each column e got 3 digits inputed in to addition operation (Something that i forgot to say: digit in binery system = bit, 14 has 2 digits, 1101 has 4 bits):

-Bit from 1st number (we will call it A)
-Bit from 2nd number (we will call it B)
-Carried bit from last column (we call it C-IN)

And all those inputed bits are being added and return output of 2 different bits

-Bit that will be part of result (we will call it S)
-Bit that gonna be carried to next column from overflow, since we can only have 0 or 1 in one spot of result (we will call it C-OUT)

Now try to input different combination in to this addition and you will notice that there only 6 possible combinations and they have specific results:


A B C-IN | S C-OUT
---------------------
0 0 0 | 0 0
1 0 0 | 1 0
0 1 0 | 1 0
0 0 1 | 1 0
1 1 0 | 0 1
1 0 1 | 0 1
0 1 1 | 0 1
1 1 1 | 1 1

You might gone to conclusion that this works like logic gates, specific result on specific inputs.... you are not wrong You just discovered most basic element (or should i call gate?) of every calculator called "Full Adder" and of corse it's basic element of every LittleBigCalculator you seen and part of my BCD Calculator

Mystic powers of Full Adder

Now lets try to interpret Full Adder in to logic gates. First lets take look on S output, it only outputs 1 in two situations:

-In only one input (A or B or C-IN) is 1
-All inputs are 1

Now lets change this in to logic circut, let's take only A and B at first, S is only outputed if one of them is 1 but not both, what logic gate should we use here? XOR that returns 1 only if one input gives 1, so we gonna plug A and B to XOR gate inputs. Now let's take C-IN input in to the mix, C-OUT output one if C-IN is 1 or all inputs are 1, since we already got XOR gate returning 0 if A and B are both 1 or none of them, we can plag C-IN and that XOR gate output in to another XOR gate. By that at the end of our circuit will output same results as S in table above.

Now lets take care of 2nd output C-OUT, same as S it output 1 only in two stations:

-A and B are both 1 (whatever C-IN is 0 or 1)
-C-IN is 1 and only A or only B is 1

This one is very simple and if you good in logic gates you should get how to do it

-In first situation A and B need to be 1... so we simply AND gate those two inputs
-On 2nd station A and B need to be diffrent, our first XOR gate already output 1 on such situation, and C-In need to be 1, so we plug first XOR output and C-IN in to other AND gate

Both AND gates we gonna plug in to single OR gate and job is done, out C-OUT gonna output same results as in the table. Our final circuit should look like this:

http://academic.greensboroday.org/~regesterj/potl/Electronics/LogicGates/550px-Full-adder.png

Remember it, it will be useful in LBP2 and we can present this in to form of single microchip:

http://www.cs.cmu.edu/~ref/pgss/lecture/11/faddr-1b.gif[img]

Now you remember that out Full Adder represent addition operation of single column in column addition method, how we gonna add more columns in to this operation, again, very simple just place full adders near each other and connect there them from first free adder C-OUT to next adder C-IN and we will form chain of adders that should look like this:

[img]http://www.cs.cmu.edu/~ref/pgss/lecture/11/faddr-4b.gif

Now to calculate add binary numbers, you need to input bits of first number in to A inputs and 2nd number to B inputs, result will be outputted in S outputs. first C-IN need to be nullify with 0, and last C-OUT will output extra bit that need to be included in to result.

Due LBP1 wiring limits making this circuit with simple gates it's nice wise idea and it would be messy to use, there easier way and more nice looking. Thanks to flagging pistons idea (that i will describe feather in decoders) we can replce this bunch of gates with 3 pistons that will function as input and 2 triple input OR gates that will functions as output, piston contraction that you see in image lower place mag key on specific heights resulting specific esult from mag switches connected to or gates. You can get adder from my numeral logic components level and here how it looks like:

http://img829.imageshack.us/img829/3225/aphoto31.jpg

Congratulations, you got working addition calculator in LBP ^^

Conversation

Now we need to take care of how to input bits and how to output the result in more readable form. Binary numbers are easily convertible to Hex, since 4 bit of binary number can have 16 diffrent combinations, same as number of Hex digits. To convert Binary in to Hex and vice-versa we will need we need to build components called coder and decoder

Coder (Hex/Decimal in to Binary)

It's simple to understand and build, if you look on first table of this article and count 1s in each bit from numbers from 0 to 15 (in Hex from 0 to F), you will notice that each of 4 bits that we gonna use is 1 only 8 times not less not more. You might already dot some ideas in your head how to do it, let's take 4 OR gates that have 8 inputs each, now lets make 15 mag switches (or 16 if we want to know if we want to count 0), side by side and each mag switch gonna represent each Hex digit (reminder: 0123456789ABCDEF). Now look on first first table (conversation table) and connect mag switch to specific OR gates where binary bit of Hex digit output 1, if you not get it here table that will give you idea:

Switches 0123456789ABCDEF
OR Gate 1 0101010101010101
OR Gate 2 0011001100110011
OR Gate 3 0000111100001111
OR Gate 4 0000000011111111

Now whatever the mag switch will react, OR gates will output binary number of mag switch Hex digit. Remember that coder will work correctly only if one mag switch reacting at one time. We can also place Mag key on piston connected to 3 way switch and we create some kind of number selector/inputer, heres how my coder looks like, you are free to get it from may level with numeral logic components in 2 versions Hex and Decimal :

http://img521.imageshack.us/img521/7729/aphoto17.jpg

So universal way to build coder is to use:

-Switches as we need numbers (here we used 16)
-OR gates as maximum number of bits that gonna be outputted (here we used 4 since our decoder will only output 4 bits
-OR gates input winches as much as there will be possible 1s in each individual bit (here 8 on each bit)

If you ever made a code door lock with sliding number input, you should have basic idea how to improve this and display and coder in one body Bah, it can improve your code door lock by useing coder (read the first bonus)

Decoder (Binary to Hex/Decimal)

Decoder is reversal to coder and it's job is to convert binary number in to individual Hex digit. Now this is little more complicated to do in LBP1, same as we did with Full Added lets inspire our selfs from real world example how to convert Binery number in to Decimal (and practically any other system). Binary is 2-base system so each bit on 1 represents rising power of 2 from 2 ^ 0 to number of bit that we need to convert. To do so then we need to multiply that rising power with each bit and add them all together, foe example on number 11 (1011 in binary):

(1 * (2 ^ 0)) + (1 * (2 ^ 1)) + (0 * (2 ^ 2)) + (1 * (2 ^ 3)) =
(1 * 1) + (1 * 2) + (0 * 4) + (1 * 8) =
1+2+0+8 = 1+2+8 = 11

See? it worked now how to bring this in to LBP1, i had idea that i call flagging pistons (since this method of conversion by rising power reminds me flag values in programing... that is essentially the same thing), it's a tower of pistons that minimum length is 0.0 and maximum is rising power of 2 each piston (1, 2, 4, 8 etc.) multiply to some number since they are small at beginning.

How to easily build them? First of all "Small Grid" mode here is a must or else it will be much much harder, now make a square of black matter (1x1 or 2x2 or 3x3 or 4x4 etc), now think that this square is the smallest unit that you can use to build a level (if you have "Small Grid" and 1x1 square, it's actually is ;]) now we gonna place wooden squeres in same size side by side with rising distance (representing rising power of 2), so first distance will be 1 size of the squere, next will be 2 sizes of the squere and next distance will be 4 sizes of the squere etc etc. number of distences that you will do is number of bits that your decoder will have as input when we put pistons between them, with 4 bit it should look like this:


BPWPPWPPPPWPPPPPPPPW

B - Black matter square
W - Wooden square
P- Place for piston

Now connect them with pistons and set each on minimum length to 0.0 (or other but then you will need to move resulting part of decoder fader) also even with Small Grid LBP1 like to set maximum length of piston little feather away so you can calibrate it a little more, for example your first piston have maximum on 10.0 then next ill have double size of last one and so on and so on (10.0, 20.0, 40.0, 80.0).

Device that we just made have unique properties, each combination directional signals will bring last square (attached to longest piston in to unique position. So we can place mag key in to last square, and row of mag switches near it (4 bits, 16 possible combinations, so we will need 16 of them), whatever combination of bits we set it will be in unique postion and so we can assign each mag switch to Hex digit and here we have decoder. Heres how my looks like that you can get in my numeral logic components level:

http://img529.imageshack.us/img529/5606/aphoto15.jpg

In same way my adder works, but different is 2 pistons (A and B inputs) rising mag key in to same length and last one rises much higher (C-IN input).

Here some interesting thing that allows to use much smaller amount of thermo. Keys and Switches takes lot of termo and display that will show numbers will take even more, how to avoid that? Same as coders, simply by making connecting 2 of those things in to one, and making our decoder still being a decoder but functions also as display. Our decoders moves last element (on longest piston) in to unique potion, so if we make it longer and place stickers with numbers in specific potion and place stickers in specific positions (remember our square we used is the smallest unit of this positions) place cursor in pointing maximal digit when all bits are inputed 1 and here we got a simple display that points a number that been inputed in to decoder in form of binary number. You should get idea how this works right no, so you can design some fancy displays as you like, i used this kind of display in CALTRON also i made example tat looks like this and you can get it from my component level:

http://img97.imageshack.us/img97/8687/aphoto29.jpg

Back to the problem

So now you know how to make coder and decoder, but here we hit real problem that we forget in past (first sections of this article), our player most likely won't know binary or hexadecimal numeral system and our components that we do not works in decimal that everyone knows. So what we gonna do?

Lets see what we got now at this moment, most critical point is our display based on decoder, let's think how we can make it show decimal numbers.. only way to do it is to deliver decimal digits in to binary number and heres when BCD kicks in.

Binary-coded Decimal

It's a coding method using 4-bit of binary numbers representing single decimal digit (from 0 to 9), each decimal digit takes another 4 bits and so on and so on. So for example number 14 have digits 1 and 4, so:


In Decimal: 14
In Binary: 1101
In BCD: 0001 0100

If we had 2 decoders and input those BCD digits (4-bits each decoder) it would show 1 and 4, 14 you may notice i placed examples already in conversation table at beginning of articles. Also you may notice that we have 5 unused combination of 4 bits (A - 1010, B - 1011, C - 1100, D - 1101, E -1110, F - 1111), those are simply invalid and for BCD they don't exist.
Choose your destiny

Whatever we do we need to use BCD output anyway, there no other way since logic circuitry works only in binary way and we need to present it somehow, I it might sound hypocritical after i said that we can't go 10000 stright and it's waste of space, 1. mostly BCD is made outside device memory 2. i needed excues to make you learn something about numeral systems Since we don't have other way we have 2 ways to inject BCD in to it:

1. Use binary calculator that we build in earlier part of this article and convert it's output in to BCD
2. Make calculator based on BCD, inputing and outputting BCD digits without any need of conversation

So lets see pros and cons of each:

Solution 1
Pros: Calculation part will take less thermo and more bits means much much more bigger numbers that can be calculated, also it's easier to turn this in to subjective calculator
Cons: ... but converting it to BCD would take much more thermo with space

Solution 2
Pros: No need of any form of BCD converted, so no thermo use for that
Cons: Calculation part takes more space and thermo, so we can calculate smaller numbers

Even BCD conversion is possible by shifting and adding and using ton of logic gates it uses to much thermo (and keep in mind we would need to build such converted in input and output) that it would not fit in to LBP1, even if it would we could not use it to do something useful from it. So solution number 2 is much better and have less cons. Solution number 1 will probably be possible in LBP2

Let's build BCD Calculator

Do we need to rebuild anything? not at all, we just need to think We made binary calculator that can calculate many bits as we want, let's take a look on single BCD digit, it has 4-bit, so why won't we put 4 full adders connected to each other in to 1 box (microchip), since 4 bits it's all we need for a single BCD digit, let's call it 4-bit full adder. It will look like this:

http://engr.nmsu.edu/~etti/spring98/electronics/tapper/img00058.gif
(sry could't find better pic)

Same as single full adders we can connect full 4-bit adders to each other and they will function as binary calculator, as we remember each full adder represent single column of column addition method, since in BCD single digit is 4-bit long let's make our 4-bit adder a representation of a single column... but for decimal numeral system, So let's try to input BCD number in to it, if you play around and thin a little bit you will notice 2 problems:

1. When result of each 4-bit result go over 9 it starts to output invalid digits for BCD (1010-1111, A-F), as we remember they not exist in BCD
2. C-OUT of our 4-bit adder is not returning 1 when it need to (result is over 9), it only outputs 1 on C-OUT if result is over 15

Let's crash this problems and turn our binary calculator in to BCD calculator

Solving problem 1, magical number 6

As we know BCD is about going in binary numeral system from 1001 (number 9) stright to 10000 (number 16) instead of 1010 (number 10), the last bit with 1 should be our C-OUT output, how to make out 4bit adder output 0000, first digit of number 10 ? Well let's look how fur are we to make 4-bit output this number, we got 5 BCD invalid digits to crossover, we would need to add 6 to the result to get there.... wait a minute, thats it! let's try it out of Hexadecimal system since as we should know 4-bit in binary system is direct representation of Hex digit:

5 + 5 = A (its 10 in decimal and 1010 in binary one of BCD invalid digits let's add 6 to it)
A + 6 = 10 (in this situation first first 4 bits in out adder will be 0000, as it should be)

6 + 6 = C (it's 12 and 1100 in decimal, invalid)
C + 6 = 12 (first 4-bit will return 0010 as it should be in BCD calculator)

So we in conclusion that to correct invalid BCD digit we need to add 6 in to number that number and it should return real digit of our addition, same as we would do with column addition method in decimal numer system. So soultion is simple we need to put 2nd 4bit-adder above that gonna add 6 in to result of first 4-bit adder when BCD digit is invalid and to do so we just need to wire up output of first adder in to A inputs of 2nd and B of 2nd bit adder and 3bit adder (since 6 is 0110 in binary) tologic gates that gonna sense when number is invalid

Our problem number 1 is solved and also is connected to problem number 2, we need to detect when our 4-bit adder returns invalid BCD digit (over 9) to know when to add 6, since this also when C-OUT of our added should output 1.

Solving problem 2, in search of nonexistence

Invalid digits of BCD is over 9 in binary numeral system and this is also when C-OUT of our BCD calculator need to output 1, so we can simply connect C-OUT to 2nd and 3rd bit of number B of 1nd 4bit adder, but first we need to solve problem of C-OUT by detecting when 1st 4-bit adder outputs invalid numbers, let's take a look of them first


10 A 1010 0001 0000
11 B 1011 0001 0001
12 C 1100 0001 0010
13 D 1101 0001 0011
14 E 1110 0001 0100
15 F 1111 0001 0101
Same as we did with full adder we need to find situations allowing to claim that 1st adder return invalid BCD digit and set logic gates that will output 1 in such situation:

1. First we need to note those are not maximum what our 1st 4-bit adder can return, for example we gonna input 9 on A and 9 on B, result should be 18 and adder would return 10011, highest bit here is C-OUT, so first situation that we can depend on is when current C-OUT of first bit adder outputs 1

2. 4th bit always output 1 when adder outputs invalid digit and at least 3rd or 2nd bits also output 1, also keeping in mind that 2 valid digits that outputs 1 in 4th bit (9 -1001, 8 - 1000) have 0 on those bits, so as we just said we need to OR gate 3rd and 2nd bit of 1st adder and AND gate it's output in to 4th bit of 1st adder,in this way this small circuit at it's end will return 1 if 1st adder output one of digits in table above

Since now we also need OR gate C-OUT if output of logic gates in situation 2, we can do this in more optimal way by changing logic gates that detect situation 2. We can and AND gate 4th bit with 2nd bit and 4th bit with 3rd bit, we can OR gate both outputs of those gated and also include C-OUT in to this OR gate and we gonna gave same effect. Somewhat this way is more popular in world of electronics and this is what i implemented in to my BCD Adder, also output of this logic circuit will be our new C-OUT of BCD Adder

Final result, BCD Full Adder!

So here final result of what we build in our mind:

http://www.lizarum.com/assignments/boolean_algebra/images/adders/adders.png

and heres how this circuit will look like LBP1:

http://img840.imageshack.us/img840/2973/aphoto11.jpg

(It's a miniature of it since it so big it won't fit in single picture)

Now we can pack this in to one microchip and call it BCD Full Adder same as other full adders we can connect them in to chain with C-IN and C-OUT and they will look this way:

http://engr.nmsu.edu/~etti/spring98/electronics/tapper/img00080.gif

From the right this chain calculate ones, tens, hundreds, thousands etc etc of specific numbers.

Carry from last BCD adder need to be added as number 1 (that is 0001) in to next BCD Adder and we have unused C-IN in 4-bit adder so we can add carry to next BCD digit by this way. Last C-OUT will be 0 or 1 of next digit, in this example it will be ten thousands

Heres nice illustration showing how this will work circuit on binary numbers:

http://engr.nmsu.edu/~etti/spring98/electronics/tapper/img00081.gif

As you see it should work. Now lets pack this together in LBP1 and make working calculator.

Joining all together

You might jump to this section to see only how to connect stuff, so here simple summery what you need to know about BCD digit, i hope you read explanation of LBP Logic and it's dictionary first :

This will be full BCD calculator, BCD is a binary presentation of single decimal digit heres conversion table:


Dec BCD
4321
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

Any other combination of 0s and 1s are invalid and should be not used, or else BCD Full Adder will function improbably

Now lets take a closer look on my BCD calculator, lets start with inputs

http://img243.imageshack.us/img243/4015/aphoto28.jpg

You can see inputs are numbered showing what bit of BCD digits you should input in that pistons, you got info which bit is which in top of conversation table. All other of may components are also marked, so simply connect one color to same color

Bottom row of pistons are is where we input first digit (number A) and middle row is where we input (number B) and top piston in bit number 1 is C-IN, i you can keep it sealed with a switch if this BCD is responsible with is first digit (ones), but if this higher digit you need to plug C-IN to C-OUT of last/lower digit, that you can find here:
http://img810.imageshack.us/img810/7676/aphoto18.jpg

Switch on this big OR gate is C-OUT of BCD Adder

Now result of calculation will be outputted in OR gates on top:

http://img816.imageshack.us/img816/997/aphoto19.jpg

Same numbered same colord now you can connect those BCD Adders number with more digits by connecting them to each other, as we said C-OUT of lest one to C-IN of next one, each BCD Adder will calculate higher digits, from the right: ones, tens, hundreds, thousands, ten thousands hundred thousands, millions etc etc. more adders = bigger number we can calculate, but also more thermo we lose for rest of the level (!!!), single BCD adder placed close to each other takes somewhere around 1/6-1/8 of thermo.

Heres example of chain that can calculate 3 digit numbers (also part of CALTRON logic) ;]:

http://img839.imageshack.us/img839/1710/aphoto30.jpg

Last C-OUT of chain is a next digit 0 or 1, for example this chain allows to calculate 3 digits of decimal numbers, last digit is hundreds so C-out will return digit of thousands.

To input and output information from and to the player we can use coders and decoders (see sections above for details), my coders and decoders are are 4bit ones and work in Hex numeral system, but they can also output decimal digits codec in BCD. We can connect to of decimal version of my coders in to input (color to color) of BCD Adder A and B inputs and also plug them to the decoder (if you ever did door code lock in LBP1 and you read how to made coder above, you should get idea how to input display with a coder and reduce use of thermo), so player will know what number it inputs. we can connect output of BCD Adder to decoder (Again color to color) and it gonna show to player result of calculation

We repeat this process to each BCD Adder in the chain also we need to make display last 0 or 1 digit from last C-OUT of the digit, but i think you smart enough how to do it ;] you can plug whole decoder in to it and seal last 3bits... but it would be waste of thermo.

And here you go, you got functional Addition calculator in LBP1. This practically concludes my (long already) article, but wait, there some bonuses

More professional articles

As i said on the beginning in not native English speaker and not good article writer and theres more professional articles regarding problems of numeral logic circuitry out there, if you with my article is lame in terms of science and you want to dive in to the topic, jump in to the topic here links to them, they use more scientific terms (you will need to know the basics of digital electronics and some math) but i recommend to read them to, who know you might come up with easier solutions :

http://engr.nmsu.edu/~etti/spring98/electronics/tapper/bcdpaper.html
http://www.lizarum.com/assignments/boolean_algebra/chapter6.html
http://www.cs.cmu.edu/~ref/pgss/lecture/11/index.html

Ofcore they not cover how to bring this in to LBP1 piston logic, like my article
As you may notice i used images from those articles in my article, so credit from them should go to original authors

Also some wiki pages with terms we used:

http://en.wikipedia.org/wiki/Numeral_system
http://en.wikipedia.org/wiki/Binary_numeral_system
http://en.wikipedia.org/wiki/Decimal
http://en.wikipedia.org/wiki/Hexadecimal
http://en.wikipedia.org/wiki/Binary-coded_decimal

Oh, time for bonuses

Bonuses

Compare numbers

In my component pack (see links on beginning of article), you will find pack of 4 NXORs. XORs are very magical for binary numbers,this section will describe first property. Negated XOR can detect if bit is the same, since normal XOR return 1 if inputed bits are different, so by using 4 NXORs all connected to one OR gate we can see if all of 4-bits of BCD digit is the same. For example we got 2 coders we plug both of them in NXOR gates connected in one OR,that OR gate will only output 1 if both coders are set to same number(you can see demo of that in my component level and this way i CALTRON knows that you give him correct anwser). You can also improve your good all code door lock to ability that allows to set the code by the user,thanks to that you can make level "Go find code and back typing in" style of level or if you have some LBP clan HQ protected with lock (like LBPCentral logo level) it will reduce time to play with switches to set new code ;]

(NXOR image soon here)

Subtraction in binary numbers

(Work in progress, LBP2 beta is coming)

BCD based Subtraction

(Work in progress, LBP2 beta is coming)
2010-09-07 17:20:00

Author:
Shadowriver
Posts: 3991


WOW, that's a huge tutorial shadow, thank you so much for sharing. I'll definitely be mentioning this on my blog since we just actually started a new type of post, tutorials/help/glitches Once again, thansk a lot

Edit: It's out
2010-09-07 18:03:00

Author:
Dragonvarsity
Posts: 5208


Cool! I'm the one who should be thank you

Edit: lol, reading my article now i see some large language mistakes, i think i rushed a little bit, i will try to fix them later
2010-09-07 18:33:00

Author:
Shadowriver
Posts: 3991


http://a.imageshack.us/img202/1203/explodinghead.jpg2010-09-07 20:26:00

Author:
trip090
Posts: 1562


Make your head not explode, this is just a basics and you gonna see more advanced stuff in LBP2 2010-09-07 21:23:00

Author:
Shadowriver
Posts: 3991


Update:

-Killed some article bugs
-Added info on custom coder
-Added first bonus about comparing numbers

Enjoy even if your head explodes!
2010-09-10 01:47:00

Author:
Shadowriver
Posts: 3991


Oo, awesome update

*Head implodes*
2010-09-15 13:57:00

Author:
Dragonvarsity
Posts: 5208


ermm I'm not quite sure what i just... I think my brains bleeding from the information overload.2010-09-15 22:34:00

Author:
Pattington_Bear
Posts: 777


But you understand something from it? ^^'2010-09-18 02:39:00

Author:
Shadowriver
Posts: 3991


lol

To make something akin to "LittleBigCalculator" I used 2 wobble bolts, 39 magnetic keys and 39 LEDs.

You are in a computer science mindset... there is no need to work in binary. Work in decimal! It's much much more efficient in LBP - it's akin to parallel processing. Also you don't need to worry about converting/deconverting - it's just there.

If you want to make an accurate calculator (wobble bolts can be tricky, but it does work) just use pistons/winches like so

[]-----------------[]-----------------[]
[]-----------------[]-----------------[]
[]-----------------[]-----------------[]
[]============[]============[]

Where there there are 3 blocks of material (the first is dark matter), ---- is a winch and ==== is a piston. Now you can set the first cardboard block to move X units to the right depending on your input. Then set the second cardboard block to move Y units to the right depending on your input. Et voila the right-hand block has moved X+Y units to the right relative to the dark matter. Now all you need are some magnetic keys to measure the output. And hey, if you want, you just need ONE magnetic key to check if you need to carry! Just see if the block is past the 9th position.

Here's a tip - rather than building a NAND gate and thinking "yay now I can build complex logic purely out of NANDs" - think if there is a simpler way to achieve what you want. USE the physics engine which does millions of addition operations per second - there's got to be some way to extract some of that.

Edit: Come to think of it, pistons would work well on their own as well (if you didn't mind it being a bit innacurate).
2010-09-20 12:48:00

Author:
thor
Posts: 388


Holy wobble bolts now that's a tutorial if there ever was one.

I made a really super thermo efficient calculator once using only an emitter and a button...though it could only add up to 1...hmmm...

Ill have to give it a full read when I find the time
2010-09-20 18:02:00

Author:
theamilien
Posts: 485


... TOO... MUCH... TO... HANDLE!!!!!!!!

http://2.bp.blogspot.com/_3xqz_H5ThN0/S5AxzwKUudI/AAAAAAAAAiU/Okn5neLDSKM/s320/exploding-head.gif

Thanks for the help!
2010-09-20 23:50:00

Author:
OK1124
Posts: 126


@thor, you right, im after technical electronical school (i don't know if other countries have something like that, is you could call it high school with heavy set for electronical job) and have some programing skills, so this is hat brings to head at top and it's easier to work in binary XD I made it for CALTRON and if you play that level you can see it works quite well. I never seen level that gives some use to piston calculator as mine, yet if you know other level like that then tell me, i ould like to see it ^^2010-09-21 14:18:00

Author:
Shadowriver
Posts: 3991


Holy Jesus! That's some logic right there!2010-10-05 03:39:00

Author:
Emogotsaone
Posts: 1030


@thor, you right, im after technical electronical school (i don't know if other countries have something like that, is you could call it high school with heavy set for electronical job) and have some programing skills, so this is hat brings to head at top and it's easier to work in binary XD I made it for CALTRON and if you play that level you can see it works quite well. I never seen level that gives some use to piston calculator as mine, yet if you know other level like that then tell me, i ould like to see it ^^

I can't think where actually adding numbers would really come in handy, because most gameplay in LBP is physical. The only situation would be in some kind of dynamic maths puzzle, or a really advanced AI for playing some game.

I'm thinking of how to do multiplication and division in LBP, just as a technical showpiece. Got to think out of the box though - I think building custom log tables would be the way to do it
2010-10-05 10:13:00

Author:
thor
Posts: 388


CALTRON is dynamic mathematical puzzler ;] hmmm... but more like addition on time challenger. If you didn't try go check it out.

I build some custom stuff for it too, jet based randomizer (yea i know i'm crazy), resettable sequencer and resettable counter (but it think they are easy to figure out)
2010-10-06 04:03:00

Author:
Shadowriver
Posts: 3991


This is an awesome tutorial (like I'd ever have the time to read it)2010-11-19 04:32:00

Author:
tjb0607
Posts: 1054


best calculator tut ever!! (well, only calculator tut i no. )2010-11-25 19:51:00

Author:
FEAR
Posts: 337


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.