beautypg.com

Function precaution, Sample program, 2 instructions – Omron SYSMAC CP CP1E-N@@D@-@ User Manual

Page 391

background image

2-355

2 Instructions

CP1E CPU Unit Instructions Reference Manual(W483)

Basic

I/O U

n

it I
n

stru

ctio

ns

2

SDEC

Function

Precaution

If more than one digit is specified for conversion in Di, digits are converted in order toward the most-

significant digit. Digit 0 is the next digit after digit 3.

Results are stored in D in order from the specified portion toward higher-address words. If just one of

the bytes in a destination word receives converted data, the other byte is left unchanged.

Sample program

When CIO 0.00 turns ON in the following example, the contents of the 3 digits beginning with digit 1 in
D100 will be converted from hexadecimal data to 7-segment data, and the results will be output to the
upper byte of D200 and both bytes of D201. The specifications of the bytes to be converted and the
location of the output bytes are made in CIO 100.

SDEC(078) regards the data specified by
S as 4-digit hexadecimal data, converts the
digits specified in S by Di (first digit and
number of digits) to 7-segment data and
outputs the results to D in the bits specified
in Di.

Number of digits

Rightmost 8 bits (0)

7-segment

First digit to convert

S

S+1

n

m

D

D+1

D+2

Di

0

1/0

8

11

12

15

m

n

0

3

4

7

HEX

SDEC

D100

100

D200

0.00

S

Di

D

8

11

12

15

3

2

1

0

0

3

4

7

1

8

11

12

15

2

1

F

1

7

1

5

B

0

6

0

3

4

7

Hexadecimal to 7-segment data conversion
(F

→ 71, 1 → 06, and 2 → 5B)

S: D100

Di: 100

3

D: D200

D201

This manual is related to the following products: