Detailed instructions for use are in the User's Guide.
[. . . ] 8. 1 WS02-CXPC1-V8
OPERATION MANUAL Function Blocks/ Structured Text
CX-Programmer
Ver. 8. 1 WS02-CXPC1-V8 Operation Manual Function Blocks/Structured Text
Revised February 2009
iv
Notice:
OMRON products are manufactured for use according to proper procedures by a qualified operator and only for the purposes described in this manual. The following conventions are used to indicate and classify precautions in this manual. Failure to heed precautions can result in injury to people or damage to property.
!DANGER
!WARNING
Indicates an imminently hazardous situation which, if not avoided, will result in death or serious injury. [. . . ] Input the source address for the input variable or the destination address for the output variable.
Set the Function Block Memory Allocations (Instance Areas) 1, 2, 3. . .
Refer to 3-2-6 Setting the FB Instance Areas for details.
1. Select the instance and select Function Block/SFC Memory - Function Block/SFC Memory Allocation from the PLC Menu. Set the function block memory allocations.
Printing, Saving, and Reusing Function Block Files
Compile the Function Block Definition and Save It as a Library File 1, 2, 3. . . Refer to 3-2-12 Compiling Function Block Definitions (Checking Program) and 3-2-16 Saving and Reusing Function Block Definition Files for details. Read the file into another PLC project.
Transferring the Program to the PLC
Refer to 3-2-17 Downloading/Uploading Programs to the Actual CPU Unit.
Monitoring and Debugging the Function Block
Refer to 3-2-18 Monitoring and Debugging Function Blocks.
81
Procedures
Section 3-2
3-2
3-2-1
Procedures
Creating a Project
Creating New Projects with CX-Programmer 1, 2, 3. . . In the Change PLC Window, select a Device Type that supports function blocks. These are listed in the following table.
Device CJ2H CS1G-H CS1H-H CJ1G-H CJ1H-H CJ1M CP1H CP1L NSJ CPU CPU68/67/66/65/64/68-EIP/67-EIP/66-EIP/65-EIP/64-EIP CPU42H/43H/44H/45H CPU63H/64H/65H/66H/67H CPU42H/43H/44H/45H CPU65H/66H/67H/64H-R/65H-R/66H-R/67H-R CPU11/12/13/21/22/23 CP1H-XA/X/Y CP1L-M/L G5D (Used for the NSJ5-TQ0@-G5D, NSJ5-SQ0@-G5D, NSJ8TV0@-G5D, NSJ10-TV0@-G5D, and NSJ12-TS0@-G5D) M3D (Used for the NSJ5-TQ0@-M3D, NSJ5-SQ0@-M3D, and NSJ8-TV0@-M3D) FQM1-CM002 FQM1-MMA22 FQM1-MMP22
FQM1-CM FQM1-MMA FQM1-MMP
3. For details on other settings, refer to the CX-Programmer Operation Manual (W446).
3-2-2
Creating a New Function Block Definition
1, 2, 3. . . When a project is created, a Function Blocks icon will appear in the project workspace as shown below.
Function Blocks will appear under the PLC.
2. Function block definitions are created by inserting function block definitions after the Function Blocks icon. Creating Function Block Definitions Function blocks can be defined by the user using either ladder programming or structured text.
82
Procedures
Section 3-2
Creating (Inserting) Function Block Definitions with Ladders 1. Select Function Blocks in the project workspace, right-click, and select Insert Function Blocks - Ladder from the pop-up menu. (Or select Function Block - Ladder from the Insert Menu. ) Creating (Inserting) Function Block Definitions with Structured Text 1. Select Function Blocks in the project workspace, right-click, and select Insert Function Blocks - Structured Text from the pop-up menu. (Or select Function Block - Structured Text from the Insert Menu. )
FunctionBlock1 is displayed as the Icon under the Function Blocks Icon ( ).
2. A function block called FunctionBlock1 will be automatically inserted either after the for ladder programming language (default) or the for ST language. This icon contains the definitions for the newly created (inserted) function block. Whenever a function block definition is created, the name FunctionBlock@ will be assigned automatically, where @ is a serial number. All names must contain no more than 64 characters.
Using OMRON FB Library Files
Use the following procedure to insert OMRON FB Library files (. cxf). Select Function Blocks in the project workspace, right-click, and select Insert Function Blocks - Library File from the pop-up menu. The following Select Function Block Library File Dialog Box will be displayed.
Note
To specify the default folder (file location) in the Function Block Library File Dialog Box, select Tools - Options, click the General Tab and the select the default file in the OMRON FB library storage location field.
3. Specify the folder in which the OMRON FB Library file is located, select the library file, and click the Open Button. [. . . ] RXD_SCU: Receive String via Serial Port on Serial Communications Unit · Function Receives a text string from a serial port on a Serial Communications Unit (SCU). · Application RXD_SCU (Storage_location, Number_of_characters, SCU_unit_number, Serial_port, Internal_logic_port); · Conditions The serial communications mode of the serial port must be set to no-protocol communications.
198
Function Descriptions
· Arguments and Return Values
Variable name Storage_location Number_of_characters SCU_unit_number Serial_port Internal_logic_port Data type STRING INT, UINT, WORD INT, UINT, WORD INT, UINT, WORD INT, UINT, WORD
Appendix C
Description Specifies the storage location for the received text string. 1: Serial port 1 2: Serial port 2 0 to 7: Internal logic port number specified 16#F: Automatic internal logic port allocation
· Example
Serial Communications Unit (SCU) CPU Unit Unit No. : 0 Message Value to read
Serial port 2
Barcode reader
Variables BOOL INT STRING BOOL BOOL P_DoRecvData iProcess Message P_RXDU_Recv (* Variable to control receive function *) (* Process number *) (* Variable to store received message *) (* Status of Serial Communications Unit *) AT 1519. 06 Unit No. 0 Use serial port 2 P_ComInstEnable (* Communications Port Enable Flag *)*) AT A202. 07 Use port 7
(* Use the following: Unit number: 0, Serial port number: 2, Logical port number: 7 *) (* Receive data when P_DoRecvData is ON and iProcess is 0 *) IF (P_DoRecvData = TRUE) AND (iProcess = 0) THEN iProcess := 1; P_DoRecvData := FALSE; END_IF; (* Execute receive processing according to process number *) CASE iProcess OF 1: (* Reception function executed if Communications Enabled Flag and Reception Completed Flag are ON. [. . . ]