شارك برايك يهمنا Feedback Feedback mhassanabo@gmail.com
maboeleneen@yahoo.com

Truth Table-NOT Gate











Read more: http://www.circuitstoday.com/logic-gates#ixzz1GcOHJ0xA
Under Creative Commons License: Attribution




Read more: http://www.circuitstoday.com/half-adder-and-full-adder#ixzz1GcOY6Lsi
Under Creative Commons License: Attribution





















Recently Viewed:

















maboeleneen@yahoo.com
Digital Logic Gates
This article explains the basic logic gates like NOT Gate, AND Gate, OR Gate, NAND Gate, NOR Gate, EXOR Gate and EXNOR gate with their corresponding truth tables and circuit symbols.
Logic Gates are considered to be the basics of Boolean Logic. To know more about Boolean Logic click on the link below.
TAKE A LOOK : BOOLEAN LOGIC
To know about the application of logic gates, click on the links below
TAKE A LOOK : HALF ADDER AND FULL ADDER
TAKE A LOOK : FLIP FLOPS
There are mainly 7 types of logic gates that are used in expressions. By combining them in different ways, you will be able to implement all types of digital components. Take a look at each basic logic gate and their operation.
- NOT Gate/Inverter
As the name suggests, this gate is used to produce the inverted output. This is the simplest gate with single input single output logic. The logic symbol and truth table is shown below. When a 0 [LOW] is given to the input, the output will be a 1 [HIGH]. If a HIGH input is given, the output will be LOW.

NOT Gate Symbol
Truth Table-NOT Gate- AND GATE
In this type of a logical gate, there can be 2 or multiple number of inputs. The operation performed by the gate is called the “AND” operation. The logic symbol and truth table is shown below. A 2-input AND gate is shown below. If both the inputs A and B are HIGH, then the output will also be HIGH. If both of them or any one of them is low, then the output will also be low.

AND Gate

Truth Table-AND Gate
- OR GATE
In this type of logic gate, the operation carried out by the gate is called “OR” operation. The logic symbol and truth table is shown below. A 2-input OR gate is shown below. If any one of the input or both the inputs are HIGH, then the output will be HIGH. If both the inputs are LOW, then the output will also be low.

OR Gate

Truth Table-OR Gate
- NAND Gate and NOR Gate
Since you have understood the working of AND Gate, OR Gate, and NOT gate, it is easy to understand the working of NAND and NOR gate as well. A NAND Gate is just a combination of an AND gate and a NOT Gate. The logic symbol and truth table is shown below. The output will be just the opposite of a AND Gate. That is, if both the inputs are HIGH, the output will be LOW. If both the inputs are LOW, or any one of them is LOW, the output will be HIGH.

NAND Gate

Truth Table-NAND Gate
A NOR Gate is a combination of an OR Gate and a NOT Gate. The logic symbol and truth table is shown below. The output will be just the opposite of a OR Gate. That is, if any one of the input or both the inputs are HIGH, then the output will be LOW. If both the inputs are LOW, then the output will be HIGH.

NOR Gate

Truth Table-NOR Gate
These two gates are commonly referred to as the Universal Gates, because either one of them can be used to create the basic AND, OR and NOT gate.
- EXOR Gate and EXNOR Gate
In an EXOR Gate, if both the inputs are HIGH, or if both the inputs are LOW, the output will be LOW. If any one of the two inputs is HIGH, the output will be HIGH. The logic symbol and truth table are shown below.

EXOR Gate

Truth Table-EXOR Gate
An EXNOR Gate will be just the opposite of an EXOR Gate. That is, if both the inputs are HIGH, or if both the inputs are LOW, the output will be HIGH. If any one of the two inputs is HIGH, the output will be LOW. The logic symbol and truth table are shown below.

EXNOR Gate

Truth Table-EXNOR Gate
Usually XOR Gate is not included in the list because the logic can be easily implemented with the help of the other gates. An easy implementation using the AND Gate, OR Gate and the NOT Gate is shown below
Read more: http://www.circuitstoday.com/logic-gates#ixzz1GcOHJ0xA
Under Creative Commons License: Attribution
Half Adder
With the help of half adder, we can design circuits that are capable of performing simple addition with the help of logic gates.
Let us first take a look at the addition of single bits.
0+0 = 0
0+1 = 1
1+0 = 1
1+1 = 10
These are the least possible single-bit combinations. But the result for 1+1 is 10. Though this problem can be solved with the help of an EXOR Gate, if you do care about the output, the sum result must be re-written as a 2-bit output.
Thus the above equations can be written as
0+0 = 00
0+1 = 01
1+0 = 01
1+1 = 10
Here the output ‘1’of ‘10’ becomes the carry-out. The result is shown in a truth-table below. ‘SUM’ is the normal output and ‘CARRY’ is the carry-out.
INPUTS OUTPUTS
A B SUM CARRY
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
From the equation it is clear that this 1-bit adder can be easily implemented with the help of EXOR Gate for the output ‘SUM’ and an AND Gate for the carry. Take a look at the implementation below.

Half Adder Circuit
For complex addition, there may be cases when you have to add two 8-bit bytes together. This can be done only with the help of full-adder logic.
Full Adder
This type of adder is a little more difficult to implement than a half-adder. The main difference between a half-adder and a full-adder is that the full-adder has three inputs and two outputs. The first two inputs are A and B and the third input is an input carry designated as CIN. When a full adder logic is designed we will be able to string eight of them together to create a byte-wide adder and cascade the carry bit from one adder to the next.
The output carry is designated as COUT and the normal output is designated as S. Take a look at the truth-table.
INPUTS OUTPUTS
A B CIN COUT S
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
From the above truth-table, the full adder logic can be implemented. We can see that the output S is an EXOR between the input A and the half-adder SUM output with B and CIN inputs. We must also note that the COUT will only be true if any of the two inputs out of the three are HIGH.
Thus, we can implement a full adder circuit with the help of two half adder circuits. The first will half adder will be used to add A and B to produce a partial Sum. The second half adder logic can be used to add CIN to the Sum produced by the first half adder to get the final S output. If any of the half adder logic produces a carry, there will be an output carry. Thus, COUT will be an OR function of the half-adder Carry outputs. Take a look at the implementation of the full adder circuit shown below.

Full Adder Circuit
Though the implementation of larger logic diagrams is possible with the above full adder logic a simpler symbol is mostly used to represent the operation. Given below is a simpler schematic representation of a one-bit full adder.

Single-bit Full Adder
With this type of symbol, we can add two bits together taking a carry from the next lower order of magnitude, and sending a carry to the next higher order of magnitude. In a computer, for a multi-bit operation, each bit must be represented by a full adder and must be added simultaneously. Thus, to add two 8-bit numbers, you will need 8 full adders which can be formed by cascading two of the 4-bit blocks. The addition of two 4-bit numbers is shown below.

Multi-Bit Addition using Full Adder
Read more: http://www.circuitstoday.com/half-adder-and-full-adder#ixzz1GcOY6Lsi
Under Creative Commons License: Attribution
Next: Multiplexers and Decoders Up: Combinational Logic Previous: Signal Race
From basic gates, we will develop a full adder circuit that adds two binary numbers. Consider adding two 2-bit binary numbers
and
.
, where
is the carry bit. The truth table for all combinations of
and
is shown in table 7.5.
From the truth table
The mechanization of these two equation is shown in figure 7.7.
This circuit is known as the half adder. It can not handle the addition of any two arbitrary numbers because it does not allow the input of a carry bit from the addition of two previous digits. A circuit that can handle these three inputs can perform the addition of any two binary numbers.
The truth table for three input variables is shown in figure 7.8.
From the truth table
This is known as majority logic. And a majority detector is shown in figure 7.9
The following device (figure 7.10) is known as a full adder and is able to add three single bits of information and return the sum bit and a carry-out bit.
The circuit shown in figure 7.11 is able to add any two numbers of any size. The inputs are
and
, and the output is
.
Example: If the input to the circuit in figure 7.12 is written as a number ABCD, write the nine numbers that will yield a true Q.
ABCD=(2,3,6,7,11,12,13,14,15) gives Q true.
Example: Using the 2's complement convention, the 3-bit number ABC can represent the numbers from -3 to 3 as shown in table 7.7 (ignore -4). Assuming that A, B, C and
are available as inputs, the goal is to devise a circuit that will yield a 2-bit output EF that is the absolute value of the ABC number. You have available only two- and three-input AND and OR gates.
1. Fill a truth table with the ABC and EF bits.
The truth table is shown in table 7.7.
2. Write a Boolean algebra expression for E and for F.


3. Mechanize these expressions.
The mechanized expressions are shown in figure 7.13.
Example: Suppose that the 2-bit binary number AB must be transmitted between devices in a noisy environment. To reduce undetected errors introduced by the transmission, an extra bit P is often included to add redundancy to the information. Assume that P is set true or false as needed to make an odd number of true bits in the resulting 3-bit number ABP. When the number is received, logic circuits are required to generate an error signal E whenever the odd number of bits condition is not met.
1. Develop a truth table of E in terms of A, B and P.
The truth table is shown in table 7.8.
2. Write a Boolean expression for E as determined directly from the truth table.
3. Using De Morgan's theorem twice, reduce this expression to one EOR and one NEOR operation. (This is very similar to the half-adder problem.)

Multiplexers and Decoders
Multiplexers and decoders are used when many lines of information are being gated and passed from one part of a circuit to another.
Multiplexing is when multiple data signals share a common propagation path. Time multiplexing is when different signals travel along the same wire but at different times. These devices have data and address lines, and usually include an enable/disable input. When the device is disabled the output is locked into some particular state and is not effected by the inputs. Shown in figure 7.15 is a 4-line to 1-line multiplexer.
A decoder de-multiplexes the signals back onto several different lines. Shown in figure 7.16 is a binary-to-octal decoder (3-line to 8-line decoder).
Decoders (octal decoder) can also convert a 3-bit binary number to an output on one of eight lines. Hexadecimal decoders are 4-line to 16-line devices. When the decoder is disabled the outputs will be high. A decoder would normally be disabled while the address lines were changing to avoid glitcChapter 3 - A Binary Adder
It's about time that you were given a practical example of all this. The following shows how we can construct a circuit that is found in the heart of every processing chip - a circuit to perform binary addition. If you need an introduction to binary numbers and binary addition, click here.
A half adder
The following diagram shows the basic addition of two binary digits (1 or 0). In fact, the addition is exactly what you would expect, except that when 1 is added to 1, the result (which is 2 in normal addition) addition is written as 10:
| | 0 | | | 0 | | | 1 | | | 1 |
| + | 0 | | + | 1 | | + | 0 | | + | 1 |
| | | | | | | | ||||
| | 0 | | | 1 | | | 1 | | | 0 |
| | | | | | | | ||||
| | 1 | | ||||||||
The reason that I write the 1 produced when 1 is added to 1 under the line is that there may be another column of figures to the left of this column. In this case, the 1 that is produced will be a carry out that affects the figures in the next column. Here is the last part of that calculation again, this time as part of a larger calculation:
| | 0 | 1 | 1 |
| + | 1 | 0 | 1 |
| | |||
| 1 | 0 | 0 | 0 |
| | |||
| | 1 | 1 | |
A circuit that performs the addition of two binary digits like this is called a half adder (I'll explain why we say "half" in the next section). A half adder can only add two binary digits. If you wanted a long binary number added to another long binary number, you would use several circuits (termed "full" adders in this case), each of which handles one digit of each number, all connected end to end - see the next section.
In fact, the binary addition of two digits always produces two numbers - the sum of those digits and a carry out digits which is then added to the next column along, assuming there is one, or which just disappears into the void. Here is that first diagram again with both the sum digit and the carry out digits explicitly listed:
![]() |
|
You will notice that the sum digit has exactly the same truthtable as an XOR gate and the carry digit has exactly the same truthtable as an AND gate. This means that the binary half adder circuit just consists of two gates:

The small loop drawn just in front of the two gates shows two wires which cross without connecting, i.e. there is no connection between the Digit 1 input and the Digit 2 input.
A full adder
So what's the difference between a binary half adder and a full adder, then? Well, a half adder doesn't take into account a crucial aspect of a column of two binary digits - there may be a carry in to the column, as well as a carry out!
Here is a column which has been extracted from the middle of the sum somewhere. You will notice that a there is a carry digit underneath the column itself, as well as one under the next column. Now, including the carry in, there are 8 possible combinations of inputs, and I have listed them all:

Again, we just turn this into a truthtable. However, there are now three inputs, called Digit1, Digit2 and Carry In, and two outputs, called Sum Digit and Carry Out:
| Digit 2 | Carry In | Sum Digit | Carry Out | |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
The easiest way to turn this into a circuit is to imagine the table split into a top half and a bottom half. The top half of the table occurs when the Digit 1 input is 0. In this case, the Sum digit is equivalent to an XOR gate and the Carry Out digit is equivalent to an AND gate. The bottom half of the table occurs when the Digit 1 input is 1. In this case, the Sum digit is the opposite of the XOR (i.e. equivalent to an Exclusive OR with the output inverted) and the Carry Out digit is equivalent to an OR gate. This would give a circuit as follows:


Although there are really only three inputs to the circuit, we have written each of the inputs twice (once for the Sum Digit and once for the Carry Out). Don't be put off by this - just assume that both the lines marked "Digit 1" are connected to the same input, that both the lines marked "Digit 2" are connected to the same input and that both the lines marked "Carry In" are connected to the same input.
In practice, there's not a great deal that you can do with adding a single pair of digits. We duplicate the circuit that you see above several times (8 times, 16 times or 32 times - usually a power of 2) to form a proper binary adder:

In this diagram each of the yellow rectangles represents one instance of the circuit that we developed above. It has two digit inputs and a Carry In input which is the Carry Out output from the previous column. Each Carry Out output is then connected to the Carry In input of the next column. The initial Carry In input is fed from a binary digit called the Carry Flag, which is usually set to 0 (The Carry Flag is used to perform multi-byte addition - see the section on Computer Architecture). The final Carry Out output is fed back into the Carry Flag for use later on.
In the example given in the diagram, the two numbers being added are 11010011 and 11101010. They produce an answer which is 10111101 with a final Carry Out. This is equivalent to adding the decimal numbers 211 and 234 and getting the answer 189. I realise that 211 + 234 is not 189, but this has happened because the answer has "overflowed" off the end of the adding unit, and the fact that a Carry Out was produced from the final calculation indicates that the real answer should be (256) + 189 = 445. Unfortunately, this adding device is an 8-bit device which cannot produce answers larger than 255, so it sets the Carry Flag at the end to indicate that there is a 256 missing from the answer.
Incidentally, the same circuit can be used to perform subtraction, except the number to be subtracted is inverted (all the bits are reversed, so 1 becomes 0 and vice-versa) and 1 is added to it.
hes on the output lines.
Chapter 3 - A Binary Adder
It's about time that you were given a practical example of all this. The following shows how we can construct a circuit that is found in the heart of every processing chip - a circuit to perform binary addition. If you need an introduction to binary numbers and binary addition, click here.
A half adder
The following diagram shows the basic addition of two binary digits (1 or 0). In fact, the addition is exactly what you would expect, except that when 1 is added to 1, the result (which is 2 in normal addition) addition is written as 10:
| | 0 | | | 0 | | | 1 | | | 1 |
| + | 0 | | + | 1 | | + | 0 | | + | 1 |
| | | | | | | | ||||
| | 0 | | | 1 | | | 1 | | | 0 |
| | | | | | | | ||||
| | 1 | | ||||||||
The reason that I write the 1 produced when 1 is added to 1 under the line is that there may be another column of figures to the left of this column. In this case, the 1 that is produced will be a carry out that affects the figures in the next column. Here is the last part of that calculation again, this time as part of a larger calculation:
| | 0 | 1 | 1 |
| + | 1 | 0 | 1 |
| | |||
| 1 | 0 | 0 | 0 |
| | |||
| | 1 | 1 | |
A circuit that performs the addition of two binary digits like this is called a half adder (I'll explain why we say "half" in the next section). A half adder can only add two binary digits. If you wanted a long binary number added to another long binary number, you would use several circuits (termed "full" adders in this case), each of which handles one digit of each number, all connected end to end - see the next section.
In fact, the binary addition of two digits always produces two numbers - the sum of those digits and a carry out digits which is then added to the next column along, assuming there is one, or which just disappears into the void. Here is that first diagram again with both the sum digit and the carry out digits explicitly listed:
![]() |
|
You will notice that the sum digit has exactly the same truthtable as an XOR gate and the carry digit has exactly the same truthtable as an AND gate. This means that the binary half adder circuit just consists of two gates:

The small loop drawn just in front of the two gates shows two wires which cross without connecting, i.e. there is no connection between the Digit 1 input and the Digit 2 input.
A full adder
So what's the difference between a binary half adder and a full adder, then? Well, a half adder doesn't take into account a crucial aspect of a column of two binary digits - there may be a carry in to the column, as well as a carry out!
Here is a column which has been extracted from the middle of the sum somewhere. You will notice that a there is a carry digit underneath the column itself, as well as one under the next column. Now, including the carry in, there are 8 possible combinations of inputs, and I have listed them all:

Again, we just turn this into a truthtable. However, there are now three inputs, called Digit1, Digit2 and Carry In, and two outputs, called Sum Digit and Carry Out:
| Digit 1 | Digit 2 | Carry In | Sum Digit | Carry Out |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
The easiest way to turn this into a circuit is to imagine the table split into a top half and a bottom half. The top half of the table occurs when the Digit 1 input is 0. In this case, the Sum digit is equivalent to an XOR gate and the Carry Out digit is equivalent to an AND gate. The bottom half of the table occurs when the Digit 1 input is 1. In this case, the Sum digit is the opposite of the XOR (i.e. equivalent to an Exclusive OR with the output inverted) and the Carry Out digit is equivalent to an OR gate. This would give a circuit as follows:


Although there are really only three inputs to the circuit, we have written each of the inputs twice (once for the Sum Digit and once for the Carry Out). Don't be put off by this - just assume that both the lines marked "Digit 1" are connected to the same input, that both the lines marked "Digit 2" are connected to the same input and that both the lines marked "Carry In" are connected to the same input.
In practice, there's not a great deal that you can do with adding a single pair of digits. We duplicate the circuit that you see above several times (8 times, 16 times or 32 times - usually a power of 2) to form a proper binary adder:

In this diagram each of the yellow rectangles represents one instance of the circuit that we developed above. It has two digit inputs and a Carry In input which is the Carry Out output from the previous column. Each Carry Out output is then connected to the Carry In input of the next column. The initial Carry In input is fed from a binary digit called the Carry Flag, which is usually set to 0 (The Carry Flag is used to perform multi-byte addition - see the section on Computer Architecture). The final Carry Out output is fed back into the Carry Flag for use later on.
In the example given in the diagram, the two numbers being added are 11010011 and 11101010. They produce an answer which is 10111101 with a final Carry Out. This is equivalent to adding the decimal numbers 211 and 234 and getting the answer 189. I realise that 211 + 234 is not 189, but this has happened because the answer has "overflowed" off the end of the adding unit, and the fact that a Carry Out was produced from the final calculation indicates that the real answer should be (256) + 189 = 445. Unfortunately, this adding device is an 8-bit device which cannot produce answers larger than 255, so it sets the Carry Flag at the end to indicate that there is a 256 missing from the answer.
Incidentally, the same circuit can be used to perform subtraction, except the number to be subtracted is inverted (all the bits are reversed, so 1 becomes 0 and vice-versa) and 1 is added to it.
Half Adders, Full Adders, Ripple Carry Adders
© 2003 by Charles C. Lin. All rights reserved.
Introduction
At the very least, most people expect computers to do some kind of arithmetic computation, and thus, most people expect computers to add.
We're going to construct combinational logic circuits that perform binary addition. The first question you should ask when adding binary numbers, given all the time we've spent talking about representation is "what representation are we talking about"?
Clearly the choice of representation is going to affect how we perform the addition. Certain representations allow us to add in the way we add base ten numbers. So, initially, we assume UB representation.
First, let's consider adding two 3-bit UB numbers.
1 1 0
+ 0 1 1
-----------Most of add numbers right to left. We start at the rightmost column (the least signifcant bit) and work our way to the left.
1 1 0
+ 0 1 1
----------- 1As we add, we may need to carry. We add 0 to 1. What should we carry? You might answer "Nothing". Technically, you don't have to carry anything. However, hardware isn't so simple. In general, once you decide there is an output (such as carry), you need to generate that output all the time. Thus, we need to find a reasonable carry, even when there's "no need" to carry.
In this case, a reasonable carry is to carry a 0, into the next column, and then add that column.
01 1 0
+ 0 1 1
-----------0 1
This time, when we add the middle column, we get 0 + 1 + 1 which sums to 0, with a carry of 1.
1 0
1 1 0
+ 0 1 1
-----------(1) 0 0 1
The final (leftmost) column adds 1 + 1 + 0, which sums to 0, and also generates a carry. We put the carry in parentheses on the left.
Typically, when we perform an addition of two k-bit numbers, we expect the answer to be k-bits. If the numbers are represented in UB, the result can be k+1 bits. To handle that case, we have a carry bit (the one written in parentheses above).
Building Blocks: Half Adders
As you look at how numbers are added, it seems to be added column by column. While we might create an addition circuit which adds two 3-bit values at once, it might not allow us to generalize to adding two k-bit values.
It makes some sense to design a circuit that adds in "columns". To begin, let's consider adding the rightmost column. We're adding two bits. So, the adder we want to create should have two inputs bits. It generates a sum bit for that column, plus a carry. So there should be two bits of output.
This device is called a half-adder. I have no idea why, except that it can't really be used to (easily) build k-bit adders.
- Data inputs: 2 (call them x and y)
- Outputs: 2 (call them s, for sum, and c, for carry)
Here's a truth table for half adders.
| Row | x | y | c | s |
| 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 2 | 1 | 0 | 0 | 1 |
| 3 | 1 | 1 | 1 | 0 |
Let's see what's happening. Look at row 3. We add x + y = 1 + 1. This has a sum of 0, and a carry of 1.
Writing a Boolean Expression
The first step to converting a truth table to a circuit is to write a Boolean expression.
We use the same technique as before. Identify rows with 1, and create a minterm. This doesn't always produce a minimal expression, but at least it produces an expression without too much work.
c = xy s = \xy + x\y = x XOR yAgain, we use multiplication to denote AND2 and addition to denote OR2.
Drawing the Circuit
The next step is to draw the circuit. First, we draw it as a black box.

Then, we add the detail of the circuits.

In this circuit above, you see an AND2 gate and an XOR2 gate.
Building Blocks: Full Adders
The problem with a half-adder is that there it doesn't handle carries. When you look at the left column of the addition
1 0
1 1 0
+ 0 1 1
-----------(1) 0 0 1
you see that you add three bits. Half adders only add two bits.
We need a circuit that can add three bits. That circuit is called a full adder.
Here are the characteristics of a full adder.
- Data inputs: 3 (call them x, y, and cin, for carry in)
- Outputs: 2 (call them s, for sum, and cout, for carry out)
Notice we now need to make a distinction whether the carry is an input (cin) or an output (cout). Carry in's in column i are due to carry outs from column i - 1 (assuming we number columns right to left, starting at column 0 at the least significant bit).
Here's a truth table for full adders.
| Row | x | y | cin | cout | s |
| 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 | 1 |
| 2 | 0 | 1 | 0 | 0 | 1 |
| 3 | 0 | 1 | 1 | 1 | 0 |
| 4 | 1 | 0 | 0 | 0 | 1 |
| 5 | 1 | 0 | 1 | 1 | 0 |
| 6 | 1 | 1 | 0 | 1 | 0 |
| 7 | 1 | 1 | 1 | 1 | 1 |
Exercise
As an exercise, write out the Boolean expressions for cout and s. Draw the circuit, too.
Ripple Carry Adders
Once you have half adders and full adders, you can now construct ripple carry adders.
A ripple carry adder allows you to add two k-bit numbers. We use the half adders and full adders and add them a column at a time.
Let's put the adder together one step at a time.
Before Adding

Adding Column 0
We add x0 to y0, to produce z0.

Adding Column 1
In column 1, We add x1 to y1 and c1 and, to produce z1, and c2, where ci is the carry-in for column i and ci + 1 is the carry-out of column i.

Adding Column 2
In column 2, We add x2 to y2 and c2 and, to produce z2, and c3.

Using Only Full Adders
We don't really need to use the half adder. We could replace the half adder with a full adder, with a hardwired 0 for the carry in.

Delay
We know that combinational logic circuits can't compute the outputs instantaneously. There is some delay between the time the inputs are sent to the circuit, and the time the output is computed.
Let's say the delay is T units of time.
Suppose you want to implement an n-bit ripple carry adder. How much total delay is there?
Since an n-bit ripple carry adder consists of n adders, there will be a delay of nT. This is O(n) delay.
Why is there this much delay? After all, aren't the adders working in parallel?
While the adders are working in parallel, the carrys must "ripple" their way from the least significant bit and work their way to the most significant bit. It takes T units for the carry out of the rightmost column to make it as input to the adder in the next to rightmost column.
Thus, the carries slow down the circuit, making the addition linear with the number of bits in the adder.
This is not a big problem, usually, because hardware adders are fixed in size. They add, say, 32 bits at a time. There's no way to make an adder add an arbitrary number of bits. It can be done in software, not in hardware. In effect, this is what makes hardware "hard". It's not flexible to change.
Even though there are a fixed number of bits to add in an adder, there are ways to make the adder add more quickly (at least, by a constant).
Carry lookahead adders add much faster than ripple carry adders. They do so by making some observations about carries. We will look at this at a later set of notes.
Which Representation?
When we designed the adder, we were making some assumption about the representation of x3-0 and y3-0. We assumed they were UB.
Or we could also assume the representation is 2C. This is the advantage of using 2C for signed representation. The same hardware that adds UB can be used to add 2C (although the conditions for overflow are not the same for UB as 2C).
Summary
Here are some summarizing facts about adders.
- Half adders add two bits.
- Full adders add three bits.
- Ripple carry adders use half adders and full adders to add two n-bit numbers represented in either UB or 2C.
- Ripple carry adders have O(n) delay. Even though the adders can add xi and yi in parallel (for all i between 0 and n-1, inclusive), the delay is due to the carry "rippling" from the rightmost adder to the leftmost.
- There are adders that can add faster than O(n), by using more hardware (see Carry Lookahead Adders).
![]() | The 4008 is a 4-bit binary full adder with two 4-bit data inputs (A0 to A3, B0 to B3), a carry input (CIN), four sum outputs (S0 to S3), and a carry output (COUT). The outputs give the sum of the two 4-bit binary numbers. |
Adder circuits are essential inside microprocessors as part of the ALU, or arithmetic logic unit, where the processing and manipulation of binary numbers takes place.
How does binary addition work? The simplest addition you can do is to add together two 1-bit binary numbers. Suppose the numbers are called A and B. Each of these numbers can take the values 0 or 1. There are four possible additions:

As you can see, in binary addition, 0+0=0, 0+1=1, 1+0=1 and 1+1=10. For each of these additions, you can identify a SUM digit and a CARRY digit. The truth table below shows these additions in a different form:
| input B | input A | CARRY digit | SUM digit |
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
What do you notice about the values in the CARRY digit and the SUM digit columns? The CARRY digit follows the truth table for an AND gate, while the SUM digit follows the truth table for an EXOR gate.
In other words, 1-bit binary addition can be carried out by a circuit which looks like this:

This circuit is called a half adder because, although it can generate a CARRY OUT, it cannot accept a CARRY IN. To see why a CARRY IN is needed, think about what happens when 2-bit, 3-bit or longer binary numbers are added:

Use the diagram to follow the stages involved in the addition of the binary numbers A=011 and B=110. In the LSB, or least significant bit, column, there is no CARRY IN. However, the second and subsequent columns must accept a CARRY IN and generate a CARRY OUT. The final CARRY OUT provides the MSB, or most significant bit, of the answer to the addition operation. (All of this is almost identical to the addition of decimal numbers.)
In each column to the left of the LSB, there are eight possible input combinations depending on the numbers being added:

The equivalent truth table is:
| CARRY IN | input B | input A | CARRY OUT | SUM digit |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
A circuit which obeys this truth table is called a full adder. You can make a full adder by linking together two half adder circuits:

A simpler representation of a full adder is as follows:

The 4008 contains four full adders which are linked to allow the addition of two 4-bit binary numbers:

The addition of the high speed parallel carry subsystem speeds up the overall operation of the circuit.
To investigate the 4008, you need to provide binary inputs which are easily changed. In the prototype circuit shown below the A0-A3 and B0-B3 values are set by a special variety of switches, called DIL switches. DIL stands for dual-in-line. The pins of the switch are arranged in two rows on a 0.1 in matrix and fit conveniently across the central gap of the prototype board. The switches are operated with the aid of a small screwdriver. Moving the slider to the right, into the ON position, closes the switch and connects the corresponding input to a HIGH voltage. In the OFF position, the switch is open and the input becomes LOW. This is the effect of the 10 kW pull down resistor.

As you can see, the S0-S3 SUM outputs and the CARRY OUT pins are connected to the indicators on the lower prototype board.
What outputs would you expect when A=0 1 1 0 and B=1 1 0 0?
4008 adders can be cascaded to allow the addition of 8-bit, or longer, binary numbers.
| Full Adder Circuit | Truth Table | |||||
![]() | Input | Output | ||||
| C | A | B | S | C | ||
| 0 | 0 | 0 | 0 | 0 | ||
| 1 | 0 | 0 | 1 | 0 | ||
| 0 | 1 | 0 | 1 | 0 | ||
| 1 | 1 | 0 | 0 | 1 | ||
| 0 | 0 | 1 | 1 | 0 | ||
| 1 | 0 | 1 | 0 | 1 | ||
| 0 | 1 | 1 | 0 | 1 | ||
| 1 | 1 | 1 | 1 | 1 | ||
| Select An Input Value | | | ||||
Table of Contents:
· Decoder
· Encoder
·
Recently Viewed:
· Print
· PDF
A Full-Adder
We need your help! This page requires proofreading - If you notice any errors, please post on our forums
The half-adder is extremely useful until you want to add more that one binary digit quantities. The slow way to develop a two binary digit adders would be to make a truth table and reduce it. Then when you decide to make a three binary digit adder, do it again. Then when you decide to make a four digit adder, do it again. Then when ... The circuits would be fast, but development time would be slow.
Looking at a two binary digit sum shows what we need to extend addition to multiple binary digits.
11 11 11 --- 110Look at how many inputs the middle column uses. Our adder needs three inputs; a, b, and the carry from the previous sum, and we can use our two-input adder to build a three input adder.
Σ is the easy part. Normal arithmetic tells us that if Σ = a + b + Cin and Σ1 = a + b, then Σ = Σ1 + Cin.


What do we do with C1 and C2? Let's look at three input sums and quickly calculate:
Cin + a + b = ?0 + 0 + 0 = 0 0 + 0 + 1 = 1 0 + 1 + 0 = 1 0 + 1 + 1 = 101 + 0 + 0 = 1 1 + 0 + 1 = 10 1 + 1 + 0 = 10 1 + 1 + 1 = 11If you have any concern about the low order bit, please confirm that the circuit and ladder calculate it correctly.
In order to calculate the high order bit, notice that it is 1 in both cases when a + b produces a C1. Also, the high order bit is 1 when a + b produces a Σ1 and Cin is a 1. So We will have a carry when C1 OR (Σ1 AND Cin). Our complete three input adder is:


For some designs, being able to eliminate one or more types of gates can be important, and you can replace the final OR gate with an XOR gate without changing the results.
We can now connect two adders to add 2 bit quantities.


A0 is the low order bit of A, A1 is the high order bit of A, B0 is the low order bit of B, B1 is the high order bit of B, Σ0is the low order bit of the sum, Σ1 is the high order bit of the sum, and Cout is the Carry.
A two binary digit adder would never be made this way. Instead the lowest order bits would also go through a full adder.


There are several reasons for this, one being that we can then allow a circuit to determine whether the lowest order carry should be included in the sum. This allows for the chaining of even larger sums. Consider two different ways to look at a four bit sum.
111 1<-+ 11<+- 0110 | 01 | 10 1011 | 10 | 11 ----- - | — | --- 10001 1 +-100 +-101If we allow the program to add a two bit number and remember the carry for later, then use that carry in the next sum the program can add any number of bits the user wants even though we have only provided a two-bit adder. Small PLCs can also be chained together for larger numbers.
These full adders can also can be expanded to any number of bits space allows. As an example, here's how to do an 8 bit adder.

This is the same result as using the two 2-bit adders to make a 4-bit adder and then using two 4-bit adders to make an 8-bit adder or re-duplicating ladder logic and updating the numbers.

Each "2+" is a 2-bit adder and made of two full adders. Each "4+" is a 4-bit adder and made of two 2-bit adders. And the result of two 4-bit adders is the same 8-bit adder we used full adders to build.
For any large combinational circuit there are generally two approaches to design: you can take simpler circuits and replicate them; or you can design the complex circuit as a complete device.
Using simpler circuits to build complex circuits allows a you to spend less time designing but then requires more time for signals to propagate through the transistors. The 8-bit adder design above has to wait for all the Cxout signals to move from A0 + B0 up to the inputs of Σ7.
If a designer builds an 8-bit adder as a complete device simplified to a sum of products, then each signal just travels through one NOT gate, one AND gate and one OR gate. A seventeen input device has a truth table with 131,072 entries, and reducing 131,072 entries to a sum of products will take some time.
When designing for systems that have a maximum allowed response time to provide the final result, you can begin by using simpler circuits and then attempt to replace portions of the circuit that are too slow. That way you spend most of your time on the portions of a circuit that matter.
Decoder
We need your help! This page requires proofreading - If you notice any errors, please post on our forums
A decoder is a circuit that changes a code into a set of signals. It is called a decoder because it does the reverse of encoding, but we will begin our study of encoders and decoders with decoders because they are simpler to design.
A common type of decoder is the line decoder which takes an n-digit binary number and decodes it into 2n data lines. The simplest is the 1-to-2 line decoder. The truth table is

A is the address and D is the dataline. D0 is NOT A and D1 is A. The circuit looks like



Developed into a circuit it looks like


Larger line decoders can be designed in a similar fashion, but just like with the binary adder there is a way to make larger decoders by combining smaller decoders. An alternate circuit for the 2-to-4 line decoder is

Replacing the 1-to-2 Decoders with their circuits will show that both circuits are equivalent. In a similar fashion a 3-to-8 line decoder can be made from a 1-to-2 line decoder and a 2-to-4 line decoder, and a 4-to-16 line decoder can be made from two 2-to-4 line decoders.
You might also consider making a 2-to-4 decoder ladder from 1-to-2 decoder ladders. If you do it might look something like this:

For some logic it may be required to build up logic like this. For an eight-bit adder we only know how to sum eight bits by summing one bit at a time. Usually it is easier to design ladder logic from boolean equations or truth tables rather than design logic gates and then "translate" that into ladder logic.
A typical application of a line decoder circuit is to select among multiple devices. A circuit needing to select among sixteen devices could have sixteen control lines to select which device should "listen". With a decoder only four control lines are needed
| البحث في المنتدى | |
| الذهاب إلى الصفحة... | |
| #21 | |||
| |||
| 4-1-2 وحدات الخرج عندما تمد وحدة الخرج جهاز الخرج بالتيار تسمى مصدر sourcing كما فى الشكل (4-6-أ) و عندما يمد جهاز الخرج وحدة الخرج بالتيار تسمى مصب sinking كما فى الشكل (4-6-ب) .وغالبا ما تستخدم وحدات الدخل المصب للربط مع المعدات الإلكترونية ويستخدم وحدات خرج مصدرللربط مع الملفات solenoids . ![]() وحدات الخرج قد تكون : بريلاى أو بترانزستور أو بترياك . الشكل (4-7) يبين الاشكال الأساسية لوحدات الخرج بالريلاى والشكل (4-8) يبين وحدات الخرج بالترانزستور والشكل (4-9) يبين وحدات الخرج بالترياك. ![]() ![]() ![]() وغالبا ما نحتاج إلى مخارج تناظرية ويمكن الحصول عليها بإمداد قناة الخرج بمحول من رقمى إلى تناظرى DAC .الدخل إلى المحول هو تتابع (تسلسل) من الخانات مع كل خانة على طول خط موازى. الشكل (4-10) يبين الوظسفة الأساسيى للمحول . الإدخال إلى المحول هو تسلسل بت مع كل بت على طول خط مواز. ![]() الخانة بالخط رقم 0 تعطى نبضة خرج بأرتفاع بحجم معين . الخانة بالخط رقم 1 تعطى نبضة خرج بأرتفاع ضعف نبضة الخط رقم 0 . الخانة بالخط رقم 2 تعطى نبضة خرج بأرتفاع ضعف نبضة الخط رقم 1 . الخانة بالخط رقم 3 تعطى نبضة خرج بأرتفاع ضعف نبضة الخط رقم 2 . وهكذا . جميع المخارج تضاف (تجمع) معا لاعطاء نسخة تناظرية من الدخل الرقمى . عندما يتغير الدخل الرقمى يتغير الخرج التناظرى يشكل درجات ويتغير الجهد بالتغيرات المصاحبة بكل خانة . على سبيل المثال إذا كان لدينا محول 8 بت عندئذ يكون الخرج مكون من قيم لعدد 28 = 256 خطوة تناظرية. نفترض أنه تم تحديد مدى الخرج ليكون 10 V d.c . عندئذ فإن الخانة الواحدة تعطى تغيير قدره 10/255V أو 0.04 V ونحصل على : ![]() وعادة يتم توفير وحدات الخرج بعدد من المخارج ،على سبيل المثال : 4 to 20 mA و 0 to +5 V d.c و 0 to +10 V d.c. حيث يمكن إختيار نوع الخرج المطلوب عن طريق مفاتيح بالوحدة . عموما يكون للوحدات نوعين من المخارج , النوع الأول يكون جميع المخارج من الوحدة لها جهد تغذية مشترك والنوع الثانى يكون لكل خرج جهد تغذيته الخاص به . الشكل (4 -11) يبين المبادئ الأساسية لهذين الشكلين من أشكال المخارج . ![]() 4-2 تكييف (تهيئة) الإشارة Signal conditioning |
| Admin | ||||
| #22 | ||||
| ||||
| 4-2 تكييف (تهيئة) الإشارة Signal conditioning عند توصيل أجهزة الاستشعار التي تولد إشارات رقمية أو منفصلة إلى وحدة الإدخال لابد من إتخاذ الحيطة والحذر لضمان مستويات الجهد المناسبة . يوجد العديد من أجهزة الإستشعار الى تولد إشارات تناظرية وللتعامل مع القنوات المختلفة يستخدم دوائر تكييف (تهيئة) لتحويلها جميعا إلى إشارات تناظرية قياسية ليمكن إستخدامها بمحولات ADC المتاحة. الشكل ( 4-12 ) يوضح الطريقة المشتركة القياسية لتحويل الإشارة التناظرية كتيار فى المدى 4 to 20 Ma حيث يمر هذا التيار فى مقاومة 250 أوم فيعطى إشارة دخل فى المدى 1 إلى 5V , على سبيل المثال فإن الحساس المستخدم لمراقبة مستوى السائل و مدى الارتفاع من 0 ألى 1m وعند مستوى الصفر يكون التيار 4 mA بينما عند مستوى 1m يكون التيار 20 mA . إستخدام 4 مللي أمبير لتمثيل الحد المنخفض للمدى التناظرى يخدم غرض التمييز بين حالتين : حالة مايبين الحساس الصفر وحالة عدم عمل الحساس حيث يكون التيار 0 mA . علاوة على أن التيار 4mA غالبا ما يكون مناسبا لعمل الحساس وعدم الحاجة إلى مصدر تغذية منفصل . ![]() يمكن إستخدام مجزىء (مقسم) جهد كما فى الشكل (4-13) لتخفيض جهد الحساس الى المستوى المطلوب ويكون جهد الخرج Vout : ![]() ![]() يمكن إستخدام المكبرات لزيادة مستوى الجهد , الشكل (4-14) يبين الدائرة الأساسية التت تستخدم مكبر العمليات 741 كمكبر عاكس (الشكل أ ) أو كمكبر غير عاكس (الشكل ب) . للمكبر العاكس يكون الخرج Vout وللمكبر الغير عاكس يكون غالبا ما نحتاج إلى مكبر فرق differential amplifier لتكبير الفرق بين جهدى دخلين . مثال لذلك عند اشتخدام حساس قياس إجهاد strain gauge وتوصيله على شكل قنطرة هويستون ويكون الخرج هو الفرق بين جهدين . أو عند إستخدام ثرموكابل حيث يكون فرق الجهد بين الوصلة البالردة والوصلة الساخنة . الشكل ( 4-14) يبين الشكل الاساسى لدائرة مكبر العمليات المستخدمة فى هذا الغرض . جهد الخرج Vout يكون ![]() الشكل (4-16) يبين طريقة تكييف الإشارة عند إستخدام حساس مقياس أجهاد . كمثال لاستخدام تكييف الإشارة ، ويبين الشكل 4.16الترتيب التي يمكن استخدامها لقياس الضغط الاستشعار. يوصل الحساس فى قنطرة هويستون ويتم تكبير جهد الفرق لعدم الإتزان بمكبر فرق قبل أن يتم توصيله إلى محول ADC وهو جزء من وحدة دخل المتحكم . ![]() | ||||
| Admin | ||||
| #23 | ||||
| ||||
| الفصل الخامس البرمجة بلغة مخطط السلم Ladder programming توضع (تحمل) البرامج فى الأنظمة التى تعتمد فى بنائها على المعالج الدقيق فى شكل كود (شفرة) الماكينة (الآلة) . وهى سلسلة من شفرة الأرقام الثنائية تمثل تعليمات البرنامج . يمكن إستخدام لغة الأسمبلى والتى تعتمد على إستخدام كلمات كتذكرة (مفكرة) لتساعد على تذكر التعليمة مثل إستخدام LD لبيان أن العملية المطلوبة هى تحميل البيانات load فيقوم برنامج الترجمة المسمى الأسمبلر وبمساعدة كومبيوتر شخصى فى ترجمة LD إلى شفرة الماكينة . كما يمكن البرمجة باللغات التى يطلق عليها لغات المستوى المرتفع مثل C, BASIC . وهذه اللغات تستخدم وظائف معدة سلفا وتمثل بكلمات سهلة أو رموز تصف الوظيفة المطلوبة. فمثلا فى لغة ال C يستخدم الرمز & للعملية المنطقية (و) AND . إستخدام هذه الطرق يتطلب بعض المهارات فى البرمجة بينما المتحكم PLC أعد ليستخدمه المتخصصين الذين ليس لديهم مهارات عالية فى البرمجة . نتيجة لذلك تم عمل البرمجة بلغة السلم . وهى وسيلة لكتابة البرامج والتى يمكن تحويلها إلى شفرة الماكينة ببعض البرمجيات من أجل المعالج الدقيق بالمتحكم PLC . هذه الطريقة فى كتابة البرامج أصبحت معتمدة من معظم صناع المتحكم PLC ,على الرغم من أن كل صانع له إصداره الخاص به . لذلك تم توحيد وإعتماد مواصفات قياسية عالمية للبرمجة بلغة السلم وتعرف IEC 1131-3 والتى إشتملت على لغات البرمجة الآتية : البرمجة بلغة السلم وإختصارا (LAD) البرمجة بقائمة التعليمات وإختصارا (IL) البرمجة بخرائط الوظائف المتتابعة وإختصارا(SFC) البرمجة بالنصوص وإختصارا (ST) البرمجة بمخططات بلوك (مربع) الوظيفة وإختصارا (FBD). 5-1 مخططات السلم : كمقدمة لمخططات السلم إعتبر مخطط الدائرة الكهربائية البسيطة بالشكل 5-1- أ . يوضح المخطط دائرة توصيل وفصل محرك كهربائى . يمكننا إعادة هذا المخطط بطريقة مختلفة . باستخدام خطين رأسيين لتمثيل قضيبى (خطى) القدرة ووضع (رص) باقى الدائرة بينهما . الشكل 5-1- ب يبين النتيجة . كلا الدائرتان بهما مفتاح على التوالى مع المحرك والذى يتم أمداده بالقدرة الكهربية عند غلق المفتاح . الدائرة المبينة بالشكل 1-5- ب اصطلح على تسميتها بمخطط السلم . ![]() فى هذا المخطط يكون مصدر التغذية للدوائر دائما على شكل خطين رأسيين وباقى الدائرة على شكل خطوط أفقية . خطوط القدرة (أو قضبان القدرة كما اصطلح على تسميتها) تشبه الجانبين الرأسيين لسلم والخطوط الأفقية للدائرة تشبه درجات هذا السلم . الخطوط أو الدرجات الأفقية تبين فقط جزء التحكم من الدائرة ففى حالة الشكل 5- 1 هى فقط مفتاح على التوالى مع محرك . مخططات الدوائر غالبا ما تبين الموقع الفيزيائى (الطبيعى) النسبى لمكونات الدائرة وكيفية توصيلها الفعلى . ولكن مع مخططات السلم لايمكن محاولة بيان المواقع الفعلية للمكونات ولكن الغرض هو بيان وبوضوح كيفية تنفيذ التحكم . الشكل 5- 2 يبين مثال لمخطط سلم للدائرة المستخدمة فى بدء وإيقاف محرك باستخدام مفاتيح (أزرار) ضاغطة . فى الحالة العادية (الوضع الطبيعى) يكون الزر الضاغط 1 مفتوح (غير موصل) والزر الضاغط 2 مغلق (موصل) . عند الضغط على الزر 1 تكتمل دائرة المحرك ويبدأ الدوران . أيضا تلامسات المسك للمحرك الموصلة على التوازى مع الزر 1 تغلق وتظل مغلقة طالما أن المحرك يدور . لذلك عند تحرير (إزالة الضغط) الزر 1 فإن تلامسات المسك تحافظ على الدائرة ومن ثم القدرة الى المحرك . لإيقاف المحرك يتم الضغط على الزر 2 , حيث يؤدى إلى فصل القدرة عن المحرك ومن ثم تفتح تلامسات المسك للمحرك . عند تحرير الزر 2 أيضا لن تصل القدرة إلى المحرك . ويكون لدينا تحكم فى المحرك حيث يبدأ الدوران عند الضغط على الزر 1 ويقف عن الدوران عند الضغط على الزر 2 . ![]() 5-1-1 البرمجة السلمية للمتحكم PLC | ||||
| Admin | ||||
| #24 | ||||
| ||||
| 5-1-1 البرمجة السلمية للمتحكم PLC الطريقة الاكثر شيوعا فى برمجة المتحكم PLC تعتمد على مخططات السلم . كتابة البرنامج تكافىء رسم دائرة التحويل أو التحكم . أتفق عند رسم مخطط السلم على الاتى : 1- ألخطين الرأسيين بالمخطط يمثلان قضيبى ألقدرة والذى يوصل بينهما الدوائر. وسريان ألقدرة يبدأ من ألخط ألرأسى الأيسر ثم يمر عبر ألخط الأفقى أى الدرجة . 2- كل درجة من السلم تعرف عملية واحدة من عمليات التحكم . 3- يقرأ مخطط السلم من اليسار إلى اليمين ومن أعلا الى اسفل . الشكل 5-3 يبين طريقة أو حركة المسح أو التنفيذ المستخدمة فى المتحكم PLC . يقرأ السطر الأول العلوى من اليسار إلى اليمين . ثم السطر الثانى من اليسار إلى اليمين وهكذا. عندما يكون المتحكم PLC فى نظام العمل يسير خلال برنامج السلم كله حتى النهاية . آخر سطر فى البرنامج يجب أن يكون معروفا تماما ومن ثم يستأنف على الفور من البداية . وهذا الإجراء أى المرور بجميع أسطر البرنامج أصطلح على تسميته ب "الدورة " cycle . كما أن السطر الأخير يعرف بمربع به كلمة END أوRET ليعود البرنامج فورا من حيث بدأ. ![]() 4- كل سطر يجب أن يبدأ بدخل أومداخل ويجب أن ينتهى بخرج واحد على الأقل. ألمصطلح "دخل"يستخدم من أجل فعل تحكم ( مثل قفل تلامسات مفتاح ) يستخدم كدخل للمتحكم PLC . و ألمصطلح "خرج" يستخدم من أجل جهاز موصل إلى خرج المتحكم PLC مثل المحرك. 5- الأجهزة الكهربية تظهر فى حالتها العادية (الطبيعية) , أى المفتاح الذى يكون فى وضعه العادى مفتوح (حتى يحدث ما يغير وضعه) يظهر مفتوحا فى مخطط السلم والمفتاح الذى يكون فى وضعه العادى مغلق يظهر مغلقا . 6- أى جهاز معين يمكن أن يظهر فى اكثر من سطر . مثال : قد يكون لدينا ريلاى ويتحكم فى تحويل أكثر من جهاز . نفس الحروف و / أو الأرقام تستخدم فى تسمية الجهاز فى أماكنه المختلفة . 7- المداخل والمخارج تعرف جميعها بعناوينها . والطريقة تعتمد على صناع المتحكم PLC , وهى عناوين المدخل أو المخارج فى ذاكرة المتحكم PLC . الشكل 5-4 يبين الرموز القياسية IEC 1131-3 المستخدمة فى أجهزة الدخل والخرج . لاحظ أن المداخل تمثل برموز مختلفة حسب حالتها العادية NO أو NC بينما ملفات الخرج تمثل برمز واحد فقط . ![]() مثال توضيحى : لتوضيح رسم سطر من مخطط سلم لنعتبر الموقف حيث إثارة (تشغيل) جهاز الخرج (مثل المحرك) تعتمد على مفتاح بدء مفتوح عادى وعند تشغيله أو تحويله يغلق. وهكذا يكون الدخل هو المفتاح والخرج هو المحرك . الشكل 5-5 يبين مخطط السلم . ![]() أبدا بالدخل : لدينا تلامسات دخل من النوع NOو رمزه | | . لا يوجد أجهزة دخل أخرى وينتهى السطر بالخرج ورمزه ( ) . عند غلق المفتاح و يقال "عند وجود دخل " تتم إثارة الخرج أى المحرك ويقال "يوجد خرج" , أى طالما وجد دخل يوجد خرج. إذا كان المفتاح من النوع NC ورمزه |/| الشكل 5-5- ب يكون هناك خرج حتى يتم فتح المفتاح أى أن فتح المفتاح أو الفعل أو تغير الحالة الطبيعية وهو المسمى "دخل" ,أى طالما لا يوجد دخل يوجد خرج . عند رسم مخططات السلم فإن أسماء المتغيرات أو العناوين تلحق برموزها . وهكذا فالشكل 5-6 يبين طرق العنونة المختلفة . الشكل أ للنوع متسوبيشى والشكل ب للنوع سيمنس والشكل ج للنوع الن برادلى والشكل د للنوع تليميكانيك . الشكل أ يوضح أن هذا السطر من مخطط السلم به دخل من العنوان X400 وبه خرج إلى العنوان Y430 . وعند توصيل المداخل والمخارج يجب مراعاة توصيل أطراف المداخل والمخارج المناسبة للعناوين . ![]() 5-2 ألوظائف ألمنطقية : | ||||
| Admin | ||||
| #25 | ||||
| ||||
| 5-2 ألوظائف ألمنطقية : هناك مواقف أو حالات تحكم كثيرة يتطلب فيها بدأ عمل أو فعل ما عندما تتحقق مجموعة معينة من الشروط ,مثل : دوران محرك كهربائى (كعمل أو فعل) عندما تتحقق الشروط ( توصيل مفتاح التغذية و الضغط على زر البدء وعدم وجود أوفر لود ) وهى تسمى وظيقة منطقية . 5-2-1 ألوظيفة (أو ألبوابة) ألمنطقية " و" AND: الشكل 5-7- أ يبين موقف أوحالة : عدم وجود خرج إلا إذا تم غلق كلا المفتاحين ( المفتوحان فى الوضع العادى NO ) . هذه الحالة تسمى المنطق "و"AND. يمكننا النظر إليها كما لو كانت تمثل نظام تحكم بدخلين هما ( Aو B ) كما فى الشكل 5-7- ب. يوجد خرج فقط إذا كان كل من A و B فى حالة ON . فإذا استخدمنا 1 للدلالة على حالة الإشارة ON واستخدمنا 0 للدلالة على حالة الإشارة OFF عندئذ : لكى يكون "الخرج 1 "يجب أن يكون "A = 1" و B" = 1" . مثل هذه العملية يقال أنها متحكم فيها "ببوابة منطقية " والعلاقة بين مداخل هذه البوابة المنطقية ومخارجها توضع على شكل جدول يعرف باسم "جدول الحقيقة ". ![]() مثال على بوابة AND : هو نظام التحكم والحماية (التعشيق) لماكينة بحيث لا تعمل إلا إذا كان كل من وسيلة أو مفتاح الأمان فى وضع السماح (أمان) " و" مفتاح القدرة على وضع تشغيل ON . الشكل 5-8- أ يبين نظام بوابة AND بمخطط السلم . يبدأ مخطط السلم بالرمز | | (تلامسات مفتوحة فى الوضع العادى واسمها الدخل A) ويمثل المفتاح A . وعلى التوالى معه الرمز | | ( تلامسات أخرى مفتوحة فى الوضع العادى واسمها الدخل B) ويمثل المفتاح B . ينتهى السطر بالرمز ( ) الذى يمثل الخرج . لكى يوجد خرج يجب حدوث (وجود) كل من A "و" B أى ان يكون التلامسات A مغلقة "و" التلامسات B مغلقة أيضا كما فى الشكل 5-8- ب . وكقاعدة عامة فى مخطط السلم : التلامسات المتصلة على التوالى فى السطر الأفقى تمثل عمليات منطقية من النوع " و" AND. ![]() 5-2-2 ألوظيفة (أو ألبوابة) ألمنطقية " أو" OR: | ||||
| Admin | |||
| | | ||
« الموضوع السابق | الموضوع التالي »
| | |||||
| | ||||
الفصل الرابع : معالجة المداخل والمخارج I/O Processing
فى هذا الفصل نستمر فى مناقشة المدخلات والمخرجات المذكورة فى الفصل الثانى حيث نتناول باختصار معالجة الإشارات من أجهزة الإدخال والإخراج.
وحدات الدخل أو الخرج I/O تقوم بعمل "الوسيط" interface بين المتحكم PLC والعالم الخارجى وبالتالى يجب أن تقوم بعملية التكييف (التهيئة) اللآزمة للإشارة من حيث المستوى المطلوب للأشارة وكذلك عزلها من أى أخطار كهربائية محتملة مثل الجهد المرتفع .
يتضمن هذا الفصل أشكال نموذجية لوحدات الإدخال / الإخراج ( تسمى موديول modules )وطريقة إتصالها بالمتحكم PLC حيث تكون أجهزة الاستشعار مثبتة على مسافة من معالجة المتحكم .
4-1 وحدات الإدخال و الإخراج Input / Output Units
إشارات الدخل من الحساسات (المستشعرات) والمخارج المطلوبة للأجهزة المنفذة تنقسم إلى :
1- إشارات تناظرية (تماثلية – تشابهية) "أنالوج" Analog: أى الإشارات التى يكون قياسها (مقدارها) مرتبط بقياس الكمية التى يتم الإحساس بها .
2- إشارات متقطعة (منفصلة) Discrete : أى فى الاساس مجرد إشارة توصيل وفصل on/off .
3- إشارات رقمية Digital : أى عبارة عن تتابع من النبضات .
وحدة المعالجة المركزية CPU يجب أن يكون دخلها إشارات رقمية بقياس محدد (عادة من 0 إلى 5 فولت ) . والخرج من وحدة المعالجة المركزية أيضا يكون رقمى (عادة من 0إلى 5 فولت ).
لذلك نحتاج فى الغالب إلى معالجة إشارات الدخل والخرج لكى تصبح فى الشكل المطلوب .
4-1-1 وحدات الإدخال :
المصطلح "مصدر" sourcingوالمصطلح "مصب أو بالوعة" sinking توضح حالة الربط بين الأجهزة ووحدات الدخل للمتحكم .
فوحدات الدخل المصدر تكون هى مصدر الإمداد بالتيار لجهاز الدخل المتصل بها (الشكل 4-1-أ ) .
ووحدات الدخل المصب يكون جهاز الدخل هو الذى يمدها بالتيار (الشكل 4-1-ب).

الأشكال 4-2 و 4-3 تبين دوائر وحدات الدخل الأساسية لكل من مداخل التيارالمستمر DC والتيار المتردد AC. تستخدم العوازل الضوئية لتوفير الحماية .
فى حالة وحدة الدخل للتيار المتردد يستخدم دائرة قنطرة (بريدج) توحيد لتوحيد التيار المتردد وإشارة التيار المستمر الناتج تستخدم مع العازل الضوئى لتعطى إشارات دخل الى وحدة المعالجة المركزية للمتحكم PLC .
يتم إضافة مصدر ضوئى لبيان حالة كل مدخل عندما تصل الإشارة اليه .


يمكن إدخال الإشارات التماثلية إلى المتحكم PLC إذا كانت قناة الدخل قادرة على تحويل الإشارة إلى إشارة رقمية باستخدام المحول من تناظرى إلى رقمى .مع نظام الرفوف rack (راك) يمكن تحقيق ذلك من خلال وحدة (بطاقة - كارتة card) دخل تناظرى مناسبة في الراك rack.بحيث لا يتطلب بطاقة لمدخل تناظرى وغالبا ما يستخدم عملية إنتخاب multiplexing كما فى الشكل (4-4) . وهذا يعنى أنه يمكن توصيل أكثر من دخل تناظرى إلى البطاقة ثم تستخدم تحويلات (مفاتيح) ألكترونية لإختيار كل دخل على حدة . عادة ما تتاحبطاقات بعدد 4 أو 8 أو 16 دخل تناظرى.

الشكل (4-5-أ ) يبين وظيفة المحولADC . إشارة دخل مفردة (وحيدة) تعطى بالمقابل إشارات خرج على شكلon/off ربما تصل الى ثمانى إشارات .
الإشارات الثمانية تشكل ما يطلق عليه "الكلمة الرقمية" المناظرة لمستوى الدخل التناظرى . ويسمى المحول بمحول 8-bit .
مع مثل هذا المحول يكون هناك عدد قدره 2 أس 8 من القيم التنائية أى 256 قيمة وهذه القيم من 0000 0000 الى 1111 1111 أى من 0 الى 255.
الخرج الرقمى يرتفع على شكل درجات (الشكل 4-4-ب )والجهود التناظرية اللآزمة لإنتاج كل خرج رقمى (درجة واحدة) تسمى المستويات الكمية quantization .

المصطلح resolution "القدرة على التحليل أو التمييز" يستخدم للتعبير عن أصغر تغيير فى الجهد التناظرى يعطى مقابله تغييرفى خانة واحدة فى الخرج الرقمى .
إذا استخدمنا 8-bit ADC وكانت إشارة الدخل التناظرية تتغير بين 0V و 10V فإن الخطوة أوالدرجة لخانة رقمية واحدة تعبر عن أو تشمل تغير فى الدخل التناظرى قدره 10/255 V أو حوالى 0.04 .وهذا يعني أن تغيير 0.03V فى الدخل سوف لا ينتج أي تغيير فى الخرج الرقمى . لذلك فإن عدد الخانات (البتات) فى الخرج من محول الأنالوج إلى رقمى تتحدد على دقته .
إذا تم إستخدام محول ADC من نوع 10-bit يكون عدد القيم الرقمية المتاحة هى 2 أس 10 أى 1024, وللمدى الكامل للدخل التناظرى الذى يتغير من 0 إلى 10V تكون خطوة الخانة الرقمية الواحدة تناظر تغيير فى الدخل التناظرى قيمته10/1023 V أو خرج قدره 0.01 V.
وإذا كان المحول ADC من نوع 12-bit يكون عدد القيم الرقمية الممكنه هى 2 أس 12 أى 4096, وللمدى الكامل للدخل التناظرى الذى يتغير من 0 إلى 10V تكون خطوة الخانة الرقمية الواحدة تناظر تغيير فى الدخل التناظرى قيمته10/4095 V أو خرج قدره 2.4 mV.
وعموما تكون دقة المحول ADC من نوع n-bit هى 1/(2n – 1) .
وفيما يلى توضيح لعمل محول ADC نوع 8-bit عندما يكون الدخل التناظرى فى المدى من 0 إلى 10V :

لتوضيح ما ورد أعلاه نعتبر إستخدام الثرموكابل كحساس مع المتحكم PLC ويعطى خرج 0.5 mV لكل درجة مئوية .
ما هى الدقة التى سوف يعمل بها المتحكم PLC على تشغيل جهاز خرج إذا كان الثرموكابل موصل إلى مدخل تناظرى ذات مدى 0 إلى 10V d.c والمحول ADC من النوع 10-bit ؟
بإستخدام محول 10-bit يكون عدد الخانات التى تغطى المدى من 0 إلى 10V هى 210 = 1024 bits . ويكون التغير المناظر لخانة واحدة هو 10/1023 V أو حوالى 0.01 V أى 10 mV . ومن ثم تكون الدقة التى سوف يتعرف بها المتحكم PLC على الدخل من الثرموكابل هى ±5 mV أو ±10oC .
فى هذا الفصل نستمر فى مناقشة المدخلات والمخرجات المذكورة فى الفصل الثانى حيث نتناول باختصار معالجة الإشارات من أجهزة الإدخال والإخراج.
وحدات الدخل أو الخرج I/O تقوم بعمل "الوسيط" interface بين المتحكم PLC والعالم الخارجى وبالتالى يجب أن تقوم بعملية التكييف (التهيئة) اللآزمة للإشارة من حيث المستوى المطلوب للأشارة وكذلك عزلها من أى أخطار كهربائية محتملة مثل الجهد المرتفع .
يتضمن هذا الفصل أشكال نموذجية لوحدات الإدخال / الإخراج ( تسمى موديول modules )وطريقة إتصالها بالمتحكم PLC حيث تكون أجهزة الاستشعار مثبتة على مسافة من معالجة المتحكم .
4-1 وحدات الإدخال و الإخراج Input / Output Units
إشارات الدخل من الحساسات (المستشعرات) والمخارج المطلوبة للأجهزة المنفذة تنقسم إلى :
1- إشارات تناظرية (تماثلية – تشابهية) "أنالوج" Analog: أى الإشارات التى يكون قياسها (مقدارها) مرتبط بقياس الكمية التى يتم الإحساس بها .
2- إشارات متقطعة (منفصلة) Discrete : أى فى الاساس مجرد إشارة توصيل وفصل on/off .
3- إشارات رقمية Digital : أى عبارة عن تتابع من النبضات .
وحدة المعالجة المركزية CPU يجب أن يكون دخلها إشارات رقمية بقياس محدد (عادة من 0 إلى 5 فولت ) . والخرج من وحدة المعالجة المركزية أيضا يكون رقمى (عادة من 0إلى 5 فولت ).
لذلك نحتاج فى الغالب إلى معالجة إشارات الدخل والخرج لكى تصبح فى الشكل المطلوب .
4-1-1 وحدات الإدخال :
المصطلح "مصدر" sourcingوالمصطلح "مصب أو بالوعة" sinking توضح حالة الربط بين الأجهزة ووحدات الدخل للمتحكم .
فوحدات الدخل المصدر تكون هى مصدر الإمداد بالتيار لجهاز الدخل المتصل بها (الشكل 4-1-أ ) .
ووحدات الدخل المصب يكون جهاز الدخل هو الذى يمدها بالتيار (الشكل 4-1-ب).

الأشكال 4-2 و 4-3 تبين دوائر وحدات الدخل الأساسية لكل من مداخل التيارالمستمر DC والتيار المتردد AC. تستخدم العوازل الضوئية لتوفير الحماية .
فى حالة وحدة الدخل للتيار المتردد يستخدم دائرة قنطرة (بريدج) توحيد لتوحيد التيار المتردد وإشارة التيار المستمر الناتج تستخدم مع العازل الضوئى لتعطى إشارات دخل الى وحدة المعالجة المركزية للمتحكم PLC .
يتم إضافة مصدر ضوئى لبيان حالة كل مدخل عندما تصل الإشارة اليه .


يمكن إدخال الإشارات التماثلية إلى المتحكم PLC إذا كانت قناة الدخل قادرة على تحويل الإشارة إلى إشارة رقمية باستخدام المحول من تناظرى إلى رقمى .مع نظام الرفوف rack (راك) يمكن تحقيق ذلك من خلال وحدة (بطاقة - كارتة card) دخل تناظرى مناسبة في الراك rack.بحيث لا يتطلب بطاقة لمدخل تناظرى وغالبا ما يستخدم عملية إنتخاب multiplexing كما فى الشكل (4-4) . وهذا يعنى أنه يمكن توصيل أكثر من دخل تناظرى إلى البطاقة ثم تستخدم تحويلات (مفاتيح) ألكترونية لإختيار كل دخل على حدة . عادة ما تتاحبطاقات بعدد 4 أو 8 أو 16 دخل تناظرى.

الشكل (4-5-أ ) يبين وظيفة المحولADC . إشارة دخل مفردة (وحيدة) تعطى بالمقابل إشارات خرج على شكلon/off ربما تصل الى ثمانى إشارات .
الإشارات الثمانية تشكل ما يطلق عليه "الكلمة الرقمية" المناظرة لمستوى الدخل التناظرى . ويسمى المحول بمحول 8-bit .
مع مثل هذا المحول يكون هناك عدد قدره 2 أس 8 من القيم التنائية أى 256 قيمة وهذه القيم من 0000 0000 الى 1111 1111 أى من 0 الى 255.
الخرج الرقمى يرتفع على شكل درجات (الشكل 4-4-ب )والجهود التناظرية اللآزمة لإنتاج كل خرج رقمى (درجة واحدة) تسمى المستويات الكمية quantization .

المصطلح resolution "القدرة على التحليل أو التمييز" يستخدم للتعبير عن أصغر تغيير فى الجهد التناظرى يعطى مقابله تغييرفى خانة واحدة فى الخرج الرقمى .
إذا استخدمنا 8-bit ADC وكانت إشارة الدخل التناظرية تتغير بين 0V و 10V فإن الخطوة أوالدرجة لخانة رقمية واحدة تعبر عن أو تشمل تغير فى الدخل التناظرى قدره 10/255 V أو حوالى 0.04 .وهذا يعني أن تغيير 0.03V فى الدخل سوف لا ينتج أي تغيير فى الخرج الرقمى . لذلك فإن عدد الخانات (البتات) فى الخرج من محول الأنالوج إلى رقمى تتحدد على دقته .
إذا تم إستخدام محول ADC من نوع 10-bit يكون عدد القيم الرقمية المتاحة هى 2 أس 10 أى 1024, وللمدى الكامل للدخل التناظرى الذى يتغير من 0 إلى 10V تكون خطوة الخانة الرقمية الواحدة تناظر تغيير فى الدخل التناظرى قيمته10/1023 V أو خرج قدره 0.01 V.
وإذا كان المحول ADC من نوع 12-bit يكون عدد القيم الرقمية الممكنه هى 2 أس 12 أى 4096, وللمدى الكامل للدخل التناظرى الذى يتغير من 0 إلى 10V تكون خطوة الخانة الرقمية الواحدة تناظر تغيير فى الدخل التناظرى قيمته10/4095 V أو خرج قدره 2.4 mV.
وعموما تكون دقة المحول ADC من نوع n-bit هى 1/(2n – 1) .
وفيما يلى توضيح لعمل محول ADC نوع 8-bit عندما يكون الدخل التناظرى فى المدى من 0 إلى 10V :

لتوضيح ما ورد أعلاه نعتبر إستخدام الثرموكابل كحساس مع المتحكم PLC ويعطى خرج 0.5 mV لكل درجة مئوية .
ما هى الدقة التى سوف يعمل بها المتحكم PLC على تشغيل جهاز خرج إذا كان الثرموكابل موصل إلى مدخل تناظرى ذات مدى 0 إلى 10V d.c والمحول ADC من النوع 10-bit ؟
بإستخدام محول 10-bit يكون عدد الخانات التى تغطى المدى من 0 إلى 10V هى 210 = 1024 bits . ويكون التغير المناظر لخانة واحدة هو 10/1023 V أو حوالى 0.01 V أى 10 mV . ومن ثم تكون الدقة التى سوف يتعرف بها المتحكم PLC على الدخل من الثرموكابل هى ±5 mV أو ±10oC .









































ليست هناك تعليقات:
إرسال تعليق