Transcript Lecture_2

Lecture 2
2. Number systems, codes, signals fundamentals
2.1 The decimal number system
2.2 The binary number system
2.3 The BCD code
2.4 The hexadecimal number system
2.5 Signed binary numbers
2.6 Real numbers
2.7 Generation of binary and digital signals
3. Boolean operations - fundamentals
3.1 Basic logic functions
3.2 Further logic operations
3.3 Establishing switching functions
3.4 Simplification of logic functions
3.5 Karnaugh-Veitch diagram
2.1 The decimal number system
• Characteristic of the decimal number system
used in general is the linear array of digits and
their significant placing.
Example:
The number 4344, for instance, can be
represented as follows:
4344 = 4 x 1000 + 3 x 100 + 4 x 10 + 4x1
Number 4 on the far left is of different significance
to that of number 4 on the far right.
The decimal number system - 2
• The basis is 10.
• 10 different digits permit counting from 0
to 9.
• If counting is to exceed the number 9, this
constitutes a carry over to the next place
digit.
• The significance of this place is 10, and
the next carry over takes place when 99 is
reached etc.
„Decimal“: originating from the latin 'decem' = 10
The decimal number system - 3
• Weights of particular places are powers of 10
• 718 711=
7x100000+1x10000+8x1000+7x100+1x10+1x1
• The digit on the far right is referred to as the least
significant digit (1), and the digit on the far left as
the most significant digit (7).
The decimal number system - 4
• Any number system can be configured on
the basis of this example.
• The fundamental structure can be applied
to number systems of any number of
digits.
• Consequently, any computing operations
and computing methods which use the
decimal number system can be applied
with other number systems.
2.2 The binary number system
• We are indebted to Leibnitz, who applied the
structures of the decimal number system to twodigit calculation.
• As long ago as 1679, this created the premises
essential for the development of the computer,
since electrical voltage or electrical current only
permits a calculation using just two values: e.g.
"current on", "current off". These two values are
represented in the form of digits: "1" and „0".
The binary number system - 2
• If one were to be limited to exactly 2 digits per
place a number system would be configured as
follows:
• Weights are the powers of the digit „2“:
128, 64,32,….
Because of the exclusive use of two digits, this
number system is known as the binary or also the
dual number system
The binary number system - 3
Example ( 8 places ):
1
0
1
1
0
0
0
1
Value of the number (8 places):
1x128+0x64+1x32+1x16+0x8+0x4+0x2+1x1=177
The individual places of the binary number system
can adopt one of the two digits 0 or 1
The binary number system - 4
• Up to a maximum of (2 powered by 8 – 1) = 256
- 1 = 255 can be calculated with eight places,
which would be the number 1111 1111.
•
•
•
•
•
1 bit
1 nibble
1 byte
1 word
1double word
1 digit
4 digits ( a half of a byte)
8 digits
16 digits
32 digits
The binary number system - 5
• Generally up to a maximum of
(2 powered by n – 1)
can be expressed with n places.
Example:
1.How many various values can we obtain
using 10 places A/D converter??
2.What is the maximum accuracy of the
convertor?
The binary number system - 6
Ad 1:
(2 powered by n – 1)=[n=10]=
(2 powered by 10 – 1)=1024-1=1023
Maximum value of 10 digit binary number is
1023.
Ad 2:
Maximum accuracy of the convertor 1/1023=
approximatelly 1 promille
The binary number system - 7
• A/D converter:
Analog value
Eg. (0-10) V
4V
Digital value (binary number)
Eg. (0-1023)
1023/10 x 4=(409,2)=409
2.3 The BCD code
• For people used to dealing with the decimal
system, binary numbers are difficult to read.
• For this reason , a more easily readable numeral
representation was introduced, i.e. the binary
coded decimal notation, the so-called BCD code
(Binary Coded Decimal).
• With this BCD code, each individual digit of the
decimal number system is represented by a
corresponding binary number
The BCD code - 2
• Representation of
decimal numbers in
BCD code
The BCD code - 3
• 4 digits in binary notation are therefore
required for each digit in the decimal
system
Example:
Decimal number 7133 is thus represented
0111 0001 0011 0011
in this way in BCD code
The BCD code - 4
Example:
Number 0101 0010 0111 in BCD code
represents 527 decimal number
BCD coded numbers are often used for
seven segment displays and coding
switches
2.4 The hexadecimal number
system
• The use of binary numbers is often difficult
(long, not providing an easy survey)
• The BCD code takes up a lot of space
• This is why the octal (3 bits,8 various
digits: 0-7) and hexadecimal (4 bits, 16
various digits: 0-F) systems were
developed
The hexadecimal number system-2
• Usable digits at one place of the number
0123456789 A B C D E F
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
• Base is the number 16
• Weights are the powers of the digit „16“:
1,16,256,4096….
The hexadecimal number system-3
• Example:
Hexadecimal number 87BC has in decimal
system value 34 748
8x4096+7x256+11x16+12x1=34 748
The hexadecimal number system-4
• Often is convenient to express long binary
number in hexadecimal system for bettter
readability
Example:
Double word binary number:
0110010111111001
Groups of 4 binary digits
0110 0101 1111 1001
Number in hexadecimal system
6
5
F
9
The hexadecimal number system-5
Example:
Number in hexadecimal system
4
D
5
Groups of 4 binary digits
0100 1110 0101
Double word binary number:
010011100101
0000 010011100101
2.5 Signed binary numbers
• Up to now, we have dealt solely with whole
positive numbers, not taking into account
negative numbers.
• To enable working with these negative numbers,
it was decided that the most significant bit on the
far left of a binary number is to be used to
represent the preceding sign:
– „0" thus corresponds to "+" and
– "1" corresponds to „-".
Signed binary numbers -2
Example:
Signed binary number
11111111 represents -127 decimal number
Signed binary number
01111111 represents +128 decimal number
On one byte (8 digits) we can express
signed numbers in range (-127 to +128 )
Signed binary numbers -3
• Since the most significant bit has been
used, one bit less is available for the
representation of a signed number.
• One byte (8 binary digits)
Integer
Range of values
Unsigned
0 to 255
Signed
-127 to + 128
Signed binary numbers -4
• Two bytes – one word (16 binary digits)
Integer
Unsigned
Signed
Range of values
0 to 65 535
-32768 to + 32767
2.6 Real numbers
• Although it is now possible for whole positive
and whole signed numbers to be represented
with 0 or 1 , there is still the need for points or
real numbers.
• In order to represent a real number in computer
binary notation, the number is split into two
groups, a power of ten and a multiplication
factor. This is also known as the scientific
representation of digits.
Real numbers - 2
• The number 27,3341 is thus converted
into 273 341 x 10 powered by -4.
• Two whole signed numbers are therefore
required for a real number to be represented in a computer or PLC.
2.7 Generation of binary and
digital signals
• As has already become clearly apparent in
the previous section, all computers and as
such all PLCs operate using binary or
digital signals.
• By binary signal, we understand a signal
which recognises only two defined values
• These values are termed „0" or "1", the
terms „Iow“ and „high“, or abreviations „L“
and „H“ are also used.
Generation of binary and digital signals - 2
• Binary signal
1
0
t
Generation of binary and digital signals - 3
• The signals can be very easily realised with
contacting components.
-an actuated normally open contact (NOC)
corresponds to a logic 1-signal and
-an unactuated one to a logic 0-signal.
• When working with contactless components, this
can give rise to certain tolerance bands. For this
reason, certain voltage ranges have been
defined as logic 0 or logic 1 ranges.
Generation of binary and digital signals - 4
• When working with contactless
components, this can give rise to certain
tolerance bands. For this reason, certain
voltage ranges have been defined as logic
0 or logic 1 ranges.
Generation of binary and digital signals - 5
• Voltage ranges
V
30
1 range
11
5
0 range
0
-3
Generation of binary and digital signals - 6
• lEC 1131-2 defines
a value range of -3 V to 5 V as logic 0-signal, and
11 V to 30 V as logic 1-signal
(for contactless sensors).
This is binding for PLCs, whose device technology is
to conform to lEC 1131-2.
In current practice, however, other voltage ranges can
often be found for logic 0- and 1-signal. Widely
used are: -30 V to +5 V as logic 0,
+ 13 V to 30 V as logic 1.
Generation of binary and digital signals - 7
• Unlike binary signals, digital signals can
assume any value.
• These are also referred to as value stages.
• A digital signal is thus defined by any number
of value stages. The change between these
is non-sequential.
• Any???, How many???
Example
Generation of binary and digital signals - 8
• The following illustration shows three
methods of converting an analogue signal
into a digital signal, depending on the step
hight set.
• We use step hight of
–3V
–1V
– 0.5 V
Generation of binary and digital signals - 9
V
step hight 3V
5
4
3
2
1
0
t
Generation of binary and digital signals - 10
V
step hight 1V
5
4
3
2
1
0
t
Generation of binary and digital signals - 11
V
step hight 0,5V
????
5
4
3
2
1
0
t
Generation of binary and digital signals - 12
• Digital signals may be formed from analogue
signals. This method is for instance used for
analogue processing via PLC. Accordingly, the
analogue input signal within a range of 0 to 10 V
is reduced into a series of step values.
• Depending on the quality of the PLC and the
possible step height set, the digital signal would
thus be able to operate in steps of value of 0.1
V, 0.01 V or 0.001 V.
• Naturally, the smallest possible range is to be
selected in order for the analogue signal to be
reproduced as accurately as possible.
Generation of binary and digital signals - 13
• Simple example of an analogue signal is
pressure, which is measured and displayed by a
pressure gauge. The pressure signal may
assume any intermediate value between its
minimum and maximum values. Unlike the
digital signal, it changes continually. In the case
of the processing of analogue values via a PLC,
as described, analogue voltage signals are
evaluated and converted.
Generation of binary and digital signals - 14
PLC
Analog
value
A/D
convertor
Digital
value
(1 byte)
(Pressure p)
Analog
input
modul
CPU
Output
modul
Generation of binary and digital signals - 15
Digital values on one byte - 8 bits
Generation of binary and digital signals - 16
• On the other hand, digital signals can be
formed by adding together a certain
number of binary signals.
• In this way again, as described above, it is
also possible to generate digital signal with
256 (8 bits), 65 535 (16 bits) values.
• This is for instance used to implement
timer and counter functions.
Literature
• Nripendra N. Biswas: Logic Design
Theory,Prentice Hall
International,1993,ISBN 0-13-010695-X