Data conversion instructions, Htob (hex to bcd), Htob (hex to bcd) -1 – IDEC MicroSmart User Manual

Page 253: Onversion, Nstructions, Introduction

Advertising
background image

« FC4A M

ICRO

S

MART

U

SER

S

M

ANUAL

»

14-1

14: D

ATA

C

ONVERSION

I

NSTRUCTIONS

Introduction

Data conversion instructions convert data format among binary, BCD, and ASCII.

The ENCO (encode), DECO (decode), and BCNT (bit count) instructions processes bit operand data.

The ALT (alternate output) instruction turns on and off an output each time an input button is pressed.

HTOB (Hex to BCD)

Applicable CPU Modules

Valid Operands

For the valid operand number range, see pages 6-1 and 6-2.

Internal relays M0 through M1277 can be designated as D1. Special internal relays cannot be designated as D1.

When T (timer) or C (counter) is used as S1, the timer/counter current value is read out. When T (timer) or C (counter) is
used as D1, the data is written in as a preset value which can be 0 through 65535.

Valid values for the source operand are 0 through 9999 (270Fh). Make sure that the source designated by S1 is within the
valid value range. If the source data is out of the valid range, a user program execution error will result, turning on special
internal relay M8004 and the ERR LED.

Since the HTOB instruction is executed in each scan while input is on, a pulse input from a SOTU or SOTD instruction
should be used as required.

Valid Data Types

Example: HTOB

FC4A-C10R2/C

FC4A-C16R2/C

FC4A-C24R2/C

FC4A-D20K3/S3

FC4A-D20RK1/RS1 & FC4A-D40K3/S3

X

X

X

X

X

Operand

Function

I

Q

M

R

T

C

D

Constant

Repeat

S1 (Source 1)

Binar y data to conver t

X

X

X

X

X

X

X

X

D1 (Destination 1)

Destination to store conversion results

X

▲ X

X

X

X

W (word)

I (integer)

X

S1

→ D1

When input is on, the 16-bit data designated by S1 is conver ted into BCD and
stored to the destination designated by operand D1.

Valid values for the source operand are 0 through 9999.

HTOB(W)

S1

*****

D1

*****

When a bit operand such as I (input), Q (output), M (internal relay), or R (shift register) is
designated as the source or destination, 16 points are used.

When a word operand such as T (timer), C (counter), or D (data register) is designated as the
source or destination, 1 point is used.

D1

D20

S1

D10

I1

HTOB(W)

Binar y

SOTU

0

D10

(0000h)

BCD

0

D20

(0000h)

1234

D10

(04D2h)

4660

D20

(1234h)

9999

D10

(270Fh)

39321

D20

(9999h)

Advertising