- No category
advertisement
Machine Automation Controller NJ-series
General-purpose Serial
Connection Guide
(RS-
232C
)
OMRON Corporation
Fixed Laser-Type Barcode Reader
(
V500-R2 Series
)
P 565 E1-01
About Intellectual Property Rights and Trademarks
Microsoft product screen shots reprinted with permission from Microsoft Corporation.
Windows is a registered trademark of Microsoft Corporation in the USA and other countries.
EtherCAT
®
is registered trademark and patented technology, licensed by Beckhoff Automation
GmbH, Germany.
Sysmac is a trademark or registered trademark of OMRON Corporation in Japan and other countries for OMRON factory automation products.
Company names and product names in this document are the trademarks or registered trademarks of their respective companies.
Table of Contents
Applicable Devices and Device Configuration ....................................... 7
Applicable Devices............................................................................. 7
Device Configuration.......................................................................... 8
Serial Communications Settings ........................................................... 10
Serial Communications Settings ...................................................... 10
Cable Wiring Diagram .......................................................................11
Example of Connection Check......................................................... 13
Connection Procedure ............................................................................ 14
Setting UP the Bar Code Reader ..................................................... 16
Setting Up the Controller.................................................................. 17
Checking the Serial Communications .............................................. 35
Initializing the Controller................................................................... 41
Initializing the Bar Code Reader ...................................................... 42
Communications sequence.............................................................. 47
Error Detection Processing .............................................................. 48
ST Program...................................................................................... 52
Protocol Macro Data ........................................................................ 57
Timing Charts................................................................................... 64
Error Process ................................................................................... 65
1. Related Manuals
The table below lists the manuals related to this document.
To ensure system safety, make sure to always read and heed the information provided in all
Safety Precautions, Precautions for Safe Use, and Precaution for Correct Use of manuals for each device which is used in the system.
Cat. No. Model
W500 NJ501-[][][][]
NJ301-[][][][]
Manual name
NJ-series CPU Unit Hardware User's Manual
NJ-series CPU Unit Software User's Manual W501 NJ501-[][][][]
NJ301-[][][][]
W494 CJ1W-SCU[]2
Manual for NJ-series CPU Unit
W344 CXONE-AL[][]C-V4 CX-Protocol Operation Manual
/AL[][]D-V4
NJ-series Instructions Reference Manual W502 NJ501-[][][][]
NJ301-[][][][]
Z334 V500-R2 Series Fixed Laser-Type Barcode Reader
V500-R2 Series User's Manual
1
2. Terms and Definitions
Term
Protocol macro
Protocol
Sequence
Step
Send message
Receive message
Matrix
Case
AT
(AT specification)
Explanation and Definition
A protocol macro is a function that stores a data send/receive procedure
(protocols) in a Serial Communications Board or Serial Communications
Unit to exchange data with general-purpose external devices by executing the ExecPMCR instruction on the CPU Unit.
A unit of independent communication processing with a specific general-purpose device. A protocol includes a data send/receive procedure. A protocol consists of multiple sequences.
A unit of the independent communication processing which can be started by executing the ExecPMCR instruction of a program. A sequence that is started will execute steps registered in its own sequence.
A unit to execute any one of the followings: message send processing, message receive processing, message send/receive processing, clear receive buffer, or step wait. Up to 15 steps can be set per sequence.
A communication frame (command) sent to the external general-purpose device. A send message is read from the step in the sequence, and sent to the external general-purpose device.
A communication frame (response) sent from the external general-purpose device. A receive message is read from the step in the sequence and is compared with data received from the general-purpose external device.
A matrix is used when a general-purpose external device sends multiple types of communications frames (responses). More than one communication frame can be registered in one matrix.
A unit to register multiple communication frames (response) to a matrix.
One communication frame is registered as one case. Up to 15 types of cases can be registered per matrix.
This attribute allows the user to specify an address assigned to a variable. An I/O port or an address in memory used for CJ-series Units can be specified.
2
3. Remarks
3. Remarks
(1) Understand the specifications of devices which are used in the system. Allow some margin for ratings and performance. Provide safety measures, such as installing safety circuit in order to ensure safety and minimize risks of abnormal occurrence.
(2) To ensure system safety, always read and heed the information provided in all Safety
Precautions, Precautions for Safe Use, and Precaution for Correct Use of manuals for each device used in the system.
(3) The user is encouraged to confirm the standards and regulations that the system must conform to.
(4) It is prohibited to copy, to reproduce, and to distribute a part or the whole of this document without the permission of OMRON Corporation.
(5) The information contained in this document is current as of August 2013. It is subject to change without notice for improvement.
3
3. Remarks
The following notation is used in this document.
Indicates a potentially hazardous situation which, if not avoided, will result in minor or moderate injury, or may result in serious injury or death. Additionally there may be significant property damage.
Indicates a potentially hazardous situation which, if not avoided, may result in minor or moderate injury or in property damage.
Precautions for Safe Use
Precautions on what to do and what not to do to ensure safe usage of the product.
Precautions for Correct Use
Precautions on what to do and what not to do to ensure proper operation and performance.
Additional Information
Additional information to read as required.
This information is provided to increase understanding or make operation easier.
Symbol
4
●
Warning display
●
Caution display
3. Remarks
5
4. Overview
4. Overview
This document describes the procedure for connecting OMRON Corporation's Fixed
Laser-Type Barcode Reader (V500-R2 series) (hereinafter referred to as the Bar Code
Reader) with NJ-series Machine Automation Controller (hereinafter referred to as the
Controller) via serial communications, and describes the procedure for checking their connection.
Refer to the serial communications settings of the prepared Sysmac Studio project file and understand the setting method and key points to connect the devices via serial communications.
The user program in the Sysmac Studio project file and the protocol macro data in the
CX-Protocol project file are used to check the serial connection by executing the "Reading trigger" command on the Bar Code Reader.
Prepare the latest Sysmac Studio project file and the CX-Protocol project file beforehand. To obtain the files, contact your OMRON representative.
Name File name Version
Sysmac Studio project file OMRON_V500-R2_PMCR232C_EV100.smc Ver.1.00
(extension: smc)
(extension: psw)
*Hereinafter, the Sysmac Studio project file is referred to as the "project file"
The user program in the project file is referred to as the "program"
The CX-Protocol project file is called the "Protocol macro data"
This document aims to explain the wiring method and communications settings necessary to connect the corresponding devices and provide the setting procedure. The program used in this document is designed to check if the connection was properly established and is not designed to be constantly used at a site. Therefore, functionality and performances are not sufficiently taken into consideration. When you construct an actual system, please use the wiring method, communications settings and setting procedure described in this document as a reference and design a new program according to your application needs.
6
5. Applicable Devices and Device Configuration
5. Applicable Devices and Device Configuration
5.1. Applicable Devices
The applicable devices are as follows:
Manufacturer Name
OMRON
OMRON
OMRON
NJ-series CPU Unit
Serial Communications Unit
Fixed Laser-Type Barcode Reader
Model
NJ501-[][][][]
NJ301-[][][][]
CJ1W-SCU[]2
V500-R2CF
Precautions for Correct Use
As applicable devices above, the devices with the models and versions listed in Section 5.2. are actually used in this document to describe the procedure for connecting devices and checking the connection.
You cannot use devices with versions lower than the versions listed in Section 5.2.
To use the above devices with versions not listed in Section 5.2 or versions higher than those listed in Section 5.2, check the differences in the specifications by referring to the manuals before operating the devices.
Additional Information
This document describes the procedure to establish the network connection. Except for the connection procedure, it does not provide information on operation, installation or wiring method. It also does not describe the functionality or operation of the devices. Refer to the manuals or contact your OMRON representative.
7
5. Applicable Devices and Device Configuration
5.2. Device Configuration
The hardware components to reproduce the connection procedure of this document are as follows:
Personal computer
(Sysmac Studio installed,
OS:Windows 7)
NJ501-1500
CJ1W-SCU42
USB cable
Special cable (RS-232C)
V509-W011
5 VDC power supply
Bar Code Reader
V500-R2CF
Manufact urer
Name Model Version
CJ1W-SCU42 Ver.2.0
OMRON NJ-series CPU Unit NJ501-1500
OMRON Power Supply Unit
OMRON
OMRON
OMRON
-
CX-Protocol
Sysmac Studio project file
CX-Protocol project file
Personal computer (OS: Windows7)
NJ-PA3001
SYSMAC-SE2[][][]
(Included in Sysmac
Studio.)
OMRON_V500-R2_PMC
R232C_EV100.smc
OMRON_V500-R2_PMC
R_EV100.psw
Ver.1.06
Ver.1.97
Ver.1.00
Ver.1.00
-
-
(USB 2.0 type B connector)
OMRON Fixed Laser-Type Barcode Reader
OMRON Special cable (RS-232C)
- 5 VDC power supply
V500-R2CF
V509-W011
-
Precautions for Correct Use
Prepare the latest project file and protocol macro data in advance.
To obtain the file, contact your OMRON representative.
Precautions for Correct Use
Update the Sysmac Studio and CX-Protocol to the versions specified in this section or higher versions using the auto update function. If a version not specified in this section is used, the procedures described in Section 7 and subsequent sections may not be applicable. In that case, use the equivalent procedures described in the Sysmac Studio Version 1 Operation
Manual (Cat. No. W504) and the CX-Protocol Operation Manual (Cat. No. W344).
8
5. Applicable Devices and Device Configuration
Additional Information
It may not be possible to reproduce the same operation with different devices or versions.
Check the configuration, model and version. If they are different from your configuration, contact your OMRON representative.
Additional Information
For information on the special cable (V509-W011), refer to
Cable for programmable controller connection made by OMRON (V509-W011)
in
External Dimension
in
Section 6 Appendix
of the
V500-R2 Series Fixed Laser-Type Barcode Reader V500-R2 Series User's Manual
(Cat.
No. Z334).
Additional Information
The system configuration in this document uses USB for the connection to the Controller. For information on how to install a USB driver, refer to
A-1 Driver Installation for Direct USB Cable
Connection
of the
Sysmac Studio Version 1 Operation Manual
(Cat. No. W504).
9
6. Serial Communications Settings
This section describes the specifications such as communication parameters and wiring that are set in this document.
Additional Information
To perform communications without using the settings described in this section, you need to modify the program. For information on the program, refer to
Section 9. Program
.
6.1. Serial Communications Settings
The serial communications settings are shown below.
Setting item
Device name
Serial Communications Unit
J01
Unit number
Communications
(connection) port
0
Port 2 (RS-232C)
Serial communications mode Protocol macro
Data length 8 bits
Stop bit 1 bit
-
-
-
Bar Code Reader
-
8 bits (Default)
1 bit (Default)
Transmission rate (Baud rate) 9,600 bps (Default)
Protocol macro transmissions Full-duplex
Header -
Footer -
Number of digit output
RS/CS control
-
-
9,600 bps (Default)
-
CS waiting time
ACK/NAK waiting time
-
-
None (Default)
None (no protocol system)
(Default)
Not limited (Default)
Not limited (Default)
Precautions for Correct Use
This document describes the setting procedure of the CJ1W-SCU42 Serial Communications
Unit with unit number 0, communications (connection) port 2, and device name J01. To connect devices under different conditions, change the variable names and setting values used in the program by referring to 9. Program.
10
6. Serial Communications Settings
6.2. Cable Wiring Diagram
For details on the cable wiring, refer to
Section 3 Installation and Wiring
of the
CJ-series Serial
Communications Units Operation Manual for NJ-series CPU Unit
(Cat. No. W494).
Check the connector configuration and pin assignment before wiring.
You do not need to make a cable when you use the special cable (V509-W011).
■
Connector configuration and pin assignment
<CJ1W-SCU42> Applicable connector: D-sub 9 pin
<V500-R2CF> Applicable connector: DIN 8 pin
11
6. Serial Communications Settings
■
Cable/Pin assignment
CJ1W-SCU42 Serial
Communications Unit
Signal name
Pin No.
Fixed Laser-Type Barcode
Reader (V500-R2CF
)
RS-232C interface
Pin No.
Signal name
1 SD
2 RD
3 RS
4 CS interface
5 TRIG
6 NC
7 S.GND
8 VCC
SG 9
FG Shell
D-SUB 9-pin
Cable connector type: Male
External trigger
DIN 8-pin
Cable connector type: Female
+5V
0V
*The external trigger is not used in this document. Insulate it from other cables.
*Connect +5V and 0V to the external power supply.
■
Recommended parts for the connector
When you make a connection cable, use the following connectors to connect it to the connector of the Bar Code Reader.
NJ501-1500
CJ1W-SCU42
Bar Code Reader
V500-R2CF
Connection cable
■
Special cable
5 VDC power supply
The special cable (V509-W011) is used in this document.
NJ501-1500
CJ1W-SCU42
Special cable (V509-W011)
*The external trigger is not used in this document. Insulate it from other cables.
*Connect +5V and 0V to the external power supply.
Bar Code Reader
V500-R2CF
12
6. Serial Communications Settings
6.3. Example of Connection Check
This document shows an example of an ST (structured text) program and protocol macro data in which the Controller sends/receives the message to/from the Bar Code Reader.
The Controller and the Bar Code Reader send and receive the message of "Reading Trigger
(sequence No. 900)". The following figure outlines the sequence operation.
●
Overview of sequence operation
(1)The ST program executes the protocol macro instruction (ExecPMCR instruction) for which sequence No. 900 of protocol macro data is specified.
(2)The Reading Trigger command (sequence No. 900) is selected from the protocol macro data, and it is sent to the Bar Code Reader.
(3)The Bar Code Reader executes the command according to the send data from the
Controller.
(4)The Controller receives the result of the command executed by the Bar Code Reader, and then stores in the specified variable.
CPU Unit
Project file
ST Program
IF …. THEN
……….
ELSE
……….
END_IF;
ExecPMCR(….
Controller
Serial Communications Unit
(1)Executing the protocol macro instruction
(Specifying sequence No.900)
Protocol macro data
Sequence No.1
Sequence No.2
Sequence No.900
RS-232C
(2)Reading Trigger
(Sequence No.900)
Send data
Output_RecvData
Receive data storage area
(4)Receiving the execution result of the command and storing it in the specified variable.
Receive data
Bar Code Reader
(3)Executing the command
13
7. Connection Procedure
This section describes the procedure for connecting the Bar Code Reader to the Controller via serial communications. This document explains the procedures for setting up the Controller and the Bar Code Reader from the factory default setting. For the initialization, refer to
Section
8 Initialization Method
.
7.1. Work Flow
Take the following steps to connect the Bar Code Reader to the Controller via serial communications.
7.2. Setting Up the Bar Code Reader
↓
7.2.1. Cable Connection
↓
7.3. Setting Up the Controller
↓
7.3.1. Hardware Settings
↓
7.3.2. Starting the Sysmac Studio and
Importing the Project File
↓
7.3.3. Checking the Parameters and
Building
Set up the Bar Code Reader.
Connect a cable to the Bar Code Reader.
Set up the Controller.
Set the hardware switches on the Serial
Communications Unit.
Start the Sysmac Studio and import the project file.
↓
7.3.4. Connecting Online and
Transferring the Project Data
↓
7.3.5. Transferring the Unit Settings
Check the parameters that are set, execute the program check on the project data and build the
Controller.
Connect online with the Sysmac Studio and transfer the project data to the Controller.
Transfer the setting data of the Serial
Communication Unit.
Start the CX-Protocol and open the protocol macro data.
↓
7.3.6. Starting the CX-Protocol and
Opening the Protocol Macro
Data
↓
7.3.7. Connecting Online and
Transferring the Protocol Macro
Data
↓
7.4. Checking the Serial
Communications
↓
7.4.1. Starting the Trace
↓
7.4.2. Executing the Program
↓
Connect online with the CX-Protocol, and transfer the protocol macro data to the Serial
Communications Unit.
Execute the program and confirm that serial communications are normally performed.
Start tracing with the CX-Protocol.
Execute the program with the Sysmac Studio.
14
7.4.3. Checking the Trace Data
↓
7.4.2. Checking the Receive Data
7. Connection Procedure
Confirm that the correct data is sent and received by checking the trace data of the CX-Protocol.
Confirm that the correct data are written to the variables of the Controller with the Sysmac Studio.
15
7. Connection Procedure
7.2. Setting UP the Bar Code Reader
Set up the Bar Code Reader.
7.2.1. Cable Connection
Connect a cable to the Bar Code Reader.
1
Connect the special cable
(V509-W011) to the Bar Code
Reader.
Connect the 5 VDC power supply to the special cable and turn ON the power supply.
Bar Code Reader
(V500-R2CF)
Special cable
(V509-W011)
5 VDC power supply
Precautions for Correct Use
This document explains the procedures for setting up the Bar Code Reader from the factory default setting. If the Bar Code Reader was changed from the factory default setting, make sure to initialize by referring to Section 8.2. Initializing the Bar Code Reader.
Additional Information
For details on the factory default setting of the Bar Code Reader, refer to
Factory default setting
in
Return to the factory default setting
in
Menu Sheet/Command List
in
Section 4
Setting Method
of the
V500-R2 Series Fixed Laser-Type Barcode Reader V500-R2 Series
User's Manual
(Cat. No. Z334).
16
7. Connection Procedure
7.3. Setting Up the Controller
Set up the Controller.
7.3.1. Hardware Settings
Set the hardware switches on the Serial Communications Unit.
Precautions for Correct Use
Make sure that the power supply is OFF when you perform the setting up.
1
Make sure that the power supply to the Controller is OFF.
*If the power supply is turned
ON, settings may not be applicable as described in the following procedure.
Check the hardware switches located on the front panel of the
Serial Communications Unit by referring to the right figure
Check the connector for Port 2
(RS-232C) by referring to the right figure.
*This setting is required to use
Port 2 of the Serial
Communications Unit.
2
Set the Unit No. Switch to 0.
(The unit number is set to 0 as the factory default setting.)
3
Connect the Serial
Communications Unit to the
Controller as shown on the right.
Connect the special cable for the Bar Code Reader to the
Serial Communications Unit.
Connect the personal computer to the Controller with a USB cable.
Personal computer
USB cable
Controller
Power Supply Unit
Serial Communications Unit
End Cover
Special cable
Bar Code Reader
17
7. Connection Procedure
7.3.2. Starting the Sysmac Studio and Importing the Project File
Start the Sysmac Studio and import the project file.
Install the Sysmac Studio and USB driver in the personal computer beforehand.
1
Confirm that the personal computer and the Controller are connected with the USB cable and turn ON the power supply to the Controller.
Start the Sysmac Studio. Click the
Import
Button.
*If a confirmation dialog for an access right is displayed at start, select to start.
2
The Import File Dialog Box is displayed. Select
OMRON_V500-R2_PMCR232C
_EV100.smc and click the
Open
Button.
*Obtain the project file from
OMRON.
3
The
OMRON_V500-R2_PMCR232C
_EV100 project is displayed.
The left pane is called Multiview
Explorer, the right pane is called
Toolbox and the middle pane is called Edit Pane.
*If an error message is displayed stating "Failed to
Load Descendants", change the version of the Sysmac
Studio to the version specified in 5.2. Device Configuration or higher version.
Multiview
Explorer
Edit Pane Toolbox
18
7. Connection Procedure
7.3.3. Checking the Parameters and Building
Check the parameters that are set, execute the program check on the project data and build the Controller.
1
Double-click
CPU/Expansion
Racks
under
Configurations and Setup
in the Multiview
Explorer.
2
3
The CPU/Expansion Racks Tab is displayed in the Edit Pane.
Select the Serial
Communications Unit icon as shown on the right.
Confirm that CJ1W-SCU42 is displayed, the Device name is
J01, and the Unit No. is 0.
*If the settings are different, change the values.
Click
Edit Special Unit
Settings
.
The 0 [Unit 0]: Tab is displayed.
Select
Port2: Protocol macro
Settings
from the pull-down list of Parameter group to show.
19
4
Parameter group to show is set to Port2: Protocol macro
Settings.
The setting items of the Port 2:
Protocol macro Settings are shown.
Confirm that the Port2: Port
Settings is set to User settings and other settings are the same as those listed in Section 6.1.
*If the settings are different from the above, change the values from the pull-down lists. After changing the values, click the
Apply
Button.
5
Double-click
I/O Map
under
Configurations and Setup
on the Multiview Explorer.
The I/O Map Tab is displayed and then the parameters for the
Unit are listed.
6
Confirm that data in the Variable
Columns start with J01 and the
Global Variable is set in each
Variable Type Column.
*If the settings are different from the above, right-click on
CJ1W-SCU42
and select
Create Device Variable
.
7. Connection Procedure
7
Double-click
Task Settings
under Configurations and Setup in the Multiview Explorer.
20
8
The Task Settings Tab is displayed in the Edit Pane. Click the
Program Assignment
Settings
Button and confirm that Program0 is set under
PrimaryTask.
9
Select
Check All Programs
from the Project Menu.
10
Confirm that "0 Errors" and "0
Warnings" are displayed in the
Build Tab Page under the Edit
Pane.
11
Select
Rebuild Controller
from the Project Menu.
A confirmation dialog box is displayed. Check the contents and click the
Yes
Button.
A screen is displayed indicating the conversion is being performed.
12
Confirm that "0 Errors" and "0
Warnings" are displayed in the
Build Tab Page.
7. Connection Procedure
21
7. Connection Procedure
7.3.4. Connecting Online and Transferring the Project Data
Connect online with the Sysmac Studio and transfer the project data to the Controller.
Always confirm safety at the destination node before you transfer a user program, configuration data, setup data, device variables, or values in memory used for CJ-series Units from the Sysmac Studio.
The devices or machines may perform unexpected operation regardless of the operating mode of the CPU Unit.
Always confirm safety before you reset the Controller or any components.
1
Select
Change Device
from the
Controller Menu.
2
The Change Device Dialog Box is displayed.
Confirm that the Device and
Version are set as shown on the right and click the
OK
Button.
*If the settings are not correct, select the setting items from the pull-down list.
3
If the settings were changed in step 2, the Build Dialog Box is displayed. Check the contents and click the
Yes
Button.
*This dialog box is not displayed if no change was made.
22
4
Select
Communications Setup
from the Controller Menu.
5
The Communications Setup
Dialog Box is displayed.
Select the
Direct connection via
USB
Option for Connection
Type.
Click the
OK
Button.
7. Connection Procedure
6
Select
Online
from the
Controller Menu.
*If the dialog on the right is displayed, the model or version of the Controller does not match that of the project file.
Review the Controller model, version and device settings of the project file, and then repeat the procedure from step 1 in this section. Close the dialog box by clicking the
OK
Button.
*The model and version displayed on the confirmation dialog box differ depending on the Controller used and the device setting of the project file.
*Example of confirmation dialog box
23
7. Connection Procedure
7
A confirmation dialog box is displayed as shown on the right.
Check the contents and click the
Yes
Button.
*The displayed dialog depends on the status of the Controller used. Check the contents and click the
Yes
Button to proceed with the processing.
*The displayed serial ID differs depending on the device.
Additional Information
For details on online connections to a Controller, refer to
Section 5 Online Connections to a
Controller
of the
Sysmac Studio Version 1 Operation Manual
(Cat. No. W504).
8
9
When an online connection is established, a yellow bar is displayed on the top of the Edit
Pane.
Select
Synchronization
from the Controller Menu.
24
10
The Synchronization Dialog Box is displayed.
Confirm that the data to transfer
(NJ501 in the right dialog) is selected. Then, click the
Transfer To Controller
Button.
*After executing the Transfer to
Controller, the Sysmac Studio project data is transferred to the
Controller and the data are compared.
11
12
A confirmation dialog box is displayed. Confirm that there is no problem and click the
Yes
Button.
A screen stating "Synchronizing" is displayed.
A confirmation dialog box is displayed. Confirm that there is no problem and click the
No
Button.
*Click the
No
Button to operate in PROGRAM mode in the following steps.
Confirm that the synchronized data is displayed with the color specified by "Synchronized", and that a message is displayed stating "The synchronization process successfully finished"
If there is no problem, click the
Close
Button.
*A message stating "The synchronization process successfully finished" is displayed if the Sysmac Studio project data if the data in the
Controller match.
*If the synchronization fails, check the wiring and repeat the procedure in this section.
7. Connection Procedure
25
13
Select
Reset Controller
from the Controller Menu.
*When Mode is set to RUN
Mode, Reset Controller cannot be selected. In this case, select
Mode
-
PROGRAM Mode
from the Controller Menu to change to PROGRAM mode and perform the procedure in this step.
7. Connection Procedure
14
A confirmation dialog box is displayed several times. Check the contents and click the
Yes
Button.
15
The Controller is reset and the
Sysmac Studio goes offline.
Then, the yellow bar on the top of the Edit Pane disappears.
Go online again by following steps 6 to 8.
26
7.3.5. Transferring the Unit Settings
Transfer the setting data of the Serial Communication Unit.
1
Select
Mode
-
PROGRAM
Mode
from the Controller Menu.
7. Connection Procedure
2
A confirmation dialog box is displayed. Confirm that there is no problem and click the
Yes
Button.
3
PROGRAM mode is displayed on the Controller Status Pane.
4
5
Double-click
CPU/Expansion
Racks
under
Configurations and Setup
in the Multiview
Explorer.
Select the Serial
Communications Unit icon.
Click
Edit Special Unit
Settings
.
The 0 [Unit 0]: Tab is displayed.
Click the
Transfer To
Controller
Button.
27
6
A confirmation dialog box is displayed. Check the contents and click the
Yes
Button.
A dialog box is displayed indicating transferring is being performed, and a confirmation dialog box is displayed. Check the contents and click the
Yes
Button.
7
The Port Selection Dialog Box is displayed.
Select
All ports
and click the
OK
Button.
8
A confirmation dialog box is displayed. Check the contents and click the
OK
Button.
9
Select
Port2: Protocol macro
Settings
from the pull-down list of Parameter group to show.
Click the
Compare
Button.
7. Connection Procedure
10
Confirm that "
≠
" (mismatch) is not shown in the red frame on the right.
28
7. Connection Procedure
7.3.6. Starting the CX-Protocol and Opening the Protocol Macro Data
Start the CX-Protocol and open the protocol macro data.
1
Start the CX-Protocol.
Project Window
Project workspace
Output Tab Page
(
CX-Protocol
)
2
Select
Open
from the File Menu.
3
On the Open Dialog Box, select
OMRON_V500-R2_PMCR_EV1
00.psw and click the
Open
Button.
*Obtain the protocol macro data from OMRON.
4
The project workspace and the
Project Window display the protocol macro data that was read.
29
7. Connection Procedure
7.3.7. Connecting Online and Transferring the Protocol Macro Data
Connect online with the CX-Protocol, and transfer the protocol macro data to the Serial
Communications Unit.
1
Double-click the
OMRON_V500-R2_PMCR_EV1
00
on the project workspace to display a tree.
2
Select
Edit PC-PLC Comms
Settings
from the PLC Menu.
3
The Change PLC Dialog Box is displayed. Select a device type to use from the pull-down list of the Device Type, and click the
Settings
Button.
*NJ501 is used in this document.
4
The Device Type Settings
Dialog Box is displayed. Select the CPU type to use from the pull-down list, and click the
OK
Button.
*1500 is used in this document.
30
5
Confirm that the Network Type is set to USB on the Change PLC
Dialog Box and click the
OK
Button.
*If the Network Type is not set to
USB, select
USB
from the pull-down list.
6
Select
Connect to PLC
from the
PLC Menu.
7
8
The PLC icon on the project workspace changes from Offline to Program. It means that the
Controller is connected online.
*If Run is displayed, change it to
Program by following steps 8 and 9.
If the operating mode of the
Controller is Run, select
Operating Mode
-
Program
from the PLC Menu.
9
The dialog box on the right is displayed. Confirm that there is no problem and click the
Yes
Button.
Confirm that the operating mode was changed to Program mode as shown in step 7.
10
Double-click the
New Protocol
List
on the project workspace to display a tree.
7. Connection Procedure
31
11
The Project Window on the right is displayed. Confirm that
SCU[0] is entered in the Target
Column.
*If SCU[0] is not entered, select
SCU[0]
as shown on the right figure.
12
Select
New Protocol List
and select
Download Protocols
from the Protocol Menu.
13
The dialog box on the right is displayed. Select the
Include
Source Information
Check Box and click the
Compile
Button.
7. Connection Procedure
14
When 100% is displayed in the
Complied % Column, the compiling operation is completed.
After confirming that the compiling operation is completed, click the
Download
Button.
32
15
The dialog box on the right is displayed. Confirm that there is no problem and click the
OK
Button.
16
Check that 100% is displayed in the Downloaded % Column in the right figure, and click the
Close
Button.
7. Connection Procedure
17
Select
New Protocol List
and select
Compare Protocols
from the Protocol Menu.
18
The dialog box on the right is displayed. Select the
Include
Source Information
Check Box and click the
Compile
Button.
33
19
When 100% is displayed in the
Complied % Column, the compiling operation is completed.
Confirming that the compiling operation is completed, and click the
Compare
Button.
20
The dialog box on the right is displayed. Confirm that
Successful is displayed in the
Result Column and click the
OK
Button.
21
Confirm that 100% is displayed in the Compared % Column in the right figure, and click the
Close
Button.
7. Connection Procedure
34
7. Connection Procedure
7.4. Checking the Serial Communications
Execute the program and confirm that serial communications are normally performed.
Avoid eye exposure to direct or scattered radiation reflected by a mirror surface.
Laser beam emitted from a laser has high power density and may become blind when the beam is directed into eyes.
Sufficiently confirm safety before you change the values of variables on a Watch
Tab Page when the Sysmac Studio is online with the CPU Unit. Incorrect operation may cause the devices that are connected to Output Units to operate regardless of the operating mode of the Controller.
Precautions for Correct Use
This document explains the procedures for setting up the Bar Code Reader from the factory default setting. If the Bar Code Reader was changed from the factory default setting, make sure to initialize by referring to Section 8.2. Initializing the Bar Code Reader.
Precautions for Correct Use
Confirm that the serial cable is connected before proceeding to the following procedure.
If it is not connected, turn OFF the power supply to each device, and then connect the serial cable.
7.4.1. Starting Tracing
Start tracing with the CX-Protocol.
1
Select
Operating Mode
-
Run
from the PLC Menu of the
CX-Protocol.
2
The dialog box on the right is displayed. Confirm that there is no problem and click the
Yes
Button.
35
3
Confirm that the operating mode was changed to the Run mode, and double-click NewPLC1 .
4
The tree under NewPLC1 expands. Select the Serial
Communications Unit (SCU[0] is selected in the right figure).
5
Select the Trace 2 Icon ( ) on the Project Window.
Confirm that Trace 2 is highlighted as shown in the right figure.
6
*Trace 2 corresponds to port 2 of the Serial Communications
Unit.
Select
Start Trace
-
One Shot
Trace
from the PLC Menu.
7
Confirm that the status of Trace
2 in the Project Window was changed to One-shot Trace
Running.
7. Connection Procedure
36
7.4.2. Executing the Program
Execute the program with the Sysmac Studio.
1
Select
Watch Tab Page
from the View Menu of the Sysmac
Studio.
2
3
The Watch1 Tab Page is displayed in the lower section of the Edit Pane.
Confirm that the variables shown on the right are displayed in the
Name Columns.
*To add a variable, click
Input
Name
...
*If is displayed to the left of the variable instead of , click
and open the configuration of the structure variable.
*Program0 of the Name is omitted from the following descriptions.
4
Read the bar code shown on the right as an example.
Position the Bar Code Reader so that it can read the bar code shown on the right.
7. Connection Procedure
Start Input
Program execution status
Error codes
Receive data after converted into a string
Receive data storage area
37
7. Connection Procedure
5
Click
TRUE
on the Modify
Column of
Input_Start
.
The online value of
Input_Start
changes to True.
The program operates, serial communications are performed with the Bar Code Reader, and then the bar code is read.
*If READ OK LED that is on the back of the Bar Code Reader is lit green and a buzzer sounds, then the read operation succeeds.
*If the bar code shown in the document cannot be read, read a bar code shown in
Corresponding Bar Code List
in
Section 6 Appendix
of
the
V500-R2 Series Fixed
Laser-Type Barcode Reader
V500-R2 Series User's Manual
(Cat. No. Z334)
. When reading, change
Input_Start
to False and then change
Input_Start
to True again by using the same procedure as this step.
A buzzer sounds if the read operation succeeds.
38
7. Connection Procedure
7.4.3. Checking the Trace Data
Confirm that the correct data is sent and received by checking the trace data of the
CX-Protocol.
1
Select
Upload Trace
from the
PLC Menu from the
CX-Protocol.
2
A dialog box on the right is displayed. Check the contents and click the
Yes
Button.
3
Check the send/receive message on the trace data file shown in the right figure.
*In the example on the right, the
Reading Trigger command is sent from the Controller and the bar code data that are shown in step 4 of Section 7.4.2. are received.
■
Send message
Hex :1B 5A 0D
String :[ESC]”Z”[CR]
■
Receive message
Hex :34 39 31 32 33 34 35 36 37 38 39 30 34 0D
String :”4912345678904”[CR]
39
7. Connection Procedure
7.4.4. Checking the Receive Data
Confirm that the correct data are written to the variables of the Controller by using the Sysmac
Studio.
1
Confirm that the online value of
Local_Status.Done
, which indicates the program execution status, was changed to True.
*This means the program ended normally.
*In the case of an error end,
Local_Status.Error
changes to
True. Troubleshoot the error by referring to step 2.
[Normal end]
[Error end]
2
If the program ended normally, confirm that each error code is 0.
*If the program ended in an error, the error code corresponding to the error is stored. Troubleshoot the error by referring to 9.8. Error
Process.
[Normal end]
[Error end]
3
Check the received data (code that was read) in the Watch
Window of the Sysmac Studio.
*In the example on the right, the data stored in
Output_RecvMessage
is
4912345678904. It is the same as the data in step 3 of Section
7.4.3.
*The number of words used to store the receive data (0008 in hexadecimal) is stored in
Output_RecvData[0]
. The bar code data that were read are stored from
Output_RecvData[1] to [7]
. The number of used words is 8 including
Output_RecvData[0]
.
Receive data (Hex)
•Output_RecvData[0]: “0008”
•Output_RecvData[1]:”3439”
•Output_RecvData[2]:”3132”
•Output_RecvData[3]:”3334”
•Output_RecvData[4]:”3536”
•Output_RecvData[5]:”3738”
•Output_RecvData[6]:”3930”
•Output_RecvData[7]:”3400”
Number of words used to store the receive data
Eight words from 0 to 7
Values of Bar Code (String)
Output_RecvMessage
4912345678904
40
8. Initialization Method
This document explains the setting procedure from the factory default setting.
Some settings may not be applicable as described in this document unless you use the devices with the factory default setting.
8.1. Initializing the Controller
To initialize the Controller, it is necessary to initialize the Serial Communications Unit and the
CPU Unit. Place in PROGRAM Mode before the initialization.
8.1.1. Serial Communications Unit
To initialize the settings of the Serial Communications Unit, select
Edit Special Unit Settings
of CJ1W-SCU42 in CPU/Expansion Racks from the Sysmac Studio.
Click the
Return to default
Button and click the
Apply
Button. Then, click the
Transfer to
Controller
Button.
41
8. Initialization Method
8.1.2. CPU Unit
To initialize the settings of the Controller, select
Clear All Memory
from the Controller Menu of the Sysmac Studio. The Clear All Memory Dialog Box is displayed. Click the
OK
Button.
8.2. Initializing the Bar Code Reader
For the initialization of the Bar Code Reader, refer to
Return to the factory default setting
in
Menu Sheet/Command List
in
Section 4 Setting Method
of the
V500-R2 Series Fixed
Laser-Type Barcode Reader V500-R2 Series User's Manual
(Cat. No. Z334).
42
9. Program
9. Program
This section describes the details on the program and the protocol macro data used in this document.
9.1. Overview
This section explains the specifications and functions of the program and the protocol macro data that are used to check the connection between the Bar Code Reader (hereinafter referred to as the destination device) and the Controller (Serial Communications Unit)
(hereinafter referred to as the Serial Communications Unit).
This program and protocol macro data use the protocol macro function of the Serial
Communications Unit to send/receive the Reading Trigger command to/from the destination device and to detect whether the operation ends normally or ends in an error.
A normal end of this program means a normal end of the communications sequence of the protocol macro.
An error end means an error end of the communications sequence of the protocol macro.
In this section, the prefix "10#" (possible to omit) is added to decimal data and the prefix "16#" to hexadecimal data when it is necessary to distinguish between decimal and hexadecimal data. (e.g., "1000" or "10#1000" for decimal data and "16#03E8" for hexadecimal data, etc.)
Also, to specify a specific data type, the prefix "<data type>#" is added. (e.g.,
"WORD#16#03E8")
Additional Information
OMRON has confirmed that normal communications can be performed using this program and protocol macro data under the OMRON evaluation conditions including the test system configuration, version and product lot number of each device which was used for evaluation.
OMRON does not guarantee the normal operation under the disturbance such as electrical noise or the performance variation of the device.
43
9. Program
9.1.1. Communications Data Flow
The following figure shows the data flow from when the Controller (Serial Communications
Unit) issues the serial communications command to the destination device until when the
Controller receives the response data from the destination device.
1. Executing the The CPU Unit executes the protocol macro instruction communications sequence
↓
2. Sending a command
↓
3. Response receive processing
(Instruction: ExecPMCR) with the sequence number specified in the program, and loads the communications sequence (protocol macro data) registered in the Serial Communications Unit.
The Serial Communications Unit issues the send message (command data) to the destination device based on the sequence number specified in step 1.
The Serial Communications Unit receives the message
(response data) from the destination device, and stores it in the specified internal memory of the CPU Unit.
44
9. Program
9.1.2. Function Block for Executing Protocol Macro and Send/Receive
Messages
This section describes the function block for executing the protocol macro (hereinafter referred to as ExecPMCR instruction) and outlines the general operation of the send/receive messages.
Additional Information
Refer to
Serial Communications Instructions (ExecPMCR)
in
2 Instruction Descriptions
of the
NJ-series Instructions Reference Manual
(Cat. No. W502) for details.
●
ExecPMCR instruction
This program uses the following standard instruction to perform serial communications.
Name
Protocol macro
Function block
ExecPMCR
Explanation
Requests execution of a communications sequence (protocol data) registered in a Serial Communications Unit.
●
ExecPMCR instruction argument data
•Data type (_sPORT) of destination port Port
45
9. Program
●
Send/Receive messages
[Overview of send/receive messages]
Send message * *
*
Controller
Data
* * * * *
Terminator
Destination device
Receive message * * * * * * * *
Data
Terminator
[Relationship between the SrcDat[ ] send data array and the send message]
Bit
CPU
→
Communications Unit
Send data array: ScrDat[ ]
ScrDat[0]
* * * *
ScrDat[1]
* * * *
ScrDat[2] ScrDat[n-1]
15 0 15
* * * * * * * *
0
No. of words of send data
Communications Unit
→
Destination device
Send message
* * * * * * * *
Data Terminator
[Relationship between the DstDat[ ] receive data array and the receive message]
Destination device
→
Communications Unit
Receive message
* * * * * * * *
Data Terminator
No. of words of receive data
Bit
Communications Unit
→
CPU
Receive data array: DstDat[ ]
* * * *
DstDat[0]
* * * *
15 0 15
* * * * * * * *
0
DstDat[1] DstDat[2] DstDat[n-1]
46
9. Program
9.2. Communications sequence
This section explains the communications sequence (protocol macro data) that can be used for the ExecPMCR instruction of this program.
9.2.1. Communications sequence No.
A communications sequence (protocol macro data) that is registered in the Serial
Communications Unit is identified by a communications sequence number. The Controller executes the corresponding command on the destination device by specifying a communications sequence number in the ExecPMCR instruction.
This protocol macro data includes the following communications sequence.
No.
900
Command name
Reading Trigger
Description
Issues the reading trigger for a bar code.
9.2.2. ExecPMCR instruction input variables
The ExecPMCR instruction input variables for communication sequence No.900 Reading
Trigger are set as follows:
Port
Variable Name (data format)
Destination port specification
(_sPROT)
Data (Description)
-
UnitNo
PhysicPortNo Serial port number (USINT)
SeqNo
SrcDat[] (array)
DstDat[] (array)
Communications sequence number (UINT)
Send data array (WORD)
Receive data array (WORD)
_eUnitNo#_CBU_No00
(Specifies the unit number for the
Serial Communications Unit.)
USINT#10#2
(Use serial port No.2.)
UINT#10#900
(Specifies Reading Trigger.)
WORD#16#0000
(The number of words of send data is 0.: Specifies that no parameter is required for the command.)
(Receive data. Setting is unnecessary)
47
9. Program
9.3. Error Detection Processing
This program detects and handles the errors (1) to (3) below. For information on error codes, refer to
9.8 Error Process
.
Controller
Destination device
Serial cable
(1)(2) (3)
(1)Errors when executing the ExecPMCR instruction (ExecPMCR instruction error)
Errors occurred during an execution of the ExecPMCR instruction such as a unit error and communications error are detected as ExecPMCR instruction errors. An error is detected with the error code (ErrorID) and the expansion error code(ErrorIDEx) of the ExecPMCR instruction.
(2)Errors at an execution of the protocol macro (protocol macro error)
When an operation ends in an error during an execution of a protocol macro for some reason, it is detected as a protocol macro error. An error is detected with the Sequence
Abort Completion Flag (J01_P2_PmrSeqAbtSta).
(3)Errors in the destination device (Destination device errors)
Destination device errors include a command error, a parameter error, data error, and an execution failure in the destination device. An error is detected with the response data which is returned from the destination device. With this program, the destination device does not send a response when an error occurs. Therefore, this error is detected as a timeout error described in (2).
The causes of errors (1) and (2) may be related to each other. Therefore, all of the following error codes are stored when either error occurs.
•Error code of ExecPMCR instruction (ErrorID)
•Expansion error code of ExecPMCR instruction (ErrorIDEx)
•Protocol macro error code (lower four bits of J01_P2_PmrSta)
•Transmission error status (J01_P2_TransErrSta)
48
9. Program
9.4. Variables
The variables used in this program are listed below.
9.4.1. List of user-defined variables
The following tables list the data type, external variables (user-defined global variables/device variable for CJ-series Unit/system-defined variable) and internal variables that are used in this program.
●
Data type (Structure)
[Communications processing status flags] sStatus
Name Data type
STRUCT
Explanation
Structure of communications processing status flags
Communications processing in progress flag in progress.
Communications processing normal end flag
Done BOOL
TRUE: Normal end / FALSE: Other than normal end
Communications processing error end flag
Error BOOL
TRUE: Error end / FALSE: Other than error end
●
External Variables
[User-defined global variables]
Variable name Data type Explanation
Communication start switch
TRUE
Input_SendData
ARRAY[0..249]
OF WORD
Send data storage area (500 bytes (WORD))
Output_RecvData
ARRAY[0..249]
OF WORD
Output_RecvMessage STRING[498]
Output_PmrErrorID WORD
Output_PmrErrorIDEx DWORD
Output_PmrStaErrCode WORD
Output_TransErrCode WORD
Receive data storage area (500 bytes (WORD))
An area that stores DstDat[ ] of the ExecPMCR instruction
AT
%5500
(*)
An area that stores the receive data after converted in to a string. (498 characters)
An area that stores an error code of the ExecPMCR instruction
Normal end: 16#0000
An area that stores an expansion error code of the
ExecPMCR instruction
Normal end: 16#00000000
An area that stores a protocol macro error code
Normal end: 16#0000
An area that stores the transmission error status flag
Storage area of
J01_P2_TransErrSta
Normal end: 16#0000
*You need to use an AT specification for the area that stores DstDat[ ] of the ExecPMCR instruction to specify an address in the memory used for CJ-series Units.
49
9. Program
[Device variables for CJ-series Unit] (Serial Communications Unit)
Variable name Data type
J01_P2_PmrSta WORD
Explanation
Protocol macro operation status
Bits 03 to 00: Protocol macro error code
J01_P2_PmrExecSta BOOL Protocol Macro Execution Flag
J01_P2_PmrSeqEndSta BOOL Sequence End Completion Flag
J01_P2_PmrSeqAbtSta BOOL
J01_P2_TransErrSta WORD
Sequence Abort Completion Flag
Transmission error status
Additional Information
For details on the variables of the Serial Communications Unit, refer to
2-3 Device Variable for CJ-series Unit
in the
CJ-series Serial Communications Units Operation Manual for
NJ-series CPU Unit
(Cat.No. W494).
[System-defined variable]
Variable name Data type
_Port_isAvailable BOOL
Explanation
Communications Port Enabled Flag
TRUE: A port is available
FALSE: A port is not available
Additional Information
For information on the system-defined variables when the ExecPMCR instruction is used, refer to
Related System-defined Variables
in
Serial Communications Instructions
(ExecPMCR)
in
Section 2 Instruction Descriptions
of the
NJ-series Instructions Reference
Manual
(Cat. No. W502).
●
Internal variables (Instance variables)
The following tables list the internal variables used to execute the function blocks in the program. An internal variable is called an "instance". The name of the function block to use is specified as the data type of the variable.
Variable name Data type
ExecPMCR_instance ExecPMCR
F_TRIG_instance F_TRIG
Explanation
Requests execution of a communications sequence
(protocol data) registered in a Serial Communications Unit.
Outputs TRUE for one task period only when the input signal changes to FALSE.
Additional Information
For information on the ExecPMCR instruction, refer to
Serial Communications Instructions
(ExecPMCR)
in
Section 2 Instruction Descriptions
of the
NJ-series Instructions Reference
Manual
(Cat. No. W502).
Additional Information
For information on the F_TRIG instruction, refer to
Sequence Input Instructions (F_TRIG)
in
Section 2 Instruction Descriptions
of the
NJ-series Instructions Reference Manual
(Cat. No.
W502).
50
9. Program
●
Internal variables
Variable name Data type Explanation
Local_Status sStatus
This variable is defined as sStatus structure
Local_State
Local_ExecFlgs
DINT
BOOL
Local_EndExecPMCR BOOL
Status processing number
Communications instruction execution flag
Protocol macro execution end detection flag
Local_SeqNo
Local_PmrStaCode
Local_RecvWordData
Local_RecvWordSize
Local_RecvByteData
Local_RecvByteSize
UINT
WORD
ARRAY[0..248]
OF WORD
UINT
ARRAY[0..497]
OF BYTE
UINT
Communications sequence number
Protocol macro error code edit area
An area that extracts and stores the data to be converted into a string from the receive data (498 bytes)
A size of data to be converted into a string (unit: WORD)
An area that stores data in a byte array, which will be converted into a string (498 bytes)
A size of data to be converted into a string (unit: BYTE)
51
9. Program
9.5. ST Program
9.5.1. Functional Components of the Program
This program is written in the ST language. The functional components are as follows:
Major classification
1.Communications processing
2.Initialization processing
3.PMCR communications processing
4.Processing number error process
Minor classification
1.1. Starting the communications processing
1.2. Clearing the communications processing status flags
1.3. Entering in the communications in progress status and shifting to each state processing
2.1. Initializing the communications instruction
2.2. Initializing the communications instruction execution flag
2.3. Initializing the error code storage areas
2.4. Setting the input variable of the
ExecPMCR instruction
2.5. Initializing the receive data storage areas
2.6. Initialization setting end processing
3.1. Determining the communications processing status and setting the execution flag
3.2. Executing the communications instruction
-
Description
The communications processing starts.
The parameter setting of the communications instruction
(ExecPMCR instruction) and the receive data storage areas are cleared.
The ExecPMCR instruction is executed.
A normal end or an error end of the execution is detected.
The error processing is executed when a non-existent status processing number is detected.
52
9. Program
9.5.2. Program List
The program is shown below.
●
Program: Program0 (General-purpose serial communications connection check program)
1.Communications processing
53
9. Program
2.Initialization processing
To change the input values such as the unit number of the Serial Communications Unit, the port number to be used, protocol macro sequence number and send data size, change the code indicated by a red frame.
54
3.PMCR communications processing
9. Program
55
4.Processing number error process
9. Program
56
9. Program
9.6. Protocol Macro Data
Protocol macro data consists of sequence, step, send/receive message, and matrix. Its composition is described as follows.
●
When there is only one receive message format for a step (send/receive once)
•Set one send message and one receive message for the step
Sequence No.900
Step No.00 Send message 00 Receive message 00
•
•
Step No.yy
Sequence No. xxx xxx: 999 max. yy: 15 max
Send message yy Receive message yy
●
When there are several types of receive message formats for a step (send/receive once)
•Set the send message and matrix for the step
•Set several types of cases (receive messages) for the matrix
Sequence No.900
Step No.00 Send message 00 <Matrix>
•
•
•
Step No.yy
Receive message
00 yy: 15 max
Sequence No. xxx xxx: 999 max zz: 14 max
Case No.15 is automatically set
Case No.zz
Case No.15
Receive message zz
Other
9.6.1. Composition of Protocol Macro Data
In this protocol macro data, there is only 1 type of receive message (SD_RDCODE) for the send message (SD_RDCODE). Therefore, the following composition is used without using the matrix. Refer to
9.6.6. Receive Message Settings
for details.
Sequence No.900
Step No.00 SD_RDCODE RV_RDCODE
57
9. Program
9.6.2. Protocol Macro Processing Procedure
This section describes the processing procedure of the protocol macro.
1. [Step No.00]
Issuing send message (SD_RDCODE)
↓
2. When step No.00 ends normally
↓
When step No.00 ends in an error
↓
3. Next Process: Terminates the communications sequence as an
Error Process: Interrupts the step as an
Abort and terminates the communications
End. sequence.
↓
(End)
↓
(End)
58
9. Program
9.6.3. Sequence Settings
This protocol macro data performs Reading Trigger (read bar code) by using communications sequence No. 900. Set the timeout periods for the communications sequence.
Additional Information
Refer to
3-2 Sequence Attributes (Common to All Steps)
of the
CX-Protocol Operation
Manual
(Cat. No. W344) for details on sequence settings.
●
Timeout period setting
The following is the settings of the timeout periods (Timer Tr, Tfr, and Tfs) which are set for the sequence.
[Communications sequence setting screen]
<Settings>
Item
Timer Tr
Timer Tfr
Timer Tfs
Description
Receive wait monitoring time
Receive finished monitoring time
Send finished monitoring time
Explanation
Monitors the time from the receive wait status to the reception of the first data (header) in the step of the sequence.
This timer is set to 3 seconds in this protocol macro data.
Monitors the time from the reception of the first data to the completion of the reception in the step of the sequence.
This timer is set to 3 seconds in this protocol macro data.
Monitors the time from the sending of the header to the sending of the last data.
This timer is set to 3 seconds in this protocol macro data.
Additional Information
Refer to
Section 4-5 Calculation Method of Monitoring Time
of the
CX-Protocol Operation
Manual
(Cat. No. W344) for the calculation method of monitoring time.
59
9. Program
9.6.4. Step Settings
This section describes the step settings for communications sequence No. 900. The settings include retry count, send/receive messages (message names), next process, and error process. The sequence of this protocol macro data includes Step No.00 only.
Additional Information
Refer to
3-3 Step Attributes
of the
CX-Protocol Operation Manual
(Cat. No. W344) for details on step settings.
●
Retry count setting
This section describes the retry count setting for the step. The step is retried for the specified number of times (0 to 9 times) when an error occurs. If an error occurs after retries, the step moves to the error process.
The retry count is enabled for the Send&Receive command only.
<Step setting screen>
<Settings>
Step No. Retry count
00 3
●
Send/Receive message (massage name) settings
This section describes the settings for the send/receive messages of the step. Here, a registered send message name and message name are selected.
<Step setting screen>
<Settings>
Step No. Send message Receive message
60
9. Program
●
Next process and error process settings
This section describes the settings for the next process and error process of the step. The process set in the Next Column is executed when the step execution ends normally. If a communications error occurs, the process set in the Error Column is executed.
<Step setting screen>
<Settings>
Step No. Next process Error process
00 End Abort
<Process list>
Process.
End
Next
Abort
Goto
Matrix
Description
Ends the communications sequence
Moves to the next step No
Interrupts the step and ends the communications sequence
Moves to the specified step number
Uses the settings of the matrix
61
9. Program
9.6.5. Send Message Settings
This section explains the settings of the send message.
Additional Information
Refer to
3-4 Communication Message Attributes
of the
CX-Protocol Operation Manual
(Cat.
No. W344) for details on send message settings.
<Send message setting screen>
●
Settings of SD_RDCODE send message
<Settings>
<h>+"Z"+<t>
(1) (2) (3)
No. Code
①
<h >(Header) Type: Code, Data: ESC
Description
(2) "Z"
(3) <t>(Terminator *) Type: Code, Data: CR
*The footer for the destination device is the terminator for the protocol macro data. Hereinafter, the term "terminator" is used.
<Send message command format>
This is the command format of the message that is sent from the Serial Communications
Unit to the destination device according to the settings of
SD_RDCODE
.
<ESC> "Z" <CR>
Command
Header
"Z"
Terminator *
Number of bytes
1 Fixed: <ESC> (16#1B)
Remarks
1 Fixed: "Z" (16#5A) (Reading Trigger (destination device command))
1 Fixed: <CR> (16#0D)
62
9. Program
9.6.6. Receive Message Settings
This section describes the settings of the receive message.
Additional Information
Refer to
3-4 Communication Message Attributes
of the
CX-Protocol Operation Manual
(Cat.
No. W344) for details on receive message settings.
[Receive message setting screen]
●
Setting of receive message RV_RDCODE
<Settings>
No.
(W(1),*)+<t>
(1) (2)
Code
(1) (W(1),*)
Description
Message data: Variable
All variable length data are read and stored from array variable [n], which is specified with DstDat of the
ExecPMCR instruction, + [1]. (With this program, data is stored from
Output_RecvData[1]
.)
Message data: Constant hex, Type: Code, Data: CR (2) <t>(Terminator)
*The header <h> is set to None.
<Response format of receive message>
This is the response format of the receive message which is received by the Serial
Communications Unit from the destination device according to the settings of
RV_RDCODE
.
Command
Data
Terminator
Read bar code value
Number of bytes
Variable length
<CR>
Remarks
Variable: Read bar code value
1 Fixed: <CR> (16#0D)
63
9. Program
9.7. Timing Charts
The timing charts of the program are shown below.
The definitions of the timing chart patterns are as follows:
Pattern Normal end
Command Normal
Destination device
Normal
Response Yes
Error end (1)
ExecPMCR instruction error
Error
Normal or error
None
Error end (2)
Protocol macro error
Error
Normal or error
None
●
Normal end
Input_Start
Local_Status.Busy
Output_RecvData Normal response Normal response
Local_Status.Done
Output for 1 period *
Local_Status.Error
Output_PmrErrorID
Output_PmrErrorIDEx
Output_PmrStaErrCode
Output_TransErrorCode
16#0000
16#00000000
16#0000
16#0000
●
Error end (1) (2)
Input_Start
Local_Status.Busy
Output_RecvData
Local_Status.Done
Local_Status.Error
Output for 1 period *
Output_PmrErrorID
Output_PmrErrorIDEx
Output_PmrStaErrCode
Output_TransErrorCode
16#0000
16#00000000
16#0000
16#0000
16#****
16#********
16#****
16#****
16#0000
16#00000000
16#0000
16#0000
16#****
16#********
16#****
16#****
*If Input_Start changes from TRUE to FALSE during an execution (Busy=TRUE), a normal end or an error end is output for one period after the processing is completed (Busy=FALSE).
64
9. Program
9.8. Error Process
The following tables list the errors that are generated by executing this program.
9.8.1. ExecPMCR Instruction Errors
The error codes generated when the ExecPMCR instruction ends in an error are given below.
●
Output_PmrErrorID
After the ExecPMCR is executed, the content of
ExecPMCR_instance.ErrorID
is set.
Code Description
16#0400
16#0406
16#0407
16#0800
16#0801
An input parameter for an instruction exceeded the valid range for an input variable.
The memory address or data size of the data specified in the instruction is incorrect.
The results of instruction processing exceeded the data area range of the output parameter.
An error occurred when a FINS command was sent or received.
The FINS port is being used.
Additional Information
For details on ErrorID and error codes not listed in the table above, refer to
A-2 Error Code
Descriptions and A-3 Error Code Details in Appendices
of
the NJ-series Instructions
Reference Manual
(Cat. No. W502).
●
Output_PmrErrorIDEx
The content of
ExecPMCR_instance.ErrorIDEx
is set when the value of
ExecPMCR_instance.ErrorID
is 16#0800.
Code Description
16#00001106 A communications sequence number that is not registered was specified.
The operation was not possible because a protocol macro is already in
16#00002201 execution.
16#00002202 The operating mode is wrong.
16#00002401
A checksum error occurred in the protocol macro data or the data transfer is not yet completed.
Additional Information
For details on ErrorIDEx and error codes not listed in the table above, refer to
Serial
Communications instructions (ExecPMCR)
in
Section 2 Instruction Descriptions
of
the
NJ-series Instructions Reference Manual
(Cat. No. W502).
65
9. Program
9.8.2. Protocol Macro Error Codes
The protocol macro error codes generated when a protocol macro related error occurs are given below.
These codes are set in
Output_PmrStaErrCode
.
●
Output_PmrStaErrCode
The contents of the lower 4-bit of
J01_P2_PmrSta
are set.
Code
16#0000 There are no errors
16#0002 Sequence No. error
Description
16#0004 Protocol macro syntax error
Additional Information
For details on the protocol macro error codes (PmrStaErrCode), refer to
4-2-6 Protocol Status
of the
CJ-series Serial Communications Units Operation Manual for NJ-series CPU Unit
(Cat.
No. W494).
9.8.3. Transmission error status
The error flags used when a transmission error occurs are shown below.
They are set in
Output_TransErrCode
.
●
Output_TransErrCode
The content of
J01_P2_TransErrSta
is set.
Bit
14
13
12
Description
0:No transmission error
1:Send Finished Monitoring Time Exceeded 0:Normal
1:Receive Finished Monitoring Time Exceeded 0:Normal
1:Receive Wait Monitoring Time Exceeded
8 to 11 Retry count
0:Normal
7 1:FCS Check Error 0:Normal
0:Normal
0 and 1 (Not used)
Additional Information
For details on the transmission error status (TransErrCode), refer to
4-2-5 Device Variables for CJ-series Unit for Status
of the
CJ-series Serial Communications Units Operation Manual for NJ-series CPU Unit
(Cat.No. W494).
66
10. Revision History
10. Revision History
Revision code
01
Date of revision
Aug. 2, 2013 First edition
Revision reason and revision page
67
68
P 5 65 E1 -01
201 3
0911(-)
advertisement
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Related manuals
advertisement
Table of contents
- 4 Related Manuals
- 5 Terms and Definitions
- 6 Remarks
- 9 Overview
- 10 Applicable Devices and Device Configuration
- 10 Applicable Devices
- 11 Device Configuration
- 13 Serial Communications Settings
- 14 Cable Wiring Diagram
- 16 Example of Connection Check
- 17 Connection Procedure
- 17 Work Flow
- 19 Setting UP the Bar Code Reader
- 20 Setting Up the Controller
- 38 Checking the Serial Communications
- 44 Initialization Method
- 44 Initializing the Controller
- 45 Initializing the Bar Code Reader
- 46 Program
- 46 Overview
- 50 Communications sequence
- 51 Error Detection Processing
- 52 Variables
- 55 ST Program
- 60 Protocol Macro Data
- 67 Timing Charts
- 68 Error Process
- 70 Revision History