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
1. Related Manuals........................................................................................ 1
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 Manual name
W500 NJ501-[][][][] NJ-series CPU Unit Hardware User's Manual
W501 NJ501-[][][][] NJ-series CPU Unit Software User's Manual
W494 CJ1W-SCU[]2 CJ-series Serial Communications Units Operation Manual for
NJ-series CPU Unit
W502 NJ501-[][][][] NJ-series Instructions Reference Manual
W504 SYSMAC-SE2[][][] Sysmac Studio Version 1 Operation Manual
Z922 G9SP-[][][][] G9SP Series Safety Controller Operation Manual
Z923 G9SP-[][][][] G9SP Series Safety Controller Instructions Reference Manual
2. Terms and Definitions
Terms Explanation and Definition
No-protocol No-protocol Mode enables you to receive or send data by using SCU
Send Serial (SerialSend) or SCU Receive Serial (SerialRcv)
instructions. In this mode, messages are sent/received to/from a
destination device.
Send message A send message is a communications frame (command) sent from the
Serial Communications Unit to the destination device. This is executed
by the SerialSend instruction and sent to the destination device.
Receive message A receive message is a communications frame (response) sent from the
destination device to the Serial Communications Unit. The SerialRcv
instruction is used to read data received from the destination device.
1
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 of or whole part 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.
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.
3. Remarks
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.
2
4. Overview
This document describes the procedure for connecting a Safety Controller (G9SP series) of
OMRON Corporation (hereinafter referred to as OMRON) with an NJ-series Machine
Automation Controller (hereinafter referred to as the Controller) via serial communications,
and the procedure for checking their connection.
Refer to the serial communications settings of the project file you prepared to understand the
setting method and key points to connect the devices via serial communications.
This project file is used to check a serial connection by sending the monitor I/O command to
the destination device.
Obtain the latest "Sysmac Studio project file" from OMRON beforehand.
Name
Sysmac Studio project file
(extension: SMC)
File name
OMRON_G9SP_SERI232_LD_E
V100.SMC
Version
Ver.1.00
4. Overview
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.
3
5. Applicable Products and Support Software
5. Applicable Products and Support Software
5.1. Applicable Products
The applicable devices are as follows:
Manufacturer Name Model
OMRON NJ series CPU Unit NJ501-[][][][]
NJ301-[][][][]
OMRON Serial Communications Unit CJ1W-SCU[]2
OMRON Safety Controller G9SP-[][][][]
OMRON Expansion I/O Unit CP1W-20EDT[]
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 function or operation of the devices. Refer to the
manuals or contact your OMRON representative.
4
5. Applicable Products and Support Software
5.2. Device Configuration
The hardware components to reproduce the connection procedure of this document are as
follows:
Personal computer
(Sysmac Studio installed,
OS:Windows7)
4
USB cable
NJ501-1500+
CJ1W-SCU42
Serial Communications
Cable (RS-232C)
G9SP-N20S
CP1W-CIF01
CP1W-ME05M
Expansion I/O Connecting Cable
Manufacturer Name Model Version
OMRON Serial Communications Unit CJ1W-SCU42 Ver.2.0
OMRON NJ-series CPU Unit NJ501-1500 Ver.1.01
OMRON Power Supply Unit NJ-PA3001
OMRON Sysmac Studio
SYSMAC-SE2[][][]
OMRON Sysmac Studio project file OMRON_G9SP_SERI23
Obtain the latest Sysmac Studio project file from OMRON in advance.
(To obtain the files, contact your OMRON representative.)
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 serial cable (RS-232C), refer to 3-3 RS-232C and RS-422A/485
Wiring in the CJ-series Serial Communications Units Operation Manual for NJ-series CPU
Unit (Cat.No. W494).
Additional Information
In this document, a USB is used to connect with 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).
5
6. Serial Communications Settings
6. Serial Communications Settings
This section describes the specifications such as cable wiring and communication parameters
that are set in this document.
Additional Information
This document and project file can be used to perform operations using the settings and
command described in this section. Modifications are necessary to perform communications
using different settings.
6.1. Serial Communications Settings
The table below lists the settings for serial communications.
CJ1W-SCU42 G9SP-N20S
Unit number 0 Communications (connection) port Port 2 (RS-232C) Serial communications mode No-protocol Data length 8 bits 8 bits (fixed)
Stop bit 1 bit 1 bit (fixed)
Parity Even (default value) Even (fixed)
Baud rate 9,600 bps (default value)9,600 bps (fixed)
No-protocol Start Code Yes (#40) #40 (fixed)
No-protocol End Code No (#2A0D (fixed))
*One byte data can only be set as the no-protocol End Code. Thus, in this document, #2A0D
is treated as data.
Precautions for Correct Use
This document explains the setting procedure with Serial Communication Unit CJ1W-SCU42
whose Unit No. is 0, communication port is port 2 and device name is SCU. To connect
devices under different conditions, refer to 9. Project File and create a ladder program by
changing the variable names and setting values.
6
6. Serial Communications Settings
6.2. Cable Wiring Diagram
For details on the cable wiring, refer to Section 3 Installation and Wiring in 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.
Signal
name
FG 1 1 FG
SD 2 2 SD
RD 3 3 RD
RS 4 4 RS
CS 5 5 CS
5V 6 6 5V
DR 7 7 DR
ER 8 8 ER
SG 9 9 SG
FG Shell Shell FG
Pin No. Pin No. Signal
Safety Controller
D-sub 9-pin
(G9SP-N20S)
RS-232C
name
Cable connector type: Male
Interface
7
6. Serial Communications Settings
6.3. Example of Checking Connection
This connection example uses the ladder program for network connection. For details on the
ladder program, refer to 9. Project File.
The Controller and Safety Controller send and receive a message of Monitor I/O. The
following figure shows the outline of the operation.
CPU Serial
Communications
Unit
User memory
Ladder program
SerialSend
instruction
RS-232CSafety Controller
G9SP_
Comma
ndData
G9SP_
Respon
seData
Executing SerialSend instruction
Monitoring I/O
Send data
Send data
Setting area
Sending/receiving serial
communication command
Monitoring I/O
SerialRcv
instruction
Receive data
Executing SerialRcv instruction
Monitoring I/O
Receive data
Storage area
8
7. Connection Procedure
7. Connection Procedure
This section describes the procedure for connecting the Controller via serial communications.
This document explains the procedures for setting up the Controller 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 Controller via serial communications.
7.2 Setting Up the Safety Controller Set up the Safety Controller.
↓
7.2.1 Installing the Option Board
↓
7.3 Setting Up the Controller Set up the Controller.
↓
7.3.1 Hardware Settings of the Serial
Communications Unit
↓
7.3.2 Starting the Sysmac Studio and
Importing the Project File
↓
7.3.3 Going Online and Transferring
the Project Data
↓
7.4 Connection Status Check Check the serial network connection status.
↓
7.4.1 Checking the Connection StatusConfirm that serial communications are performed
↓
7.4.2 Checking Data that are Sent and
Received
Install the Option Board of the Safety Controller.
Set the hardware switches on the Serial
Communications Unit and connect to the Controller.
Start the Sysmac Studio, and import the Sysmac
Studio project file.
Connect online with the Sysmac Studio and transfer
the project data to the Controller.
normally.
Confirm that the correct data are sent and received.
Precautions for Correct Use
Obtain the latest Sysmac Studio project file from OMRON in advance.
(To obtain the files, contact your OMRON representative.)
9
7.2. Setting Up the Safety Controller
Set up the Safety Controller.
7.2.1. Installing the Option Board
Install the Option Board.
Precautions for Correct Use
Make sure that the power supply is OFF when you install.
Confirm that the power supply to
1
the Safety Controller is OFF.
Remove the cover of the option
2
board slot, and install the
RS-232C option board
(CP1W-CIF01).
RS-232C communications
settings of the Safety Controller
are as follows and cannot be
changed.
•RS-232C communications
setting (fixed)
Baud rate: 9,600 bps
Data length: 8 bits
Stop bits: 1 bit
Parity: E (Even parity)
7. Connection Procedure
(Front of Safety Controller)
Connect the serial cable
3
(RS-232C) to the Safety
Controller as shown on the right.
Connect the expansion I/O
connecting cable to the Safety
Controller.
Connect the 24VDC(+) line to
terminal V1 of the Safety
Controller, and the GND line to
terminal G1.
Turn ON the power supply to the
4
Safety Controller.
(RS-232C Option Board)
24VDC power supply
Serial Cable
10
7. Connection Procedure
7.3. Setting Up the Controller
Set up the Controller.
7.3.1. Hardware Settings of the Serial Communications Unit
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.
Confirm that the power supply to
1
the Controller is OFF.
*If the power supply is turned
ON, settings may not be
applicable as described in the
following procedure.
Connect the serial cable
2
(RS-232C) to Port 2 connector.
*This setting is required to use
Port 2 of Serial
Communications Unit.
Set the Unit No. Switch to 0.
3
(The unit number is factory-set
to 0.)
Connect the Serial
4
Communications Unit to the
Controller.
Connect the personal computer,
Safety Controller and Controller
using the Serial cable and USB
cable as shown in 5.2 Device
Configuration.
Turn ON the power supply to the
Controller.
USB cable
NJ501-1500
Power Supply Unit
CJ1W-SCU42
End cover
Serial Cable
11
7. Connection Procedure
7.3.2. Starting the Sysmac Studio and Importing the Project File
Start the Sysmac Studio, and import the Sysmac Studio project file.
Install the programming software and USB driver in the personal computer beforehand.
Start the Sysmac Studio.
1
Click the Import Button.
*If a confirmation dialog for an
access right is displayed at
start, select to start.
The Import File Dialog Box is
2
displayed. Select
OMRON_G9SP_SERI232_LD_
EV100.smc (Sysmac Studio
project file) and click the Open
Button.
*Obtain the Sysmac Studio
project file from OMRON.
OMRON_G9SP_SERI232_LD_
3
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.
Multiview
Explorer
Edit Pane Toolbox
12
7. Connection Procedure
7.3.3. Checking the Parameters and Building
Check the set parameters, execute the program check on the project data and build the
Controller.
Double-click CPU/Expansion
1
Racks under Configurations
and Setup in the Multiview
Explorer.
The CPU/Expansion Racks Tab
2
is displayed on the Edit Pane.
Select the Serial
Communications Unit icon as
shown on the right.
Confirm that CJ1W-SCU42 is
displayed, the device name is
SCU, and the unit number is 0.
*If the settings are different,
change the values.
Click Edit Special Unit Settings.
The 0 [Unit 0]: Tab is displayed.
3
Open the pull-down menu of
Parameter group to show and
select Port2: No-Protocol Settings.
13
7. Connection Procedure
Parameter group to show is set
4
to Port 2: No-Protocol Settings.
The items of the Port 2:
No-Protocol Settings are
displayed.
Confirm that the Port2: Port
settings is set to User settings
and other items are the same as
Section 6.1.
*If the settings are different from
the above, change the values
from the pull-down menu. Click
the Apply Button after
changing values.
Double-click I/O Map under
5
Configurations and Setup on
the Multiview Explorer.
The I/O Map Tab Page is
displayed and the parameters of
the Unit are displayed.
Confirm that the data in the
6
Variable Columns on the I/O
Map Tab Page start with SCU
and that the Global Variables
are set in the Variable Type
Columns.
*If the settings are different from
the above, right-click on
CJ1W-SCU42 and select
Create Device Variable.
Double-click the Task Settings
7
under Configurations and
Setup in the Multiview Explorer.
14
The Task Settings Tab Page is
8
displayed in the Edit Pane.
Click the Program Assignment Settings Button and confirm
that Program0 is set under
PrimaryTask.
Select Check All Programs
9
from the Project Menu.
The Build Tab Page is displayed
10
in the Edit Pane.
Confirm that "0 Errors" and "0
Warnings" are displayed.
Select Rebuild Controller from
11
the Project Menu.
A screen is displayed indicating
the conversion is being
performed.
7. Connection Procedure
12
Confirm that "0 Errors" and "0
Warnings" are displayed in the
Build Tab Page.
15
7. Connection Procedure
7.3.4. Going 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.
Select Change Device from the
1
Controller Menu.
The Change Device Dialog Box
2
is displayed.
Confirm that the Device and
Version are set as shown on the
right.
*If the settings are different,
change the value from the
pull-down list.
Click the OK Button.
If the settings were changed in
3
Step 2, the Build Dialog Box is
displayed. Click the Yes Button.
16
Select the Communications
4
Setup from the Controller Menu.
The Communications Setup
5
Dialog Box is displayed.
Select the Direct Connection via USB Option in the Connection
Type Field.
Click the OK Button.
7. Connection Procedure
SelectOnlinefrom the
6
Controller Menu.
A confirmation dialog box is
displayed. Click the Yes Button.
*The displayed dialog depends
on the status of the Controller
used. Select the Yes Button to
proceed with the processing.
Additional Information
For details on online connections to a Controller, refer to Section 5 Going Online with a
Controller in the Sysmac Studio Version 1.0 Operation Manual (Cat. No. W504).
When an online connection is
7
established, a yellow bar is
displayed on the top of the Edit
Pane.
Select Synchronization from
8
the Controller Menu.
17
The Synchronization Dialog Box
9
is displayed.
Confirm that the data to transfer
(NJ501 in the right figure) is
selected. Then, click the
Transfer to Controller Button.
A confirmation dialog is
10
displayed. Click the Yes Button.
A screen stating "Synchronizing"
is displayed.
A confirmation dialog box is
displayed. Click the No Button.
7. Connection Procedure
Confirm that the synchronized
11
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.
*If the synchronization fails,
check the wiring and repeat the
procedure described in this
section.
18
Select Reset Controller from
12
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
13
14
A confirmation dialog box is
displayed several times. Click
the Yes Button.
The Controller is reset, and
Sysmac Studio goes offline.
The yellow bar on the top of the
Edit Pane disappears.
Use steps 6 and 7 to go online.
19
7.3.5. Transferring the Unit Settings
Transfer the setting data of the Serial Communication Unit.
Select Mode - PROGRAM
1
Mode from the Controller Menu.
A confirmation dialog box is
2
displayed. Click the Yes Button.
7. Connection Procedure
PROGRAM mode is displayed
3
on the Controller Status Pane.
Double-click CPU/Expansion
4
Racks under Configurations
and Setup in the Multiview
Explorer.
Select the Serial
Communications Unit figure.
Click Edit Special Unit Settings.
The 0 [Unit 0]: Tab is displayed.
5
Click the Transfer to Controller
Button.
20
A confirmation dialog box is
6
displayed.
Click the Yes Button.
A dialog box is displayed
indicating transferring is being
performed.
A confirmation dialog box is
displayed.
Click the Yes Button.
The Port Selection Dialog Box is
7
displayed.
Select All ports and click the
OK Button.
*You can select HostLink2
instead of All ports.
7. Connection Procedure
A confirmation dialog box is
8
displayed.
Click the OK Button.
Select Port2: No-Protocol
9
Settings from the pull-down list
of Parameter group to show.
Click the Compare Button.
Confirm that “≠” (mismatch) is
10
not shown in the red frame on
the right.
21
7. Connection Procedure
7.4. Connection Status Check
Execute the project file that was transferred and confirm that serial communications are
performed normally.
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
Please confirm that the serial cable is connected before proceeding to the following steps.
If it is not connected, turn OFF the power of the devices, and then connect the serial cable.
7.4.1. Executing the Ladder Program and Checking the Receive Data
Execute the ladder program and confirm that the correct data are written to the variables of
the Controller.
Select Mode - RUN Mode from the
1
Controller Menu.
A confirmation dialog box is
displayed. Click the Yes Button.
The Online value of Input_Start
changes to True.
The Online Values of Output Status
and etc. are initialized to FFFF.
When serial communications are
completed normally, the Online
Values of Output Status and etc.
change to 0000.
The response data that was
7
received are stored in
G9SP_ResponseData[0] to [198].
Specify variables you want to see in
the Watch Tab Page as shown in the
right figure and check them.
If values are stored in
G9SP_ResponseData[2] to [5] as
shown on the right, the operation is
completed normally.
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 CPU Unit and Serial Communications
Unit.
8.1.1. CPU Unit
To initialize the settings of the Controller, select Clear All Memory from the Controller
Menu of the Sysmac Studio.
24
8. Initialization Method
8.1.2. 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.
25
9. Project File
9. Project File
This section describes the details on the project file used in this document.
9.1. Overview
This section explains the specifications and functions of the project file used to connect the
Safety Controller (hereinafter referred to as the destination device or G9SP) to the Controller
(Serial Communications Unit) (hereinafter referred to as an SCU Unit).
The project file means a Sysmac Studio project file.
The following data has already been set in this project file.
·SCU Unit communications settings and program task settings
·Ladder program for serial communications
·Variable tables and data type definitions of the variables used in ladder programs
This project file uses the serial communications of the SCU Unit to execute “read the I/O
monitor results” on the destination device and to detect whether the operation ends normally
or abnormally.
A normal end of this project file means a normal end of that the serial communications.
An error end means an error end of the serial communications and a destination device error
(Detected with the response data from the destination device).
Additional Information
OMRON has confirmed that normal communications can be performed using this project file
under the OMRON evaluation conditions including the test system configuration, version of
each product, and product Lot, No. 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.
Additional Information
With Sysmac Studio, the “data type + #” prefix is added to decimal data and “data type + # +
16 + #" prefix is added to hexadecimal data when it is necessary to distinguish between
decimal and hexadecimal data. (e.g., INT#1000 decimal -> INT#16#03E8 hexadecimal. For
DINT, a data type + "#" are unnecessary.)
26
9. Project File
9.1.1. Communications Data Flow
The following figure shows the data flow from when the Controller (SCU Unit) issues a
communications command (hereinafter referred to as command) to the destination device
until when the SCU receives the response data from the destination device.
1. Sending a command The SCU Unit sends the send message set with the
ladder program to the destination device.
↓
2. Receiving a response The response data, which was received by the SCU
Unit from the destination device, is stored in the
specified internal variable of the CPU Unit.
9.1.2. Serial Communications Instruction and Send/Receive Message
This section outlines the function blocks for Serial Communications Unit (hereinafter
referred to as serial communications instructions) and the general operation of the
send/receive messages.
Additional Information
For details, refer to Communications Instructions under Section 2 Instruction Descriptions of
NJ-series Instructions Reference Manual (Cat. No. W502).
●Serial communications instructions
In this project file, serial communications are performed by using the following 2 types of
standard instructions.
Name Function blocksDescription
SCU Send Serial SerialSend Sends data in No-protocol Mode from a
serial port. (Send instruction)
SCU Receive Serial SerialRcv Reads the receive data from the serial port in
No-protocol Mode. (Receive instruction)
●Serial communications instructions argument data
·SCU Send Serial
27
·SCU Receive Serial
9. Project File
·The data type (_sPORT) of destination port (Port)
●Send/receive messages
[Overview of send/receive message]
256 bytes or less
Send message
Controller
:SerialSend instruction SrcDat[]
Data
Destination
device
Data
Receive message
256 bytes or less
:SerialRcv instruction DstDat[]
*The set values shown below for the SCU Unit are stored in ST (Start Code) and ED (End
Code).
28
9.2. Destination Device Command
This section explains the destination device command used in this project file.
9.2.1. Command Format
The command format of the destination device is as follows:
*The checksum is calculated based on ST and G9SP_ResponseData[0] to [7].
*The response length is calculated based on G9SP_ResponseData[3] to [11].
9. Project File
Additional Information
For details, refer to Section 7 Communications with a Standard PLC Using an Option Board
in the G9SP-series Safety Controller Operation Manual (Z922).
9.2.3. Send/Receive Messages
Data are sent in sequence from ST of the command format.
Data are received in sequence from ST of the response format.
*Send message
40 00 00 0F 4B 03 4D0001..(Total of 19 bytes)
*Receive message 1 (at normal processing)
40 00 00 C3 00 00 CBaa..(Total of 199 bytes)
*Receive message 2 (at error processing)
40 00 00 09 00 00 CBaa..(Total of 13 bytes)
32
9. Project File
9.3. Error Detection Processing
This project file detects and handles errors (1) to (3). For information on error codes, refer to
9.7 Error Status List.
NJ501-1500+
Destination device
CJ1W-SCU42
Serial cable
(1) (2)(3)
(1) Errors during execution of SerialSend/SerialRcv instructions (communications instruction
errors)
An error end of SerialSend/SerialRcv instruction due to an incorrect SCU Unit setting or
incorrect variable setting, etc is detected as a communications instruction error. The error is
detected with the error flag (Error) at the execution of an instruction.
(2) SCU Unit errors (Unit errors)
An error that prevents the SCU Unit from being ready for communications is detected as a
Unit error. This error is detected when a timeout occurs.
(3) Errors in the destination device (Destination device errors)
An error that occurs during communications with a destination device is detected as a
destination device error. Destination device errors include a transmission error caused by a
destination device's command error, parameter error, data error and an error that preven ts
execution, character corruption or unmatched baud rate setting. The error is detected with
the response data which is sent from the destination device.
With this project file, the destination device error is detected when there is a difference
between a normal receive message (hereinafter referred to as a normal message) and an
error receive message (hereinafter referred to as an error message). (Refer to 9.2.3. Send/Receive Message for details.)
#40 #0000C3#0000 #CB 188Byte #**** #2A0D Normal
message
(Normal
response)
Start code Response
length
End codeService
code
Data Checksum Delimiter
#40 #000009#0000#CB #**** #**** #2A0D Error
message
(Error
response)
Start code Response
length
End codeService
code
Reserve
data
Checksum Delimiter
33
9. Project File
9.4. Variables
The table below lists the variables used in this project file.
9.4.1. External variables
These external variables are necessary to execute this program.
To use global variables, they must be declared in each program.
Additional Information
With the Sysmac Studio, the data type is expressed as ARRAY[0..2] OF WORD when an
array is specified for a data type. However, a data type of an array is simplified in this
document (e.g. WORD[3]).
It is possible to set either of the following to specify an array for a data type with the Sysmac
Studio.
·ARRAY[0..2] OF WORD
·WORD [3]
In the example above, 3 WORD array elements are secured.
●Variables that are used
(1)These variables are used to operate and check this program.
_Checksum_WORD
G9SP_SendCommand
_Checksum_HighByte
G9SP_SendCommand
_Checksum_LowByte
G9SP_ResponseData BYTE[199] BYTE array data received by the SerialRcv instruction
G9SP_Com
mandFormat
BYTE[18]
WORD
BYTE
BYTE
This project file is started by changing from FALSE
(OFF) to TRUE (ON).
Stores the execution results of this project file.
#16#FFFF: Default
#16#0000: Normal end
#16#FF01: SerialSend instruction error
#16#FF02: SerialRcv instruction error
#16#FF03: Destination device error (receive data
value error)
#16#FF04: Communications error (timeout
detection)
Stores the value of ErrorID and destination device
error code for each instruction when an instruction
error occurs.
(Default: #16#FFFF)
Stores the value of ErrorIDEx and destination device
error code for each instruction when an instruction
error occurs.
(Default: #16#FFFF FFFF)
Sets the unit number and port number of the SCU
Unit.
Sets the command sent to G9SP.
Data obtained by converting G9SP_CommandData
into a BYTE array to be used in the SerialSend
instruction.
Checksum value (WORD) of the send data
The leftmost byte data of the checksum value
(WORD)
The rightmost byte data of the checksum value
(WORD)
34
9. Project File
(2)These variables of the SCU Unit are used in this program.
Name Data type Description
SCU_P2_NopSerialS
endExecSta
SCU_P2_NopRcvCo
mpleteSta
SCU_P2_NopRcvCn
tSta
BOOL
BOOL
UINT Receive counter: Stores the size of the received data.
Additional Information
For information on variables of the Serial Communications Unit, refer to 5-2 Device Variables
for CJ-series Unit and System-defined Variables (During Serial Gateway Mode) in the
CJ-series Serial Communications Units Operation Manual for NJ-series CPU Unit (Cat.No.
W494).
(3)This system variable is used in this program.
Name Data type Description
_Port_isAvailable BOOL Communications Port Enabled Flag
SerialSend instruction executing flag:
ON during data send operation and OFF when the send
operation is completed.
Receive completion flag:
ON when reception of data is completed and OFF when
storing the receive data in a variable specified with the
SerialRcv is completed.
Additional Information
For information on system variables when using the serial communications instructions, refer
to SerialSend and SerialRecv in Section 2 Instruction Descriptions of the NJ-series Instructions Reference Manual (Cat. No. W502).
●Structure
The structures used in the external variables are shown below.
(1)_sPORT
Variable Meaning Description Data typeValid range Default
SCU_Inport Destination
port
UnitNo Unit number Unit number of SCU
PhysicP
ortNo
Serial port
number
Destination port _sPORT
_eUnitNo _CBU_No00 to
Unit
Serial port number of
SCU Unit
USINT 1 or 2 1
-
_CBU_No15
_CBU_No00
(2)G9SP_CommandFormat
Variable Meaning Description Data type Valid range Default
G9SP_Comman
dFormat
FixationArea1 Fixed area 1 Sets the fixed data that
SendData User
CheckSum Checksum
FixationArea2 End code
G9SP
command
setting
specification
area
area
area
Specifies command
data sent to G9SP.
cannot be changed by
the user.
Sets communications
receive data and echo
back data that can be
changed by the user.
Sets a checksum value.UINT #16#00 to
Sets the end code
(#16#2A0D).
G9SP_Comm
andFormat
USINT[8] Fixed -
USINT[6] #16#00 to
USINT[2] Fixed -
-
16#FF
#16#FF
-
-
35
9. Project File
9.4.2. Internal Variables
These internal variables are necessary to execute this project file.
They can be used only in this program.
●Variables for internal processing
These function blocks are used in this program.
Name Data typeDescription
G9SP_SerialSend_Instance SerialSendThe instance of the SerialSend instruction
G9SP_SerialRcv_Instance SerialRcv The instance of the SerialRcv instruction
Data receive waiting timer. Normally, the SerialRcv
instruction is executed after the reception of data is
completed (after SCU_P2_NopRcvCompleteSta is
G9SP_RcvWait_Timer TON
G9SP_Check_Timer TON
●Variables that are used
These variables are used in this program.
Name Data typeDescription
G9SP_ResponseData_OK BOOL
G9SP_Error_End BOOL Turns ON an error occurs after executing this program.
G9SP_Excuting BOOL
G9SP_SerialSend_Excute BOOL
G9SP_SerialSend_Wait BOOL
G9SP_SerialSend_End BOOL
G9SP_SerialSend_Error BOOL
G9SP_SerialRcv_Excute BOOL
G9SP_SerialRcv_End BOOL
G9SP_SerialRcv_Error BOOL
G9SP_TimeOUT BOOL
turned ON). This timer is used to execute the
SerialRcv instruction after a certain pe riod of time
after completion of the send processing even if
completion of the receive operation cannot be
detected. (Setting value: 200 ms)
G9SP send/receive completion check timer. This
timer operates after Input_Start is turned ON until
send/receive operations are completed. A timeout
error occurs when this timer is turned ON. (Setting
value 20 seconds)
Turns ON when this program receives a normal
response.
Serial communications executing flag.
Turns ON from when Input_Start is turned ON until
when the normal end (G9SP_ResponseData_OK) or
the error end (G9SP_Error_End) is turned ON.
SerialSend instruction execution flag.
Turns ON during execution of the SerialSend
instruction (until Done is turned ON).
Data sending flag.
Turns ON after the SerialSend instruction is completed
until the data send processing is completed (until
SCU_P2_NopSerialSendExecSta is turned OFF).
Data send completion flag.
Turns ON when the data send processi ng is completed.
SerialSend instruction error flag.
Turns ON when the SerialSend instru ction ends in an
error.
SerialRcv instruction execution flag.
Turns ON during execution of the SerialRcv instruction
(until Done is turned ON).
Data receive completion flag.
Turns ON when the data receive processing is
completed.
SerialRcv instruction error flag.
Turns ON when the SerialRcv instruction ends in an
error.
G9SP send/receive timeout flag.
Turns ON when the G9SP_Check_Timer times out.
36
Name Data typeDescription
G9SP_ReceiveData_error BOOL
Receive data error flag.
Turns ON when the receive data is not normal.
9.5. Ladder Program
9.5.1. Ladder Program Function Configuration
The functional configuration of this program is as follows
Major
classification
1. Initialization
processing
2. Managing
the
SerialSend
instruction
executing
status
3. Managing
the SerialRcv
instruction
executing
status
4.End
processing
1.1. SCU Unit setting
1.2. Setting the G9SP command
1.3. Generating a checksum
1.4. Converting the send data
1.5. Initializing the response data
1.6. Turning ON the serial
2.1. Generating a SerialSend
2.2. Executing the SerialSend
2.3. Checking for the SerialSend
2.4. Waiting for data send
2.5. Checking for data send
2.6. Saving the error status
3.1. Generating a SerialRcv
3.2. Executing the SerialRcv
3.3. Checking for SerialRcv
3.4. Checking for data receive
3.5. Saving the error status
4.1. Checking the response data
4.2. Generating an error flag
Minor classification Description
data
(USINT→BYTE)
area and status
communications executing
flag and enabling the monitor
timer (20 seconds)
instruction execution flag
instruction
instruction error
completion
completion
instruction execution flag
instruction
instruction error
completion
9. Project File
Preparation for communications.
Variables to be used are cleared
and initialization settings are
performed.
The SerialSend instruction is
executed and the program waits
for the completion of data send
operation.
The error status is stored in the
status area when the operation
ends in an error.
The SerialRcv instruction is
executed and the program waits
for the completion of data receive
operation.
The error status is stored in the
status area when the operation
ends in an error.
The receive data is checked.
The error flag is turned ON when
an error occurs.
37
9. Project File
9.5.2. Explanation on Each Functional Component
This section shows the details on the functions of this program.
1. Initialization processing
No. Overview Description
1.1. SCU Unit setting Sets the Unit number and serial port number of the SCU Unit
in the SCU_Inport structure.
38
9. Project File
No. Overview Description
1.2. Setting the G9SP
command data
1.3. Generating a
checksum
Sets a command sent to G9SP.
Data in the red frame are communication receive data and
echo back data that can be changed by the user. Any value
can be set.
Calculates the checksum value of the set command data.
39
9. Project File
No. Overview Meaning
1.4. Converting the send
data
(USINT→BYTE)
Converts the set command data and calculated checksum
value into a BYTE array to set them for the SerialSend
instruction.
40
9. Project File
No. Overview Meaning
1.5. Initializing the
response data area
and status
1.6. Turning ON the
serial
communications
executing flag and
executing the
monitor timer (20
seconds)
Initializes the response area and status area. The status area
is initialized to #16#FFFF.
Tur ns ON G9SP_Excuting that indicates the serial
communications are in progress.
G9SP send/receive completion check timer
(G9SP_Check_Timer) is operated to detect a timeout.
When the G9SP send/receive completion check timer times
out, G9SP_TimeOUT is turned ON and the error status is
stored.
41
2. Managing the SerialSend instruction executing status
9. Project File
No. Overview Meaning
2.1. Generating a
SerialSend instruction
execution flag
2.2. Executing the
SerialSend instruction
2.3. Checking for a
SerialSend instruction
error
2.4. Waiting for data send
completion
2.5. Checking data send
completion
Tur ns ON G9SP_SerialSend_Excute and starts the
SerialSend instruction execution processing if the
SerialSend instruction executing flag is not turned ON.
Turns OFF this flag when Done flag of the SerialSend
instruction is turned ON.
Executes the SerialSend instruction.
Turns ON the G9SP_SerialSend_Error flag when Error flag
of the SerialSend instruction is turned ON.
Tur ns ON G9SP_SerialSend_Wait when
G9SP_SerialSend_Excute is turned OFF. When the
SerialSend instruction executing flag is turned ON, the send
processing is completed, G9SP_SerialSend_Wait is turned
OFF and G9SP_SerialSend_End is turned ON.
42
No. Overview Meaning
2.6. Saving error status Sets the following status when the SerialSend instruction
ends in an error.
·Output_Status: #16#FF01
·Output_ErrorCode1: ErrorID of SerialSend instruction
·Output_ErrorCode2: ErrorIDEx of SerialSend instruction
9. Project File
Additional Information
For information on the error status, refer to 9.7 Error Status List.
43
3. SerialRcv instruction execution management
9. Project File
No. Overview Description
3.1. Generating a
SerialRcv instruction
execution flag
3.2. Executing the
SerialRcv instruction
3.3. Checking for
SerialRcv instruction
error
3.4. Checking for data
receive completion
If G9SP_SerialSend_End is turned ON and the receive
completion flag is turned ON, Turns ON
G9SP_SerialRcv_Excute and starts the SerialRcv instruction
execution processing.
This flag is turned OFF when Done flag of the SerialRcv
instruction is turned ON.
If the receive completion flag is not turned ON for a certain
period of time (200 ms), G9SP_SerialRcv_Excute is turned
ON and the SerialRcv instruction is executed.
Executes the SerialRcv instruction
Tur ns ON the G9SP_SerialRcv_Error flag when the Error flag
of the SerialRcv instruction is turned ON.
Tur ns ON G9SP_SerialSend_End when
G9SP_SerialRcv_Excute is turned OFF.
44
No. Overview Meaning
3.4. Checking for data
receive completion
3.5. Saving the error
status
Tur ns ON G9SP_SerialSend_End when
G9SP_SerialRcv_Excute is turned OFF.
Sets the next status when the SerialRcv instruction ends in an
error.
·Output_Status: #16#FF02
·Output_ErrorCode1: ErrorID of SerialRcv instruction
·Output_ErrorCode2: ErrorIDEx of SerialRcv instruction
9. Project File
Additional Information
For derails on the error status, refer to 9.7 Error Status List.
45
4. End processing
9. Project File
No. Overview Meaning
4.1. Checking if the
response data is
normal
Checks if the receive response data
(G9SP_ResponseData[2] to [5]) is the same as the fixed
data. If they are the same, the following data are set.
Output_Status: #16#0000
Output_ErrorCode1: #16#0000
Output_ErrorCode2: #16#00000000
G9SP_ResponseData_OK: ON
46
9. Project File
47
No. Overview Meaning
4.2. Saving the response
data error code
4.3. Generating an error
flag
If the comparison results are different in No. 4.1, the following
data are set.
Output_Status: #16#FF03
G9SP_ResponseData_error: ON
Output_ErrorCode: G9SP_ResponseData[5]+[2] (Service
(3) Error end 2 (Unit error) (4) Error end 3 (Destination device error)
SerialSend not executed.
Response data error occurs
Timeout error
50
9.7. Error Status List
9.7.1. SerialSend/SerialRcv instruction errors
This error occurs when the SerialSend/SerialRcv instruction ends in an error.
The status code (Output_Status) for each instruction error is shown below.
For details on the errors, refer to A-3 Error Code Details in the NJ-series Instructions
Reference Manual (Cat. No. W502). For troubleshooting the errors, refer to 9-3 Troubleshooting in the CJ-series Serial
Communications Units Operation Manual for NJ-series CPU Unit (Cat.No. W494).
9.7.2. Destination Device Error
The error codes for destination device errors are shown below.
The status code (Output_Status) of the destination device error is #16#FF03.
[Destination device error code list]
Meaning Destination device
error code
ErrorCode1
rightmost
ErrorCode1
leftmost
ErrorCode2
rightmost
ErrorCOde2
leftmost
·Destination device error record function
The response data from the Safety Controller include Present Error Information, Error
Log Count (Operation Log Count), Error Log (Error Code: Conduction Time), Operation
Log (Operation Code: Conduction Time), which are stored in
G9SP_ResponseData[100] and the subsequent variables.
Note that this project does not detect these errors.
Response
length
Service code #16#CB
End code #16#0000
Reserve data
at error
response
#16#C3
#16#09
#16#00
#16#xx
#16#xx
#16#xxxx
#16#0000
#16#xxxx
Description
Normal
Error response
No response data
Other errors
Both normal/error response
(#CB is received)
Other errors
Normal
Incorrect command
Normal
Error state
9. Project File
Additional Information
For details and troubleshooting the destination device errors, refer to Section 13
Troubleshooting in the G9SP Series Safety Controller Operation Manual (Cat. No. Z922).
52
9. Project File
53
10. Revision History
Revision
code
01 Aug. 1, 2013 First edition
Date of revision Revision reason and revision page
10. Revision History
54
2013
P545-E1-01
1308**(-)
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.