Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 15 of 60

SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 1 PC Setup and Other Features, pages 131 to 134

Pages 131 to 134 of 520, from SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual

The original document is the PDF (2.1 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Omron CQM1-CPU21

Page 131

Section 1-10

Calculating with Signed Binary Data

Reception Complete: When either the end code, the specified no. of bytes, or 256 bytes are received.

1-9-15 No Protocol Communications Program Example The following program example is for no protocol communication conducted through a RS-232C port using TXD(48) and RXD(47) instructions. If AR 0805 (Transmission Enable Flag) is ON when 00100 is ON, then data from DM0100 to DM0104 is transmitted from higher to lower values. When AR 0806 (Reception Enable Flag) turns ON, 256 bytes of received data are read and written to DM 0200 from higher to lower values. 00100 DIFU(13)

No protocol communications start

00101 00100

AR0805 @TXD DM0100 #0000 #0010

First word holding send data. Using the RS-232C port data is stored from higher to lower values 10 bytes transmitted

AR0806 @RXD DM0200

First word to store receive data.

#0000

Using the RS-232C port data is stored from higher to lower values

256

256 bytes transmitted

1-10 Calculating with Signed Binary Data The CQM1/CPM1/CPM1A/SRM1 allow calculations on signed binary data. The following instructions manipulate signed binary data. Signed data is handled using 2’s complements. CQM1 Instructions

The following signed-binary instructions are available in CQM1 PCs: Single-word Instructions • 2’S COMPLEMENT – NEG(––) • BINARY ADD – ADB(50) • BINARY SUBTRACT – SBB(51) • SIGNED BINARY MULTIPLY – MBS(––) • SIGNED BINARY DIVIDE – DBS(––) Double-word (Long) Instructions • DOUBLE 2’S COMPLEMENT – NEGL(––) • DOUBLE BINARY ADD – ADBL(––) • DOUBLE BINARY SUBTRACT – SBBL(––) • DOUBLE SIGNED BINARY MULTIPLY – MBSL(––) • DOUBLE SIGNED BINARY DIVIDE – DBSL(––)

CPM1/CPM1A/SRM1 Instructions

The following signed-binary instructions are available in CPM1/CPM1A/SRM1 PCs: • BINARY ADD – ADB(50) • BINARY SUBTRACT – SBB(51)

111

Page 132

Section 1-10

Calculating with Signed Binary Data Signed Data Calculations Addition 7 + 3 = 10

Subtraction 7–3=4

(–7) + 3 = –4

(–7) – 3 = –10

7 + (–3) = 4

7 – (–3) = 10

(–7) + (–3) = –10

(–7) – (–3) = –4

Multiplication 7 3 = 21

Division 7 3 = 2 with a remainder of 1

(–7) 3 = –21

(–7)

7 (–3) = –21

7

(–7) (–3) = 21

(–7)

3 = –2 with a remainder of –1 (–3) = –2 with a remainder of 1 (–3) = 2 with a remainder of –1

1-10-1 Definition of Signed Binary Data The CQM1 provides instructions that operate on either one or two words of data; the CPM1/CPM1A/SRM1 provide just two instructions that operate on one word of data. Signed binary data is manipulated using 2’s complements and the MSB of the one- or two-word data is used as the sign bit. The range of data that can be expressed using one or two words is thus as follows: • One-word data: –32,768 to 32,767 (8000 to 7FFF hexadecimal) • Two-word data: –2,147,483,648 to 2,147,483,647 (8000 0000 to 7FFF FFFF hexadecimal) The following table shows equivalents between decimal and hexadecimal data. Decimal 2147483647 2147483646 . . . 32768 32767 32766 . . . 2 1 0 –1 –2 . . . –32767 –32768 –32769 . . . –2147483647 –2147483648

112

16-bit Hex ––– ––– . . . ––– 7FFF 7FFE . . . 0002 0001 0000 FFFF FFFE . . . 8001 8000 ––– . . . ––– –––

32-bit Hex 7FFFFFFF 7FFFFFFE . . . 00008000 00007FFF 00007FFE . . . 00000002 00000001 00000000 FFFFFFFF FFFFFFFE . . . FFFF8001 FFFF8000 FFFF7FFF . . . 80000001 80000000

Page 133

Section 1-10

Calculating with Signed Binary Data

1-10-2 Arithmetic Flags The results of executing signed binary instructions is reflected in the arithmetic flags. The flags and the conditions under which it will turn ON are given in the following table. The flags will be OFF when these conditions are not met. Flag Carry Flag (SR 25504)

ON conditions Carry in an addition. Negative results for subtraction.

Equals Flag (SR 25506)

Overflow Flag (SR 25404)

The results of addition, subtraction, multiplication, or division is 0. Results of converting 2’s complement is 0. 32,767 (7FFF) was exceeded in results of 16-bit addition or subtraction. 2,147,483,647 (7FFF FFFF) was exceeded in results of 32-bit addition or subtraction.

Underflow Flag (SR 25405)

–32,768 (8000) was exceeded in results of 16-bit addition or subtraction, or conversion of 2’s complement. –2,147,483,648 (8000 0000) was exceeded in results of 32-bit addition or subtraction, or conversion of 2’s complement.

1-10-3 Inputting Signed Binary Data Using Decimal Values Although calculations for signed binary data use hexadecimal expressions, inputs from the Programming Console or SSS can be done using decimal inputs and mnemonics for the instructions. The procedure to using the Programming Console to input using decimal values is shown in the CQM1 Operation Manual, CPM1 Operation Manual, CPM1A Operation Manual and SRM1 Master Control Unit Operation Manual. Refer to the SSS Operation Manual: C-series PCs for details on using the SSS. Input Instructions

Only 16-bit operands can be input for the following instructions: NEG(––), ADB(50), SBB(51), MBS(––), and DBS(––). Refer to the CQM1 Operation Manual, CPM1 Operation Manual, CPM1A Operation Manual or SRM1 Master Control Unit Operation Manual for details on inputting instructions from the Programming Console.

1-10-4 Using Signed-binary Expansion Instructions (CQM1 Only) The following CQM1 instructions must be allocated function codes in the instructions table before they can be used. • 2’S COMPLEMENT – NEG(––) • DOUBLE 2’S COMPLEMENT – NEGL(––) • DOUBLE BINARY ADD – ADBL(––) • DOUBLE BINARY SUBTRACT – SBBL(––) • SIGNED BINARY MULTIPLY – MBS(––) • DOUBLE SIGNED BINARY MULTIPLY – MBSL(––) • SIGNED BINARY DIVIDE – DBS(––) • DOUBLE SIGNED BINARY DIVIDE – DBSL(––) Allocating Function Codes

The procedure to using the Programming Console to allocate function codes is shown in the CQM1 Operation Manual. Be sure that pin 4 on the CQM1’s DIP switch is turned ON to enable use of a user-set instruction table before performing this operation.

113

Page 134

Section 1-10

Calculating with Signed Binary Data

1-10-5 Application Example Using Signed Binary Data The following programming can be used to performed calculations such as the following in the CQM1: ((1234 + (–123)) x 1212 – 12345) (–1234) = –1081, Remainder of 232 000 = 04D2 ← 1234 001 = FF85 ← –123 LR00 = 04BC ← 1212 HR50 = 3039 ← 12345 HR51 = 0000 ← DM1000 = FB2E ← –1234 DM1001 = FFFF ← 10000 CLC(41)

ADB(50) 000 001 010

04D2 FF85 X 0 0457

MBS(––) 010 LR00 020

0457 X 04BC 00148BE4

CLC(41)

SBBL(––) 020 HR50 030

00148BE4 00003039 – 0 00145BAB

DBSL(––) 030 DM1000 040

114

00145BAB FFFFFB2E FFFFFBC7 000000E8

Result Remainder