Codes and code converters
This presentation is the property of its rightful owner.
Sponsored Links
1 / 29

Codes and Code Converters PowerPoint PPT Presentation


  • 73 Views
  • Uploaded on
  • Presentation posted in: General

Codes and Code Converters. Lecture L6.12 Section 6.5 Section 9.5. Codes and Code Converters. ASCII Binary-to-BCD Converters Gray Code Bar Codes. Table 9.2. Standard. ASCII codes. Dec. 0. 16. 32. 48. 64. 80. 96. 112. Hex. 0. 1. 2. 3. 4. 5. 6. 7. 0. 0. NUL. DLE.

Download Presentation

Codes and Code Converters

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Codes and code converters

Codes andCode Converters

Lecture L6.12

Section 6.5

Section 9.5


Codes and code converters1

Codes and Code Converters

  • ASCII

  • Binary-to-BCD Converters

  • Gray Code

  • Bar Codes


Standard ascii codes

Table 9.2

Standard

ASCII codes

Dec

0

16

32

48

64

80

96

112

Hex

0

1

2

3

4

5

6

7

0

0

NUL

DLE

blank

0

@

P

p

1

1

SOH

DC1

!

1

A

Q

a

q

2

2

STX

DC2

"

2

B

R

b

r

3

3

ETX

DC3

#

3

C

S

c

s

4

4

EOT

DC4

$

4

D

T

d

t

5

5

ENQ

NAK

%

5

E

U

e

u

6

6

ACK

SYN

&

6

F

V

f

v

7

7

BEL

ETB

'

7

G

W

g

w

8

8

BS

CAN

(

8

H

X

h

x

9

9

HT

EM

)

9

I

Y

i

y

10

A

LF

SUB

*

:

J

Z

j

z

11

B

VT

ESC

+

;

K

[

k

{

12

C

FF

FS

,

<

L

\

l

|

13

D

CR

GS

-

=

M

]

m

}

14

E

SO

RS

.

>

N

^

n

~

15

F

SI

US

/

?

O

_

o

DEL

Standard ASCII Codes


Codes and code converters

ASCII Codes


Definitions of ascii control characters

Definitions of ASCIIControl Characters


Codes and code converters2

Codes and Code Converters

  • ASCII

  • Binary-to-BCD Converters

  • Gray Code

  • Bar Codes


Binary to bcd converter

Binary-to-BCD Converter


Codes and code converters

I = 1110

E

D

C

B

A

1 4

bin2bcd.abl

MODULE bin2bcd

TITLE 'Binary to binary coded decimal'

DECLARATIONS

" INPUT PINS "

I3..I0 PIN 11,7,6,5;" Switches S6 - 1..4

I = [I3..I0];" 4-bit input vector

" OUTPUT PINS "

[E,D,C,B,A] PIN 5,4,3,2,1 ISTYPE 'com';" LEDs 12..16

BCD = [E,D,C,B,A];


Codes and code converters

EQUATIONS

@radix 16;" Identify the Hex Base

truth_table ( I -> BCD )" Binary to BCD Code Converter

0 -> 00;

1 -> 01;

2 -> 02;

3 -> 03;

4 -> 04;

5 -> 05;

6 -> 06;

7 -> 07;

8 -> 08;

9 -> 09;

0A -> 10;

0B -> 11;

0C -> 12;

0D -> 13;

0E -> 14;

0F -> 15;

END bin2bcd

bin2bcd.abl (cont’d)


Shift and add 3 algorithm

Shift and Add-3 Algorithm

1.      Shift the binary number left one bit.

2.      If 8 shifts have taken place, the BCD number is in the

Hundreds, Tens, and Units column.

3.      If the binary value in any of the BCD columns is 5 or greater,

add 3 to that value in that BCD column.

4.      Go to 1.


Codes and code converters

Steps to convert an 8-bit binary number to BCD


Example of converting hex e to bcd

Example of converting hex E to BCD


Truth table for add 3 module

Truth table for Add-3 Module

A3 A2 A1 A0

C

S3 S2 S1 S0


Codes and code converters

Binary-to-BCD

Converter


Codes and code converters

Binary-to-BCD

Converter


Other binary coded decimal representations

Other Binary Coded Decimal Representations


Codes and code converters3

Codes and Code Converters

  • ASCII

  • Binary-to-BCD Converters

  • Gray Code

  • Bar Codes


Gray code

Gray Code

Note that the least significant bit

that can be changed without

repeating a value is the bit

that is changed


Gray codes eliminate errors

Gray codes eliminate errors

Gray Code

Binary Code


Gray code conversion

Gray Code Conversion

Gray Code Decimal equivalent

G_in = [G2..0];

G_out = [B2..0];

0000

0011

0112

0103

1104

1115

1016

1007

Truth_table (G_in => G_Out)

Fill in this TRUTH_TABLE

Command so as to convert

the Gray code input, [G2..0],

to the binary output, [B2..0]


Gray code conversion1

Gray Code Conversion

Gray Code Decimal equivalent

G_in = [G2..0];

G_out = [B2..0];

0000

0011

0112

0103

1104

1115

1016

1007

Truth_table (G_in => G_Out)

0 -> 0; 1 -> 1;

3 -> 2; 2 -> 3;

6 -> 4; 7 -> 5;

5 -> 6; 4 -> 7;

Fill in this TRUTH_TABLE

Command so as to convert

the Gray code input, [G2..0],

to the binary output, [B2..0]


Codes and code converters4

Codes and Code Converters

  • ASCII

  • Binary-to-BCD Converters

  • Gray Code

  • Bar Codes


Code 39 bar code

Code 39 Bar Code

A

B

C

D

3-of-9 bars are WIDE bars

(Bars can be black or white)


  • Login