51
KEYENCE CODE-READERSIEMENS S7-300Connection Guide I. Configuration (Hardware/Software) I. SIEMENS Products Hardware Configuration II. SIEMENS Products Software Configuration III. KEYENCE Hardware Configuration IV. KEYENCE Software Configuration II. Connection I. Communication Cable Connecting Diagram between CP341<->N-R2 II. Overall Connecting Diagram III. Configuration of KEYENCE Code Reader I. Communication Setting for KEYENCE Code Reader II. Terminal Setting for KEYENCE Code Reader IV. Configuration of SIEMENS S7-300 I. Device Connection between PC and S7-300 II. Operation of STEP[Basic Configuration + Communication Setting] V. Creating S7-300 RS-232C Communication Program (Command Trigger) I. Creating OB II. Creating FC III. Editing OB1 IV. Creating DB100 BL Communication Data VI. Program Operation Test (Command Trigger) I. Creating Variable Table II. Downloading and Monitoring the Project VII. Sample Program (Command Trigger) I. Overall Configuration of Sample Program II. Introduction of Sample Program (Common Parts) III. Introduction of Sample Program (FBDFunction Block Diagram) IV. Introduction of Sample Program (STL Structured Text) VIII. Sample Program (Hard Trigger) I. Overall Configuration of Sample Program II. Introduction of Sample Program (Common Parts) III. Introduction of Sample Program (FBDFunction Block Diagram) IV. Introduction of Sample Program (STL Structured Text) IX. Troubleshooting Table of Contents 1/51

Barcode With s7

Embed Size (px)

DESCRIPTION

Barcode With s7

Citation preview

Page 1: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

I. Configuration (Hardware/Software)I. SIEMENS Products Hardware ConfigurationII. SIEMENS Products Software ConfigurationIII. KEYENCE Hardware ConfigurationIV. KEYENCE Software Configuration

II. Connection I. Communication Cable Connecting Diagram between CP341<->N-R2II. Overall Connecting Diagram

III. Configuration of KEYENCE Code ReaderI. Communication Setting for KEYENCE Code ReaderII. Terminal Setting for KEYENCE Code Reader

IV. Configuration of SIEMENS S7-300I. Device Connection between PC and S7-300II. Operation of STEP7 [Basic Configuration + Communication Setting]

V. Creating S7-300 RS-232C Communication Program (Command Trigger)I. Creating OBII. Creating FCIII. Editing OB1IV. Creating DB100 BL Communication Data

VI. Program Operation Test (Command Trigger)I. Creating Variable TableII. Downloading and Monitoring the Project

VII. Sample Program (Command Trigger)I. Overall Configuration of Sample ProgramII. Introduction of Sample Program (Common Parts)III. Introduction of Sample Program (FBD: Function Block Diagram)IV. Introduction of Sample Program (STL:Structured Text)

VIII. Sample Program (Hard Trigger)I. Overall Configuration of Sample ProgramII. Introduction of Sample Program (Common Parts)III. Introduction of Sample Program (FBD: Function Block Diagram)IV. Introduction of Sample Program (STL:Structured Text)

IX. Troubleshooting

Table of Contents

1/51

Page 2: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

I. Configuration (Hardware/Software)I. SIEMENS Products Hardware Configuration

Power supply unit PS307 5A [6ES7 307-1EA00-0AA0] CPU unit CPU315-2PN/DP [6ES7 315-2EH13-0AB0] I/O unit SM323 DI8/DO8×DC24V [6ES7 323-1BH01-0AA0]RS-232C communication unit CP 341-RS232C [6ES7 341-1AH02-0AE0]Memory card 512Kbyte MMC512KB [6ES7 953-6LJ20-0AA0]Front connecter 20 pin [6ES7 392-1BJ00-0AA0]

II. SIEMENS Products Software Configurationi STEP7 Basic v5.4

Software for configuration of SIEMENS PLC and programmingLanguages available: ladder, function block diagram, structured text

ii Configuration Package for Point to Point CommunicationSoftware attached to CP341 and software adding parameter setting function to STEP7.

III. KEYENCE Hardware Configuration

IV. KEYENCE Software ConfigurationAutoIDNavigator

Software for configurations of KEYENCE Code Reader and peripheral devicesInterface: RS-232C, USB, Ethernet

* unnecessary in the case of command

Model number Order numberFunction

F

D

Mark

E

* unnecessary in the case of command

A B C

A B C D

E F

Barcode ReaderBL-1300 Series

Communication unitN-R2

2D Code ReaderSR-600 Series

Cross cableKEYENCE Code Reader Communication unit and cable

2/51

Page 3: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II. Connection I. Communication Cable Connecting Diagram between CP341<->N-R2

Connect CP341 and N-R2 (KEYENCE Code Reader communication unit) as thefollowing diagram.

II. Overall Connecting Diagram

I Command Trigger

CP-341 N-R2

D-Sub9pin(male)

D-Sub9pin(male)

3/51

Page 4: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II Hard Trigger

*2

*1

*1 *2

4/51

Page 5: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III. Configuration of KEYENCE Code ReaderI. Communication Setting for KEYENCE Code Reader

I Communication Setting for BL-1300 SeriesBL-1300 Series enable communication in default setting when S7-300 configuration is the same as described in IV-II-iii (BL-1300).If you want communication setting other than below, you also have to change the communication setting for CP341-RS232C as mentioned in IV-II-iii.

Setting item ParameterBaud rate 9600bpsParity Even Data bits 7 bitsStop bit 1 bitMulti-drop link DisableRTS/CTS protocol DisablePLC Link DisableHandshaking NonproceduralFormat Length DisableCheck sum ExcludedHeader NoneDelimiter CR

5/51

Page 6: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II Communication Setting for SR-600 SeriesSR-600 Series enable communication in default setting when the configuration screenis the same as that of S7-300 described in IV-II-iii (SR-600).If you want communication setting other than below, you also need to change the communication setting of CP341-RS232C as mentioned in IV-II-iii as well.

Setting item ParameterBaud rate 115200bpsParity EvenData bits 8bitsStop bit 1bitMulti-drop link DisableRTS/CTS protocol DisablePLC link DisableHandshaking NonproceduralFormat Length DisableCheck sum ExcludedHeader NoneDelimiter CR

II. Terminal Setting for KEYENCE CODE READERActivate AutoID Navigator and "Change terminal setting".

Setting item SettingIN1 Function Timing

OUT1 Function OKOUT2 Function NG+ERROROUT3 Function ERROROUT4 Function BUSY

6/51

Page 7: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

IV. Configuration of SIEMENS S7-300I. Device Connection between PC and S7-300

Connect PC to which STEP7 and Configuration Package for Point to Point Communication are installed and S7-300 with a PC adapter (USB 1.1/MPI conversion).

II. Operation of STEP7 [Basic Configuration + Communication Setting]

I Creating a New Project

Activate STEP7and select "New" from "File" menu to create an arbitrary name forthe new project.(In this sample of this document, the project is named as "KYE_BL_RS232C").

EngineeringPC

PC adapter (USB1.1/MPI conversion)

7/51

Page 8: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II Creating a New Project

Select the newly created project."Right click"->"Insert new object"-> and create "SIMATIC 300 Station".

III STEP7 Hardware Configuration

i Double click Hardware for the hardware configuration.

ii From the device list on the right of the screen, select "SIMATIC 300" -> "RACK-300" -> "Rail".Drag & drop "Rail" to create an original frame for the configuration.Then, drag & drop each unit to the original frame to add to the configuration.

8/51

Page 9: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

IV Communication Setting for RS232C

ⅰ Double click CP341-RS232C to display unit properties and click Parameters.Select ASCII for the Protocol (1) and double click Protocol (2).

ⅱ Adapt the communication setting to KEYENCE Code Reader using the ASCII tab

Default setting for BL-1300 Series

Default setting for SR-600 Series

* The above shows communication setting for S7-300. Adapt this setting to communication setting of KEYENCE Code Reader.

Parity

Parity

9/51

Page 10: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

ⅳ Change the number of "Buffered Receive Message Frames", a tab in the "Receiving Data", from 250 to 1. Eliminate the check on "Prevent Overwriting".

v Compile (Setting Storage)Click "OK" and close all parameter screens for the compile.

All procedures for communication setting for CP341-RS232C is completed.Close the hardware configuration window.

10/51

Page 11: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

I. Creating OB

Program overviewAdd the system program OB (Organization Block) which is originally loaded on the system.OB is an interface program between the system and user program.Since OB is triggered by the system, its execution conditions are predetermined.* CPU stops when there is no applicable OB in case of errors.

ⅰ Add OB (Organization Block) to Blocks.As shown on the right diagram, specify the OB No. and press "OK" button.

ⅱ Create entire OBs as shown below. (OB80, 82, 85, 86, 87, 121, 122)

* OB is a system program, mainly activated in case of system errors.

V. Creating S7-300 RS-232C Communication Program (Command Trigger)

An error occurs in user program such as a call for non-existing FC.

When executing PIW/PQW command from program, there is a module thatcannot be accessed.

It is activated when diagnosis interruption from module that has diagnosisfunction occurs.It is activated when non-existing OB is called or there is some modules thatCPU cannot access.When a fault occurs in expended rack or DP slave stations.

When an error occurs in MPI communication such as global data network.

Description of program functions

OB85[DI/O access

error]

It is activated at the time of call error such as cycle time over or cycleinterruption OB.

OB121[Program error]

OB122[I/O access error]

OB86[Rack error]

OB87[MPI communication error]

ProgramOB80

[OB call error]OB82

[Diagnosis interruption]

11/51

Page 12: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II.Creating FC

I. Creating FC100 Initial Circuit

Program overviewCreate Normal ON flag and Normal OFF flag to be used in the program created by users.

ⅰ Add FC (the function created by users) to Blocks.As shown on the right diagram, input FC100 as a name to create an initial program.

ⅱ Double click FC100 to activate ladder editor and create the circuit as shown below.《FC100 : INITIAL》 * Users can freely specify the name of FC No.

12/51

Page 13: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II. Creating FC201 BL Communication Setting

Program overviewCreate a trigger circuit for the barcode reader initiated by hardware output as well as a receiving circuit for the data read by the code reader.

ⅰ Add FC (the function created by users) to Blocks.(Give tentative name FC201 here to create barcode reader receiving program).

ⅱ Register a device for TEMP (temporary memory area) in FC201.

13/51

Page 14: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

iii Creating a network to receive data from the code reader

Insert FB7 P_RCV_RK by drag & drop from the live area on the left of the screen.

(1) Just above FB7, specify DB No. to be used. (DB70 as for this sample)(2) To the left of FB7, specify the value to be input.(3) To the right of FB7, specify an address to be output (created TEMP address).* All output here is used for monitoring, not for the control.

* Parameters are available until the next FB is called.

Error specification

BOOLRequest ended with errors

INT

Message frame length receivedINT

INPUT

OUTPUT WORD

Reception DB No.:CPU-specific, no zero

STATUSparameter==16#00

0≦DBB_NO≦8190 Datareceived as data word

STATUS

1≦LEN≦1024, specified bybyte numberLEN OUTPUT

Data byte number

Data type Description

In the case of ERROR==1,STATUS parametersinclude error details.

Current request is stopped.Reception is blocked.

INTBasic address for CP341 Basic address is obtained

from STEP7.

BOOLStops request

STATUS parametersinclude error details.

Request ended/data receivedwithout errors

DBB_NO

Possible value, comment

EN_R INPUT BOOLEnables data read

Name Type

ERROR OUTPUT

INPUT

INTDB_NO

NDR OUTPUT BOOL

Data block number

R INPUT

LADDR

INPUT

②③

FB P_RCV_RK parameter

14/51

Page 15: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

iv Creating a network to transmit triggers to the code reader

v Creating a network for the input from the code reader.

15/51

Page 16: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

vi Creating a network to suspend reading from the code reader.

vii Creating a network to send command to the code reader.

16/51

Page 17: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Insert FB8 P_SND_RK by drag & drop from the live area on the left of the screen.

(1) Just above FB8, specify DB No. to be used. (DB80 as for this sample)(2) To the left of FB8, specify the value to be input.(3) To the right of FB8, specify an address to be output (created TEMP address).* All output here is used for monitoring, not for the control.

* Parameters are available until the next FB is called.

STATUS OUTPUT WORD

STATUSparameter==16#00;

Request ended without errors

In the case of ERROR==1,STATUS parametersinclude error details.

STATUS parametersinclude error details.

Error specification

Request ended with errorsERROR OUTPUT BOOL

0≦DBB_NO≦8190 Datasent as data word

LEN INPUT INT

DBB_NO INPUT INTData byte number

1≦LEN≦1024, specified bybyte number

Data bits

Basic address is obtainedfrom STEP7.Reception DB No.:CPU-specific, no zeroDB_NO INPUT INT

Data block number

Starts request upon signalactivation

LADDR INPUT INTBasic address for CP341

Stops request

REQ

R BOOL

Name Type

OUTPUT BOOL

Data type Description

INPUT BOOLCurrent request is stopped.Send is blocked.

Possible value, comment

DONE

INPUT

FB P_SND_RK parameter

17/51

Page 18: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III. Editing OB1

Create a program to call FC100,FC101 for OB1.

18/51

Page 19: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

IV. Creating DB100 BL Communication Data

Program overviewCreate data area to store the data read by the code reader.

i Add DB (data block created by users) to Blocks.Give tentative name DB100 to create an area for receiving data from the code reader.《DB100 : BL Communication Data》 * Users can freely specify the name of DB.

19/51

Page 20: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

ii Add DB (data block created by users) to Blocks.Give tentative name DB200 to create an area for send command to the code reader.《DB200 : BL Command Data》 * Users can freely specify the name of DB.

All procedures for creating S7-300 RS-232C communication program is completed.

20/51

Page 21: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

VI. Program Operation Test (Command Trigger)I. Creating Variable Table

Right-click Blocks in the below diagram and click "Insert New Object"-> "Variable Table".

Register variables in the variable table as shown below.(A name"TEST" is used here for the tentative name of variables.)

21/51

Page 22: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II. Downloading and Monitoring the Project

I Downloading the Project

Connect a PC and S7-300 using a PC adapter. Select entire project.Click download button (red frame) to download the project to S7-300.

II Monitoring the Project Execution

i Open the variable table to enable monitoring.

ii Select "true" for the laser emission trigger (M100.0) for the code reader.

22/51

Page 23: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

iii When the sample barcode is read as shown below,KEYENCE will be input in each address starting from DB100.DBW0.When the sample barcode is not read and the reading is not completed within READ TIME OUT (1sec) set in the sample program,ERROR will appear in each address starting from DB100.DBW0.

Sample barcode

* K E Y E N C E *

23/51

Page 24: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

VII. Sample Program (Command Trigger)I. Overall Configuration of the Sample Program

FB7

OB1

OB80~OB122

FC100

This is a function block prepared by SIEMENS for the RS232Ccommunication.

This program creates a trigger circuit for the barcode reader and a receivingcircuit for the data read by the code reader.

This is the main function of the program activated on the system, and whilethe program is running, it is repeatedly executed in a cycle.These are system programs originally given to the system.They are automatically activated when an error occurs.

FC101

This is a variable table for the read test performed by the code reader.From here, trigger is issued or barcode data is monitored.

Program name Description of program functions

DB70

DB100

TEST

This is a data block to assign FB7 system data as shown above.

This is a data block to store the data read by the code reader.

This is a function to store initial settings.There are Normal ON and Normal OFF flags here.

24/51

Page 25: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II. Introduction of Sample Program (Common Parts)

I DB100 (Data Block for the Code Reader Communication)

This is a data block to store the data read by the code reader.

25/51

Page 26: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

I DB200 (Data Block to Send Command to the Code Reader)

This is a data block to store the send command data issued by the code reader.

26/51

Page 27: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II TEST (Variable Table for the Program Operation Test)

This is a variable table for the read test performed by the code reader.From here, trigger is issued or barcode data is monitored.

27/51

Page 28: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II. Introduction of Sample Program (LAD: Ladder)

I OB1 (Main Function)

This is the main function of the program activated on the system, and while the program is running, it is repeatedly executed in a cycle.

II FC100 (INITIAL Function)

This is a function to store initial settings.

Call and run FC100.

Call and run FC101.

M0.1NORMAL OFF.

M0.0NORMAL ON.

28/51

Page 29: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III FC201 (BL Communication Setting function)

バーコードリーダーへのトリガー回路と、バーコード読込みデータの受信回路となります。

Activate (ON) a receivetrigger to activate (ON)the barcode laser.

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "V-II-II. CreatingFC201 BL CommunicationSetting" for details.

29/51

Page 30: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Input data length of the data areafor the Send Command"LON[CR]".

Specify a send command stringfor the data block.

30/51

Page 31: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Input data length of the data areafor the Send Command"LOFF[CR]".

Specify a send command stringfor the data block.

31/51

Page 32: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Execute instructions to send acommand.Execute the command when theinstruction for the laser of CodeReader is ON or OFF.

Set timer value startingfrom activating (ON) thelaser of Code Reader untila read error is found.

* 1 sec for the tentativevalue.

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "V-II-II. CreatingFC201 BL CommunicationSetting" for details.

32/51

Page 33: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III. Introduction of Sample Program (FBD: Function Block Diagram)

I OB1 (Main Function)

This is the main function of the program activated on the system, and while the program is running, it is repeatedly executed in a cycle.

II FC100 (INITIAL Function)

This is a function to store initial settings.

Call FC100 and execute theprogram.

Call FC101 and execute theprogram.

M0.1NORMAL OFF.

M0.0NORMAL ON.

33/51

Page 34: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III FC201 (BL Communication Setting Function)

This function creates a trigger circuit for the barcode reader and a receiving circuit for the data read by the code reader.

Activate (ON) a receivetrigger to activate (ON)the barcode laser.

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "V-II-II. CreatingFC201 BL CommunicationSetting" for details.

34/51

Page 35: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Input data length of the data areafor the Send Command"LON[CR]".

Specify a send command stringfor the data block.

Input data length of the data areafor the Send Command"LOFF[CR]".

Specify a send command stringfor the data block.

35/51

Page 36: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "V-II-II. CreatingFC201 BL CommunicationSetting" for details.

Set timer value startingfrom activating (ON) thelaser of Code Reader until aread error is found.

*1 sec for the tentativevalue.

Execute instructions to send acommand.Execute the command whenthe instruction for the laser ofCode Reader is ON or OFF.

36/51

Page 37: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

IV. Introduction of Sample Program (STL:Structured Text)

I OB1 (Main Function)

This is the main function of the program activated on the system, and while the program is running, it is repeatedly executed in a cycle.

Ⅱ FC100 (INITIAL function)

This is a function to store initial settings.

Call FC100 and executethe program.

Call FC101 and executethe program.

M0.1NORMAL OFF.

M0.0NORMAL ON.

37/51

Page 38: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Ⅲ FC201 (BL Communication Setting function)

Activate (ON) a receivetrigger to activate (ON) thebarcode laser.

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "V-II-II. CreatingFC201 BL CommunicationSetting" for details.

Input data bits of the data areafor the Send Command"LON[CR]".

Specify a send command stringfor the data block.

38/51

Page 39: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Execute instructions to send acommand.Execute the command when theinstruction for the laser of CodeReader is ON or OFF.

Set timer value startingfrom activating (ON) thelaser of Code Reader untila read error is found.

* 1 sec for the tentativevalue.

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "V-II-II. CreatingFC201 BL CommunicationSetting" for details.

Input data bits of the data area forthe Send Command "LOFF[CR]".

Specify a send command stringfor the data block.

39/51

Page 40: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

VIII. Sample Program (Hard Trigger)I. Overall Configuration of Sample Program

This program creates a trigger circuit for the barcode reader and a receivingcircuit for the data read by the code reader.FC101

Program Name Program description

OB1 This is the main function of the program activated on the system, and whilethe program is running, it is repeatedly executed in a cycle.

OB80~OB122

FB7

TEST This is a variable table for the read test performed by the code reader.From here, trigger is issued or barcode data is monitored.

DB70 This is a data block to assign FB7 system data as shown above.

DB100 This is a data block to store the data read by the code reader.

This is a function block prepared by SIEMENS for the RS232Ccommunication.

These are system programs originally given to the system.They are automatically activated when an error occurs.

FC100 This is a function to store initial settings.There are Normal ON and Normal OFF flags here.

40/51

Page 41: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II. Introduction of Sample Program (Common Parts)

I DB100 (Data Block for the Code Reader Communication)

This is a data block to store the data read by the code reader.

41/51

Page 42: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II TEST (Variable Table for the Program Operation Test)

This is a variable table for the read test performed by the code reader.From here, trigger is issued or barcode data is monitored.

42/51

Page 43: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

II Introduction of Sample Program (LAD: Ladder)

Ⅰ OB1 (Main Function)

This is the main function of the program activated on the system, and while the program is running, it is repeatedly executed in a cycle.

II FC100 (INITIAL Function)

This is a function to store initial settings.

Call FC100 and executethe program.

Call FC101 and executethe program.

M0.1NORMAL OFF.

M0.0NORMAL ON.

43/51

Page 44: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III FC101 (BL Communication Setting Function)

This program creates a trigger circuit for the barcode reader anda receiving circuit for the data read by the code reader.

Activate (ON) a receivetrigger to activate (ON)the barcode laser.

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "II-II. CreatingFC101 BLCommunication Setting"for details.

44/51

Page 45: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Output for activating (ON)the barcode laser .

Monitoring circuit for OKsignals from the barcodereader.

Monitoring circuit for NG +ERROR signals from thebarcode reader.

Monitoring circuit forERROR signals from thebarcode reader.

Monitoring circuit forBUSY signals from thebarcode reader.

Set timer value startingfrom activating (ON) thelaser of Code Reader untila read error is found.

* 1 sec for the tentativevalue.

Inactivate (OFF) thebarcode laser.

45/51

Page 46: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III. Introduction of Sample Program (FBD: Function Block Diagram)

Ⅰ OB1 (Main Function)

This is the main function of the program activated on the system, and while the program is running, it is repeatedly executed in a cycle.

II FC100 (INITIAL Function)

This is a function to store initial settings.

Call FC100 and executethe program.

Call FC101 and executethe program.

M0.1NORMAL OFF.

M0.0NORMAL ON.

46/51

Page 47: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III FC101 (BL Communication Setting Function)

This program creates a trigger circuit for the barcode reader anda receiving circuit for the data read by the code reader.

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "II-II. CreatingFC101 BL CommunicationSetting" for details.

Activate (ON) a receivetrigger to activate (ON) thebarcode laser.

Output for activating (ON)the barcode laser .

47/51

Page 48: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

Monitoring circuit for OKsignals from the barcodereader.

Monitoring circuit for NG +ERROR signals from thebarcode reader.

Monitoring circuit forERROR signals from thebarcode reader.

Monitoring circuit forERROR signals from thebarcode reader.

Set timer value startingfrom activating (ON) thelaser of Code Reader untila read error is found.

* 1 sec for the tentativevalue.

Inactivate (OFF) thebarcode laser.

48/51

Page 49: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

IV. Introduction of Sample Program (STL:Structured Text)

Ⅰ OB1 (Main Function)

This is the main function of the program activated on the system, and while the program is running, it is repeatedly executed in a cycle.

II FC100 (INITIAL Function)

This is a function to store initial settings.

Call FC100 and executethe program.

Call FC101 and executethe program.

M0.1 NORMAL OFF.

M0.0 NORMAL ON.

49/51

Page 50: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

III FC101 (BL Communication Setting Function)

Set input/outputparameters of FB for theCP341(RS232C)communication unitreception.

* See "II-II. CreatingFC 101 BLCommunication Setting"for details.

Activate (ON) a receivetrigger to activate (ON) thebarcode laser.

Output for activating (ON)the barcode laser.

Monitoring circuit for OKsignals , NG+ERRORsignals, ERROR signalsandBUSY signals

Set timer value startingfrom activating (ON) thelaser of Code Reader untila read error is found.

* 1 sec for the tentativevalue.

Inactivate (OFF) thebarcode laser.

50/51

Page 51: Barcode With s7

【KEYENCE CODE-READER】 【SIEMENS S7-300】 Connection Guide

IX. Troubleshooting

Q CPU does not run or a system error occurs.

A Please refer to hardware configuration for the place and cause of the error.

Switch to online from Tool Bar (press down the button in the red frame) to monitorthe current status. By double clicking each unit, detailed status can be monitored.

Q PLC cannot retrieve barcode read data from the code reader.

A Please check LED display of TXD and RXD on the surface of CP341.

If LED of TXD and RXD is off, that may be caused by problems withcommunication cable or communication setting.If LED of TXD and RXD is on, that may be caused by problems with internal setting of PLC.Please review the communication setting and check the communication program.

51/511084-1 600F16