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

The text of a manual · part 8 of 15

SYSMAC C200H-IDS01-V1/IDS21 ID Sensor Operation Manual: SECTION 3 Programming, pages 54 to 62

Pages 54 to 62 of 114, from SYSMAC C200H-IDS01-V1/IDS21 ID Sensor Operation Manual

The original document is the PDF (1.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 C200H-IDS01-V1

Page 54

SECTION 3 Programming This section describes programming and includes example programs that illustrate data transfer between the Unit and the CPU. Monitoring functions and timing considerations are also covered in this section. 3-1

3-2

3-3

Program Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

40

3-1-1

Writing to the Data Carrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

40

3-1-2

Reading from the Data Carrier . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

43

Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

51

3-2-1

Connecting the Handheld Programming Console . . . . . . . . . . . . . .

51

3-2-2

Mode Setting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

52

3-2-3

The JOB Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

56

3-2-4

Address/Data Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

59

3-2-5

Read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

62

3-2-6

Step Write (WRITE 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

63

3-2-7

Continuous Write (WRITE 2). . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

64

3-2-8

Monitor Test (TEST) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

65

3-2-9

Error Log Display (ERR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

66

3-2-10 Error Codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

70

Timing Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

70

3-3-1

Command Processing Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

70

3-3-2

Turnaround Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

72

39

Page 55

Program Examples

Section 3-1

Section Overview

This section contains example programs that illustrate data transfer between the ID Sensor Unit and the CPU of the PC. Six communication commands (Write, Auto Write, Read, Auto Read, Clear-all, and Auto Read/Write Abort) can be used. Also included in this section are a description of Monitoring functions and an explanation of Command Processing Time and Turnaround Time.

3-1

Program Examples The following conditions apply to the example programs in this section: 1,2,3...

1. The ID Sensor Unit unit number switch is set to 0. 2. The command data is stored in the DM area of the CPU. Refer to 2-3 The User Program for an overview of program operation.

3-1-1

Writing to the Data Carrier This section illustrates program examples of the Write, Auto Write, and Clearall commands.

Program Example 1: The Write Command Command execution input

10400 ID busy

10900

MOV (21) #0007 101

MOV (21) #0000 102

Sets the number of words in the command data (7 in this example) Word n+1 Sets the beginning word where the command data is stored (DM 0000 in this example). Word n+2

10900

(Bit in IR area) Holds the status until the ID Sensor Unit begins executing the command.

10000

Command execution flag

10900

Command data in CPU 15

40

Data to be written to Data Carrier 0 Address 7

00

DM 0000

57

54

WT (Write)

DM 0001

48

31

H1 (Hexadecimal, Head 1)

DM 0002

00

06

DM 0003

10

11

Beginning address in which data is to be written in Data Carrier

DM 0004

12

13

Data to be written to Data Carrier, numbers 10 through 14 (5 bytes)

DM 0005

14

2A

DM 0006

0D

00

0006

10

0007

11

Write is executed. 0008

12

0009

13

000A

14

If the number of bytes to be written to the Data Carrier is odd, shift codes 2A and 0D forward one byte and write 00 into the last 8 bits.

Data cannot be written to write-protected areas.

Page 56

Program Examples

Section 3-1

Operation

When the command execution input is ON, the number of words in the command (7) and the beginning word where the command is stored (DM 0000) are set using MOV, and the command execution flag (10000) is turned ON. IR 10900 holds this status until the ID Sensor Unit begins executing the command. While the ID Sensor Unit is executing the command, the ID Busy flag (word n+4 bit 00) is set to ON. When the write operation is complete, the ID Busy flag turns OFF. Although the ID Busy flag normally turns OFF upon completion of the command, if the command execution flag is ON at this time, the ID Busy flag will stay ON. Therefore, design the program so that the command execution flag will be turned OFF when the ID Busy flag turns ON, as in the example.

Program Example 2: The Auto Write Command Command execution input

10400 ID busy

10901

MOV (21) #0008 101

MOV (21) #0100 102

Sets the number of words in the command data (8 in this example) Word n+1 Sets the beginning word where the command data is stored (example shows DM 0100). Word n+2

10901

(Bit in IR area) Holds the status until the ID Sensor Unit begins executing the command.

10000

Command execution flag

10901

Command data in the CPU 15

Data to be written to Data Carrier 0 Address 7

00

DM 0100

41

57

AW (auto write)

DM 0101

48

31

H1 (Hexadecimal, Head 1)

DM 0102

00

0B

Beginning address in which the data is to be written in the Data Carrier

DM 0103

15

16

DM 0104

17

18

DM 0105

19

1A

DM 0106

1B

2A

DM 0106

0D

00

Operation

Auto write is executed.

Data to be written to the Data Carrier, 15 through 1B (7 bytes)

If the number of bytes to be written to the Data Carrier is odd, shift codes 2A and 0D forward one byte and write 00 into the last 8 bits.

000B

15

000C

16

000D

17

000E

18

000F

19

0010

1A

0011

1B

Data cannot be written to write-protected areas.

When the command execution input is ON, the number of words in the command (8) and the beginning word where the command data is stored (DM 0100) are set using MOV, and the command execution flag (10000) is turned ON. IR 10901 holds this status until the ID Sensor Unit starts executing the command.

41

Page 57

Program Examples

Section 3-1 While the ID Sensor Unit is executing the command, the ID Busy flag (word n+4 bit 00) is turned ON. When the Auto Write operation is complete, the ID Busy flag turns OFF. While the ID Sensor Unit is waiting for the Data Carrier to approach the antenna, the Data Carrier waiting flag (word n+4 bit 01) is ON. Although the ID Busy flag normally turns OFF upon completion of the command, if the command execution flag is ON at this time, the ID Busy flag will stay ON. Therefore, design the program so that the command execution flag will be turned OFF when the ID Busy flag turns ON, as in the example.

Program Example 3: The Clear-all Command Command execution input 10400 MOV (21) #0003 101

ID busy 10904

MOV (21) #0600 102

Sets the number of words in the command data (fixed to 3 words). Word n+1 Sets the beginning word where the command data is stored (example shows DM 0600). Word n+2

10904

(Bit in IR area) Holds the status until the ID Sensor Unit begins executing the command.

10000

Command execution flag

10904

Command data in the CPU 15 00

Operation

Contents of Data Carrier's memory after Clear-all execution

DM 0600

43

41

CA (Clear-all)

DM 0601

00

31

Head 1

DM 0602

2A

0D

* Clear-all is executed.

0002 0003

0 Addresses 0000 to 0001 in the Data CarXX rier's memory are reserved for registerXX ing the Data Carrier's production date and 00 cannot be cleared. 00

* If the number of bytes to be cleared is odd, shift codes 2A and OD forward one byte and write 00 into the last 8 bits.

07FE

00

07FF

00 address 7 0000 0001

When the command execution input is ON, the number of words in the command (fixed to 3 words) and the beginning word where the command is stored (DM 0600) are set using MOV, and the command execution flag (10000) is set turned ON. IR (10904) keeps the status until the ID Sensor Unit begins executing the command. While the ID Sensor Unit is executing the command, the ID Busy flag (word n+4 bit 00) is turned ON. When the Clear-all operation is complete, the ID Busy flag turns OFF. Although the ID Busy flag normally turns OFF upon completion of the command, if the command execution flag is ON at this time, the ID Busy flag will

42

Page 58

Program Examples

Section 3-1 stay ON. Therefore, design the program so that the command execution flag will be turned OFF when the ID Busy flag turns ON, as in the example. Note Clearall clears all memory areas, including those that are write-protected.

3-1-2

Reading from the Data Carrier This section shows program examples for the Read and Auto Read commands.

Program Example 4: The Read Command Command execution input 10400 MOV (21) #0005 101

ID busy 10902

MOV (21) #0200 102

MOV (21) #0300 103

Sets the beginning word where the command data is stored (example shows DM 0200). Word n+2 Sets the receiving area (in the CPU) where the data to be read will be transferred. (DM 0300 in this example.) Word n+3 (Bit in IR area) Holds the status until the ID Sensor Unit begins executing the command.

10000

Command execution flag

Area in the CPU to which the data is read

Data in the Data Carrier 0

000A

14

000B

15

000C

16

000D

17

000E

18

000F

19

Operation

Word n+1

10902 10902

Address 7

Sets the number of words in the command data (fixed to 5 words).

15 Read is executed.

Command data in the CPU 15 00 DM 0200

52

44

RD (Read)

DM 0201

48

31

DM 0202

00

0A

DM 0203

00

06

H1 (Hexadecimal, Head 1) Beginning address of the data to be read from the Data Carrier Number of bytes to be read

DM 0204

2A

0D

00

DM 0300

14

15

DM 0301

16

17

DM 0302

18

19

If the number of bytes to be read is odd, the last 8 bits of data are undefined.

If the number of bytes to be read is odd, shift codes 2A and OD forward one byte and write 00 into the last 8 bits.

When the execution command input is ON, the number of words in the command (fixed to 5 words), the beginning word where the command is stored (DM 0200), and the beginning word number of the receiving area in the CPU are set using MOV, and the command execution flag (10000) is turned ON. IR

43

Page 59

Program Examples

Section 3-1 10902 holds this status until the ID Sensor Unit begins executing the command. While the ID Sensor Unit is executing the command, the ID Busy flag (word n+4 bit 00) is turned ON. When the Read operation is complete, the ID Busy flag turns OFF. Although the ID Busy flag normally turns OFF upon completion of the command, if the command execution flag is ON at this time, the ID Busy flag will stay ON. Therefore, design the program so that the command execution flag will be turned OFF when the ID Busy flag turns ON, as in the example.

Program Example 5: The Auto Read Command Command execution input

10400 MOV (21) #0005 101

ID busy 10903

MOV (21) #0400 102

MOV (21) #0500 103

Sets the number of words in the command data (fixed to 5 words). Word n+1 Sets the beginning word where the command data is stored (example shows DM 0400). Word n+2 Sets the receiving area (in the CPU) where the data to be read will be transferred. (DM 0500 in this example.) Word n+3

10903

(Bit in IR area) Holds the status until the ID Sensor Unit begins executing the command.

10000

Command execution flag

10903

Data in the Data Carrier Address 7 001A

001C

3A

Operation

44

38 39

001E

15

0

001B

001D

Receiving area in the CPU

3B 3C

Command data in the CPU 00 15

Auto Read is executed.

DM 0400

41

52

AR (Auto read command)

DM 0401

48

31

DM 0402

00

1A

DM 0403

00

05

H1 (Hexadecimal, Head 1) Beginning address of the data in the Data Carrier Number of bytes to be read

DM 0404

2A

0D

00

DM 0500

38

39

DM 0501

3A

3B

DM 0502

3C

XX

If the number of by tes to be read is odd, the last 8 bits of data are undefined.

If the number of bytes to be read is odd, shift codes 2A and OD forward one byte and write 00 into the last 8 bits.

When the command execution is ON, the number of words in the command (fixed to 5), the beginning word where the command is stored (DM 0400), and the beginning word of the receiving area in the CPU (DM 0500) are set using MOV, and the command execution flag (10000) is turned ON. IR 10900 holds this status until the ID Sensor Unit begins executing the command.

Page 60

Program Examples

Section 3-1 While the ID Sensor Unit is executing the command, the ID Busy flag (word n+4 bit 00) is turned ON. When Auto Write is complete, the ID Busy flag turns OFF. While the ID Sensor Unit is waiting for the Data Carrier to approach, the data Carrier waiting flag (word n+4 bit 01) is ON. Although the ID Busy flag normally turns OFF upon completion of the command, if the command execution flag is ON at this time, the ID Busy flag will stay ON. Therefore, design the program so that the command execution flag will be turned OFF when the ID Busy flag turns ON, as in the example.

Program Example 6: The Auto Read/Write Abort Command Command execution input

10401 MOV (21) #0002 101

ID busy 10905

MOV (21) #0700 102

Sets the number of words in the command data (fixed to 2 words) Word n+1 Sets the beginning word where the command data is stored (DM 0700 in this example). Word n+2

10905

(Bit in IR area) Holds the status until the ID Sensor Unit begins executing the command.

10000

Command execution flag

10905

Command data in the CPU 15 00

Operation

DM 0700

41

41

AA (Auto Read/Write Abort)

DM 0701

00

31

If the number of bytes to be read is odd, shift codes 00 and 31 forward one byte and write 00 into the last 8 bits.

When the execution command input is ON, the number of words in the command (fixed to 2 words) and the beginning word where the command is stored (DM 0700) are set using MOV, and the command execution flag (10000) is turned ON. IR (10905) holds the status until the ID Sensor Unit aborts the auto command (i.e. the Data Carrier waiting flag is OFF). While the ID Sensor Unit is executing the command, the Data Carrier waiting flag (word n+4 bit 01) and the ID Busy flag (word n+4 bit 00) are turned OFF. The Auto Read/Write Abort end flag (word n+4 bit 02) is turned ON, signifying completion of the operation. Although the ID Busy flag normally turns OFF upon completion of the command, if the command execution flag is ON at this time, the ID Busy flag will stay ON. Therefore, design the program so that the command execution flag will be turned OFF when the DC waiting flag turns OFF, as in the example.

45

Page 61

Program Examples

Section 3-1

Program Example 7: Calculation and Writing of Data Carrier’s Data Check Code Command execution input

10400 MOV(21) ID busy

#0005 101

10906

Sets the number of words in the command data to 5 words.

MOV(21) #0800 102

Sets the beginning word where the command data is stored to DM 0800.

10906

Holds the status until the ID Sensor Unit begins executing the command.

10000

Command execution flag

10906

10400 DIFD(14) 10908

Processing end

10908 ANDW(34) 104 #FF00 DM0810 CMP(20)

Judges the result of processing

DM0810 #0000 25506 10907

Command error output

Equal flag

Data in the Data Carrier Command Data in the CPU

00

15

Address

DM 0800

4D

44

0010

DM 0801

4B

31

0011

DM 0802

00

10

0012

DM 0803

00

20

0

DM 0804

2A

0D

Calculation object Check area

002D 002E 002F 0030

46

7

000F

Check code

Page 62

Program Examples Operation

Section 3-1 When the command execution input is ON, the number of words in the command (5) and the beginning word where the command is stored (DM 0800) are set using MOV, and the command execution flag (10000) is turned ON. IR 10906 holds this status until the ID Sensor Unit begins executing the command. While the ID Sensor Unit is executing the command, the ID Busy flag (word n+4 bit 00) is set to ON. When the write operation is completed, the ID Busy flag turns OFF. When the write operation has been completed, the result can be checked with an error flag. If there has been an error, the Command Error Output (10907) turns ON. Note Although the ID Busy flag normally turns OFF upon completion of the command, if the command execution flag is ON at this time, the ID Busy flag will stay ON. Therefore, design the program so that the command execution flag will be turned OFF when the ID Busy flag turns ON, as in the example.

47