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

page 272

21.2 DATA VALUES

21.2.1 Binary

Binary is best used in computers because signals are ON/OFF which is well suited to the two binary digits.

Converting between number systems can be done by looking at digit magnitude.

26 = 64 25 = 32 24 = 16 23 = 8 22 = 4 21 = 2 20 = 1

1 1 1 0 0 0 1

A binary to decimal conversion 64 32 16

1

113

Conversion can also be done between systems by division.

For division use remainders.

page 273

e.g., convert 932 in decimal (base 10) to a binary number (base 2)

 

932

=

466.0

for binary

--------

2

 

 

 

 

466

=

233.0

 

--------

 

2

 

 

 

 

233

=

116.5

 

--------

 

2

 

 

 

 

116

=

58.0

 

--------

 

2

 

 

 

 

58

=

29.0

 

-----

 

2

 

 

 

 

29

=

14.5

 

-----

 

2

 

 

 

 

14

=

7.0

 

-----

 

2

 

 

 

 

7

 

 

 

 

2--

=

3.5

 

 

3

 

 

 

 

2--

=

1.5

 

 

1

 

 

 

 

2--

=

0.5

0

0

1

0

0

1

0 1110100100

1

1

1

multiply places after decimal by division base, in this case it is 2 because of the binary.

*This method works for other number bases also, the divisor and multipliers should be changed to the new number bases.

Convert the following numbers to/from binary

page 274

base 10

base 2

54,321

110000101101

• Binary bytes and words are shown below.

BYTE

WORD

 

MSB LSB

MSB

LSB

0110 1011

0110 1011 0100 0010

 

most

least

 

significant

significant

 

byte

byte

21.2.2 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

page 275

111 = All three motors are on

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

21.2.3 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,

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