Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(EOD).Mechatronics.pdf
Скачиваний:
81
Добавлен:
23.08.2013
Размер:
5.07 Mб
Скачать

 

 

page 424

• Examples of the functions are,

 

 

 

 

 

 

 

 

 

 

 

 

 

AND

 

 

 

source A N7:0

 

 

 

source B N7:1

 

 

 

dest. N7:2

 

 

 

 

 

 

 

OR

 

 

 

source A N7:0

 

 

 

source B N7:1

 

 

 

dest. N7:3

 

 

 

 

 

 

 

XOR

 

 

 

source A N7:0

 

 

 

source B N7:1

 

 

 

dest. N7:4

 

 

 

 

 

 

 

NOT

 

 

 

source A N7:0

 

 

 

dest. N7:5

 

 

 

 

 

addr.

data (binary)

 

 

N7:0

0011010111011011

 

N7:1

1010010011101010

 

after N7:2

1010010011001010

 

N7:3

1011010111111011

 

N7:4

1001000100110001

 

N7:5

1100101000100100

24.2.3 Boolean Operations

• In most discrete systems the inputs and outputs (I/O) are either on or off. This is a binary state that will be represented with,

1 = on

0 = off

Because there are many inputs and outputs, these can be grouped (for convenience) into binary numbers.

Consider an application of binary numbers. There are three motors M1, M2 and M3

100 = Motor 1 is the only one on

111 = All three motors are on

page 425

in total there are 2n or 23 possible combinations of motors on.

• The most common Binary operations are,

Name

Example

Result

 

 

 

 

 

 

AND

0010

* 1010

0010

 

OR

0010

+ 1010

1010

 

NOT

0010

 

1101

 

EOR

0010 eor 1010

1000

 

NAND

0010

* 1010

1101

 

shift left

111000

110001

(other results are possible)

shift right

111000

011100

(other results are possible)

etc.

 

 

 

 

*There are many other operations in addition to this list.

** These operations and the others can be useful for some complicated operations

24.2.4 Binary Mathematics

These include standard logic forms such as,

-and/or/add, etc.

-compliments

Negative numbers are a particular problem with binary numbers. As a result there are two common numbering systems use,

-signed binary - the most significant bit (MSB) of the binary number is used to indicate positive/negative

-2s compliment - negative numbers are represented by complimenting the binary number and then adding 1.

Signed binary numbers are easy to understand, but much harder to work with when doing calculations.

An example of 2s compliments are given below,

page 426

decimal

binary byte

METHOD FOR MAKING A NEGATIVE NUMBER

 

 

1. write the binary number for the positive

2

00000010

1

00000001

for -30 we write 30 = 00011110

0

00000000

 

-1

11111111

2. Invert (compliment) the number

-2

11111110

00011110 becomes 11100001

 

 

 

 

3. Add 1

 

 

11100001 + 00000001 = 11100010

• When adding 2s compliment numbers, additional operations are not needed to deal with negative numbers. Consider the examples below,

00000001 = 1 + 11111111 = -1

C+00000000 = 0

ignore the carry bits

 

00000001 = 1

 

00000010 = 2

+

11111110 = -2

+

11111111 = -1

 

 

 

 

 

 

 

11111111 = -1

C+00000001 = -1

Note: Normally the carry bit is ignored during the operation, but some additional logic is required to make sure that the number has not ‘overflowed’ and moved outside of the range of the numbers. Here the 2s compliment byte can have values from -128 to 127.

24.2.5 BCD (Binary Coded Decimal)

• Each digit is encoded in 4 bits

 

1263

BCD

0001 0010 0110 0011

decimal

Note: this example shows four digits in two bytes. The hex values would also be 1263.

• This numbering system makes poor use of the digits, but is easier to convert to/from base 10

Соседние файлы в предмете Электротехника