Wednesday, January 28, 2015

Basic Gates

The core of breadboarding, and circuit building is based off of AOI logic.  AOI stands for AND, OR, INVERTER.  These are the most basic gates to use.  These gates all have different truth tables and outputs depending on their input.
The AND gate outputs a 1 only when all of the inputs are a 1, and outputs a 0 when only one or none of the outputs are a 1. When inputs are put through an AND gate, the result is written by multiplying the inputs together.  The truth table is as follows:
X   Y    F
0    0    0
0    1    0
1    0    0
1    1    1



The OR gate outputs a one when any of the outputs are a 1, or when all of them are, and outputs a 0 when all of the outputs are a 0. The result of inputs put through an OR gate are written with an addition sign written between the inputs.  The truth table is as follows:
X   Y    F
0    0    0
0    1    1
1    0    1
1    1    1




The NOT gate, also known as the INVERTOR gate, outputs a 1 when the input is 0, and outputs a 0 when the input is 1. This gate is particularly special because it is the only basic gate that only has one input.  (AND and OR gates can have two or more, unless one was to tie the inputs together) The truth table is as follows:
X    F
0    1
1    0

Click Here for more information on the gates and a few more complex ones.

Voltage, Current, and Resistance

Voltage, current, and resistance are all terms used in electricity. Voltage is the force that is moving the electrons along the circuit. Current is the amount of electrons moving in a circuit. Resistance is the force acting against the current in circuits. Voltage is measured in volts (V), current is measured in amps (I), and resistance is measured in ohms (Ω). These terms all impact each other, as shown by this image to the right -->.
The Voltage is pushing the current through the circuit and the resistance is limiting the amount of current that can get through.


There are two laws that apply to this, Ohm's Law and Kirchhoff's Law. Ohm's Law states that Current (I) = Voltage (V) x Resistance (Ω).
If you know 2 of the 3 values, you can solve for the third by using Ohm's Law. Say you wanted to find resistance in a circuit. If you had 50 amps and 25 Volts the resistance would be 2 ohms. By doing 50= 25x ( in this case X is resistance) you could easily find resistance, which is 2 ohms.
Kirchhoff's Law states that the voltage dropped at each resistor equals the total voltage of that circuit from the power supply. Click here to see some examples and a better explanation of the Law,



Bread boarding

Bread boarding is used in digital electronics to wire and test a circuit. Many components can be used to bread board. For example, some include resistors, wires, capacitors, gates (like the AND, OR, and NOT), or switches. The actual bread board is wired underneath in a specific way.


Every hole in the green circle is connected. The very top line is all connected, and is separate from the line below it. The first 2 lines across the top  and the bottom are called banks. For the middle, each 5 holes vertically care connected, and are separate from the next set of 5 holes next to it, or below it. the banks are not connected to the middle area, and the 2 middle areas are not connected to each other.


There is also this type of bread board, which is a little different, but not by much.



Instead of the banks being only 2 lines on the top and bottom, its split into 2 groups, as shown by the very top red lines. These 2 banks aren't connected, and are separate from each other but everything else remains the same.

Resistors

Resistors and their color code


A resistor is a device having a designed resistance to the passage of an electric current. These resistors have different values, which means they resist a certain amount of current. The code for how much these resist is represented by colors. the resistors could have 3, 4, or 5 bands on them. The bands could be a different color, or the same color as the next one. The first 3 bands represent a number based on what color they are. The colors and the numbers are as follows: Black-0, Brown-1, Red-2, Orange-3, Yellow-4, Green-5, Blue-6, Violet-7, Grey-8, and White-9. The first band is the number that goes into the hundreds place, the second band goes into the tens place, and the number of the third band goes into the ones place. If the fourth band is any color from Black through Violet, or Gold or Silver,  there is a certain multiplier that the number from the first 3 bands gets multiplied by based on that color. The multiplier goes as follows: Black-1, Brown-10, Red-100, Orange-1K, Yellow-10K, Green-100K, Blue-1M, Violet 10M, Gold-0.1, Silver-0.01. The fifth band is the tolerance, or the amount it can vary. This goes as follows: Brown-±1%, Red-±2%, Green-±0.5%, Blue-±0.25%, Violet-±0.10%, Grey-±0.05%, Gold-±5%, Silver-±10%. For a diagram and a conversion option, Click Here.
One of the more important things to remember when dealing with resistors is the capacity that each can handle. If too much current is passing through a resistor, the result would be one big spark and one fried resistor.

Analog vs. Digital Signals


When it comes to electronics, there are two major types.  Without one, electronics as a whole will become obsolete.  Analog signals require a range of numbers.  This can be anything from how much light a sensor receives, the distance an object is from a sonar or how warm it is inside a room.  The size and magnitude of the number depends on the sensitivity of the sensor in question.  When graphed, the analog signal can have many different slopes, heights, different peaks and different low points.  When graphed the line should be a smooth continuous line, most similar to a sin curve. Digital signals are either on or off.  For example, a light switch is a digital device, either on or off.  When graphed, digital signals appear blocky, either at a high point or at a low point.  Digital signals are the ones used when logic gates are placed in a  circuit.  This is because a on or off is required in the gate, and if the gate received a numerical input like 5234, the gate would have no idea what to do with it.  Digital is used for computing and digital electronics while analog is better for video and audio signals.  It is important to understand that analog deals with ranges of numbers, and digital deals with a definite binary bit, this makes digital somewhat easier to predict the outcome.  This is because with digital, you can predict what ALL the possibilities are with a truth table.  With analog, it can sometimes be difficult to predict what the sensor will output. 

Here are some links to check out to learn more!
https://learn.sparkfun.com/tutorials/analog-vs-digital
http://www.diffen.com/difference/Analog_vs_Digital

Hexadecimal and octal number systems

                                                                                    Note:
This post assumes that you have already read the Binary Number system post, as the information given here is very similar to what is discussed there, and therefore will assume that you have a base of understanding on how base ten and two work.

By now, two number systems should be familiar, base two, and ten.  In reality there is an infinite amount of number systems.  To reaffirm the process, and to expand understanding, two more number systems should be discussed, base 8 (octal) and base 16 (hexadecimal).

Base 8: 
In base 8, as in every base, the first place value is always one.  In base ten, one of any ten numbers (0-9) can be put into this spot to represent the quantity of "one's" we have.  In binary one of two numbers (0 or 1) can be put in this spot.  In base eight, one of eight numbers can be put in this spot (0-7).  So if representing the number seven in octal, we would simply put "7" in the one's spot.  Every spot to the right in octal is the product of (8)*(the value of the place value to the left).  So the spot to the right of the "one's place" would be the "eight's place."  The next spot would be the "sixty-four's place."  This is the product of eight times the value of the place value to the left, which in this case was eight.  The next spot over would be the "five-hundred twelve's place."  This is the product of eight times the value of the place value to the left which in this case would be the "sixty-four's place."  This process could continue infinitely.  Say we wanted to represent the number 412 (base ten) in octal.  We know right off the bat that we do not have anything in the "five-hundred twelve's place" because our number is smaller than that.  So we turn to the next lowest value, the "sixty-four's place"  The question we now have to ask is how may sixty-four's do we have?  We have six. So we can write 6 in the "sixty-four's place."  What are we left with?  412-(64*6) = 28.  The next question we have is, how many eight's we have.  We can have a max of three.  28-(8*3) = 4.  That last step is simple, how many ones do we have?  The answer is four.  So to write 412 (base ten) in octal: 634 (base eight).  To convert that number back, we would do the same thing in reverse.  We would note the value that each quantity represents and multiply that times the quantity in that place.  For example, we have a four in the "one's place."  So we have four ones.  (4*1) = 4.  We have a three in the eight's place.  So we have three eight's.  (3*8) = 24.  Finally, there is a six in the "sixty-four's place."  (6*64) = 384.  The last step is to add all of those products together.  (4*1)+(3*8)+(6*64) = 4+24+384 = 412.

Base 16
Base sixteen works the exact same way, but instead of increments of two, eight or ten, it goes up in increments of sixteen.  Also note that a difference is that now there are sixteen values we can use (0-15).  Now, a problem with base 16, is that there are values we can use that should take up two place values (11, 12, 13,14, and 15.)  Therefore we use letters in their place.  A = 10, B = 11, C = 12, D = 13, E= 14, and F = 15.  The first place value, as any, is the one's place.  Then it goes up by multiplying each previous value by 16.  So, from left to right the values of the places are: 1, 16, 256, 4096, 65536, ect. So, if you were to start with, say D2, and you wanted to convert that to base ten, you would start by saying that you have 2, one's.  The next number (or in this case a letter) represents the number of sixteens.  D = 13, so you have thirteen, sixteens.  To calculate the number in base ten, you would add the products.  (13*16)+(2*1) = (208)+(2) = (212).  If you started with the 210, and you wanted that in hex., you would ask yourself how many sixteens you have.  You would find that you have 13.  Then you would find how many ones are left, which in this case is 2.  You would write, D2.

As it turns out there is a very convenient way of converting hexadecimal to binary and vice versa.  Each place value in binary is called a bit. Each letter/number in hexadecimal is equal to four bits, or one nibble in binary.  Say you have one nibble of binary, for example 1011, and you want to convert this to hex.  All you need to do is convert this nibble as you would of you were converting it to base ten.  In this case, the result would be eleven.  But since you want this in hex, you would write this as B.  But what if you started with 10101100?  Before, it was simpler because the binary number was already a nibble, so we skipped the first step.  Now we have eight bits, or two nibbles, so we want to break them up for now.  1010 and 1100.  Now convert each one individually as before.  1010 is really ten, written as A, and 1100 is twelve, written as C.  Now put the two results in order that the nibbles were, so AC.  Now say we wanted to convert this back.  Keep in mind that each place value in hex is four place values in binary, so we can use four spots to fill in to get ten.  The combination needed to make ten it 1010.  C is twelve.  Again, we can use four place values in binary to get this number.  The result would be 1100.  Now put the two of them together.  10101100.
The same can be done for binary to octal, and octal back.  In this case, however, the binary numbers would be grouped into groups of three, and each place value in octal is equal to three bits of binary. 

 Sometimes converting long sequences of binary to decimal can be a major pain.  Take for instance the sequence 10110000111010110101.  To convert this directly to base ten would be a complete waste of time.  This could be converted with much greater ease into hex.  Simply group them into nibbles and convert.  100111010110011010001 could be converted to octal by grouping the bits into groups of three and converting.  From there you could convert the octal, or hex result to decimal, but many programmers leave it as is.  Hex is also the number system of choice when dealing with colors because only three symbols are required to make any color.


Check out these sources for more info!

http://thestarman.pcministry.com/asm/hexawhat.html
http://mathworld.wolfram.com/Hexadecimal.html
http://www.wikihow.com/Understand-Hexadecimal



The Binary Number System


At the core of digital electronics, the binary number system defines digital electronics itself.  As will be discussed in Digital signals in more detail, digital electronics consists of two positions or values, on and off.  When making truth tables, one must be able to count in binary and understand the meaning of the numbers to successfully complete it. It is therefore that binary is the heart of the computer and the computer's calculations.

Perhaps the easiest way to understand binary is to compare it to base ten, the number system that humans use to do calculations.  Base ten uses a series of numbers 0-9 to represent the quantity of the place value it holds.  With all bases (base two, base eight, base seven-hundred thirty-seven, ect.) the first place holder (the rightmost) is always the "one's" place.  Each place holder to the left is a multiple of the one before it.  In base ten, then next place is the "ten's" place, and the following is the "hundred's."  So each place holder to the right is the previous place holder X 10.  In base ten, if you were to write "37" that means that you have three tens, and seven ones.  You would then add thirty and seven to get thirty seven.  Base two (Binary) multiplies X 2.  So the place to the right of the "one's" place is the "two's" place and to the left of that, the "four's" place.  With base two, the only numbers available are 1 and 0.  If you were to write 100101, that means you would have 1 one, 0 twos, 1 four, 0 eights, 0 sixteens, and 1 thirty-two.  Since there are no twos, eights or sixteens we can forget about them for now, the zero is a place holder to say that we do not have any of that particular place.  If we were to add what we are left with: the one, the four, and the thirty-two, we would get 37.  This number is in base ten.  This is the way to convert binary to base ten.  To convert from base ten to binary, the opposite process should obtain the correct results.  Say that you have 23 in base ten, and you want to convert that to binary.  First it might be beneficial, but not necessary, to find out how many places you need.  To do this, find the highest place value that does not exceed the number you have.  In this case it would be the sixteens place.  We do not need any places beyond this because the next value would be thirty-two's and we have a number below it, so we have zero thirty-two's.  So we can safely say that we do have one 16, because 23 is indeed higher than sixteen.  If we were to take sixteen away from our 23, we would have 7 left.  The next lowest value is a eight.  Eight exceeds the 7 we have left, so we have 0 eight's.  The next lowest value is four.  There is one four in the 7 we have left so we can put a 1 in the "four's" place.  We now have a 3 left.  The next lowest place is the "two's."  There is one 2 in what we have left, so put a 1 in the "two's" place.  Now all we have left is 1, and the final place value is 1, so we have one 1.  It is in this way that we can write the number 23 as: 10111. We use binary everyday without thinking about it.  Flipping a switch to turn a light on or off is binary.  Turning on the TV or turning it off in involves binary. 

But why intentionally use binary?  In digital electronics, binary is used on the basis of calculating an output in a certain scenario.  This is imperative when creating a circuit, especially if you want it to work correctly.  But more importantly, it makes you look incredibly intelligent. On a more serious note, binary is not commonly used for other uses.  The amount of ones and zeros involved with writing numbers in binary, make binary very complex to decipher, and we already have all of the calculations we do on a day-to-day basis set up for base ten, so converting to binary for any reason would be costly, and extremely difficult.  Therefore, outside of digital electronics, binary is almost obsolete.  Digital electronics, however is centered around binary, and without it digital electronics would fail.  Also, fancy watches would not exist as they do today.



Here are some links to check out to learn more:
http://binarytranslator.com/what-is-binary.php

http://l3d.cs.colorado.edu/courses/CSCI1200-96/binary.html

Truth Table to Equation

Note:
This post will not only cover how to convert Truth Tables to Equations, but it will also cover what a truth table is, and how to use it.

So, what is a truth table.  If that is what you start with, and you do not understand what it means, then it is practically useless to you.  A Truth Table is a chart that lists all possible combinations of inputs, and the output of those combinations under a set of gates.  Here is an example of a Truth Table from the Majority vote project.


P
V
S
T
Decision
Row #
0
0
0
0
0
1
0
0
0
1
0
2
0
0
1
0
0
3
0
0
1
1
0
4
0
1
0
0
0
5
0
1
0
1
0
6
0
1
1
0
0
7
0
1
1
1
1
8
1
0
0
0
0
9
1
0
0
1
1
10
1
0
1
0
1
11
1
0
1
1
1
12
1
1
0
0
1
13
1
1
0
1
1
14
1
1
1
0
1
15
1
1
1
1
1
16


Note: the column labeled "row #" is simply there for reference and is not necessary in a Truth Table.
The columns labeled "P, V, S, and T are the inputs for this particular Truth Table.  They represent President, Vice President, Secretary and Treasurer.  each row in these columns is actually just counting up from zero to fifteen in binary.  To briefly go over how to set up the Truth Table we will start with the patterns of these four columns.   For any Truth Table, to figure out how many rows there are, we use the formula 2^(n)  where n= the number of inputs.  With four inputs, we know that there will be sixteen rows.  Then, with the right-most column, we start with zero and alternate every row.  The second column we alternate every two rows, the third, we alternate every four, and finally, the fourth column alternates every eight rows.  The result of this shows that each row of inputs counts from zero in binary.

The next step is to fill in the decision column, which for the sake of time we will not get into for this example.  Each problem has a different set of outcomes, and in this case, this column has already been filled in to specify the demands of the problem. 

Now we get to how to convert this to an equation.  The first step is to look at, and mark the minterms.  A minterm is any row that resulted in a one or an on.  The way to mark them is to write down the combinations of the inputs.  Take row 8 for example.  This is a minterm because it outputted a one.  So, we write under what circumstances this happened.  The president (P) was a zero.  So we write P' (which denotes "Not P").  All of the others are a one.  So we write all of this as products of each other P'VST.  This is how we annotate this minterm.  For another example, Row 10.  Row ten would look like this; PV'S'T because both V and S we zeros and both P and T were ones.  After you do this with each row that outputted a one, you throw them all together into a Sum-of-Products equation.  This is a sum of products because if any one of these combinations occur, the output will be a one.  So you would combine the products with addition signs that represent OR gates.  All of these letters are "multiplied" together because in equations, AND gates are represented by multiplication.  The final equation for the Truth Table above would be;


P'VST + PV'S'T + PV'ST'+ PV'ST+ PVS'T'+ PVS'T+ PVST'+ PVST
This of course could be simplified using k-mapping or blooean algebra, but this equation will do for now.  If you wanted to breadboard this, you would defiantly want to simplify this, for that saves a bit of money.