Professional Documents
Culture Documents
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
IX. Troubleshooting
1/51
I. Configuration (Hardware/Software)
I. SIEMENS Products Hardware Configuration
Function
Mark
A
B
C
D
E
F
Model number
Order number
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]
2D Code Reader
SR-600 Series
Cross cable
2/51
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)
Command Trigger
3/51
II Hard Trigger
*2
*1
*1
*2
4/51
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
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
Setting
IN1 Function
Timing
OUT1 Function
OUT2 Function
OUT3 Function
OUT4 Function
OK
NG+ERROR
ERROR
BUSY
6/51
Engineering
PC
7/51
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
Adapt the communication setting to KEYENCE Code Reader using the ASCII tab
9/51
10/51
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)
Program
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
11/51
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.
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
13/51
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
Reception DB No.:
CPU-specific, no zero
0DBB_NO8190Data
received as data word
STATUS
parameter==16#00
STATUS parameters
include error details.
STATUS OUTPUT
WORD
14/51
15/51
16/51
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
Reception DB No.:
CPU-specific, no zero
0DBB_NO8190Data
sent as data word
Data bits
1LEN1024, specified by
byte number
STATUS
parameter==16#00;
STATUS parameters
include error details.
Error specification
17/51
18/51
19/51
20/51
21/51
ii Select "true" for the laser emission trigger (M100.0) for the code reader.
22/51
Sample barcode
* K E Y E N C E *
23/51
Program name
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
25/51
26/51
27/51
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.
M0.1
NORMAL OFF.
M0.0
NORMAL ON.
28/51
Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.
29/51
30/51
31/51
Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.
32/51
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 FC100INITIAL Function
This is a function to store initial settings.
M0.1
NORMAL OFF.
M0.0
NORMAL ON.
33/51
Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.
34/51
35/51
Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "V-II-II. Creating
FC201 BL Communication
Setting" for details.
36/51
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.
FC100INITIAL function
This is a function to store initial settings.
M0.1
NORMAL OFF.
M0.0
NORMAL ON.
37/51
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.
38/51
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
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
41/51
42/51
II FC100INITIAL Function
This is a function to store initial settings.
M0.1
NORMAL OFF.
M0.0
NORMAL ON.
43/51
Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "II-II. Creating
FC101 BL
Communication Setting"
for details.
44/51
45/51
II FC100(INITIAL Function)
This is a function to store initial settings.
M0.1
NORMAL OFF.
M0.0
NORMAL ON.
46/51
Set input/output
parameters of FB for the
CP341(RS232C)
communication unit
reception.
* See "II-II. Creating
FC101 BL Communication
Setting" for details.
47/51
48/51
II FC100INITIAL Function
This is a function to store initial settings.
M0.1
NORMAL OFF.
M0.0
NORMAL ON.
49/51
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.
50/51
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