Professional Documents
Culture Documents
Table of Contents
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 CP1241<->N-R2
II. Overall Connecting Diagram
IX. Troubleshooting
1/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
I. Configuration (Hardware/Software)
I. SIEMENS Products Hardware Configuration
Mark Function Model number Order number
A CPU Unit CPU 1211C DC/DC/DC 6ES7 211-1AD30-0XB0
B RS-232C Communication Unit CM1241 RS232 6ES7 241-1AH30-0XB0
C Memory Card 2Mbyte Memory Card 6ES7 954-8LF00-0AA0
A B
C
KEYENCE Code Reader Communication unit and cable
Barcode Reader 2D Code Reader Communication Cross Cable
BL-1300 Series SR-600 Series Unit N-R2
2/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
II. Connection
I. Communication Cable Connecting Diagram between CM1241<->N-R2
Connect CM1241 and N-R2 (KEYENCE Code Reader communication unit) as the following diagram.
0V
Code
Reader
3/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
0V
*2
*1
Code
Reader
*1 *2
DC24V 24VDC 1M 0V *2
DC0V 0V I0.0
I0.1
*1 IN COM I0.2
IN1 I0.3
IN2 I0.4
I0.5
DC24V OUTCOM 3L+ 24V *1
OUT1 3M 0V
OUT2 Q0.0
OUT3 Q0.1
*2 OUT4 Q0.2
Q0.3
4/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
OUT1 Function OK
OUT2 Function NG+ERROR
OUT3 Function ERROR
OUT4 Function BUSY
5/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
OUT1 Function OK
OUT2 Function NG+ERROR
OUT3 Function ERROR
OUT4 Function BUSY
6/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
Engineering
PC
LAN cable
Activate Totally Integrated Automation and create an arbitrary name for the new project.
(In this sample of this document, the project is named as ”S7-1200 RS-232C").
7/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
8/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
9/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
10/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
Programme overview
Create a Data block (DB) to be used on the programme.
Create DB20, a Data block to store the data received from the code reader, and
DB21, a Data block to store the send command to the code reader.
Navigate in the following order: PLC Programming -> Add new block -> Data block ->
Name -> Global DB -> Select Manual -> Number(20) -> Create.
11/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
Navigate in the following order: PLC Programming -> Add new block -> Data block ->
Name -> Global DB -> Select Manual -> Number (21) -> Create
12/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
II.Creating FC
Programme overview
Create normal ON flag and normal OFF flag.
As shown on the diagram below, input "100" in Number in Manual setting to create
the initial programme.
13/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
Create a trigger circuit for the code reader initiated by command output as well as
a receiving circuit for the data read by the code reader.
Input "201" in Number in Manual setting to create the initial programme as shown below.
ii Create an Interface
Double click INITIAL FC to activate ladder editor to create the circuit as shown below.
《FC100: INITIAL》 * Users can freely specify the name of FC No.
14/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
From Instruction on the right side of the screen, select Extended instruction ->
Communications and drop & drag RCV_PTP to insert.
(1) Just above RCV_PTP, specify DB No. to be used. (DB201 as for this sample)
(2) To the left of RCV_PTP, specify the value to be input.
(3) To the right of RCV_PTP, specify an address to be output (created TEMP address).
RCV_PTP Parameter
Name Type Data type Description
EN_R INPUT BOOL Check for the received messages when this input is True.
Messages received correctly will be transferred from the
module to CPU.When False, check for received messages in
CM and set the Status output. However, the messages will
not be transferred to CPU.
PORT INPUT PORT Communication port identifier
BUFFER INPUT Variant Reception of buffer starts from this point. Requires buffers
larger than the maximum length of reading data.
NDR OUTPUT BOOL Returns True for a single scan when new data is ready and
operation has been completed successfully.
ERROR OUTPUT BOOL Returns Error for a single scan process when there are
errors in the operation.
STATUS OUTPUT WORD Execution condition code
15/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
v Store Laser ON (LON) and Laser OFF (LOFF) commands to the code reader in DB21.
16/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
vi Creating the pulse to send a command transmission request to the code reader.
From Instruction on the right, go to Extended instruction -> Communications to drag & drop
and insert SEND_PTP.
(1) Just above SEND_PTP, specify DB No. to be used. (DB202 as for this sample)
(2) To the left of SEND_PTP, specify the value to be input.
(3) To the right of SEND_PTP, specify an address to be output (created TEMP address).
17/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
SEND_PTP Parameter
Name Type Data type Description
REQ INPUT BOOL Activate the requested transfer at positive edge.
BUFFER INPUT Variant Specify the location to start sending the send command.
DONE OUTPUT BOOL Returns True for a single scan process after successful
completion for the request.
ERROR OUTPUT Uint Returns Error for a single scan process when there are
errors in the operation.
STATUS OUTPUT Uint Execution condition code.
18/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
Select Watch table from the Project tree below and select "Add new Watch table".
19/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
20/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
iii Reading the sample barcode
When the sample barcode is read as shown below, "KEYENCE$R" will be input in each
address starting from DB20.DBW0.
When the sample barcode is not read and the reading is not completed within
READ TIME OUT (1sec) set in the sample programme,
ERROR will appear in each address starting from DB21.DBW0.
Sample Barcode
* K E Y E N C E *
Read data
Send command
21/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
22/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
This is a data block to store the data read by the code reader.
23/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
II INITIAL(FC100)
M0.1
Normal OFF
M0.0
Normal ON
24/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
This programme creates a trigger circuit for the code reader and a receiving circuit for the
data read by the code reader.
Temporary memory
usable within this FC
only.
Used to exchange and
monitor the values.
* See "V-II-II-iii
BL_Communication
Setting" for details.
25/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
26/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
27/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
II INITIAL(FC100)
Normal ON and Normal OFF circuits
M0.1
Normal OFF
M0.0
Normal ON
28/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
This programme creates a trigger circuit for the code reader and a receiving circuit for the
data read by the code reader.
Set input/output
parameters of FB for the
CM1241(RS232C)
communication unit
reception.
* See "V-II-II-iii
BL_Communication
Setting" for details.
29/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
30/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
31/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
32/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
This is a data block to store the data read by the code reader.
33/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
II INITIAL(FC100)
M0.1
Normal OFF
M0.0
Normal ON
34/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
This programme creates a trigger circuit for the code reader and a receiving circuit for the
data read by the code reader.
* See "V-II-II
BL_Communication Setting"
for details.
35/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
36/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
37/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
II INITIAL(FC100)
Normal ON, Normal OFF circuits.
M0.1
Normal OFF
M0.0
Normal ON
38/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
This programme creates a trigger circuit for the code reader and a receiving circuit for the data read
by the code reader.
* See "V-II-II
BL_Communication
Setting" for details.
39/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
40/41
【KEYENCE CODE-READER】 【SIEMENS S7-1200】 Connection Guide
IX. Troubleshooting
Q Communication is not available even though the code reader is connected to a LAN cable
Click Accessible Device on the tool bar to search the CPU from accessible IP address.
Check IP address of the CPU. Change the IP address to have the same subnet.
Q Laser does not come out even though TRG of M100.0 is True.
41/41