IDEC MicroSmart User Manual

Page 234

Advertising
background image

11: B

INARY

A

RITHMETIC

I

NSTRUCTIONS

11-2

« FC4A M

ICRO

S

MART

U

SER

S

M

ANUAL

»

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 or S2, 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.

Since the binary arithmetic instructions are 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

Using Carry or Borrow Signals

When the D1 (destination) data is out of the valid data range as a result of addition, a carry occurs, and special internal
relay M8003 is turned on. When the D1 (destination) data is out of the valid data range as a result of subtraction, a borrow
occurs, and special internal relay M8003 is turned on.

There are three ways to program the carrying process (see examples below). If a carry never goes on, the program does not
have to include internal relay M8003 to process carrying. If a carry goes on unexpectedly, an output can be programmed to
be set as a warning indicator. If a carry goes on, the number of times a carry occurs can be added to be used as one word
data in a specified register.

Examples: ADD

• Data Type: Word

This example demonstrates the use of a carry signal from special internal relay M8003 to set an alarm signal.

• Data Type: Integer

Operand

Function

I

Q

M

R

T

C

D

Constant

Repeat

S1 (Source 1)

Data for calculation

X

X

X

X

X

X

X

X

1-99

S2 (Source 2)

Data for calculation

X

X

X

X

X

X

X

X

1-99

D1 (Destination 1)

Destination to store results

X

▲ X

X

X

X

1-99

W (word)

I (integer)

X

X

Data Type

Carry occurs when D1 is

Borrow occurs when D1 is

W (word)

over 65,535

below 0

I (integer)

below –32,768 or over 32,767

below –32,768 or over 32,767

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 repeat is designated for a
bit operand, the quantity of operand bits increases in 16-point increments.

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. When repeat is designated for a word operand, the
quantity of operand words increases in 1-point increments.

I0

REP

S2 –

500

D1 –

D2

SOTU

M8003

I1

D2 + 500

→ D2

When a carr y occurs, output Q0 is set as a warning indica-
tor.

When the acknowledge pushbutton (input I1) is pressed,
the warning indicator is reset.

Acknowledge
Pushbutton

S1 –

D2

ADD(W)

Q0

S

Q0

R

I0

REP

S2 –

D20

D1 –

D30

S1 –

D10

ADD(I)

–4

D10

+

–15

D30

–11

D20

Advertising