You are on page 1of 51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

Table of Contents
I. Configuration (Hardware/Software)
I. SIEMENS Products
II. SIEMENS Products
III. KEYENCE
IV. KEYENCE

Hardware Configuration
Software Configuration
Hardware Configuration
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 (FBD Function Block Diagram)
IV. Introduction of Sample Program (STLStructured Text)

VIII. Sample Program (Hard Trigger)


I. Overall Configuration of Sample Program
II. Introduction of Sample Program (Common Parts)
III. Introduction of Sample Program (FBD Function Block Diagram)
IV. Introduction of Sample Program (STLStructured Text)

IX. Troubleshooting

1/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

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

Mark

A
B
C
D
E
F

Model number

Order number

Power supply unit


CPU unit
I/O unit

PS307 5A
CPU315-2PN/DP
SM323 DI8/DO8DC24V
RS-232C communication unit CP 341-RS232C
Memory card 512Kbyte MMC512KB
Front connecter
20 pin

B
E

[6ES7 307-1EA00-0AA0]
[6ES7 315-2EH13-0AB0]
[6ES7 323-1BH01-0AA0]
[6ES7 341-1AH02-0AE0]
[6ES7 953-6LJ20-0AA0]
[6ES7 392-1BJ00-0AA0]

* unnecessary in the case of command

* unnecessary in the case of command

II. SIEMENS Products Software Configuration


i

STEP7 Basic v5.4


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

ii Configuration Package for Point to Point Communication


Software attached to CP341 and software adding parameter setting function to STEP7.

III. KEYENCE Hardware Configuration


KEYENCE Code Reader
Barcode Reader
BL-1300 Series

2D Code Reader
SR-600 Series

Communication unit and cable


Communication unit
N-R2

Cross cable

IV. KEYENCE Software Configuration


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

2/51

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 the
following diagram.
CP-341

N-R2

D-Sub9pin
(male)

D-Sub9pin
(male)

II. Overall Connecting Diagram


I

Command Trigger

3/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

II Hard Trigger

*2

*1

*1

*2

4/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

III. Configuration of KEYENCE Code Reader


I. Communication Setting for KEYENCE Code Reader
I

Communication Setting for BL-1300 Series


BL-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

Parameter

Baud rate
Parity
Data bits
Stop bit
Multi-drop link
RTS/CTS protocol
PLC Link
Handshaking
Format Length
Check sum
Header
Delimiter

9600bps
Even
bits
bit
Disable
Disable
Disable
Nonprocedural

Disable
Excluded
None
CR

5/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

II Communication Setting for SR-600 Series


SR-600 Series enable communication in default setting when the configuration screen
is 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

Parameter

Baud rate
Parity
Data bits
Stop bit
Multi-drop link
RTS/CTS protocol
PLC link
Handshaking
Format Length
Check sum
Header
Delimiter

115200bps
Even
8bits
1bit
Disable
Disable
Disable
Nonprocedural

Disable
Excluded
None
CR

II. Terminal Setting for KEYENCE CODE READER


Activate AutoID Navigator and "Change terminal setting".
Setting item

Setting

IN1 Function

Timing

OUT1 Function
OUT2 Function
OUT3 Function
OUT4 Function

OK
NG+ERROR
ERROR
BUSY

6/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

IV. Configuration of SIEMENS S7-300


I. 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).

Engineering
PC

PC adapter (USB1.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 for
the new project.
(In this sample of this document, the project is named as "KYE_BL_RS232C").

7/51

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

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


Parity

Default setting for SR-600 Series


Parity

* The above shows communication setting for S7-300.


Adapt this setting to communication setting of KEYENCE Code Reader.

9/51

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

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

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

I. Creating OB
Program overview
Add 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.

Program

Description of program functions

It is activated at the time of call error such as cycle time over or cycle
interruption OB.
It is activated when diagnosis interruption from module that has diagnosis
[Diagnosis interruption] function occurs.
OB85
It is activated when non-existing OB is called or there is some modules that
[DI/O access
CPU cannot access.
error]
When a fault occurs in expended rack or DP slave stations.
OB86
[Rack error]
When an error occurs in MPI communication such as global data network.
OB87
OB80
[OB call error]
OB82

[MPI communication error]

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


OB121
[Program error]
When executing PIW/PQW command from program, there is a module that
OB122
[I/O access error] cannot be accessed.

11/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

IICreating FC
I. Creating FC100 Initial Circuit
Program overview
Create 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

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

II. Creating FC201 BL Communication Setting


Program overview
Create 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

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.
Just above FB7, specify DB No. to be used. (DB70 as for this sample)
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.
(1)
(2)

FB P_RCV_RK parameter
Name

Type

Data type

EN_R

INPUT

BOOL

INPUT

BOOL

LADDR

INPUT

INT

DB_NO

INPUT

INT

DBB_NO

INPUT

INT

NDR

OUTPUT

BOOL

ERROR OUTPUT

BOOL

LEN

OUTPUT

INT

Description

Stops request

Current request is stopped.


Reception is blocked.

Basic address for CP341

Basic address is obtained


from STEP7.

Data block number

Reception DB No.:
CPU-specific, no zero

Data byte number

0DBB_NO8190Data
received as data word

Request ended/data received


without errors

STATUS
parameter==16#00

Request ended with errors

STATUS parameters
include error details.

Message frame length received 1LEN1024, specified by


byte number
Error specification

STATUS OUTPUT

Possible value, comment

Enables data read

WORD

* Parameters are available until the next FB is called.

14/51

In the case of ERROR==1,


STATUS parameters
include error details.

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

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

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.

FB P_SND_RK parameter
Name

Type

Data type

REQ

INPUT

BOOL

INPUT

BOOL

LADDR

INPUT

INT

DB_NO

INPUT

INT

DBB_NO

INPUT

INT

LEN

INPUT

INT

DONE

OUTPUT

BOOL

ERROR OUTPUT

BOOL

STATUS OUTPUT

WORD

Description

Possible value, comment

Starts request upon signal


activation
Stops request

Current request is stopped.


Send is blocked.

Basic address for CP341

Basic address is obtained


from STEP7.

Data block number

Reception DB No.:
CPU-specific, no zero

Data byte number

0DBB_NO8190Data
sent as data word

Data bits

1LEN1024, specified by
byte number

Request ended without errors

STATUS
parameter==16#00;

Request ended with errors

STATUS parameters
include error details.

Error specification

In the case of ERROR==1,


STATUS parameters
include error details.

* Parameters are available until the next FB is called.

17/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

III. Editing OB1


Create a program to call FC100,FC101 for OB1.

18/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

IV. Creating DB100 BL Communication Data


Program overview
Create data area to store the data read by the code reader.

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

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

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

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

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

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

VII. Sample Program (Command Trigger)


I. Overall Configuration of the Sample Program

Program name

Description of program functions

This is the main function of the program activated on the system, and while
OB1
the program is running, it is repeatedly executed in a cycle.
These are system programs originally given to the system.
OB80OB122
They are automatically activated when an error occurs.
This is a function to store initial settings.
FC100
There are Normal ON and Normal OFF flags here.
This program creates a trigger circuit for the barcode reader and a receiving
FC101
circuit for the data read by the code reader.
This is a function block prepared by SIEMENS for the RS232C
FB7
communication.
This is a data block to assign FB7 system data as shown above.

DB70

DB100
TEST

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

24/51

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

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

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

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

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.

Call and run FC100.

Call and run FC101.

II FC100(INITIAL Function)
This is a function to store initial settings.

M0.1
NORMAL OFF.

M0.0
NORMAL ON.

28/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

III FC201(BL Communication Setting function)

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.

Activate (ON) a receive


trigger to activate (ON)
the barcode laser.

29/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

Input data length of the data area


for the Send Command
"LON[CR]".

Specify a send command string


for the data block.

30/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

Input data length of the data area


for the Send Command
"LOFF[CR]".

Specify a send command string


for the data block.

31/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

Execute instructions to send a


command.
Execute the command when the
instruction for the laser of Code
Reader is ON or OFF.

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.

Set timer value starting


from activating (ON) the
laser of Code Reader until
a read error is found.
* 1 sec for the tentative
value.

32/51

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.

Call FC100 and execute the


program.

Call FC101 and execute the


program.

II FC100INITIAL Function
This is a function to store initial settings.

M0.1
NORMAL OFF.
M0.0
NORMAL ON.

33/51

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.

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.

Activate (ON) a receive


trigger to activate (ON)
the barcode laser.

34/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide


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

Specify a send command string


for the data block.

Input data length of the data area


for the Send Command
"LOFF[CR]".

Specify a send command string


for the data block.

35/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

Execute instructions to send a


command.
Execute the command when
the instruction for the laser of
Code Reader is ON or OFF.

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.

Set timer value starting


from activating (ON) the
laser of Code Reader until a
read error is found.
*1 sec for the tentative
value.

36/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

IV. Introduction of Sample Program (STLStructured 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.

Call FC100 and execute


the program.
Call FC101 and execute
the program.

FC100INITIAL function
This is a function to store initial settings.

M0.1
NORMAL OFF.
M0.0
NORMAL ON.

37/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

FC201BL Communication Setting function

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.
Activate (ON) a receive
trigger to activate (ON) the
barcode laser.

Input data bits of the data area


for the Send Command
"LON[CR]".

Specify a send command string


for the data block.

38/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

Input data bits of the data area for


the Send Command "LOFF[CR]".

Specify a send command string


for the data block.

Execute instructions to send a


command.
Execute the command when the
instruction for the laser of Code
Reader is ON or OFF.

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.
Set timer value starting
from activating (ON) the
laser of Code Reader until
a read error is found.
* 1 sec for the tentative
value.

39/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

VIII. Sample Program (Hard Trigger)


I. Overall Configuration of Sample Program

Program Name

Program description

This is the main function of the program activated on the system, and while
OB1
the program is running, it is repeatedly executed in a cycle.
These are system programs originally given to the system.
OB80OB122
They are automatically activated when an error occurs.
This is a function to store initial settings.
FC100
There are Normal ON and Normal OFF flags here.
This program creates a trigger circuit for the barcode reader and a receiving
FC101
circuit for the data read by the code reader.
This is a function block prepared by SIEMENS for the RS232C
FB7
communication.
This is a data block to assign FB7 system data as shown above.

DB70

DB100
TEST

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

40/51

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

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

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.

Call FC100 and execute


the program.

Call FC101 and execute


the program.

II FC100INITIAL Function
This is a function to store initial settings.

M0.1
NORMAL OFF.

M0.0
NORMAL ON.

43/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

III FC101(BL Communication Setting Function)


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

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "II-II. Creating
FC101 BL
Communication Setting"
for details.

Activate (ON) a receive


trigger to activate (ON)
the barcode laser.

44/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

Output for activating (ON)


the barcode laser .

Monitoring circuit for OK


signals from the barcode
reader.

Monitoring circuit for NG +


ERROR signals from the
barcode reader.

Monitoring circuit for


ERROR signals from the
barcode reader.

Monitoring circuit for


BUSY signals from the
barcode reader.

Set timer value starting


from activating (ON) the
laser of Code Reader until
a read error is found.
* 1 sec for the tentative
value.

Inactivate (OFF) the


barcode laser.

45/51

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.

Call FC100 and execute


the program.

Call FC101 and execute


the program.

II FC100(INITIAL Function)
This is a function to store initial settings.

M0.1
NORMAL OFF.

M0.0
NORMAL ON.

46/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

III FC101(BL Communication Setting Function


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

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "II-II. Creating
FC101 BL Communication
Setting" for details.

Activate (ON) a receive


trigger to activate (ON) the
barcode laser.

Output for activating (ON)


the barcode laser .

47/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

Monitoring circuit for OK


signals from the barcode
reader.

Monitoring circuit for NG +


ERROR signals from the
barcode reader.

Monitoring circuit for


ERROR signals from the
barcode reader.

Monitoring circuit for


ERROR signals from the
barcode reader.
Set timer value starting
from activating (ON) the
laser of Code Reader until
a read error is found.
* 1 sec for the tentative
value.

Inactivate (OFF) the


barcode laser.

48/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

IV. Introduction of Sample Program (STLStructured 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.

Call FC100 and execute


the program.
Call FC101 and execute
the program.

II FC100INITIAL Function
This is a function to store initial settings.

M0.1
NORMAL OFF.
M0.0
NORMAL ON.

49/51

KEYENCE CODE-READER SIEMENS S7-300 Connection Guide

III FC101BL Communication Setting Function

Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "II-II. Creating
FC 101 BL
Communication Setting"
for details.
Activate (ON) a receive
trigger to activate (ON) the
barcode laser.
Output for activating (ON)
the barcode laser.

Monitoring circuit for OK


signals , NG+ERROR
signals, ERROR signals
and
BUSY signals

Set timer value starting


from activating (ON) the
laser of Code Reader until
a read error is found.
* 1 sec for the tentative
value.
Inactivate (OFF) the
barcode laser.

50/51

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 monitor
the 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 with
communication 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/51
1084-1 600F16

You might also like