0% found this document useful (0 votes)
1K views1,354 pages

0i-D - C Language Executor

Uploaded by

R SUNDAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views1,354 pages

0i-D - C Language Executor

Uploaded by

R SUNDAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1354

*

FANUC Series 0 -MODEL D

C Language Executor
PROGRAMMING MANUAL

B-64303EN-3/01
• No part of this manual may be reproduced in any form.
• All specifications and designs are subject to change without notice.

The products in this manual are controlled based on Japan’s “Foreign Exchange and
Foreign Trade Law”. The export from Japan may be subject to an export license by the
government of Japan.
Further, re-export to another country may be subject to the license of the government of
the country from where the product is re-exported. Furthermore, the product may also be
controlled by re-export regulations of the United States government.
Should you wish to export or re-export these products, please contact FANUC for advice.

In this manual we have tried as much as possible to describe all the various matters.
However, we cannot describe all the matters which must not be done, or which cannot be
done, because there are so many possibilities.
Therefore, matters which are not especially described as possible in this manual should be
regarded as ”impossible”.

This manual contains the program names or device names of other companies, some of
which are registered trademarks of respective owners. However, these names are not
followed by  or  in the main body.
B-64303EN-3/01 DEFINITION OF WARNING, CAUTION, AND NOTE

DEFINITION OF WARNING, CAUTION, AND NOTE


This manual includes safety precautions for protecting the user and
preventing damage to the machine. Precautions are classified into
Warning and Caution according to their bearing on safety. Also,
supplementary information is described as a Note. Read the Warning,
Caution, and Note thoroughly before attempting to use the machine.

WARNING
Applied when there is a danger of the user being
injured or when there is a danger of both the user
being injured and the equipment being damaged if
the approved procedure is not observed.

CAUTION
Applied when there is a danger of the equipment
being damaged, if the approved procedure is not
observed.

NOTE
The Note is used to indicate supplementary
information other than Warning and Caution.

• Read this manual carefully, and store it in a safe place.

s-1
B-64303EN-3/01 PREFACE

PREFACE
This manual consists of the following chapters.

Organization of this manual


Part I, SPECIFICATION
Describes the C Language Executor function specifications,
system configuration, application development environment, and
C Language Library functions.

Part II, PROGRAMMING


Describes the procedure for creating a C Language Executor
application, libraries related to programming, and the C
Language Executor function.

APPENDIX
Describes the procedure for checking a system alarm that occurs
in a C Language Executor application, additional information
about installation of the C compiler, and character codes.

Applicable models
The models covered by this manual, and their abbreviations are :

Model name Abbreviation


FANUC Series 0i -TD 0i -TD
Series 0i -D 0i -D
FANUC Series 0i -MD 0i -MD

NOTE
Some functions described in this manual may not
be applied to some products.
For details, refer to the DESCRIPTIONS
(B-64302EN).

p-1
PREFACE B-64303EN-3/01

Related manuals of Series 0i -D


The following table lists the manuals related to Series 0i -D. This
manual is indicated by an asterisk(*).

Table 1 Related manuals


Specification
Manual name
number
DESCRIPTIONS B-64302EN
CONNECTION MANUAL (HARDWARE) B-64303EN
CONNECTION MANUAL (FUNCTION) B-64303EN-1
USER’S MANUAL B-64304EN
(Common to Lathe System/Machining Center System)
USER’S MANUAL (For Lathe System) B-64304EN-1
USER’S MANUAL (For Machining Center System) B-64304EN-2
MAINTENANCE MANUAL B-64305EN
PARAMETER MANUAL B-64310EN
START-UP MANUAL B-64304EN-3
Programming
Macro Compiler / Macro Executor B-64303EN-2
PROGRAMMING MANUAL
Macro Compiler OPERATOR’S MANUAL B-64304EN-5
C Language Executor PROGRAMMING MANUAL B-64303EN-3 *
PMC
PMCPROGRAMMING MANUAL B-64393EN
Network
PROFIBUS-DP Board OPERATOR’S MANUAL B-64404EN
Fast Ethernet / Fast Data Server OPERATOR’S MANUAL B-64414EN
Operation guidance function
MANUAL GUIDE i B-63874EN
(Common to Lathe System/Machining Center System)
OPERATOR’S MANUAL
MANUAL GUIDE i (For Machining Center System) B-63874EN-2
OPERATOR’S MANUAL
MANUAL GUIDE i (Set-up Guidance Functions) B-63874EN-1
OPERATOR’S MANUAL
MANUAL GUIDE 0i OPERATOR’S MANUAL B-64434EN
TURN MATE i OPERATOR’S MANUAL B-64254EN

p-2
B-64303EN-3/01 TABLE OF CONTENTS

TABLE OF CONTENTS
DEFINITION OF WARNING, CAUTION, AND NOTE .................................s-1
PREFACE ....................................................................................................p-1

I. SPECIFICATION
1 Overview................................................................................................. 3
1.1 Feature .......................................................................................................... 4
2 System components.............................................................................. 6
2.1 C Language Executor .................................................................................... 7
2.2 C Language Library ....................................................................................... 8
2.3 Application program....................................................................................... 9
2.4 The hardwares of CNC which are used in C Language Executor................ 12
3 Application program development environment .............................. 14
3.1 Composition of development system ........................................................... 15
3.2 Development procedure .............................................................................. 17
4 C Language Library function list........................................................ 19
4.1 ANSI C standard library ............................................................................... 19
4.2 MS-C extended C standard library............................................................... 21
4.3 Graphic library ............................................................................................. 22
4.4 CNC/PMC window library ............................................................................ 24
4.5 Other libraries .............................................................................................. 30

II. PROGRAMMING
1 List of Functions.................................................................................. 37
1.1 ANSI C Standard library .............................................................................. 38
1.2 MS-C extended C standard library............................................................... 42
1.3 Graphic library ............................................................................................. 47
1.4 CNC/PMC window library ............................................................................ 50
1.5 Other libraries .............................................................................................. 56
1.6 Japanese(Multi-byte character) functions .................................................... 61
2 How to make application program ..................................................... 62
2.1 Wind River Compiler C/C++ installation....................................................... 63
2.2 Overview of installing the C Language Library and creating an application
program ....................................................................................................... 63
2.3 Special files.................................................................................................. 64
2.4 Variables of type 'int'.................................................................................... 64
2.5 Using compiler libraries ............................................................................... 65
2.6 Describing 2-byte characters in source-codes ............................................. 65
2.7 Remarks ...................................................................................................... 66
c-1
TABLE OF CONTENTS B-64303EN-3/01

3 Function References ........................................................................... 67


3.1 ANSI C standard library ............................................................................... 69
3.1.1 Lists of Functions ...................................................................................................69
3.1.2 Function Reference.................................................................................................74
3.2 MS-C extended C standard library............................................................. 204
3.2.1 Lists of Functions .................................................................................................204
3.3 Graphic library ........................................................................................... 208
3.3.1 Usage of graphic functions...................................................................................208
3.3.2 Lists of MS-C compatible functions.....................................................................210
3.3.3 Function Reference...............................................................................................212
3.3.4 MS-C graphic function compatibility list.............................................................275
3.3.5 Lists of C Language Executor original graphic functions....................................277
3.3.6 Function Reference...............................................................................................278
3.4 CNC/PMC window library .......................................................................... 306
3.4.1 Lists of Functions .................................................................................................306
3.4.2 Return values of data window functions ..............................................................313
3.4.3 Function Reference...............................................................................................314
3.5 MDI operation library ................................................................................. 824
3.5.1 Library outline......................................................................................................824
3.5.2 Lists of Functions .................................................................................................827
3.5.3 Function Reference...............................................................................................828
3.5.4 Key code table ......................................................................................................841
3.5.5 Reading extension MDI keys ...............................................................................843
3.6 CRT operation library................................................................................. 861
3.6.1 Supported display device......................................................................................861
3.6.2 Lists of Functions .................................................................................................863
3.6.3 Function Reference...............................................................................................865
3.7 File Operation Library ................................................................................ 968
3.7.1 Using Memory Card .............................................................................................968
3.7.2 Lists of Functions .................................................................................................969
3.7.3 Function Reference...............................................................................................970
3.8 Serial Library.............................................................................................. 975
3.8.1 Library outline......................................................................................................975
3.8.2 List of function .....................................................................................................982
3.8.3 Function Reference...............................................................................................983
3.9 Task management library .......................................................................... 996
3.9.1 Library outline......................................................................................................996
3.9.2 Lists of Functions ...............................................................................................1011
3.9.3 Function Reference.............................................................................................1012
3.10 FCA Library ............................................................................................. 1027
3.10.1 Library outline....................................................................................................1027
3.10.2 List of Functions.................................................................................................1031
3.10.3 Function Reference.............................................................................................1032
3.11 F-ROM Library ......................................................................................... 1061
3.11.1 Library outline....................................................................................................1061
3.11.2 List of functions..................................................................................................1064
3.11.3 Function reference..............................................................................................1065
3.12 Touch-panel Library................................................................................. 1077
3.12.1 Overview of library ............................................................................................1077
3.12.2 List of Functions.................................................................................................1080

c-2
B-64303EN-3/01 TABLE OF CONTENTS

3.12.3 Function Reference.............................................................................................1080

4 Keycode, screen control code and Displayable characters ........ 1085


4.1 Keycode, screen control code ................................................................. 1086
4.1.1 Keycode..............................................................................................................1086
4.1.2 Keycode of special keys on MDI panel..............................................................1087
4.1.3 CRT display control characters ..........................................................................1089
4.1.4 Display control escape sequences ......................................................................1089
4.2 Displayable characters ............................................................................ 1093
4.2.1 Single byte characters.........................................................................................1093
4.2.2 2-byte characters.................................................................................................1094
4.2.3 Display code for single byte characters..............................................................1103
4.2.4 Kanji character code ...........................................................................................1107

5 C Language Executor Function...................................................... 1108


5.1 Multitasking.............................................................................................. 1109
5.1.1 Task classes ........................................................................................................1109
5.1.2 Difference of each task class ..............................................................................1111
5.1.3 Task switching....................................................................................................1112
5.1.4 Data access between tasks ..................................................................................1113
5.1.5 Task Management ..............................................................................................1114
5.2 File system .............................................................................................. 1115
5.3 Power-on procedure ................................................................................ 1118
5.3.1 Key operation at power on .................................................................................1118
5.4 Parameter setting on CNC....................................................................... 1119
5.5 Dat2mem utility manual ........................................................................... 1123
5.6 Window task ............................................................................................ 1129
5.6.1 Overview ............................................................................................................1129
5.6.2 Window task's execution ....................................................................................1130
5.6.3 Usage of the window task ..................................................................................1130
5.6.4 Available functions for the window task............................................................1132
5.6.5 How to make application program .....................................................................1133
5.6.6 Notes...................................................................................................................1133
5.7 Conforming CNC screen display function ................................................ 1134
5.7.1 Overview ............................................................................................................1134
5.7.2 How do application program run on each equipment.........................................1135
5.7.3 Restrictions on specification...............................................................................1137
5.7.4 Making application program ..............................................................................1139
5.7.5 Function reference..............................................................................................1141
5.7.6 Specification of the memory card on the personal computer .............................1143
5.7.6.1 Using the drive on the personal computer ..................................................... 1143
5.7.6.2 Notes on application program creation.......................................................... 1144
5.7.6.3 Others............................................................................................................. 1145
5.8 High-Level Task....................................................................................... 1146
5.8.1 Overview of High-Level Task............................................................................1146
5.8.2 Specification.......................................................................................................1147
5.8.3 Task execution rule ............................................................................................1150
5.8.4 Application programming ..................................................................................1153
5.8.5 Function reference..............................................................................................1154
5.8.6 High-Level task execution management data.....................................................1156

c-3
TABLE OF CONTENTS B-64303EN-3/01

5.9 Use with MANUAL GUIDE i..................................................................... 1159


5.9.1 Overview ............................................................................................................1159
5.9.2 Screen display after power-on ............................................................................1159
5.9.3 Restrictions for Use with MANUAL GUIDE i ..................................................1161
5.10 Use with TURN MATE i ........................................................................... 1164
5.10.1 Overview ............................................................................................................1164
5.10.2 Screen display after power-on ............................................................................1164
5.10.3 Restrictions for Use with TURN MATE i..........................................................1166
5.11 Display language switching...................................................................... 1167
5.11.1 Overview ............................................................................................................1167
5.11.2 Explanation.........................................................................................................1167
5.11.2.1 Dynamic language switching......................................................................... 1167
5.11.2.2 Usable languages ........................................................................................... 1167
5.11.2.3 cnc_chglang function reference..................................................................... 1168
5.11.3 Parameters ..........................................................................................................1171
5.11.4 Diagnosis data ....................................................................................................1172
5.12 Display of Simplified Chinese messages ................................................. 1173
5.12.1 Overview ............................................................................................................1173
5.12.2 Explanation.........................................................................................................1173
5.12.2.1 Function overview ......................................................................................... 1173
5.12.2.2 Simplified Chinese mode setting function (crt_setmode function)................ 1174
5.12.2.3 Simplified Chinese display function.............................................................. 1175
5.12.2.4 Example of use .............................................................................................. 1176
5.13 Display/acquisition of Russian messages ................................................ 1181
5.13.1 Overview ............................................................................................................1181
5.13.2 Explanation.........................................................................................................1182
5.13.2.1 Function overview ......................................................................................... 1182
5.13.2.2 Russian mode setting function (crt_setmode function) ................................. 1183
5.13.2.3 Russian display/get function.......................................................................... 1184
5.13.2.4 Examples of use............................................................................................. 1185
5.14 Display/acquisition of Turkish messages ................................................. 1192
5.14.1 Overview ............................................................................................................1192
5.14.2 Explanation.........................................................................................................1193
5.14.2.1 Function overview ......................................................................................... 1193
5.14.2.2 Turkish mode setting function (crt_setmode function).................................. 1194
5.14.2.3 Turkish display/get function .......................................................................... 1195
5.15 Checking operation restart after program editing..................................... 1197
5.15.1 Overview ............................................................................................................1197
5.15.2 Explanation.........................................................................................................1197
5.15.2.1 Outline of processing..................................................................................... 1197
5.15.2.2 Function references........................................................................................ 1198
5.16 Eight-level data protection ....................................................................... 1202
5.16.1 Overview ............................................................................................................1202
5.16.2 Explanation.........................................................................................................1203
5.16.2.1 Function references........................................................................................ 1204
5.16.2.2 Data ID list..................................................................................................... 1214
5.17 FTP transfer............................................................................................. 1216
5.17.1 Overview ............................................................................................................1216
5.17.2 Explanation.........................................................................................................1217
5.17.2.1 Function references........................................................................................ 1218
5.17.3 Detailed status of communication error..............................................................1229
5.17.4 Reference items ..................................................................................................1230

c-4
B-64303EN-3/01 TABLE OF CONTENTS

5.18 C language data file series and edition display........................................ 1231


5.18.1 Overview ............................................................................................................1231
5.18.2 Explanation.........................................................................................................1232
5.18.2.1 Conditions for displaying the series and editions of user data files on
the system configuration screen..................................................................... 1232
5.18.2.2 Series and edition information file format ..................................................... 1233
5.18.2.3 Method of specifying a series and edition information file ........................... 1236
5.18.2.4 User data file that enables series and edition information to be displayed .... 1237
5.18.2.5 System configuration screen display ............................................................. 1238
5.18.2.6 Restrictions .................................................................................................... 1240

6 Programming Technique ................................................................ 1241


6.1 Various techniques .................................................................................. 1242
6.2 Application of C Language Executor to machines ................................... 1245

APPENDIX
A Troubleshooting If a System Alarm Occurs in the C Language
Executor Application Program ....................................................... 1249
B Additional Information on C Compiler Installation ....................... 1256
B.1 Installing the C compiler .......................................................................... 1257
B.2 Installing the linker ................................................................................... 1263
B.3 Installing the C Language Library ............................................................ 1263
B.4 Obtaining and installing other tools.......................................................... 1264
B.5 Customization procedure......................................................................... 1265
C Character Code List......................................................................... 1281
C.1 Half-size character code list (for 8.4-inch color LCD)............................... 1282
C.2 Half-size character code list (for 10.4-inch color LCD)............................. 1288
C.3 FANUC character code list (for 8.4-inch color LCD) ................................ 1293
C.4 FANUC character code list (for 10.4-inch color LCD) .............................. 1302
D Simplified Chinese Character Code List ....................................... 1310
E Russian (Cyrillic) Character Code List .......................................... 1335
F Turkish Character Code List........................................................... 1336

c-5
I. SPECIFICATION
B-64303EN-3/01 SPECIFICATION 1.Overview

1 Overview
FANUC Series 0i –D C Language Executor enables to add the Machine Tool Builder's original screen
into FANUC Series 0i-D and to customize screen displaying and operation interface of CNC software.
It is possible to replace arbitrary screens of CNC with user application's screen.
The user application program about screen displaying and operation interface is developed using
general C language just like ordinary PC's application program developing.
The executable file which is developed by the Machine Tool Builder is built in CNC unit.
The user program which is compiled on PC is stored in flash ROM of CNC unit, and it is read into
CNC's memory by CNC's start-up procedure,then,executed on C Language Executor.

Application program CNC software and the application program


is developed on PC. is executed simultaneously.

Series 0i-D
PC
Application program is stored
in flash ROM. Application C Language CNC
program Library Software
Memory
Card

Machine Tool Builder's


original screen is
displayed

(LCD/MDI unit)

-3-
1.Overview SPECIFICATION B-64303EN-3/01

1.1 Feature

(1) Low-cost customization

No additional hardware is required to use C Language Executor and application program on FANUC
Series 0i-D (*). The user application program can be built in your Series 0i-D as it is.

(*) It may be necessary to increase flash ROM or DRAM capacity.

(2) Application program development on PC

You can develop application program on generic PC (Personal Computer).


Designing,editing,compiling,linking and also some debugging works are executed on PC.

(3) High level compatibility with C application on PC

Function libraries of C language which are provided by C Language Executor has compatibility
with ANSI and MS-C.
Therefore, ordinary application programs on PC can be translated to CNC's as long as they don't
depend on specific hardware.

(4) Combination of CNC software and application program

The application program which is developed by the Machine Tool Builder is executed as a task
in CNC softwares.
Some arbitrary screens of existing CNC screens can be replaced with user screens which are
displayed by the user application program.
Application program can read or write various CNC data via libraries which are provided by C
Language Executor.
Therefore, the user application program works as a part of CNC software.
Additionally, it is possible not only to replace existing CNC screens, but also to add new user's
screens.

(5) Graphic display and communication (*)

Graphic display function, which has 640 × 480 resolution and 256color/pixel,is used in
application program.
This graphic screen is imposed on character screen.
For graphic display, MS-C compatible graphic functions, such as line, rectangle and arc drawing,
painting, etc.,are provided.
Communication with personal computer,etc. is available using reader/puncher interface(RS-232C)
on CNC unit.
Communication driver is built in the C Language Library, therefore, communication is processed
by just calling communication functions.
The user application program can read from or write to FANUC FLOPPY CASSETTE ADAPTER and FANUC
HANDY FILE connected to CNC unit.

(*) "READER/PUNCHER INTERFACE CONTROL" option is required to use communication function.

-4-
B-64303EN-3/01 SPECIFICATION 1.Overview

(6) Using with Macro Executor

C Language Executor can be used with Macro Executor(Execution Macro and also Conversational
Macro) of Series 0i-D.
The screen displaying part of macro program which has been developed by the Machine Tool Builder
can be replaced with C program, therefore, existing software property does not become useless.
(C Language Executor doesn't have Execution Macro function.)

(7) Using with MANUAL GUIDE i or TURN MATE i

C Language Executor can be used with MANUAL GUIDE i or TURN MATE i for the Series 0i-D. When
using C Language Executor with MANUAL GUIDE i or TURN MATE i, however, there are some restrictions
(part of sources need to be modified). For details, see Section 5.8 "Use with MANUAL GUIDE i"
and Section 5.9 "Use with TURN MATE i" later in Part II.

(8) Easy installation to CNC unit

The application program which is developed by the Machine Tool Builder is installed to CNC
unit using memory card (JEIDA/PCMCIA compatible SRAM card or ATA flash memory card).
It is easy to install and update the application program because it isn't need to write EPROM
using ROM-writer.

(9) Storing various data in flash ROM

It is available to store various data(message strings to be displayed, individual parameters


for each machines and tool information, etc.) made on PC.
The user application program can read them arbitrarily.

(10) Supporting touch-panel and input/output via memory card.

C Language Executor supports hardwares such as touch-panel and input/output via memory card.
These I/O devices are good for building better user interface.

(*) "TOUCH PANEL" option is required to use touch-panel control.

(11) Simultaneous displaying of CNC and user screen using window display

The application program can display user window on the arbitrary screens including the CNC
screens using window display function (VGA window).
It is possible to display Machine Tool Builder's original message window or the software machine
operation panel on the existing CNC screen.

-5-
2.System components SPECIFICATION B-64303EN-3/01

2 System components
The system components that C Language Executor and the user application program are shown below.

*3
Application
CNC window
program
CNC software *1

C Language Executor
*4 C Language Library

*2

FANUC Series 0i–D Hardware

*1 library function call by Application program

*2 output to screen, reading MDI key or touch-panel, etc.

*3 reading/writing of CNC information

*4 task switching, screen switching, etc.

-6-
B-64303EN-3/01 SPECIFICATION 2.System components

2.1 C Language Executor

C Language Executor provides following functions.

(1) Loading and starting application program

C Language Executor loads the application program and C Language Library from flash ROM into
DRAM in startup procedure of CNC unit, and starts executing the application program.

(2) Switching CNC screen and user screen

C Language Executor watches screen switching by operator's MDI operation.


When any user screen is selected, C Language Executor switches execution to user application.
When CNC screen is selected again, C Language Executor returns execution to CNC software.

(3) Managing CNC task and user task

C Language Executor manages the user application's background task in addition to switching
process by screen switching.

-7-
2.System components SPECIFICATION B-64303EN-3/01

2.2 C Language Library

C Language Library provides following functions.

(1) Input/output between peripheral equipments (LCD and MDI key)

C Language Library executes input/output operations, which are called by the application
program, such as character displaying to screen by "printf" function, reading MDI key by "getch"
function, graphic displaying by MS-C compatible function and input/output via reader/puncher
interface etc.

(2) Input/output CNC information (current position, parameter and tool offset, etc.)

C Language Library provides input/output function of various CNC information using CNC window
function, and also PMC information using PMC window.

(3) ANSI and MS-C compatible C language function library

C Language Library provides ANSI compatible C language standard library (there are some
exceptions) and MS-C extended C language standard library which doesn't depend on specific
hardware and operating system.

(4) MS-DOS compatible file system

C Language Library provides MS-DOS compatible file system. The application program can access
SRAM disk (max 63KB) on nonvolatile memory (SRAM) or memory card (PC card) via this file system.
It is possible to read or write files using functions such as "fopen", "fprintf", "fgets", etc.
in application program.

-8-
B-64303EN-3/01 SPECIFICATION 2.System components

2.3 Application program

(1) Program structure

Application program consists of five independent tasks.

APPLICATION PROGRAM

(A)MAIN TASK

AUXILIARY TASK

(B) ALARM TASK (C) COMMUNI-


CATION TASK

(D)WINDOW TASK

(E)HIGH LEVEL TASK

(A) MAIN TASK


Almost all processes, such as screen displaying, key input, read/write CNC information,
etc., are executed in this task.

(B) ALARM TASK


This task is periodically started usually and watches various conditions.

(C) COMMUNICATION TASK


This task is usually used for processing of input/output via reader/puncher interface
independently of MAIN TASK.

(D) WINDOW TASK


This task runs in the same way as the alarm task or communication task, and is mainly
used to display a window on an arbitrary screen. This task allows almost the same screen
display operations as the main task.

(E) HIGH LEVEL TASK


This task is executed independently at certain start periods. The start periods are fixed.
This task is used to perform operations such as real-time processing with the highest
priority and high-speed data monitoring.

-9-
2.System components SPECIFICATION B-64303EN-3/01

ALARM TASK and COMMUNICATION TASK are called AUXILIARY TASK.(Also called BACKGROUND TASK
because these tasks are executed in background of MAIN TASK) AUXILIARY TASKS are limited in their
function.

COMMUNICATION
MAIN TASK ALARM TASK
TASK
Standard function ○ ○ ○
Key input ○ × ×
Character display ○ × ×
Graphic display ○ × ×
File I/O ○ ○(*1) ○(*1)
CNC/PMC window ○ ○(*2) ×
Reader/puncher interface ○ ○(*3) ○(*3)
Reading F-ROM ○ ○(*3) ○(*3)
Reading touch-panel ○ ○ ○
○ means "available, × means "not available

(*1) The same file cannot be accessed by two or more tasks simultaneously.
It is necessary to control exclusively in application program.
(*2) Simultaneous access with MAIN TASK causes BUSY ERROR.
(*3) It is necessary to control communication port and F-ROM reading exclusively by the
application program itself.

Task switching between MAIN TASK and AUXILIARY TASK is done by calling task control library
function in application program.
Periodically starting of AUXILIARY TASK is also commanded in application program.
It is possible to compose application program with only one task.
In this case, only MAIN TASK is used.

Additionally, the window task is available in addition to the above tree tasks.
The window task runs simultaneously with above tree tasks and is used to display windows on
arbitrary screen.
The following functions are available in the window task.

HIGH-LEVEL
WINDOW TASK
TASK
Standard function ○ ○(*3)
Key input × ×
Character display ○(*1) ×
Graphic display ○(*1) ×
File I/O × ×
CNC/PMC window ○(*2) ○(*3)
Reader/puncher interface × ×
Reading F-ROM × ×
Reading touch-panel ○ ×

- 10 -
B-64303EN-3/01 SPECIFICATION 2.System components

(*1) The destination of the output of the display becomes not normal window but VGA window.
(*2) Exclusive control might be necessary with other tasks.
(*3) There is a function that cannot be used.

(2) Executable program model

Executable file format is different from EXE-format of MS-DOS.


Also execution environment is not compatible with MS-DOS.
However, the same function as MS-DOS PC's can be used in application program as long as they
are not depend on specific hardware.

(3) Example of application program

For example, the program which consists of only Main task has following structures.

main function

Initialization

Setting of user Screens

Setting of softkeys by which


user screens are selected
Repetition

Get current screen index

Branch to each screen's procedure

Read CNC information and Read numeric value from MDI ‥‥‥
display them on screen key and update data

- 11 -
2.System components SPECIFICATION B-64303EN-3/01

2.4 The hardwares of CNC which are used in C Language


Executor

ITEM SPECIFICATION REMARKS


CPU PowerPC compatible processor It is common with CNC
software.
DRAM(*1) MAX 2/4 or 6MB Independent area from
CNC software is used.
One capacity must be
specified optionally.
Use parameter No.
8781 to set the capacity
within the range
(DRAM capacity to 700
KB) that can be used
by a user application, of
the specified capacity.
SRAM 64KB Sum of SRAM disk and
SRAM DISK MAX 63KB non-volatile variables is
NON-VOLATILE VARIABLES MAX 63KB up to 63KB.
MEMORY CARD PCMCIA or JEIDA compatible SRAM cards 256KB - 2MB Other cards than
ATA Flash memory card Supporting MS-DOS format specified card aren't
supported
F-ROM Available to store arbitrary data Data size to store is
Application program can read stored data variable according to
F-ROM capacity, etc.
(Max: about 4MB)
MDI KEY ONG keyboard Key arrangement is
customizable.
TOUCH-PANEL 10.4-inch color LCD "TOUCH-PANEL
640x480 resolution control" option is
Reading status and position required.
DISPLAY DEVICE 8.4-inch color LCD(*2)
ANK characters: 80 characters × 16 lines(*3)
Kanji characters: 40 characters × 16 lines(*3)
16-color display(*5), reverse, blink, background color
specified for each character
10.4-inch color LCD(*2)
10.4-inch color LCD (with touch-panel)(*2)
ANK characters: 80 characters × 25 lines(*4)
Kanji characters: 40 characters × 25 lines(*4)
16-color display(*5), reverse, blink, background color
specified for each character
PRINTABLE Alphanumeric and Kana characters (ANK characters)
CHARACTER FANUC Kanji characters (about 2,400 characters of JIS
1st level Kanji characters)
Special symbols
User-defined characters (external character registration,
max. 256 one-byte characters)
JIS Kanji characters (about 6,800 1st and 2nd level
characters)
COEXISTENCE Each screen can coexist with the CNC's screen.
WITH CNC'S SCREEN

- 12 -
B-64303EN-3/01 SPECIFICATION 2.System components

ITEM SPECIFICATION REMARKS


DISPLAY DEVICE 8.4-inch color LCD(*2) The device cannot be
(GRAPHIC) 10.4-inch color LCD(*2) used simultaneously
10.4-inch color LCD (with touch-panel)(*2) with the CNC's graphic
640 × 400 dots × 1 screen, or 640 × 480 dots × 1 screen display.
In 16-color mode, a graphic screen can be overlapped with
a character screen; in 256-color mode, a graphic screen
cannot be overlapped with a character screen.
WINDOW DISPLAY Max. 8 windows on user screen (only characters can be
overlapped)
Max. 2 windows on arbitrary screen (characters and
graphics can be overlapped)(*6)
READER/PUNCHER 1 or 2 channels
INTERFACE (RS-232C)
FANUC CASSETTE Data can be input to and output from application programs.
ADAPTER, FANUC HANDY
FILE

"KB" means "kilo bytes" (1024 bytes),"MB" means "mega bytes" (1024 kilo bytes)

(*1) Usable memory capacity of Macro Executor is ((custom soft capacity) - (C Language
Executor DRAM capacity))
(*2) These display devices are VGA graphic devices."16-color" or "256-color" means number
of color palettes which can be simultaneously displayed on the screen. The
application program can map the arbitrary color from 4096 colors into each color
palette.
(*3) 19-line in a screen is also available.
(*4) 30-line in a screen is also available.
(*5) It is also possible to set 256-color display.
(*6) This is available on VGA display device.

- 13 -
3. Application program
development environment SPECIFICATION B-64303EN-3/01

3 Application program development


environment
Application program of C Language Executor is developed by the Machine Tool Builder.

- General PC(personal computer) is used to develop (edit and compile) application program.
- Only execution of application program is possible on CNC unit.
- Debugging of application program is worked on both PC and CNC. Some parts of application program
which can work on PC can be debugged on PC as ordinary PC's software.
Whole program is debugged on CNC.

- 14 -
3. Application program
B-64303EN-3/01 SPECIFICATION development environment

3.1 Composition of development system

(1) Goods on the market

・Microsoft Windows XP Home Edition、


PC Microsoft Windows XP Professional、
Executable for Microsoft Windows 2000 or Microsoft Windows 98

MEMORY CARD
PCMCIA Rel.1.0,JEIDA V4.0 compatible
READER/WRITER

MEMORY CARD
1MB or more capacity
(Required capacity depends on application program)

COMMERCIAL
・Microsoft Windows XP Home Edition
SOFTWARE
Microsoft Windows XP Professional
Microsoft Windows 2000 or Microsoft Windows 98
・Text editor(arbitrary)
・Wind River Compiler C/C++

(*) You can use a FANUC-recommended memory card, or a flash ATA card or CompactFlash card purchased
from FANUC, as the above memory card.

(2) Purchases from FANUC

FANUC
C LANGUAGE
LIBRARY ・ANSI compatible C standard library
・MS-C compatible library
・CNC window library

- 15 -
3. Application program
development environment SPECIFICATION B-64303EN-3/01

Software of the Machine


Tool Builder

MEM
(LINK)

FANUC C Language
Library

personal computer
MEMORY CARD
FANUC Series 0i-D

Application program & library

Flash ROM C Language Executor

CNC system software

CNC hardware

- 16 -
3. Application program
B-64303EN-3/01 SPECIFICATION development environment

3.2 Development procedure

The development procedure of software for C Language Executor is as follows.

SPECIFICATION
DESIGN

FUNCTION
DESIGN

PROGRAMIMIG
CODING, EDITING
working on PC

COMPILING,
LINKING

DEBUGGING

working on CNC

TESTING

(1) Developing program which works on PC

You develop program just like as ordinary PC's program.


In this step, some parts of application program which can work on PC are developed.
However, only library functions which are provided by C Language Executor can be used in
application program. Some extended functions by compiler maker may not be used on C Language
Executor.
Also hardware depending program such as BIOS call is not available on C Language Executor.

(2) Testing on PC

Source level debugging of application program on PC can be done by using compiler for PC.
Function module level testing can be completed even if there are some difference between PC and
C Language Executor.

- 17 -
3. Application program
development environment SPECIFICATION B-64303EN-3/01

(3) Completing program for C Language Executor

After module level testing on PC, you develop entire application with FANUC library.
If any error occurred in this step, you confirm usage of C Language Library.
You use MAKEFILE which is provided from FANUC to compile, link and make memory card file.

(4) Installing to CNC

You write application program to flash ROM on CNC via memory card.

(5) Testing application program on CNC

You test application program on CNC.

- 18 -
B-64303EN-3/01 SPECIFICATION 4.C Language Library function list

4 C Language Library function list

4.1 ANSI C standard library

The following ANSI C language standard functions are provided.

(1) Diagnostics

assert

(2) Character handling

isalnum islower isxdigit


isalpha isprint tolower
iscntrl ispunct toupper
isdigit isspace
isgraph isupper

(3) Non-local jumps

setjmp longjmp

(4) Valiable arguments

va_start va_arg va_end

(5) Input/output

remove sscanf ungetc


rename vfprintf fread
tmpnam vprintf fwrite
fclose vsprintf fgetpos
fflush fgetc fseek
fopen fgets fsetpos
freopen fputc ftell
setbuf fputs rewind
setvbuf getc clearerr
fprintf getchar feof
fscanf gets ferror
printf putc perror
scanf putchar
sprintf puts

- 19 -
4.C Language Library function list SPECIFICATION B-64303EN-3/01

(6) General utilities

atoi calloc abs


atol free div
strtol malloc labs
strtoul realloc ldiv
rand bsearch atof
srand qsort strtod

(7) String handling

memcpy strcmp strspn


memmove strncmp strstr
strcpy memchr strtok
strncpy strchr memset
strcat strcspn strlen
strncat strpbrk
memcmp strrchr

(8) Date and time

clock time gmtime


asctime localtime mktime
ctime difftime

(9) Mathematics

acos fabs pow


asin floor sin
atan fmod sinh
atan2 frexp sqrt
ceil ldexp tan
cos log tanh
cosh log10
exp modf

- 20 -
B-64303EN-3/01 SPECIFICATION 4.C Language Library function list

4.2 MS-C extended C standard library

The following MS-C extended functions are provided.

_chdrive _fstrpbrk ecvt lseek


_dos_findfirst _fstrrchr iskana ltoa
_dos_findnext _fstrrev iskanji memicmp
_dos_getdiskfree _fstrset iskanji2 mkdir
_expand _fstrspn iskmoji mtob
_fcalloc _fstrstr iskpun nthctype
_fexpand _fstrtok ispnkana open
_ffree _fstrupr isprkana read
_fstrchr _getdrive itoa rmdir
_fstrcmp _lrotl jisalpha jtohira
_fmalloc _lrotr jisdigit jtokata
_fmemchr _msize jishira jtolower
_fmemcmp _rotl jiskata stackavail
_fmemcpy _rotr jiskigou strcmpi
_fmemicmp _tolower jisl0 stricmp
_fmemmove _toupper jisl1 strlwr
_fmemset alloca jisl2 strnicmp
_fmsize btom jislower strnset
_frealloc cabs jisprint strrev
_fstrcat chdir jisspace strset
_fstrcpy chkctype jistojms strupr
_fstrcspn close jisupper swab
_fstricmp creat jiszen tell
_fstrlen eof jmstojis toascii
_fstrlwr fcvt isalkana ultoa
_fstrncat gcvt isalnmkana write
_fstrncmp getch isascii zentohan
_fstrncpy getcwd isgrkana
_fstrnicmp hantozen jtoupper
_fstrnset hypot kbhit

- 21 -
4.C Language Library function list SPECIFICATION B-64303EN-3/01

4.3 Graphic library

(1) MS-C compatible graphic functions

The following MS-C graphic functions are provided.


However, some detail specifications of functions may be different between PC and CNC because
both hardwares are not compatible completely.

_arc _getvideoconfig _setbkcolor


_clearscreen _getviewcoord _setcliprgn
_ellipse _getvisualpage _setcolor
_floodfill _getwritemode _setfillmask
_getactivepage _grstatus _setfont
_getarcinfo _imagesize _setgtextvector
_getbkcolor _kanjisize _setlinestyle
_getcolor _lineto _setpixel
_getcurrentposition _moveto _settextposition
_getfillmask _outgtext _settextrows
_getfontinfo _outmem _settextwindow
_getgtextextent _outtext _setvideomode
_getgtextvector _pie _setvideomoderows
_getimage _polygon _setvieworg
_getkanji _putimage _setviewport
_getlinestyle _rectangle _setvisualpage
_getphyscoord _registerfonts _setwritemode
_getpixel _remapallpalette _unregisterfonts
_gettextposition _remappalette _wrapon
_gettextwindow _setactivepage

- 22 -
B-64303EN-3/01 SPECIFICATION 4.C Language Library function list

(2) Original graphic functions

These functions are C Language Executor original graphic functions.

NAME FUCNTION
gr_displaychar Draw a standard size character
gr_displayfourlarge Draw a quad size character
gr_displaysixlarge Draw a hex size character
_putpattern Put monochrome image data
_getpattern Get monochrome image data
gr_dispstr Draw a standard size string
gr_disp6str Draw a hex size strings
gr_bitblt Copy image data
gr_disp4str Draw a quad size string.
gr_displaysmlchar Draw a small size character.
gr_dispsstr Draw a small size string.
gr_displayfchar Draw a FANUC character.
gr_dispfstr Draw a FANUC character string.
gr_disp9ifchar Draw 9-inch font character.
gr_disp9ifstr Draw 9-inch font character string.
mmc_line_b Draw a line between specified two points.
mmc_polyline Draw a polyline.
mmc_circle_b Draw a circle.
mmc_ellipse_b Draw an ellipse.
mmc_pie_b Draw a pie figure.
mmc_arc_b Draw an arc.
mmc_gettext Get character in the specified area.
mmc_puttext Put character data on memory to text screen.
mmc_textsize Get required byte size for getting character.

- 23 -
4.C Language Library function list SPECIFICATION B-64303EN-3/01

4.4 CNC/PMC window library

The following functions which are used to input/output data between CNC/PMC are provided.

(1) CNC window

NAME FUCNTION
cnc_sysinfo Read CNC system information
cnc_dwnstart Start output of NC program to be registered
cnc_download Output NC program to be registered
cnc_dwnend Stop output NC program to be registered
cnc_vrfstart Start output NC program to be compared
cnc_verify Output NC program to be compared
cnc_vrfend Stop output NC program to be compared
cnc_upstart Start input NC program
cnc_upload Input NC program
cnc_upend Stop input NC program
cnc_search Search specified program
cnc_delall Delete all program
cnc_delete Delete specified program
cnc_rdprogdir Read program directory
cnc_rdproginfo Read program information
cnc_rdprgnum Read program number in executing
cnc_rdseqnum Read sequence number in executing
cnc_actf Read actual feed rate of controlled axes
cnc_acts Read actual spindle speed
cnc_absolute Read absolute position
cnc_machine Read machine position
cnc_relative Read relative position
cnc_distance Read distance to go
cnc_skip Read skipped position
cnc_srvdelay Read servo delay amount
cnc_accdecdly Read acceleration/deceleration delay amount
cnc_rddynamic Read dynamic data
cnc_statinfo Read CNC status information
cnc_alarm Read alarm status
cnc_rdalminfo Read alarm information
cnc_rdtofs Read tool offset amount
cnc_wrtofs Write tool offset amount
cnc_rdtofsr Read tool offset amount (range specified)
cnc_wrtofsr Write tool offset amount (range specified)
cnc_rdzofs Read work zero offset
cnc_wrzofs Write work zero offset

- 24 -
B-64303EN-3/01 SPECIFICATION 4.C Language Library function list

NAME FUCNTION
cnc_rdzofsr Read work zero offset (range specified)
cnc_wrzofsr Write work zero offset (range specified)
cnc_rdparam Read parameter
cnc_wrparam Write parameter
cnc_rdparar Read parameters (range specified)
cnc_wrparas Write parameters (multiple output)
cnc_rdset Read setting parameter
cnc_wrset Write setting parameter
cnc_rdsetr Read setting parameters (range specified)
cnc_wrsets Write setting parameters (multiple output)
cnc_rdpitchr Read pitch error compensation data (range specified)
cnc_wrpitchr Write pitch error compensation data (range specified)
cnc_rdmacro Read custom macro variable
cnc_wrmacro Write custom macro variable
cnc_rdmacror Read custom macro variables (range specified)
cnc_wrmacror Write custom macro variables (range specified)
cnc_rdpmacro Read P-code macro variable
cnc_wrpmacro Write P-code macro variable
cnc_rdpmacror Read P-code macro variables (range specified)
cnc_wrpmacror Write P-code macro variables (range specified)
cnc_diagnoss Read diagnostics data
cnc_diagnosr Read diagnostics data (range specified)
cnc_adcnv Read A/D conversion data
cnc_rdopmsg Read operator's message
cnc_setpath Set path index (2-path system (T series))
cnc_getpath Get path index (2-path system (T series))
cnc_settimer Set calendar timer of CNC
cnc_rdspload Read load information of serial spindle
cnc_rdexecprog Read executing program
cnc_rdmovrlap Read manual overlapped motion value
cnc_getfigure Read the maximum number of significant figures and the number of decimal places
cnc_rdtofsinfo Read tool offset information
cnc_seqsrch Search for sequence number
cnc_wrrelpos Clear or preset relative position of controlled axis
cnc_acts2 Read actual spindle speed (S) (multiple spindles allowed, read of specified axis)
cnc_rdwkcdshft Read workpiece coordinate system shift
cnc_wrwkcdshft Write workpiece coordinate system shift
cnc_rdpdf_drive Read program storage drive information
cnc_rdpdf_inf Read program storage file information
cnc_rdpdf_curdir Read current directory information
cnc_wrpdf_curdir Set current directory
cnc_rdpdf_subdir Read subdirectory information

- 25 -
4.C Language Library function list SPECIFICATION B-64303EN-3/01

NAME FUCNTION
cnc_rdpdf_alldir Read file list information
cnc_pdf_add Create directory or file
cnc_pdf_del Delete directory or file
cnc_pdf_rename Rename directory or file
cnc_pdf_slctmain Select main program
cnc_pdf_cond Consolidate programs
cnc_wrpdf_attr Change attribute of directory or file
cnc_rdpdf_subdirn Get the number of directories and files in specified directory
cnc_pdf_rdmain Get main program information
cnc_information Get CNC information
cnc_rdsyssoft3 Read series and edition of CNC system software (3)
cnc_dwnstart4 Start output of NC program to be registered (4)
cnc_download4 Output NC program to be registered (4)
cnc_dwnend4 Stop output of NC program to be registered (4)
cnc_upstart4 Start reading NC program (4)
cnc_upload4 Read NC program (4)
cnc_upend4 Stop reading NC program (4)
cnc_rdpitchinfo Read pitch error compensation data information
cnc_rdmacroinfo Read custom macro variable information
cnc_rdsetinfo Read setting parameter information
cnc_rddiaginfo Read diagnostics data information
Read the minimum parameter number, maximum parameter number, and total
cnc_rdparanum
number of parameters
Read the minimum setting parameter number, maximum setting parameter number,
cnc_rdsetnum
and total number of setting parameters
Read the minimum diagnostics data number, maximum diagnostics data number,
cnc_rddiagnum
and total number of diagnostics data items
cnc_rdnspdl Read the number of spindles
cnc_rdprogdir2 Read the number of spindles (2)
cnc_rdaxisname Read axis name
cnc_rdposition Read position information
cnc_rdspeed Read speed information
cnc_rdsvmeter Read servo load meter
cnc_rdspmeter Read spindle load meter
cnc_rdgcode Read modal G code
cnc_rdcommand Read command value
cnc_alarm2 Read alarm status (2)
cnc_rdopmsg2 Read operator's message (2)
cnc_rdopmsg3 Read operator's message (3)
cnc_rdspdlname Read spindle name
cnc_rdprogdir3 Read program directory (3)
cnc_rdtofsinfo2 Read tool offset information (2)

- 26 -
B-64303EN-3/01 SPECIFICATION 4.C Language Library function list

NAME FUCNTION
cnc_rdmacror2 Read custom macro variables (double-precision floating point)
cnc_wrmacror2 Write custom macro variables (double-precision floating point)
cnc_rdaxisdata Read controlled axis/spindle-related data
cnc_dncstart2 Start output of NC program for operation (2)
cnc_dnc2 Output NC program for operation (2)
cnc_dncend2 Stop output of NC program for operation (2)
cnc_loadtorq Read abnormal load torque data
cnc_rdsyshard Read CNC hardware configuration information
cnc_sysinfo_ex Read CNC system information (2)
cnc_machine3 Read machine position of controlled axis (3)
cnc_rdjogdrun Read jogging speed or dry run speed
cnc_rdpmacror2 Read P-code macro variables (double-precision floating point)
cnc_wrpmacror2 Write P-code macro variables (double-precision floating point)
cnc_rdalmmsg Read all alarm messages at once
cnc_rdalmmsg2 Read alarm message (extended message string)
cnc_rdprogdir4 Read program directory (4)
cnc_stopophis Stop history data sampling
cnc_startophis Resume history data sampling
cnc_rdophisno Read the number of operation history data items
cnc_rdophisno3 Read the number of operation history data items (3)
cnc_rdophistry4 Read operation history data (4)
cnc_clearophis Clear history data
cnc_rdhissgnl3 Read signal to be included in operation history (3)
cnc_wrhissgnl3 Set signal to be included in operation history (3)
cnc_rdalmhisno3 Read the number of alarm history data items (3)
cnc_rdalmhistry5 Read alarm history data (5)
cnc_rdomhisno Read the number of external operator's message history data items
cnc_rdomhistry2 Read external operator's message history data (2)
cnc_rdgrpid Read tool life management data (tool group number)
cnc_rdngrp Read tool life management data (number of tool groups)
cnc_rdntool Read tool life management data (number of tools)
cnc_rdlife Read tool life management data (tool life)
cnc_rdcount Read tool life management data (tool life counter)
cnc_rd1length Read tool life management data (tool length compensation number 1)
cnc_rd2length Read tool life management data (tool length compensation number 2)
cnc_rd1radius Read tool life management data (tool radius compensation number 1)
cnc_rd2radius Read tool life management data (tool radius compensation number 2)
cnc_t1info Read tool life management data (tool information 1)
cnc_t2info Read tool life management data (tool information 2)
cnc_toolnum Read tool life management data (tool number)
Read tool life management data (number of tools, tool life, life counter)(range
cnc_rdtoolrng
specified)

- 27 -
4.C Language Library function list SPECIFICATION B-64303EN-3/01

NAME FUCNTION
cnc_rdtoolgrp Read all tool life management data in group at once
cnc_wrcountr Write tool life management data (life counter) (range specified)
cnc_wrtoolgrp Register tool life management data (tool group)
cnc_wrlife Write tool life management data (tool life)
cnc_wrcount Write tool life management data (life counter)
cnc_wrcnttype Write tool life management data (life counter type)
cnc_wr1length Write tool life management data (tool length compensation number 1)
cnc_wr2length Write tool life management data (tool length compensation number 2)
cnc_wr1radius Write tool life management data (tool radius compensation number 1)
cnc_wr2radius Write tool life management data (tool radius compensation number 2)
cnc_wrt1info Write tool life management data (tool information 1)
cnc_wrt2info Write tool life management data (tool information 2)
cnc_wrtoolnum Write tool life management data (tool number)
cnc_rdcnttype Read tool life management data (tool life counter type)
cnc_rdusegrpid Read tool life management data (number of tool group being used or to be used)
Read tool life management data (maximum number of tool groups that can be
cnc_rdmaxgrp
registered)
Read tool life management data (maximum number of tools that can be registered
cnc_rdmaxtool
in group)
cnc_rdusetlno Read tool life management data (ordinal number of tool to be used in group)
cnc_rd1tlifedata Read tool life management data (tool data 1)
cnc_rd1tlifedat2 Read tool life management data (tool data 1) (2)
cnc_rd2tlifedata Read tool life management data (tool data 2)
cnc_wr1tlifedata Write tool life management data (tool data 1)
cnc_wr1tlifedat2 Write tool life management data (tool data 1) (2)
cnc_wr2tlifedata Write tool life management data (tool data 2)
cnc_rdgrpinfo Read tool life management data (tool group information)
cnc_rdgrpinfo4 Read tool life management data (tool group information 4)
cnc_wrgrpinfo Write tool life management data (tool group information)
cnc_deltlifegrp Delete tool life management data (tool group information)
cnc_instlifedt Add tool life management data (tool data)
cnc_deltlifedt Delete tool life management data (tool data)
cnc_clrcntinfo Clear tool life management data (life counter, tool information) (range specified)
Read tool life management data (maximum number of groups that can be
cnc_rdtlinfo registered/maximum number of tools that can be registered in group/maximum tool
life value)
cnc_rdtlgrp Read tool life management data (tool group information)
cnc_rdtltool Read tool life management data (tool information)
cnc_rdgrpid2 Read tool life management data (tool group number) (2)
cnc_rdcntover Read tool life management data (count override)
cnc_getdtailerr Get CNC error details
cnc_wrmdiprog Write MDI program

- 28 -
B-64303EN-3/01 SPECIFICATION 4.C Language Library function list

NAME FUCNTION
cnc_rdmdipntr Read execution pointer for MDI operation
cnc_wrmdipntr Write execution pointer for MDI operation
cnc_statinfo2 Read CNC status information (2)
cnc_rdparainfo Read parameter data information
cnc_rdpdf_line Read program on a line-by-line basis
cnc_wrpdf_line Write program on a line-by-line basis
cnc_pdf_delline Delete program on a line-by-line basis
cnc_pdf_rdactpt Get program execution pointer
cnc_pdf_wractpt Set program execution pointer

(2) PMC window

NAME FUCNTION
pmc_rdpmcrng Read arbitrary PMC data (range specified)
pmc_wrpmcrng Write arbitrary PMC data (range specified)
pmc_rdpcmsg Read PMC message
pmc_get_current_pmc_unit Get the unit type of PMC currently being operated
pmc_get_number_of_pmc Get the number of PMC paths
pmc_get_pmc_unit_types Get PMC unit types
pmc_select_pmc_unit Select PMC unit to be operated
pmc_getpmcptr Get PMC memory address information
pmc_isvalidpmcptr Validate PMC memory address information
pmc_rdpmcchar Read 1-byte signed data from PMC memory
pmc_rdpmcshort Read 2-byte signed data from PMC memory
pmc_rdpmclong Read 4-byte signed data from PMC memory
pmc_wrpmcchar Write 1-byte signed data to PMC memory
pmc_wrpmcshort Write 2-byte signed data to PMC memory
pmc_wrpmclong Write 4-byte signed data to PMC memory
pmc_rdpmcinfo Read arbitrary PMC data (range specified)

- 29 -
4.C Language Library function list SPECIFICATION B-64303EN-3/01

4.5 Other libraries

(1) MDI operation library

These functions are used to control key input from CNC's MDI panel.

NAME FUCNTION
aux_mdi_getmatrix Get MDI key matrix
aux_mdi_putmatrix Put MDI key matrix
aux_mdi_rstmatrix Reset MDI key matrix
aux_mdi_altmatrix Alter MDI key matrix
aux_mdi_putc Put one character to key input buffer
aux_mdi_write Write block data to key input buffer
aux_mdi_control Test or control key input buffer
aux_mdi_repeat Set key repeating interval time
aux_mdi_getstat Read inputting status of MDI key.
aux_mdi_clrbuf Clear input buffer of MDI key.

(2) CRT operation library

These functions are used to control CRT display and multiple window display.

NAME FUCNTION
crt_getcurscrn Get current screen index
crt_setuserscrn Register user screen index
crt_isnewscrn Test screen switching status
crt_gettype Set CRT information
crt_setmode Set CRT screen mode
crt_cncscrn Switch to CNC screen
crt_fchar Output character by FANUC character code
crt_setuserskey Customize softkey on CNC screen
crt_setswt Set switching method between CNC's screen and user's
crt_setscrlarea Set scroll area
crt_opengr Open graphic display
crt_closegr Close graphic display
crt_graphic Enable or disable graphic display
crt_readfkey Read the status of function keys
crt_2ndcursor Display the secondary cursor
crt_settextattr Set attribute of characters on VRAM
crt_gettextattr Get attribute of character on VRAM
crt_setpalette Set color palette of VGA characters
crt_setallpalette Set all color palette of VGA characters
crt_getcncpalette Get color palette of CNC screen

- 30 -
B-64303EN-3/01 SPECIFICATION 4.C Language Library function list

NAME FUCNTION
crt_fstr Output character string by FANUC character code.
crt_gettextimg Get text data from VRAM.
crt_puttextimg Put text data into VRAM.
crt_setgraphpage Select graphics page to use.
crt_set6chmode Select drawing method of 6x sized character.
win_open Open window
win_close Close window
win_select Select window
win_activate Activate window
win_move Move window
win_size Alter window size
win_full Let active window be full screen size
win_window Let active window be window size
win_info Set window information
win_col Set color of window frame and title string
win_hide Hide window
win_show Show window
win_setttl Set window title string
win_setfrm Set window frame line character
win_getstat Get window display status
win_redraw Redraw windows.
crt_reguserchar Register user character
crt_mapuch Map user character
crt_getcgpttn Get CG pattern
vwin_open Open VGA window
vwin_close Close VGA window
vwin_select Select VGA window
vwin_show Show VGA window
vwin_hide Hide VGA window
vwin_info Get VGA window information

(3) File operation library

This function is used to maintain file device.

NAME FUCNTION
aux_file_format Format specified drive
aux_file_mount Mount memory card
aux_file_unmount Unmount memory card
aux_file_memcinfo Get memory card information

- 31 -
4.C Language Library function list SPECIFICATION B-64303EN-3/01

(4) Serial communication library

These functions are used to communicate with peripherals via reader/puncher interface
(RS-232C).

NAME FUCNTION
rs_open Initialize communication device
rs_close Terminate communication
rs_putc Put one character to communication buffer
rs_getc Get one character from communication buffer
rs_write Write block data to communication buffer
rs_read Read block data from communication buffer
rs_buffer Test or control communication buffer
rs_status Get status of communication line and buffer
rs_wait Wait communication event

(5) Task control library

These functions are used to control task execution.

NAME FUCNTION
os_show_tim Read timer
os_set_tim Set timer
os_sync_tim Wait until specified time
os_wait_tim Wait until specified term
os_make_flg Make event flag
os_delt_flg Delete event flag
os_sign_flg Signal event flag
os_wait_flg Wait event flag signal
os_clar_flg Clear event flag
os_puls_flg Signal event flag (pulse type)
os_make_sem Make counter-type semaphore
os_delt_sem Delete semaphore
os_sign_sem Signal semaphore
os_wait_sem Wait semaphore signal
os_strt_wtsk Start window task

- 32 -
B-64303EN-3/01 SPECIFICATION 4.C Language Library function list

(6) FCA library

These are the functions which communicate with FCA (FANUC CASSETTE ADAPTOR) or FANUC Handy
File.

NAME FUCNTION
fca_setparam Initialize communication line
fca_bye Close communication line
fca_open Open a binary file on FCA device
fca_close Close a binary file
fca_read Read binary data from the file
fca_write Write binary data to the file
fca_fopen Open a text file on FCA device
fca_fclose Close a text device
fca_getc Read a character from the text file
fca_putc Write a character to the text file
fca_delete Delete a file on FCA device
fca_rename Change name of a file on FCA device
fca_readdir Read directory information of FCA device
fca_status Read status information of FCA device
fca_remains Read free space size of a floppy disk

(7) F-ROM library

These are the functions which read C Language Executor data stored in the flash ROM module.

NAME FUCNTION
aux_from_open Open the specified F-ROM file
aux_from_close Close the F-ROM file
aux_from_select Select data in the F-ROM file
aux_from_moveptr Move read pointer
aux_from_read Read data from the F-ROM file
aux_from_getdir Read directory information of a F-ROM file
aux_from_getinfo Read F-ROM file information
aux_from_getc Read a character from the F-ROM file
aux_from_gets Read a line from the F-ROM file

(8) Touch-panel library

This is the function which reads the status and (X,Y) coordinate of the touch-panel.

NAME FUCNTION
aux_tpl_read Read the status and (X,Y) coordinate of touch-panel
aux_tpl_invalskey Disable output of key codes of soft keys with the touch-panel

- 33 -
II. PROGRAMMING
B-64303EN-3/01 PROGRAMMING 1.List of Functions

1 List of Functions
(abbreviation) CExe : C Language Executor
ANSI : American National Standards Institute
MS-C : Microsoft Corp. MS-C Ver 6.0, Ver 7.0 or Ver 8.0
(mark) ○ : available
× : not available
M : available only on Main task
MA : available on Main task and Alarm task
MAC : available on Main task, Alarm task and Communication task

For the functions that can be used in a window task, see Section 5.6, "Window task" in II.
For the functions that can be used in a high level task, see Section 5.8, "High-Level task" in
II.

- 37 -
1.List of Functions PROGRAMMING B-64303EN-3/01

1.1 ANSI C Standard library

C language standard functions which are prescribed in ANSI.

(1) Diagnostics ( assert.h )

NAME CExe ANSI MS-C


assert M ○ ○

(2) Character handling ( ctype.h )

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


isalnum MAC ○ ○ ispunct MAC ○ ○
isalpha MAC ○ ○ isspace MAC ○ ○
iscntrl MAC ○ ○ isupper MAC ○ ○
isdigit MAC ○ ○ isxdigit MAC ○ ○
isgraph MAC ○ ○ tolower MAC ○ ○
islower MAC ○ ○ toupper MAC ○ ○
isprint MAC ○ ○

(3) Localization ( local.h )

NAME CExe ANSI MS-C


localeconv × ○ ○
setlocale × ○ ○

- 38 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

(4) Mathematics ( math.h )

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


acos MAC ○ ○ frexp MAC ○ ○
asin MAC ○ ○ ldexp MAC ○ ○
atan MAC ○ ○ log MAC ○ ○
atan2 MAC ○ ○ log10 MAC ○ ○
cos MAC ○ ○ modf MAC ○ ○
sin MAC ○ ○ pow MAC ○ ○
tan MAC ○ ○ sqrt MAC ○ ○
cosh MAC ○ ○ ceil MAC ○ ○
sinh MAC ○ ○ fabs MAC ○ ○
tanh MAC ○ ○ floor MAC ○ ○
exp MAC ○ ○ fmod MAC ○ ○

(5) Non-local jumps ( setjmp.h )

NAME CExe ANSI MS-C


setjmp MAC ○ ○
longjmp MAC ○ ○

(6) Signal handling ( signal.h )

NAME CExe ANSI MS-C


signal × ○ ○
raise × ○ ○

(7) Valiable arguments ( stdarg.h )

NAME CExe ANSI MS-C


va_start MAC ○ ○
va_arg MAC ○ ○
va_end MAC ○ ○

- 39 -
1.List of Functions PROGRAMMING B-64303EN-3/01

(8) Input/output ( stdio.h )

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


remove MAC ○ ○ fputc MAC ○ ○
rename MAC ○ ○ fputs MAC ○ ○
tmpfile × ○ ○ getc M ○ ○
tmpnam MAC ○ ○ getchar M ○ ○
fclose MAC ○ ○ gets M ○ ○
fflush MAC ○ ○ putc M ○ ○
fopen MAC ○ ○ putchar M ○ ○
freopen MAC ○ ○ puts M ○ ○
setbuf MAC ○ ○ ungetc MAC ○ ○
setvbuf MAC ○ ○ fread MAC ○ ○
fprintf MAC ○ ○ fwrite MAC ○ ○
fscanf MAC ○ ○ fgetpos MAC ○ ○
printf M ○ ○ fseek MAC ○ ○
scanf M ○ ○ fsetpos MAC ○ ○
sprintf MAC ○ ○ ftell MAC ○ ○
sscanf MAC ○ ○ rewind MAC ○ ○
vfprintf MAC ○ ○ clearer MAC ○ ○
vprintf M ○ ○ feof MAC ○ ○
vsprintf MAC ○ ○ ferror MAC ○ ○
fgetc MAC ○ ○ perror M ○ ○
fgets MAC ○ ○

(9) General utilities ( stdlib.h )

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


atof MAC ○ ○ exit × ○ ○
atoi MAC ○ ○ getenv × ○ ○
atol MAC ○ ○ system × ○ ○
strtod MAC ○ ○ bsearch MAC ○ ○
strtol MAC ○ ○ qsort MAC ○ ○
strtoul MAC ○ ○ abs MAC ○ ○
rand MAC ○ ○ div MAC ○ ○
srand MAC ○ ○ labs MAC ○ ○
calloc MAC ○ ○ ldiv MAC ○ ○
free MAC ○ ○ mblen × ○ ×
malloc MAC ○ ○ mbtowc × ○ ×
realloc MAC ○ ○ wctomb × ○ ×
abort × ○ ○ mbstowcs × ○ ×
atexit × ○ ○ wcstombs × ○ ×

- 40 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

(10) String handling ( string.h )

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


memcpy MAC ○ ○ memchr MAC ○ ○
memmove MAC ○ ○ strchr MAC ○ ○
strcpy MAC ○ ○ strcspn MAC ○ ○
strncpy MAC ○ ○ strpbrk MAC ○ ○
strcat MAC ○ ○ strrchr MAC ○ ○
strncat MAC ○ ○ strspn MAC ○ ○
memcmp MAC ○ ○ strstr MAC ○ ○
strcmp MAC ○ ○ strtok MAC ○ ○
strcoll × ○ ○ memset MAC ○ ○
strncmp MAC ○ ○ strerror × ○ ○
strxfrm × ○ ○ strlen MAC ○ ○

(11) Date and time ( time.h )

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


clock MAC ○ ○ ctime MAC ○ ○
difftime MAC ○ ○ gmtime MAC ○ ○
mktime MAC ○ ○ localtime MAC ○ ○
time MAC ○ ○ strftime × ○ ○
asctime MAC ○ ○

- 41 -
1.List of Functions PROGRAMMING B-64303EN-3/01

1.2 MS-C extended C standard library

Compatible functions with extended library of Microsoft C Compiler (MS-C Ver 6.0).
NAME CExe ANSI MS-C NAME CExe ANSI MS-C
FP_OFF × × ○ _fstrcmp MAC × ○
FP_SEG × × ○ _fheapset × × ○
_atold × × ○ _fheapwalk × × ○
_bcalloc × × ○ _fjstradv × × ○
_beginthread × × ○ _fjstrchr × × ○
_bexpand × × ○ _fjstrcmp × × ○
_bfree × × ○ _fjstrcspn × × ○
_bfreeseg × × ○ _fjstricmp × × ○
_bheapadd × × ○ _fjstrlen × × ○
_bheapchk × × ○ _fjstrlwr × × ○
_bheapmin × × ○ _fjstrmatch × × ○
_bheapseg × × ○ _fjstrncat × × ○
_bheapset × × ○ _fjstrncmp × × ○
_bheapwalk × × ○ _fjstrncpy × × ○
_bmalloc × × ○ _fjstrnicmp × × ○
_bmsize × × ○ _fjstrnset × × ○
_brealloc × × ○ _fjstrrchr × × ○
_cexit × × ○ _fjstrrev × × ○
_c_exit × × ○ _fjstrset × × ○
_chain_intr × × ○ _fjstrskip × × ○
_chdrive MAC × ○ _fjstrspn × × ○
_clear87 × × ○ _fjstrstr × × ○
_control87 × × ○ _fjstrtok × × ○
_disable × × ○ _fjstrupr × × ○
_dos_findfirst MAC × ○ _fmalloc MAC × ○
_dos_findnext MAC × ○ _fmemccpy × × ○
_dos_getdiskfree MAC × ○ _fmemchr MAC × ○
_enable × × ○ _fmemcmp MAC × ○
_endthread × × ○ _fmemcpy MAC × ○
_exit × × ○ _fmemicmp MAC × ○
_expand MAC × ○ _fmemmove MAC × ○
_fbtom × × ○ _fmemset MAC × ○
_fcalloc MAC × ○ _fmsize MAC × ○
_fexpand MAC × ○ _fmtob × × ○
_ffree MAC × ○ _fnthctype × × ○
_fheapchk × × ○ _fpreset × × ○
_fheapmin × × ○ _frealloc MAC × ○
_fstrchr MAC × ○ _freect × × ○

- 42 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


_fsopen × × ○ _memmax × × ○
_fstrcat MAC × ○ _msize MAC × ○
_nmsize × × ○ _ncalloc × × ○
_nrealloc × × ○ _nexpand × × ○
_fstrcpy MAC × ○ _nfree × × ○
_fstrcspn MAC × ○ _nheapchk × × ○
_fstrdup × × ○ _nheapmin × × ○
_fstricmp MAC × ○ _nstrdup × × ○
_fstrlen MAC × ○ _pclose × × ○
_fstrlwr MAC × ○ _pipe × × ○
_fstrncat MAC × ○ _popen × × ○
_fstrncmp MAC × ○ _rotl MAC × ○
_fstrncpy MAC × ○ _rotr MAC × ○
_fstrnicmp MAC × ○ _searchenv × × ○
_fstrnset MAC × ○ _spilitpath × × ○
_fstrpbrk MAC × ○ _status87 × × ○
_fstrrchr MAC × ○ _strdate × × ○
_fstrrev MAC × ○ _strerror × × ○
_fstrset MAC × ○ _strtime × × ○
_fstrspn MAC × ○ _strtold × × ○
_fstrstr MAC × ○ _tolower MAC × ○
_fstrtok MAC × ○ _toupper MAC × ○
_fstrupr MAC × ○ _y0l × × ○
_fullpath × × ○ _y1l × × ○
_getdcwd × × ○ _ynl × × ○
_getdrive MAC × ○ access × × ○
_harder × × ○ acosl × × ○
_hardresume × × ○ alloca MAC × ○
_hardretn × × ○ asinl × × ○
_heapadd × × ○ atanl × × ○
_heapchk × × ○ atan2l × × ○
_heapmin × × ○ bdos × × ○
_heapset × × ○ btom MAC × ○
_heapwalk × × ○ cabs MAC × ○
_j0l × × ○ cabsl × × ○
_j1l × × ○ ceill × × ○
_jnl × × ○ cgets × × ○
_lrotl MAC × ○ chdir MAC × ○
_lrotr MAC × ○ chkctype MAC × ○
_makepath × × ○ chmod × × ○
_matherrl × × ○ chsize × × ○
_memavl × × ○ close MAC × ○

- 43 -
1.List of Functions PROGRAMMING B-64303EN-3/01

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


coshl × × ○ getcwd MAC × ○
cosl × × ○ getpid × × ○
cprintf × × ○ getw × × ○
cputs × × ○ halloc × × ○
creat MAC × ○ hantozen MAC × ○
cscanf × × ○ hfree × × ○
cwait × × ○ hypot MAC × ○
dieeetomsbin × × ○ hypotl × × ○
dmsbintoieee × × ○ inp × × ○
dosexterr × × ○ inpw × × ○
_nheapset × × ○ int86 × × ○
_nheapwalk × × ○ int86x × × ○
_nmalloc × × ○ intdos × × ○
eof MAC × ○ dup × × ○
execl × × ○ dup2 × × ○
execle × × ○ ecvt MAC × ○
execlp × × ○ iskana MAC × ○
execlpe × × ○ iskanji MAC × ○
execv × × ○ iskanji2 MAC × ○
execve × × ○ iskmoji MAC × ○
execvp × × ○ iskpun MAC × ○
execvpe × × ○ ispnkana MAC × ○
expl × × ○ isprkana MAC × ○
fabsl × × ○ itoa MAC × ○
fcloseall × × ○ j0 × × ○
fcvt MAC × ○ j1 × × ○
dopen × × ○ jisalpha MAC × ○
fgetchar × × ○ jisdigit MAC × ○
fieeetomsbin × × ○ jishira MAC × ○
filelength × × ○ jiskata MAC × ○
fileno × × ○ jiskigou MAC × ○
floorl × × ○ jisl0 MAC × ○
flushall × × ○ jisl1 MAC × ○
fmodl × × ○ jisl2 MAC × ○
fmsbintoieee × × ○ jislower MAC × ○
fputchar × × ○ jisprint MAC × ○
frexpl × × ○ jisspace MAC × ○
fstat × × ○ jistojms MAC × ○
ftime × × ○ jisupper MAC × ○
gcvt MAC × ○ jiszen MAC × ○
getch M × ○ jmstojis MAC × ○
getche × × ○ jn × × ○

- 44 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

NAME CExe ANSI MS-C NAME CExe ANSI MS-C


jstradv × × ○ movedata × × ○
jstrchr × × ○ mtob MAC × ○
jstrcmp × × ○ nthctype MAC × ○
jstrcspn × × ○ onexit (atexit) × × ○
jstricmp × × ○ open MAC × ○
jstrlen × × ○ outp × × ○
jstrlwr × × ○ outpw × × ○
jstrmatch × × ○ powl × × ○
jstrncat × × ○ putch × × ○
jstrncmp × × ○ putenv × × ○
jstrncpy × × ○ putw × × ○
jstrnicmp × × ○ read MAC × ○
jstrnset × × ○ rmdir MAC × ○
jstrrchr × × ○ rmtmp × × ○
jstrrev × × ○ jstrskip × × ○
jstrset × × ○ jstrspn × × ○
intdosx × × ○ jstrstr × × ○
isalkana MAC × ○ jstrtok × × ○
isalnmkana MAC × ○ jstrupr × × ○
isascii MAC × ○ jtohira MAC × ○
satty × × ○ jtokata MAC × ○
iscsym × × ○ jtolower MAC × ○
iscsymf × × ○ spawnlpe × × ○
isgrkana MAC × ○ spawnv × × ○
jtoupper MAC × ○ spawnve × × ○
kbhit M × ○ spawnvp × × ○
ldexpl × × ○ spawnvpe × × ○
lfind × × ○ sqrtl × × ○
locking × × ○ stackavail MAC × ○
logl × × ○ stat × × ○
log10l × × ○ strcmpi MAC × ○
lsearch × × ○ strdup × × ○
lseek MAC × ○ stricmp MAC × ○
ltoa MAC × ○ strlwr MAC × ○
matherr × × ○ strnicmp MAC × ○
max × × ○ strnset MAC × ○
memccpy × × ○ strrev MAC × ○
memicmp MAC × ○ strset MAC × ○
min × × ○ strupr MAC × ○
mkdir MAC × ○ swab MAC × ○
mktemp × × ○ tanl × × ○
modfl × × ○ tanhl × × ○

- 45 -
1.List of Functions PROGRAMMING B-64303EN-3/01

NAME CExe ANSI MS-C


tell MAC × ○
tempnam × × ○
toascii MAC × ○
tzset × × ○
u_strtoldltoa × × ○
ultoa MAC × ○
umask × × ○
ungetch × × ○
unlink × × ○
utime × × ○
wait × × ○
write MAC × ○
segread × × ○
setmode × × ○
sinhl × × ○
sinl × × ○
sopen × × ○
spawnl × × ○
spawnle × × ○
spawnlp × × ○
y0 × × ○
y1 × × ○
yn × × ○
zentohan MAC × ○

- 46 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

1.3 Graphic library

(1) MS-C compatible graphic functions

Compatible functions with a part of graphic library of Microsoft C Compiler (MS-C Ver 6.0).

NAME CExe FUNCTION


_arc M Draw an arc or an elliptic arc.
_clearscreen M Clear screen.
_ellipse M Draw a circle or an ellipse.
_floodfill M Paint the closed region.
_getactivepage M Get the current active page number.
_getarcinfo M Get the information of the previous arc or pie.
_getbkcolor M Get the current back ground color.
_getcolor M Get the current fore ground color.
_getcurrentposition M Get the current position in the view coordinate.
_getfillmask M Get the current fill mask pattern.
_getfontinfo M Get the current font information.
_getgtextextent M Get the text extent by pixel unit.
_getgtextvector M Get the output vector of text.
_getimage M Get screen image.
_getkanji M Get the font pattern of Kanji character.
_getlinestyle M Get the current line style.
_getphyscoord M Convert view coordinate into physical.
_getpixel M Get color number the pixel.
_gettextposition M Get the current output position of text.
_gettextwindow M Get the text window border.
_getvideoconfig M Get the graphic configuration.
_getviewcoord M Convert physical coordinate into view.
_getvisualpage M Get the current visual page number.
_getwritemode M Get the current writing mode.
_grstatus M Get the return status of graphic function.
_imagesize M Get image buffer size.
_kanjisize M Get font pattern size of Kanji character.
_lineto M Draw a line.
_moveto M Move the current graphic output position.
_outgtext M Draw a text string using the current font.
_outmem M Draw a text string in a memory.
_outtext M Output a text string in the current position.
_pie M Draw a pie figure.
_polygon M Draw a polygon.
_putimage M Put image data on the screen.
_rectangle M Draw a rectangle.

- 47 -
1.List of Functions PROGRAMMING B-64303EN-3/01

NAME CExe FUNCTION


_registerfonts M Register font file.
_remapallpalette M Map colors into all color palette.
_remappalette M Map a color into a color palette.
_setactivepage M Set the current active page number.
_setbkcolor M Set the current back ground color.
_setcliprgn M Set the clipping region.
_setcolor M Set the current fore ground color.
_setfillmask M Set the current fill mask pattern.
_setfont M Set the current font.
_setgtextvector M Set the current output vector of text.
_setlinestyle M Set the current line style.
_setpixel M Draw a pixel.
_settextposition M Set the current output position of text.
_settextrows M Set the text row number.
_settextwindow M Set the text window.
_setvideomode M Set the screen video mode.
_setvideomoderows M Set the screen video mode and text row number.
_setvieworg M Set the origin of the view port.
_setviewport M Set the clipping region and the view coordinate.
_setvisualpage M Set the current visual page number.
_setwritemode M Set the current writing mode.
_unregisterfonts M Delete registered font file.
_wrapon M Enable/disable line wrapping.

- 48 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

(2) C Language Executor original graphic functions

These are graphic drawing functions specific to the C Language Executor.

NAME CExe FUNCTION


gr_displaychar M Draw a standard size character.
gr_displayfourlarge M Draw a quad size character.
gr_displaysixlarge M Draw a hex size character.
_putpattern M Put monochrome image data.
_getpattern M Get monochrome image data.
gr_dispstr M Draw a standard size string.
gr_disp6str M Draw a hex size string.
gr_bitblt M Copy image data.
gr_disp4str M Draw a quad size string.
gr_displaysmlchar M Draw a small size character.
gr_dispsstr M Draw a small size string.
gr_displayfchar M Draw a FANUC character.
gr_dispfstr M Draw a FANUC character string.
gr_disp9ifchar M Draw 9-inch font character.
gr_disp9ifstr M Draw 9-inch font character string.
mmc_line_b M Draw a line between specified two points.
mmc_polyline M Draw a polyline.
mmc_circle_b M Draw a circle.
mmc_ellipse_b M Draw an ellipse.
mmc_pie_b M Draw a pie figure.
mmc_arc_b M Draw an arc.
mmc_gettext M Get character in the specified area.
mmc_puttext M Put character data on memory to text screen.
mmc_textsize M Get required byte size for getting character.

- 49 -
1.List of Functions PROGRAMMING B-64303EN-3/01

1.4 CNC/PMC window library

Functions whish are used to input/output data between CNC/PMC.

(1) CNC window library

NAME CExe FUNCTION


cnc_sysinfo MA Read CNC system information.
cnc_dwnstart MA Start output of NC program to be registered.
cnc_download MA Output NC program to be registered.
cnc_dwnend MA Stop output NC program to be registered.
cnc_vrfstart MA Start output NC program to be compared.
cnc_verify MA Output NC program to be compared.
cnc_vrfend MA Stop output NC program to be compared.
cnc_upstart MA Start input NC program.
cnc_upload MA Input NC program.
cnc_upend MA Stop input NC program.
cnc_search MA Search specified program.
cnc_delall MA Delete all programs.
cnc_delete MA Delete specified program.
cnc_rdprogdir MA Read program directory.
cnc_rdproginfo MA Read program information.
cnc_rdprgnum MA Read program number in executing.
cnc_rdseqnum MA Read sequence number in executing.
cnc_actf MA Read actual feed rate of controlled axes.
cnc_acts MA Read actual spindle speed.
cnc_absolute MA Read absolute position.
cnc_machine MA Read machine position.
cnc_relative MA Read relative position.
cnc_distance MA Read distance to go.
cnc_skip MA Read skipped position.
cnc_srvdelay MA Read servo delay amount.
cnc_accdecdly MA Read acceleration/deceleration delay amount.
cnc_rddynamic MA Read dynamic data.
cnc_statinfo MA Read CNC status information.
cnc_alarm MA Read alarm status.
cnc_rdalminfo MA Read alarm information.
cnc_rdtofs MA Read tool offset amount.
cnc_wrtofs MA Write tool offset amount.
cnc_rdtofsr MA Read tool offset amount (range specified).
cnc_wrtofsr MA Write tool offset amount (range specified).
cnc_rdzofs MA Read work origin offset.
cnc_wrzofs MA Write work origin offset.

- 50 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

NAME CExe FUNCTION


cnc_rdzofsr MA Read work origin offset (range specified).
cnc_wrzofsr MA Write work origin offset (range specified).
cnc_rdparam MA Read parameter.
cnc_wrparam MA Write parameter.
cnc_rdparar MA Read parameters (range specified).
cnc_wrparas MA Write parameters (multiple output).
cnc_rdset MA Read setting parameter.
cnc_wrset MA Write setting parameter.
cnc_rdsetr MA Read setting parameters (range specified).
cnc_wrsets MA Write setting parameters (multiple output).
cnc_rdpitchr MA Read pitch error compensation data(range specified).
cnc_wrpitchr MA Write pitch error compensation data(range specified).
cnc_rdmacro MA Read custom macro variable.
cnc_wrmacro MA Write custom macro variable.
cnc_rdmacror MA Read custom macro variables (range specified).
cnc_wrmacror MA Write custom macro variables (range specified).
cnc_rdpmacro MA Read P-code macro variable.
cnc_wrpmacro MA Write P-code macro variable.
cnc_rdpmacror MA Read P-code macro variables (range specified).
cnc_wrpmacror MA Write P-code macro variables (range specified).
cnc_diagnoss MA Read diagnostics data.
cnc_diagnosr MA Read diagnostics data (range specified).
cnc_adcnv MA Read A/D conversion data.
cnc_rdopmsg MA Read operator's message.
cnc_setpath MA Set path index (multi-path system).
cnc_getpath MA Get path index (multi-path system).
cnc_settimer MA Set calendar timer of CNC.
cnc_rdspload MA Read load information of serial spindle.
cnc_rdexecprog MA Read executing program.
cnc_rdmovrlap MA Read manual overlapped motion value.
Read the maximum number of significant figures and the number of
cnc_getfigure MA
decimal places.
cnc_rdtofsinfo MA Read tool offset information.
cnc_seqsrch MA Search for sequence number.
cnc_wrrelpos MA Clear or preset relative position of controlled axis.
Read actual spindle speed (S) (multiple spindles allowed, read of
cnc_acts2 MA
specified axis).
cnc_rdwkcdshft MA Read workpiece coordinate system shift.
cnc_wrwkcdshft MA Write workpiece coordinate system shift.
cnc_rdpdf_drive MA Read program storage drive information.
cnc_rdpdf_inf MA Read program storage file information.
cnc_rdpdf_curdir MA Read current directory information.

- 51 -
1.List of Functions PROGRAMMING B-64303EN-3/01

NAME CExe FUNCTION


cnc_wrpdf_curdir MA Set current directory.
cnc_rdpdf_subdir MA Read subdirectory information.
cnc_rdpdf_alldir MA Read file list information.
cnc_pdf_add MA Create directory or file.
cnc_pdf_del MA Delete directory or file.
cnc_pdf_rename MA Rename directory or file.
cnc_pdf_slctmain MA Select main program.
cnc_pdf_cond MA Consolidate programs.
cnc_wrpdf_attr MA Change attribute of folder or file.
cnc_rdpdf_subdirn MA Get the number of folders and files in specified directory.
cnc_pdf_rdmain MA Get main program information.
cnc_information MA Get CNC information.
cnc_rdsyssoft3 MA Read series and edition of CNC system software (3).
cnc_dwnstart4 MA Start output of NC program to be registered (4).
cnc_download4 MA Output NC program to be registered (4).
cnc_dwnend4 MA Stop output of NC program to be registered (4).
cnc_upstart4 MA Start reading NC program (4).
cnc_upload4 MA Read NC program (4).
cnc_upend4 MA Stop reading NC program (4).
cnc_rdpitchinfo MA Read pitch error compensation data information.
cnc_rdmacroinfo MA Read custom macro variable information.
cnc_rdsetinfo MA Read setting parameter information.
cnc_rddiaginfo MA Read diagnostics data information.
Read the minimum parameter number, maximum parameter number,
cnc_rdparanum MA
and total number of parameters.
Read the minimum setting parameter number, maximum setting
cnc_rdsetnum MA
parameter number, and total number of setting parameters.
Read the minimum diagnostics data number, maximum diagnostics
cnc_rddiagnum MA
data number, and total number of diagnostics data items.
cnc_rdnspdl MA Read the number of spindles.
cnc_rdprogdir2 MA Read program directory (2).
cnc_rdaxisname MA Read axis name.
cnc_rdposition MA Read position information.
cnc_rdspeed MA Read speed information.
cnc_rdsvmeter MA Read servo load meter.
cnc_rdspmeter MA Read spindle load meter.
cnc_rdgcode MA Read modal G code.
cnc_rdcommand MA Read command value.
cnc_alarm2 MA Read alarm status (2).
cnc_rdopmsg2 MA Read operator's message (2).
cnc_rdopmsg3 MA Read operator's message (3).
cnc_rdspdlname MA Read spindle name.

- 52 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

NAME CExe FUNCTION


cnc_rdprogdir3 MA Read program directory (3).
cnc_rdtofsinfo2 MA Read tool offset information (2).
cnc_rdmacror2 MA Read custom macro variables (double-precision floating point).
cnc_wrmacror2 MA Write custom macro variables (double-precision floating point).
cnc_rdaxisdata MA Read controlled axis/spindle-related data.
cnc_dncstart2 MA Start output of NC program for operation (2).
cnc_dnc2 MA Output NC program for operation (2).
cnc_dncend2 MA Stop output of NC program for operation (2).
cnc_loadtorq MA Read abnormal load torque data.
cnc_rdsyshard MA Read CNC hardware configuration information.
cnc_sysinfo_ex MA Read CNC system information (2).
cnc_machine3 MA Read machine position of controlled axis (3).
cnc_rdjogdrun MA Read jogging speed or dry run speed.
cnc_rdpmacror2 MA Read P-code macro variables (double-precision floating point).
cnc_wrpmacror2 MA Write P-code macro variables (double-precision floating point).
cnc_rdalmmsg MA Read all alarm messages at once.
cnc_rdalmmsg2 MA Read alarm message (extended message string).
cnc_rdprogdir4 MA Read program directory (4).
cnc_stopophis MA Stop history data sampling.
cnc_startophis MA Resume history data sampling.
cnc_rdophisno MA Read the number of operation history data items.
cnc_rdophisno3 MA Read the number of operation history data items (3).
cnc_rdophistry4 MA Read operation history data (4).
cnc_clearophis MA Clear history data.
cnc_rdhissgnl3 MA Read signal to be included in operation history (3).
cnc_wrhissgnl3 MA Set signal to be included in operation history (3).
cnc_rdalmhisno3 MA Read the number of alarm history data items (3).
cnc_rdalmhistry5 MA Read alarm history data (5)
cnc_rdomhisno MA Read the number of external operator's message history data items.
cnc_rdomhistry2 MA Read external operator's message history data (2).
cnc_rdgrpid MA Read tool life management data (tool group number).
cnc_rdngrp MA Read tool life management data (number of tool groups).
cnc_rdntool MA Read tool life management data (number of tools).
cnc_rdlife MA Read tool life management data (tool life).
cnc_rdcount MA Read tool life management data (tool life counter).
cnc_rd1length MA Read tool life management data (tool length compensation number 1).
cnc_rd2length MA Read tool life management data (tool length compensation number 2).
cnc_rd1radius MA Read tool life management data (tool radius compensation number 1).
cnc_rd2radius MA Read tool life management data (tool radius compensation number 2).
cnc_t1info MA Read tool life management data (tool information 1).
cnc_t2info MA Read tool life management data (tool information 2).
cnc_toolnum MA Read tool life management data (tool number).

- 53 -
1.List of Functions PROGRAMMING B-64303EN-3/01

NAME CExe FUNCTION


Read tool life management data (number of tools, tool life, life
cnc_rdtoolrng MA
counter)(range specified).
cnc_rdtoolgrp MA Read all tool life management data in group at once.
cnc_wrcountr MA Write tool life management data (life counter) (range specified).
cnc_wrtoolgrp MA Register tool life management data (tool group).
cnc_wrlife MA Write tool life management data (tool life).
cnc_wrcount MA Write tool life management data (life counter).
cnc_wrcnttype MA Write tool life management data (life counter type).
cnc_wr1length MA Write tool life management data (tool length compensation number 1).
cnc_wr2length MA Write tool life management data (tool length compensation number 2).
cnc_wr1radius MA Write tool life management data (tool radius compensation number 1).
cnc_wr2radius MA Write tool life management data (tool radius compensation number 2).
cnc_wrt1info MA Write tool life management data (tool information 1).
cnc_wrt2info MA Write tool life management data (tool information 2).
cnc_wrtoolnum MA Write tool life management data (tool number).
cnc_rdcnttype MA Read tool life management data (tool life counter type).
Read tool life management data (number of tool group being used or
cnc_rdusegrpid MA
to be used).
Read tool life management data (maximum number of tool groups that
cnc_rdmaxgrp MA
can be registered).
Read tool life management data (maximum number of tools that can
cnc_rdmaxtool MA
be registered in group).
Read tool life management data (ordinal number of tool to be used in
cnc_rdusetlno MA
group).
cnc_rd1tlifedata MA Read tool life management data (tool data 1).
cnc_rd1tlifedat2 MA Read tool life management data (tool data 1) (2).
cnc_rd2tlifedata MA Read tool life management data (tool data 2).
cnc_wr1tlifedata MA Write tool life management data (tool data 1).
cnc_wr1tlifedat2 MA Write tool life management data (tool data 1) (2).
cnc_wr2tlifedata MA Write tool life management data (tool data 2).
cnc_rdgrpinfo MA Read tool life management data (tool group information).
cnc_rdgrpinfo4 MA Read tool life management data (tool group information 4).
cnc_wrgrpinfo MA Write tool life management data (tool group information).
cnc_deltlifegrp MA Delete tool life management data (tool group information).
cnc_instlifedt MA Add tool life management data (tool data).
cnc_deltlifedt MA Delete tool life management data (tool data).
Clear tool life management data (life counter, tool information) (range
cnc_clrcntinfo MA
specified).
Read tool life management data (maximum number of groups that can
cnc_rdtlinfo MA be registered/maximum number of tools that can be registered in
group/maximum tool life value).
cnc_rdtlgrp MA Read tool life management data (tool group information).

- 54 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

NAME CExe FUNCTION


cnc_rdtltool MA Read tool life management data (tool information).
cnc_rdgrpid2 MA Read tool life management data (tool group number) (2).
cnc_rdcntover MA Read tool life management data (count override).
cnc_getdtailerr MA Get CNC error details.
cnc_wrmdiprog MA Write MDI program.
cnc_rdmdipntr MA Read execution pointer for MDI operation.
cnc_wrmdipntr MA Write execution pointer for MDI operation.
cnc_statinfo2 MA Read CNC status information (2).
cnc_rdparainfo MA Read parameter data information.
cnc_rdpdf_line MA Read program on a line-by-line basis.
cnc_wrpdf_line MA Write program on a line-by-line basis.
cnc_pdf_delline MA Delete program on a line-by-line basis.
cnc_pdf_rdactpt MA Get program execution pointer.
cnc_pdf_wractpt MA Set program execution pointer.

(2) PMC window library

NAME CExe FUNCTION


pmc_rdpmcrng MA Read arbitrary PMC data (range specified).
pmc_wrpmcrng MA Write arbitrary PMC data (range specified).
pmc_rdpcmsg MA Read PMC message.
pmc_get_current_pmc_unit MA Get the unit type of PMC currently being operated.
pmc_get_number_of_pmc MA Get the number of PMC paths.
pmc_get_pmc_unit_types MA Get PMC unit types
pmc_select_pmc_unit MA Select PMC unit to be operated.
pmc_getpmcptr MA Read data from extended nonvolatile memory.
pmc_isvalidpmcptr MA Write data to extended nonvolatile memory.
pmc_rdpmcchar MA Read the maximum size of extended nonvolatile memory.
pmc_rdpmcshort MA Get PMC memory address information.
pmc_rdpmclong MA Validate PMC memory address information.
pmc_wrpmcchar MA Read 1-byte signed data from PMC memory.
pmc_wrpmcshort MA Read 2-byte signed data from PMC memory.
pmc_wrpmclong MA Read 4-byte signed data from PMC memory.
pmc_rdpmcinfo MA Write 1-byte signed data to PMC memory.

- 55 -
1.List of Functions PROGRAMMING B-64303EN-3/01

1.5 Other libraries

(1) MDI operation library

These are the functions which customize key-input from MDI panel,alter key code, enable
key repeating and generate key code by the application program.

NAME CExe FUNCTION


aux_mdi_getmatrix MA Get MDI key matrix.
aux_mdi_putmatrix MA Put MDI key matrix.
aux_mdi_rstmatrix MA Reset MDI key matrix.
aux_mdi_altmatrix MA Alter MDI key matrix.
aux_mdi_putc MA Put one character to key input buffer.
aux_mdi_write MA Write block data to key input buffer.
aux_mdi_control MA Test or control key input buffer.
aux_mdi_repeat MA Set key repeating interval time.
aux_mdi_getstat MA Read inputting status of MDI key.
aux_mdi_clrbuf MA Clear input buffer of MDI key.

(2) CRT operation library

These are the functions which control CRT display and multiple window display.

NAME CExe FUNCTION


crt_getcurscrn MA Get current screen index.
crt_setuserscrn M Register user screen index.
crt_isnewscrn MA Test screen switching status.
crt_gettype MA Get CRT information.
crt_setmode MA Set CRT screen mode.
crt_cncscrn MA Switch to CNC screen.
crt_fchar M Output character by FANUC character code.
crt_setuserskey M Customize softkey on CNC screen.
crt_setswt MA Set switching method between CNC's screen and user's.
crt_setscrlarea M Set scroll area.
crt_opengr M Open graphic display.
crt_closegr M Close graphic display.
crt_graphic MA Enable or disable graphic display.
crt_readfkey MA Read the status of function keys.
crt_2ndcursor M Display the secondary cursor.
crt_settextattr M Set attribute of characters on VRAM.
crt_gettextattr M Get attribute of character on VRAM.
crt_setpalette M Set color palette of VGA characters.
crt_setallpalette M Set all color palette of VGA characters.

- 56 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

NAME CExe FUNCTION


crt_getcncpalette M Get color palette of CNC screen.
crt_fstr M Output character string by FANUC character code.
crt_gettextimg M Get text data from VRAM.
crt_puttextimg M Put text data into VRAM.
crt_setgraphpage M Select graphic page to use.
crt_set6chmode M Select drawing method of 6x sized character.
win_open M Open window.
win_close M Close window.
win_select M Select window.
win_activate M Activate window.
win_move M Move window.
win_size M Alter window size.
win_full M Let active window be full screen size.
win_window M Let active window be window size.
win_info M Get window information.
win_col M Set color of window frame and title string.
win_hide M Hide window.
win_show M Show window.
win_setttl M Set window title string.
win_setfrm M Set window frame line character.
win_getstat M Get window display status.
win_redraw M Redraw windows.
crt_reguserchar M Register user character.
crt_mapuch M Map user character.
crt_getcgpttn M Get CG pattern.
vwin_open M Open VGA window.
vwin_close M Close VGA window.
vwin_select M Select VGA window.
vwin_show M Show VGA window.
vwin_hide M Hide VGA window.
vwin_info M Get VGA window information.

- 57 -
1.List of Functions PROGRAMMING B-64303EN-3/01

(3) File operation library

These are the functions which maintain file device.

NAME CExe FUNCTION


aux_file_format M Format specified drive..
aux_file_mount MAC Mount memory card.
aux_file_unmount MAC Unmount memory card.
aux_file_memcinfo MAC Get memory card information.

(4) Serial communication library

These are the functions which communicate with peripherals via reader/puncher interface
(RS-232C).

NAME CExe FUNCTION


rs_open MAC Initialize communication device.
rs_close MAC Terminate communication.
rs_putc MAC Put one character to communication buffer.
rs_getc MAC Get one character from communication buffer.
rs_write MAC Write block data to communication buffer.
rs_read MAC Read block data from communication buffer.
rs_buffer MAC Test or control communication buffer.
rs_status MAC Get status of communication line and buffer.
rs_wait MAC Wait communication event.

- 58 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

(5) Task control library

These are the functions which control task execution.

NAME CExe FUNCTION


os_show_tim MAC Read timer.
os_set_tim MAC Set timer.
os_sync_tim MAC Wait until specified time.
os_wait_tim MAC Wait until specified term.
os_make_flg MAC Make event flag.
os_delt_flg MAC Delete event flag.
os_sign_flg MAC Signal event flag.
os_wait_flg MAC Wait event flag signal.
os_clar_flg MAC Clear event flag.
os_puls_flg MAC Signal event flag. (pulse type)
os_make_sem MAC Make counter-type semaphore.
os_delt_sem MAC Delete semaphore.
os_sign_sem MAC Signal semaphore.
os_wait_sem MAC Wait semaphore signal.
os_strt_wtsk M Start window task.

(6) FCA library

These are the functions which communicate with FCA (FANUC CASSETTE ADAPTOR) or FANUC Handy
File.

NAME CExe FUNCTION


fca_setparam MAC Initialize communication line.
fca_bye MAC Close communication line.
fca_open MAC Open a binary file on FCA device.
fca_close MAC Close a binary file.
fca_read MAC Read binary data from the file.
fca_write MAC Write binary data to the file.
fca_fopen MAC Open a text file on FCA device.
fca_fclose MAC Close a text device.
fca_getc MAC Read a character from the text file.
fca_putc MAC Write a character to the text file.
fca_delete MAC Delete a file on FCA device.
fca_rename MAC Change name of a file on FCA device.
fca_readdir MAC Read directory information of FCA device.
fca_status MAC Read status information of FCA device.
fca_remains MAC Read free space size of a floppy disk.

- 59 -
1.List of Functions PROGRAMMING B-64303EN-3/01

(7) F-ROM library

These are the functions which read C Language Executor data stored in the flash ROM module.

NAME CExe FUNCTION


aux_from_open MAC Open the specified F-ROM file.
aux_from_close MAC Close the F-ROM file.
aux_from_select MAC Select data in the F-ROM file.
aux_from_moveptr MAC Move read pointer.
aux_from_read MAC Read data from the F-ROM file.
aux_from_getdir MAC Read directory information of a F-ROM file.
aux_from_getinfo MAC Read F-ROM file information.
aux_from_getc MAC Read a character from the F-ROM file.
aux_from_gets MAC Read a line from the F-ROM file.

(8) Touch-panel library

This is the function which reads the status and (X,Y) coordinate of the touch-panel.

NAME CExe FUNCTION


aux_tpl_read MAC Read the status and (X,Y) coordinate of the touch-panel.
aux_tpl_invalskey MAC Disable output of key codes of soft keys with the touch-panel.

- 60 -
B-64303EN-3/01 PROGRAMMING 1.List of Functions

1.6 Japanese(Multi-byte character) functions

Japanese character/string functions (Multi-byte character functions) included in "MS-C


extended C standard library" are not available for Series 0i-D C Language Executor.

- 61 -
2.How to make application program PROGRAMMING B-64303EN-3/01

2
Table of contents
How to make application program

2.1 Wind River Compiler C/C++ installation


2.2 Overview of installing the C Language Library and creating an application
program
2.3 Special files
2.4 Variables of type 'int'
2.5 Using compiler libraries
2.6 Describing 2-byte characters in source-codes
2.7 Remarks

- 62 -
B-64303EN-3/01 PROGRAMMING 2.How to make application program

2.1 Wind River Compiler C/C++ installation

See Sections B.1 and B.2 in Appendix B, "Additional Information on C Compiler Installation"
later.

2.2 Overview of installing the C Language Library and creating


an application program

See Sections B.3, B.4, and B.5 in Appendix B, "Additional Information on C Compiler
Installation" later.

- 63 -
2.How to make application program PROGRAMMING B-64303EN-3/01

2.3 Special files

The following files are special files, whose usage is reserved.

VERSION.C : Definition file of the user application's version number.(must be required)

The user application's version number is defined in this file.


For example, version number definition is as follows.
char version[] = "TEST0001" ;
"TEST" is the series string and "0001" is edition number.
You can replace them with your original version number.
There are no particular naming rules of version number.
You can define them arbitrarily. However, limited characters(such as
uppercase and numeric character, some marks) are available in the version
string. The version string which is defined in this file is displayed in
SYSTEM screen of CNC.

DRAMVER.C : Definition file of common variables between tasks.(optional)

Define the variables which can be accessed from all tasks.


Be sure to define only the variables, but not the functions.
The defined DRAM variables must have the initial values. The initial values
are necessary to allocate the variables into the DRAM area, and are not
effective when the application actually runs. When you set the initial values
for the DRAM variables, you should add an initial value setting process to
the application program.

SRAMVER.C : Definition file of SRAM variables.(optional)

Define the variables which should be allocated into SRAM(static memory)


area.
The variables defined in this file also can be accessed from all tasks. Be
sure to define only the variables, but not the functions.
SRAM variables must have the initial values. The initial values are necessary
to allocate the variables into SRAM area and not effective in the execution
time of the application program.

2.4 Variables of type 'int'

For the compiler used with the 0i-D C Language Executor, variables of type 'int' are 4-bytes
long.

- 64 -
B-64303EN-3/01 PROGRAMMING 2.How to make application program

2.5 Using compiler libraries

The following functions use the library supplied together with the compiler.
To use these functions, add the library to the LD.OPT file in the TOOL folder in your
development environment.

1) Functions that use the library supplied together with the compiler
setjmp, longjmp
va_start, va_arg, va_end
vprintf, vprintf, vsprintf

2) Adding library path to LD.OPT


<LD.OPT>
-m2
-lc <--Add this line.

2.6 Describing 2-byte characters in source-codes

The Diab C/C++ Power-PC compiler does not support Japanese language. If a 2-byte character
whose second byte happens to be 5Ch is included directly in a source file, it is not recognized
as correct data.

- 65 -
2.How to make application program PROGRAMMING B-64303EN-3/01

2.7 Remarks

C Language Executor uses the different include files from the compiler's default.
So, the object files made for the personal computer debugging cannot be used for execution
on CNC. Recompile using include files for C Language Executor. (The include directory is
switched by the macro CC in MAKEFILE)

Do not change MAKEFILE except the place mentioned above.

When creating application programs, observe the following cautions:

1) Do not perform division by zero.


2) When using data of type float or double, do not perform an arithmetic operation on that
data with NaN (nonnumeric) held.
3) Before converting data from type float or double to an integral type, make sure that
the resulting data will not fall outside the valid data range of the target integral
type.
4) The following restrictions are imposed on the alignment of variables to be placed.
One-byte variable : No restriction
Two-byte variable : The least significant digit of the address must be 0, 2, 4,
8, a, c, or e.
Four-byte variable : The least significant digit of the address must be 0, 4, 8,
or c.
Eight-byte variable : The least significant digit of the address must be 0 or 8.

[**WARNING**]
If an application program performs one of the following operations, the CNC may behave in
an unexpected manner.
- Access to data in an area other than the application data area.
- Execution of a program other than an application program (except call the function that
the C Language Executor offers it)

- 66 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3 Function References
The function specifications that C Language Library provides with are described in
this function reference with following format.

[Example]
> ----------------------------------------------------------------------------
> 1. Format specified drive. <Main>
> ----------------------------------------------------------------------------
>
>
> [Name]
> aux_file_format
>
>
> [Syntax]
> #include <auxfile.h>
> int aux_file_format( unsigned char drive ) ;
>
>
> [Arguments]
> drive Drive name ( ='A' ).
>
>
> [Return]
> 0 Successfully.
> 9 Invalid drive name.
>
>
> [Description]
> Formats specified drive.
>
> Specify drive name to be formatted in "drive". For formatting S-RAM
> disk, execute as follows.
>
> aux_file_format( 'A' ) ;
>
> All files in specified drive will be deleted by execution of this
> function.
>
> Automatic initialization of S-RAM disk is done by setting CNC
> parameter No.8662, S-RAM capacity setting, and rebooting system.

- 67 -
3.Function References PROGRAMMING B-64303EN-3/01

"<Main>" after title shows that this function is available in the MAIN task,
not available in the Communication task and the Alarm task. If "<Main,Alarm,
Comm>" is in this section, this function is available in all tasks.
For the functions that can be used in a window task, see Section 5.6, "Window task" in II.
For the functions that can be used in a high level task, see Section 5.9, "High-Level task" in
II.

"[Name]" shows the name of this function.

"[Syntax]" shows required header files to use this function, type of return
value of this function and sequence and types of all arguments.

"[Arguments]" shows meanings of all arguments.

"[Return]" shows all possible return values and their types and meanings.

"[Description]" shows behavior of this function, concrete values to be


specified in arguments and some notices, etc.

* Note
In description of member variables and bits of bit variables in a structure, some of the variables
are listed as "Not used." These variables may be used for any other purpose due to a design change.
Currently, application programs cannot use these variables because they have undefined values.

- 68 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.1 ANSI C standard library

3.1.1 Lists of Functions

1. Diagnostics ( assert.h )

ITEM NAME FUNCTION


1.1 assert Abort by assertion.

2. Character handling ( ctype.h )

ITEM NAME FUNCTION


2.1 isalnum Test for alphanumeric character.
2.2 isalpha Test for alphabetic character.
2.3 iscntrl Test for control character.
2.4 isdigit Test for numeric character.
2.5 isgraph Test for visible character.
2.6 islower Test for lowercase alphabetic character.
2.7 isprint Test for printable character.
2.8 ispunct Test for punctuation character.
2.9 isspace Test for whitespace character.
2.10 isupper Test for uppercase alphabetic character.
2.11 isxdigit Test for hexadecimal numeric character.
2.12 tolower Convert uppercase to lowercase.
2.13 toupper Convert lowercase to uppercase.

- 69 -
3.Function References PROGRAMMING B-64303EN-3/01

3. Mathematics ( math.h )

ITEM NAME FUNCTION


3.1 acos Calculate the arc cosine value.
3.2 asin Calculate the arc sine value.
3.3 atan Calculate the arc tangent value.
3.4 atan2 Calculate the arc tangent value.
3.5 ceil Calculate the smallest integer value.
3.6 cos Calculate the cosine value.
3.7 cosh Calculate the hyperbolic cosine value.
3.8 exp Calculate the exponential function.
3.9 fabs Calculate the absolute value.
3.10 floor Calculate the largest integer value.
3.11 fmod Calculate the floating point remainder value.
3.12 frexp Calculate the mantissa value.
3.13 ldexp Calculate the value multiplied by the power of 2.
3.14 log Calculate the natural (base-e) logarithm value.
3.15 log10 Calculate the base-10 logarithm value.
3.16 modf Get the fractional part and the integer part.
3.17 pow Calculate the raised value.
3.18 sin Calculate the sine value.
3.19 sinh Calculate the hyperbolic sine value.
3.20 sqrt Calculate the square root value.
3.21 tan Calculate the tangent value.
3.22 tanh Calculate the hyperbolic tangent value.

4. Non-local jumps ( setjmp.h )

ITEM NAME FUNCTION


4.1 setjmp Save current environment for non-local jump.
4.2 longjmp Execute a non-local jump.

5. Valiable arguments ( stdarg.h )

ITEM NAME FUNCTION


5.1 va_start Initialize arg_ptr.
5.2 va_arg Get a next argument.
5.3 va_end Reset arg_ptr.

- 70 -
B-64303EN-3/01 PROGRAMMING 3.Function References

6. Input/output ( stdio.h )

ITEM NAME FUNCTION


6.1 remove Delete a file.
6.2 rename Change the name of a file.
6.3 tmpnam Generate a temporary file name.
6.4 fclose Close a stream.
6.5 fflush Flush a stream buffer.
6.6 fopen Open a stream.
6.7 freopen Re-open a same stream.
6.8 setbuf Set a buffer for stream.
6.9 setvbuf Control a buffer for stream.
6.10 fprintf Print formatted data to a stream.
6.11 fscanf Read formatted data from a stream.
6.12 printf Print formatted data to standard output.
6.13 scanf Read formatted data from standard input.
6.14 sprintf Print formatted data to memory.
6.15 sscanf Read formatted data from memory.
6.16 vfprintf Print formatted data to a file using variable arguments.
Print formatted data to standard output using variable
6.17 vprintf
arguments.
6.18 vsprintf Print formatted data to memory using variable arguments.
6.19 fgetc Read a character from a stream.
6.20 fgets Read a strings from a stream.
6.21 fputc Write a character to a stream.
6.22 fputs Write a string to a stream.
6.23 getc Read a character from a stream.
6.24 getchar Read a character from standard input.
6.25 gets Read a line string from standard input.
6.26 putc Write a character to a stream.
6.27 putchar Write a character to standard output.
6.28 puts Write a string to standard output.
6.29 ungetc Put a character into a steam.
6.30 fread Read data from a stream.
6.31 fwrite Write data to a stream.
6.32 fgetpos Get the current file position of a stream.
6.33 fseek Move the current file pointer.
6.34 fsetpos Set the current file position of stream.
6.35 ftell Get the current file pointer.
6.36 rewind Rewind the current file pointer to the top of file.
6.37 clearerr Reset error indicator of a stream.
6.38 feof Test for end-of-file.

- 71 -
3.Function References PROGRAMMING B-64303EN-3/01

ITEM NAME FUNCTION


6.39 ferror Test for error on stream.
6.40 perror Print error message.

7. General utilities ( stdlib.h )

ITEM NAME FUNCTION


7.1 atoi Convert string to int value.
7.2 atol Convert string to long value.
7.3 strtol Convert string to long value.
7.4 strtoul Convert string to unsigned long value.
7.5 rand Convert string to unsigned long value.
7.6 srand Generate pseudo-random number.
7.7 calloc Seed pseudo-random number generator.
7.8 free Free memory block.
7.9 malloc Allocate memory block.
7.10 realloc Reallocate memory block.
7.11 bsearch Perform binary search.
7.12 qsort Perform quick sort.
7.13 abs Get absolute value.
7.14 div Get quotient and remainder.
7.15 labs Get absolute value.
7.16 ldiv Get quotient and remainder.
7.17 atof Convert string to double value.
7.18 strtod Convert string to double value.

- 72 -
B-64303EN-3/01 PROGRAMMING 3.Function References

8. String handling ( string.h )

ITEM NAME FUNCTION


8.1 memcpy Copy a memory block.
8.2 memmove Move a memory block.
8.3 strcpy Copy a string.
8.4 strncpy Copy a string.
8.5 strcat Concatenate a string
8.6 strncat Concatenate a string.
8.7 memcmp Compare two memory blocks.
8.8 strcmp Compare two strings.
8.9 strncmp Compare two strings.
8.10 memchr Find a character in a memory block.
8.11 strchr Find a character in a string.
8.12 strcspn Get string length which doesn't include a character.
8.13 strpbrk Find a character position in a string.
8.14 strrchr Find the last character in a string.
8.15 strspn Get string length composed by specified character.
8.16 strstr Find a string in a string.
8.17 strtok Get a token.
8.18 memset Fill data in a memory block.
8.19 strlen Get string length.

9. Date and time ( time.h )

ITEM NAME FUNCTION


9.1 clock Get the current time.
9.2 mktime Convert local time to calendar time.
9.3 time Get the current time.
9.4 asctime Convert time to string.
9.5 ctime Convert time to string.
9.6 gmtime Convert time to Greenwich mean time.
9.7 localtime Convert time to local time.
9.8 difftime Compute the difference between the two times.

- 73 -
3.Function References PROGRAMMING B-64303EN-3/01

3.1.2 Function Reference

Refer ANSI C language regulation for detail function specifications.

1. Diagnostics ( assert.h )

------------------------------------------------------------------------------
1.1 Abort by assertion. <Main>
------------------------------------------------------------------------------

[Name]
assert

[Syntax]
#include <assert.h>
void assert( int expression ) ;

[Arguments]
expression Expression to be diagnosed.

[Return]
------

[Description]
"assert" is used to debug programs simply. "assert" displays diagnostic message and
stops the program when the value of "expression" is false (i.e. "0"). To stop the program,
"while(1);" is execute, the next step is never executed. When "expression" is true (i.e.
non-zero), "assert" does nothing.
"assert" is defined as MACRO, so, define NDEBUG identifier and recompile to remove it.

The diagnostic message is displayed with the following format.

"Assertion failed : expression [expression] in file [filename] at line linenum"

Only programmer can understand this diagnostic message. It is recommended to do user's


own error checking and to display error messages for easy application maintenance.

- 74 -
B-64303EN-3/01 PROGRAMMING 3.Function References

2. Character handling ( ctype.h )

------------------------------------------------------------------------------
2.1 Test for alphanumeric character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
isalnum

[Syntax]
#include <ctype.h>
int isalnum( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is an alphanumeric character, otherwise zero.

[Description]
"isalnum" tests whether "c" is an alphanumeric character ('A'-'Z','a'-'z','0'-'9') or
not. This function works correctly for integer value of ASCII character set. The result
is not warranted for other input value.

- 75 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
2.2 Test for alphabetic character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
isalpha

[Syntax]
#include <ctype.h>
int isalpha( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is an alphabetic character, otherwise zero.

[Description]
"isalpha" tests whether "c" is an alphabetic character ('A'-'Z', 'a'-'z') or not. This
function works correctly for integer value of ASCII character set. The result is not
warranted for other input value.

- 76 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
2.3 Test for control character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
iscntrl

[Syntax]
#include <ctype.h>
int iscntrl( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is a control character, otherwise zero.

[Description]
"iscntrl" tests whether "c" is a control character (0x00-0x1f,0x7f) or not. This function
works correctly for integer value of ASCII character set. The result is not warranted
for other input value.

- 77 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
2.4 Test for numeric character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
isdigit

[Syntax]
#include <ctype.h>
int isdigit( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is a numeric character, otherwise zero.

[Description]
"isdigit" tests whether "c" is a numeric character ('0'-'9') or not. This function works
correctly for integer value of ASCII character set. The result is not warranted for other
input value.

- 78 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
2.5 Test for visible character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
isgraph

[Syntax]
#include <ctype.h>
int isgraph( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is a visible character, otherwise zero.

[Description]
"isgraph" tests whether "c" is a visible character (0x21-0x7e) or not. This function
works correctly for integer value of ASCII character set. The result is not warranted
for other input value.

- 79 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
2.6 Test for lowercase alphabetic character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
islower

[Syntax]
#include <ctype.h>
int islower( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is a lowercase alphabetic character, otherwise zero.

[Description]
"islower" tests whether "c" is a lowercase alphabetic character ('a'-'z') or not. This
function works correctly for integer value of ASCII character set. The result is not
warranted for other input value.

- 80 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
2.7 Test for printable character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
isprint

[Syntax]
#include <ctype.h>
int isprint( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is a printable character, otherwise zero.

[Description]
"isprint" tests whether "c" is a printable character (0x20-0x7e) or not. This function
works correctly for integer value of ASCII character set. The result is not warranted
for other input value.

- 81 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
2.8 Test for punctuation character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
ispunct

[Syntax]
#include <ctype.h>
int ispunct( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is a punctuation character, otherwise zero.

[Description]
"ispunct" tests whether "c" is a punctuation character (0x21-0x2f, 0x3a-0x40, 0x5b-0x60,
0x7b-0x7e) or not. This function works correctly for integer value of ASCII character
set. The result is not warranted for other input value.

- 82 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
2.9 Test for whitespace character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
isspace

[Syntax]
#include <ctype.h>
int isspace( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is a whitespace character, otherwise zero.

[Description]
"isspace" tests whether "c" is a whitespace character (0x09-0x0d, 0x20) or not. This
function works correctly for integer value of ASCII character set. The result is not
warranted for other input value.

- 83 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
2.10 Test for uppercase alphabetic character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
isupper

[Syntax]
#include <ctype.h>
int isupper( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is an uppercase alphabetic character, otherwise zero.

[Description]
"isupper" tests whether "c" is an uppercase alphabetic character ('A'-'Z') or not. This
function works correctly for integer value of ASCII character set. The result is not
warranted for other input value.

- 84 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
2.11 Test for hexadecimal numeric character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
isxdigit

[Syntax]
#include <ctype.h>
int isxdigit( int c ) ;

[Arguments]
c Character code to be tested.

[Return]
Returns non-zero value if "c" is a hexadecimal character, otherwise zero.

[Description]
"isxdigit" tests whether "c" is a hexadecimal character ('A'-'Z', 'a'-'f','0'-'9') or
not. This function works correctly for integer value of ASCII character set. The result
is not warranted for other input value.

- 85 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
2.12 Convert uppercase to lowercase. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
tolower

[Syntax]
#include <ctype.h>
int tolower( int c ) ;

[Arguments]
c Character code to be converted.

[Return]
Returns a lowercase alphabetic character if "c" is an uppercase, otherwise "c" as it
is.

[Description]
"tolower" converts "c" to a lowercase alphabetic character if "c" is uppercase.

- 86 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
2.13 Convert lowercase to uppercase. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
toupper

[Syntax]
#include <ctype.h>
int toupper( int c ) ;

[Arguments]
c Character code to be converted.

[Return]
Returns an uppercase alphabetic character if "c" is a lowercase, otherwise "c" as it
is.

[Description]
"toupper" converts "c" to an uppercase alphabetic character if "c" is lowercase.

- 87 -
3.Function References PROGRAMMING B-64303EN-3/01

3. Mathematics ( math.h )

------------------------------------------------------------------------------
3.1 Calculate the arc cosine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
acos

[Syntax]
#include <math.h>
double acos( double x ) ;

[Arguments]
x A floating point value to be calculated arc cosine.

[Return]
Returns the arc cosine value (in radian) of "x". If argument is out of valid range, returns
0 and sets EDOM in the global variable "errno".

[Description]
Calculates the arc cosine value of "x"."x" must be in -1 through 1. The result is in
0 through PI radian.

- 88 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.2 Calculate the arc sine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
asin

[Syntax]
#include <math.h>
double asin( double x ) ;

[Arguments]
x A floating point value to be calculated arc sine.

[Return]
Returns the arc sine value (in radian) of "x". If argument is out of valid range, returns
0 and sets EDOM in the global variable "errno".

[Description]
Calculates the arc sine value of "x"."x" must be in -1 through 1. The result is in -PI/2
through PI/2 radian.

- 89 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.3 Calculate the arc tangent value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
atan

[Syntax]
#include <math.h>
double atan( double x ) ;

[Arguments]
x A floating point value to be calculated arc tangent.

[Return]
Returns the arc tangent value (in radian) of "x".

[Description]
Calculates the arc tangent value of "x".
The result is in -PI/2 through PI/2 radian.

- 90 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.4 Calculate the arc tangent value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
atan2

[Syntax]
#include <math.h>
double atan2( double y, double x ) ;

[Arguments]
x A denominator of the value to be calculated arc tangent.
y A numerator of the value to be calculated arc tangent.

[Return]
Returns the arc tangent value (in radian) of y/x.
If both "y" and "x" are 0, returns 0 and sets EDOM in the global variable "errno".

[Description]
Calculates the arc tangent value of y/x.
Both "x" and "y" are must not be 0. The result is in -PI through PI radian.

- 91 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.5 Calculate the smallest integer value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
ceil

[Syntax]
#include <math.h>
double ceil( double x ) ;

[Arguments]
x A floating point value whose fractions is raised.

[Return]
Returns the smallest integer value that is greater than or equal to "x".

[Description]
Calculates the smallest integer value that is greater than or equal to "x".

- 92 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.6 Calculate the cosine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
cos

[Syntax]
#include <math.h>
double cos( double x ) ;

[Arguments]
x A floating point value in radian to be calculated cosine.

[Return]
Returns the cosine value of "x".
If "x" is too large, returns 0 and sets ERANGE in the global variable "errno".

[Description]
Calculates the cosine value of "x".

- 93 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.7 Calculate the hyperbolic cosine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
cosh

[Syntax]
#include <math.h>
double cosh( double x ) ;

[Arguments]
x A floating point value in radian to be calculated hyperbolic cosine.

[Return]
Returns the hyperbolic cosine value of "x".If the result is too large, returns +/-HUGE_VAL
and sets ERANGE in the global variable "errno".

[Description]
Calculates the hyperbolic cosine value of "x".

- 94 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.8 Calculate the exponential function. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
exp

[Syntax]
#include <math.h>
double exp( double x ) ;

[Arguments]
x A floating point value to be calculated exponential function.

[Return]
Returns the exponential function value of "x".
If the result is too large, returns HUGE_VAL and sets ERANGE in the global variable "errno".
If the result is too small, returns 0.

[Description]
Calculates the exponential function ("e" raised to "x" power) of "x".

- 95 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.9 Calculate the absolute value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fabs

[Syntax]
#include <math.h>
double fabs( double x ) ;

[Arguments]
x A floating point value to be calculated the absolute value.

[Return]
Returns the absolute value of "x".

[Description]
Calculates the absolute value of "x".

- 96 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.10 Calculate the largest integer value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
floor

[Syntax]
#include <math.h>
double floor( double x ) ;

[Arguments]
x A floating point value whose fractions is discarded.

[Return]
Returns the largest integet value that is less than or equal to "x"

[Description]
Calculates the largest integer value that is less than or equal to "x".

- 97 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.11 Calculate the floating point remainder value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fmod

[Syntax]
#include <math.h>
double fmod( double x, double y ) ;

[Arguments]
x A divident to be calculated remainder.
y A divosor to be calculated remainder.

[Return]
Returns the remainder of "x" and "y". If "y" is 0, returns 0 and sets EDOM in the global
variable "errno".

[Description]
Calculates the remainder of "x" and "y". The remainder satisfies "x - i*y ("i" is an
integer value)" and its absolute value is smaller than the absolute value of "y".

- 98 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.12 Calculate the mantissa value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
frexp

[Syntax]
#include <math.h>
double frexp( double value, int *exp ) ;

[Arguments]
value A floating point value to be divided.
exp A integer variable in where the exponential part is
stored.

[Return]
Returns the mantissa of a divided floating point value.

[Description]
Divides "value" into a mantissa part "m" and an exponential part "n" "m" relates with
"n" as "value = m × 2n" and the absolute value of "m" is greater than or equal to 0.5
and less than 1. If "value" is 0,both "m" and "n" are 0.

- 99 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.13 Calculate the value multiplied by the power of 2. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
ldexp

[Syntax]
#include <math.h>
double ldexp( double x, int exp ) ;

[Arguments]
x A floating point value of the manttisa.
exp A exponential part.

[Return]
Returns the raied value.
If the result is too large, returns +/-HUGE_VAL and sets ERANGE in the global variable
"errno".

[Description]
Calculates the raised value "x × 2exp" by the mantissa and the exponent.

- 100 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.14 Calculate the natural (base-e) logarithm value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
log

[Syntax]
#include <math.h>
double log( double x ) ;

[Arguments]
x A floating point value to be calculated natural
logarithm.

[Return]
Returns the natural logarithm value of "x".
If "x" is 0, returns HUGE_VAL and sets ERANGE in the global variable
"errno". If "x" is negative, returns HUGE_VAL and sets EDOM in the
global variable "errno".

[Description]
Calculates the natural logarithm (base-e logarithm) value of "x".

- 101 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.15 Calculate the base-10 logarithm value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
log10

[Syntax]
#include <math.h>
double log10( double x ) ;

[Arguments]
x A floating point value to be calculated base-10 logarithm.

[Return]
Returns the base-10 logarithm value of "x".
If "x" is 0, returns HUGE_VAL and sets ERANGE in the global variable
"errno". If "x" is negative, returns HUGE_VAL and sets EDOM in the
global variable "errno".

[Description]
Calculates the base-10 logarithm value of "x".

- 102 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.16 Get the fractional part and the integer part. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
modf

[Syntax]
#include <math.h>
double modf( double value, double *iptr ) ;

[Arguments]
value A floating point value to be divided.
iptr A integer variable in where the integer part is stored.

[Return]
Returns the fractional part of "value".

[Description]
Divides "value" into a fractional part and an integer part, both parts have the same
sign.

- 103 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.17 Calculate the raised value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
pow

[Syntax]
#include <math.h>
double pow( double x, double y ) ;

[Arguments]
x A floating point value to be raised.
y An exponent value.

[Return]
Returns "x" raised to the power of "y".
If "x" is 0 and "y" is negative, returns HUGE_VAL and sets EDOM in the
global variable "errno". If both "x" and "y" are 0 or "x" is negative
and "y" is not an integer, returns 0 and sets EDOM in the global
variable "errno". If the result is too large, returns +/-HUGE_VAL and
sets ERANGE in the global variable "errno".

[Description]
Calculates "x" raised to the power of "y".

- 104 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.18 Calculate the sine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
sin

[Syntax]
#include <math.h>
double sin( double x ) ;

[Arguments]
x A floating point value in radian to be calculated
sine.

[Return]
Returns the sine value of "x".
If "x" is too large, returns 0 and sets ERANGE in the global variable
"errno".

[Description]
Calculates the sine value of "x".

- 105 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.19 Calculate the hyperbolic sine value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
sinh

[Syntax]
#include <math.h>
double sinh( double x ) ;

[Arguments]
x A floating point value in radian to be calculated hyperbolic sine.

[Return]
Returns the hyperbolic sine value of "x".
If the result is too large, returns +/-HUGE_VAL and sets ERANGE in
the global variable "errno".

[Description]
Calculates the hyperbolic sine value of "x".

- 106 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.20 Calculate the square root value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
sqrt

[Syntax]
#include <math.h>
double sqrt( double x ) ;

[Arguments]
x A floating point value to be calculated square root.

[Return]
Returns the square root value of "x".
If "x" is negative, returns 0 and sets EDOM in the global variable
"errno".

[Description]
Calculates the square root value of "x".

- 107 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
3.21 Calculate the tangent value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
tan

[Syntax]
#include <math.h>
double tan( double x ) ;

[Arguments]
x A floating point value in radian to be calculated tangent.

[Return]
Returns the tangent value of "x".
If "x" is too large, returns 0 and sets ERANGE in the global variable
"errno".

[Description]
Calculates the tangent value of "x".

- 108 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
3.22 Calculate the hyperbolic tangent value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
tanh

[Syntax]
#include <math.h>
double tanh( double x ) ;

[Arguments]
x A floating point value in radian to be calculated hyperbolic tangent.

[Return]
Returns the hyperbolic tangent value of "x".

[Description]
Calculates the hyperbolic tangent value of "x".

- 109 -
3.Function References PROGRAMMING B-64303EN-3/01

4. Non-local jumps ( setjmp.h )

------------------------------------------------------------------------------
4.1 Save current environment for non-local jump. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
setjmp

[Syntax]
#include <setjmp.h>
int setjmp( jmp_buf env ) ;

[Arguments]
env Buffer in which contents of stack is saved.

[Return]
Returns zero. When "setjmp" is called again by "longjmp", it returns
"value", one of arguments of "longjmp". If "value" is zero, it
returns 1.

[Description]
"setjmp" saves contents of stack in "env" for restoring by the later "longjmp". This
enables jumping between functions.
See also "longjmp" for more information. This function use the library supplied together
with the compiler.
For information on how to use it, see Section 2.5, “Using compiler libraries” in II,
“PROGRAMMING” earlier.

- 110 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
4.2 Execute a non-local jump. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
longjmp

[Syntax]
#include <setjmp.h>
void longjmp( jmp_buf env, int value ) ;

[Arguments]
env Buffer in which contents of stack is saved.
value Return value of "setjmp".

[Return]
------

[Description]

"longjmp" restores environment which has been saved by "setjmp" before, and jumps to
the previous "setjmp" function. This enables jumping between functions. When "setjmp"
is called from "longjmp", "setjmp" returns "value" which is an one of arguments of
"longjmp".
If "value" is zero, "setjmp" returns 1. After re-calling "setjmp", values of all variables
are ones at calling "longjmp". Global variables whish has been changed by the other
functions are not restored. All register variables are undefined. Usually, "setjmp" is
called in the function which calls a function in which "longjmp" is called. That is,
"setjmp" must be the outer nested function than "longjmp". When "longjmp" jumps to an
inner function, the program doesn't work correctly.
outer← → inner
main() process1() process2() process3()
calls calls calls
setjmp() longjmp() longjmp()

GOOD

NO GOOD

process4() process5() process6()


calls calls calls
longjmp() longjmp() longjmp()

This function use the library supplied together with the compiler.
For information on how to use it, see Section 2.5, “Using compiler libraries” in II,
“PROGRAMMING” earlier.

- 111 -
3.Function References PROGRAMMING B-64303EN-3/01

5. Valiable arguments ( stdarg.h )

------------------------------------------------------------------------------
5.1 Initialize arg_ptr. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
va_start

[Syntax]
#include <stdarg.h>
void va_start( va_list arg_ptr, prev_param ) ;

[Arguments]
arg_ptr Pointer to the list of arguments.
prev_param Previous argument to the first optional argument.

[Return]
------

[Description]
Initialize "arg_ptr" to let it point the first argument of the arguments list. This
function is defined as MACRO. There are two definitions of this macro, such as ANSI
standard macro defined in stdarg.h and UNIX System V macro defined in varargs.h. Only
the ANSI standard macro is defined in C Language Library.
This function use the library supplied together with the compiler.
For information on how to use it, see Section 2.5, “Using compiler libraries” in II,
“PROGRAMMING” earlier.

- 112 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
5.2 Get a next argument. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
va_arg

[Syntax]
#include <stdarg.h>
type va_arg( va_list arg_ptr, type ) ;

[Arguments]
arg_ptr Pointer to the list of arguments.
type Type of an argument to be gotten.

[Return]
Returns an argument pointed by "arg_ptr".

[Description]
Returns a value whose type is "type" in a position pointed by "arg_ptr", then increments
"arg_ptr" to let it point the next argument in the list. The next argument position is
determined by size of "type". More arguments can be gotten using "arg_ptr" repeatedly.

This function use the library supplied together with the compiler.
For information on how to use it, see Section 2.5, “Using compiler libraries” in II,
“PROGRAMMING” earlier.

- 113 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
5.3 Reset arg_ptr. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
va_end

[Syntax]
#include <stdarg.h>
void va_end( va_list arg_ptr ) ;

[Arguments]
arg_ptr Pointer to the list of arguments.

[Return]
------

[Description]
Initializes "arg_ptr" as NULL.

This function use the library supplied together with the compiler.
For information on how to use it, see Section 2.5, “Using compiler libraries” in II,
“PROGRAMMING” earlier.

- 114 -
B-64303EN-3/01 PROGRAMMING 3.Function References

6. Input/output ( stdio.h )

------------------------------------------------------------------------------
6.1 Delete a file. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
remove

[Syntax]
#include <stdio.h>
int remove( const char *path ) ;

[Arguments]
path Pathname of a file to be deleted.

[Return]
Returns zero if a file has been successfully deleted. If not, returns
-1 and sets an one of following values in the global variable "errno".

Symbol Meaning
EACCES Specified file is a Read-Only file.
ENOENT Specified file or path does not exist, or "path" is a directory.

[Description]
Deletes a file specified by "path".

- 115 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.2 Change the name of a file. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
rename

[Syntax]
#include <stdio.h>
int rename( const char *oldname, const char *newname ) ;

[Arguments]
oldname Pointer to the old name.
newname Pointer to the new name.

[Return]
Returns zero if file name has been successfully changed. If not,
returns -1 and sets an one of following values in the global variable "errno".

Symbol Meaning
A file or directory whose name is "newname" already exists,
EACCES "path" is invalid, or a different path is specified in "newname" for a
directory.
ENOENT Specified file or path does not exist.
EXDEV Attempted moving a file to the another device.

[Description]
Changes a file name or directory name specified by "oldname" to a new name specified
by "newname". The old name must be a path name of a file or a directory which already
exists. The new name must not be a path name of a file or a directory which already exists.
A file can be moved from some directory to another one by specifying a different path
name in "oldname" from "newname". But it is impossible to move a file from some device
to the another device. For directory, only renaming is available, moving is not available.

(Note) The library of the current version can not move any file. rename() function calling
to move a file makes an error. (errno=EACCES)

- 116 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.3 Generate a temporary file name. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
tmpnam

[Syntax]
#include <stdio.h>
char *tmpnam( char *string ) ;

[Arguments]
string Pointer to a temporary file name.

[Return]
Returns a pointer to a generated unique file name if it has been successfully generated.
If not, returns NULL.

[Description]
Generates a file name by which a temporary file can be opened without overwriting existing
files. This name is stored in a buffer pointed by "string". If "strings" is NULL, the
result is stored in the internal static buffer. So, the following calling destroy this
result. At least buffer size must be larger than L-tmpnam bytes (defined in stdio.h).
This function can generate up to TMP_MAX of unique file names.
The generated string is composed of a path prefix, such as P_tmpdir define in stdio.h,
and following sequence of numeric characters. The values of this numeric string are 1
through 65535.
A process of "tmpnam" is not changed by modifying L_tmpnam or P_tmpdir.

- 117 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.4 Close a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fclose

[Syntax]
#include <stdio.h>
int fclose( FILE *stream ) ;

[Arguments]
stream Pointer to a FILE structure.

[Return]
Returns zero if a stream has been successfully closed. If not,returns EOF.

[Description]
Closes specified stream. Buffers linked to the stream will be flushed before closing.
Buffers allocated by the system will be deallocated. But buffers which has been allocated
by user using "setbuf" or "setvbuf" will not be deallocated automatically.

- 118 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.5 Flush a stream buffer. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fflush

[Syntax]
#include <stdio.h>
int fflush( FILE *stream ) ;

[Arguments]
stream Pointer to a FILE structure.

[Return]
Returns zero if a buffer has been successfully flushed. Also if specified stream has
no buffer, or it has been opened with Read-Only mode, returns zero. If any error occurs,
returns EOF. In this case, any data may be missed because of incorrect writing.

[Description]
Flushes specified stream. If specified stream has been opened for output, contents of
the buffer are written to the file. If for input, they are cleared. All streams for output
are flushed by specifying NULL in argument. Steams will still exist as they are after
calling "fflush". Calling "fflush" makes the result of "ungetc" ineffective. Buffers
are automatically flushed when a buffer is full, a stream is closed, or program
successfully terminated without closing streams. This function does not influence to
the streams without buffering.

- 119 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.6 Open a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fopen

[Syntax]
#include <stdio.h>
FILE *fopen( const char *filename, const char *mode ) ;

[Arguments]
filename Path name of a file.
mode Permitted access type.

[Return]
Returns a pointer to the opened file. If any error, returns NULL pointer.

[Description]
Opens a file specified by "filename". Specify access type which is requested to the file
in "mode".

Type Meaning
r Opens with Read-Only mode. Error if specified file does not exist.
Opens with output mode. Opens an empty file. Contents of the existing
w
file are destroyed.
Opens with output mode, appending to the end of the file. If specified
a
file does not exist, creates it.
r+ Opens with both input and output mode. Specified file must exist.
Opens an empty file with both input and output mode. Contents of the
w+
existing file are destroyed.
a+ Opens with both input and output. If no specified file, creates it.

Additionally, the following open mode can also be specified as additional character in
the above list.

Mode Meaning
Opens the file in text mode.(default)
In this mode, line feed characters are converted as follows.
t Input CR + LF → LF
Output LF → CR + LF
Opens the file in binary mode. In this mode, line feed characters are not
b
converted.

- 120 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.7 Re-open a same stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
freopen

[Syntax]
#include <stdio.h>
FILE *freopen( const char *filename, const char *mode,
FILE *stream ) ;

[Arguments]
filename Path name of a new file.
mode Permitted access type.
stream Pointer to a FILE structure.

[Return]
Returns a pointer to the newly opened file. If any error, closes a
old file and returns NULL pointer.

[Description]
Closes a file linked to the stream, then reallocates the stream to the file specified
by "filename". This function is usually used to redirect already opened standard input
(stdin), standard output (stdout) or standard error output (stderr) to specified file.
The new file to be linked the steam is opened with "mode". Specify access type which
is requested to the file in "mode".

Type Meaning
r Opens with Read-Only mode. Error if specified file does not exist.
Opens with output mode. Opens an empty file. Contents of the existing file
w
are destroyed.
Opens with output mode, appending to the end of the file. If specified file
a
does not exist, creates it.
r+ Opens with both input and output mode. Specified file must exist.
Opens an empty file with both input and output mode. Contents of the
w+
existing file are destroyed.
a+ Opens with both input and output. If no specified file, creates it.

- 121 -
3.Function References PROGRAMMING B-64303EN-3/01

Additionally, the following open mode can also be specified as additional character in
the above list.

Mode Meaning
Opens the file in text mode.(default)
In this mode, line feed characters are converted as follows.
t Input CR + LF → LF
Output LF → CR + LF
Opens the file in binary mode.
b
In this mode, line feed characters are not converted.

- 122 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.8 Set a buffer for stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
setbuf

[Syntax]
#include <stdio.h>
void setbuf( FILE *stream, char *buffer ) ;

[Arguments]
stream Pointer to a FILE structure.
buffer Buffer allocated by user.

[Return]
------

[Description]
Controls buffering of a stream. Specified stream must be already opened file from/to
which any input/output has not been done. Buffering is not performed for the stream if
"buffer" is NULL.
Otherwise, "buffer" must point a buffer whose size is BUFSIZ. BUFSIZ is a buffer size
defined in stdio.h. By calling this function, user defined buffer is used as an
input/output buffer instead of system defined one.
Functions of "setbuf" is included in "setvbuf". It is recommended to use "setvbuf" for
newly made programs. "setbuf" is provided for compatibility with existing programs.

- 123 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.9 Control a buffer for stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
setvbuf

[Syntax]
#include <stdio.h>
int setvbuf( FILE *stream, char *buffer, int mode, size_t size ) ;

[Arguments]
stream Pointer to a FILE structure.
buffer Buffer allocated by user.
mode Buffering mode.
size Buffer size.

[Return]
Returns zero if successful. If not (invalid mode or buffer size),returns non-zero.

[Description]
Controls buffering and buffer size of stream. Specified stream must be already opened
file from/to which any input/output has not been done. Buffer pointed by "buffer" is
used unless "buffer" is NULL. If NULL, new buffer whose size is "size" is automatically
allocated. "mode" is one of follows.

Mode Meaning
Full buffering.
_IOFBF "buffer" is a pointer to the buffer, and "size is a size of the buffer. If "buffer"
is NULL, new buffer of "size" byte allocated automatically is used.
_IONBF No buffer is used regardless of "buffer" and "size".

- 124 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.10 Print formatted data to a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fprintf

[Syntax]
#include <stdio.h>
int fprintf( FILE *stream, const char *format [, argument]... ) ;

[Arguments]
stream Pointer to a FILE structure.
format Format control string.
argument Optional arguments.

[Return]
Returns number of characters which have been output. If any error, returns negative value.

[Description]
Outputs a series of formatted data to a stream. Each arguments (if exist) are output
with conversion according to the format specification in "format". Formats of "format"
are same as ones of "printf". See "printf" for details of "format" and "argument".

- 125 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.11 Read formatted data from a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fscanf

[Syntax]
#include <stdio.h>
int fscanf( FILE *stream, const char *format [, argument]... ) ;

[Arguments]
stream Pointer to a FILE structure.
format Format control string.
Argument Optional arguments.

[Return]
Returns a number of fields converted successfully. This does not includes fields which
has been read and not converted. Returns EOF if any error is detected in a stream before
the first conversion, or the end of file is detected. Return value zero means that no
fields have been converted.

[Description]
Reads formatted data to arguments (if exist) from a stream.
"argument" are pointer to variables whose types are same as type specification in "format".
Formats of "format" are same as "scanf". See "scanf" for details of "format" and
"argument".

- 126 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.12 Print formatted data to standard output. <Main>
------------------------------------------------------------------------------

[Name]
printf

[Syntax]
#include <stdio.h>
int printf( const char *format [, argument]... ) ;

[Arguments]
format Format control string.
argument Optional arguments.

[Return]
Returns number of characters which have been output. If any error, returns negative value.

[Description]
Outputs a series of formatted data to the standard output stream (stdout). "format" is
composed of ordinary characters, escape sequences and format specifications. Ordinary
characters and escape sequences are output to the standard output in order. If any
arguments follow the format string, output formatting for the arguments are performed
using the format string. The first character of format specification is '%'. Format
specification is decoded rightward from the left. The first argument following "format"
is output according to the first format specification. The second argument is output
according to the second format specification, and so forth.
More arguments than the format specifications are ignored. If a number of arguments is
short of format specifications, the result of "printf" is not warranted.

1) Format specification format.

% [flags] [width] [.precision] [{h|l|L}] type

Type Type of argument, character, strings or numeric value.


Justification, sign, space, decimal point, prefix of octal/hexadecimal
flags
number.
width Minimum width of output column.
precision Maximum number of characters output in whole or a part of output field.
h, l, L Size of argument.

- 127 -
3.Function References PROGRAMMING B-64303EN-3/01

2) "type" field specification.

Char Type Output format


d int Signed decimal number.
i int Signed decimal number.
u int Unsigned decimal number.
o int Unsigned octal number.
x int Unsigned hexadecimal number, using "abcdef".
X int Unsigned hexadecimal number, using "ABCDEF".
f double Signed floating point value with "[-]dddd.dddd" format.
e double Signed floating point value with "[-]d.dddde[sign]ddd" format.
E double Signed floating point value with "[-]d.ddddE[sign]ddd" format.
g double "f" or "e", shorter one for output string.
G double Same as "g" but 'G' before exponent.
c int A character.
String till the first null character(¥0) or limit specified by
s string
"precision".
n pointer to integer A number of characters output up to this point.
Address specified by the argument with the format
p pointer to void
according to the current memory model.

3) "flag" specification

flag Meaning Default


- Left justification. Right justification.
+ Sign before a value. Only '-' for a negative value.
0 Padding by '0' till the minimum width. No padding.
SPACE Leading space to output value. No leading space.
Prefix "0", "0x" or "0X" before non-'0' numeric
No prefix.
character for 'o','x' or 'X' format.
# Forced decimal point for 'e', 'E' or 'f' format. Decimal point if needed.
Forced decimal point and no-suppressing Decimal point if needed,
trailing '0' for 'g' or 'G' format. suppressing trailing '0'.

- 128 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.13 Read formatted data from standard input. <Main>
------------------------------------------------------------------------------

[Name]
scanf

[Syntax]
#include <stdio.h>
int scanf( const char *format [, argument]... ) ;

[Arguments]
format Format control string.
argument Optional arguments.

[Return]
Returns a number of fields converted successfully. This may be less than the requested
number to "scanf". This does not includes fields which has been read and not converted.
Returns EOF if any error is detected in a stream before the first conversion, or the
end of file is detected. Return value zero means that no fields have been converted.

[Description]
Reads formatted data to arguments from the standard input stream
(stdin). "argument" are pointer to variables whose types are same as
type specification in "format". Format specification controls
decoding input fields. Specify one or more of following characters
for format specification.

* Whitespace -- space(' '), tab('\t'), newline('\n') Skips whitespace characters


in input data till the next non-whitespace character.

* Non-whitespace character except a percent sign ('%') Skips non-whitespece


character which is same as specified one. If the next character in the standard
input (stdin) is not same as specified one, process will be terminated.

* Format specification following to a percent sign ('%') Reads input characters,


and converts to specified type. Converted value is stored in the variable pointed
by the argument.

- 129 -
3.Function References PROGRAMMING B-64303EN-3/01

1) Format specification format

% [*] [width] [{h|l}] type

Type Type of input argument, character, strings or numeric value.


Maximum number of characters input from standard input.
(positive decimal number) More characters than "width" are not
converted, and not stored in the argument. When any whitespace
width
character is detected before reaching to "width", or input characters
can not be converted according to specified format, only less
characters than "width" are read.
Object size to be read.
h, l
'l' is long version and 'h' is short version.
Only decoding of input field is performed, but no data is stored in the
*
variable.

- 130 -
B-64303EN-3/01 PROGRAMMING 3.Function References

2) "type" field specification.

Char Type of input data Type of argument


d Decimal number. Pointer to int.
o Octal number. Pointer to int.
x Hexadecimal number. Pointer to int.
i Octal, decimal or hexadecimal number Pointer to int.
u Unsigned decimal number Pointer to unsigned int.
U Unsigned decimal number Pointer to unsigned long.
e, E Floating point number which is composed of one
f or more sequential decimal number with a sign
Pointer to float.
(+,-) and decimal point (optional), exponent('e' or
g, G
'E', optional) and signed integer (optional).
Character.
c Even whitespace character can be read. To skip Pointer to char.
whitespace characters, use "%ls".
Pointer to character array
whose size if enough for
s String.
both input field and
terminating character (null).
Pointer to int, in which a
n Not read from stream or buffer number of characters input
up to this point is stored.
Value with "xxxx:yyyy" format
p Pointer to (void _far *).
'x' and 'y' are uppercase hexadecimal number.

- 131 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.14 Print formatted data to memory. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
sprintf

[Syntax]
#include <stdio.h>
int sprintf( char *buffer, const char *format [, argument]... ) ;

[Arguments]
buffer Buffer in which string is stored.
format Format control string.
argument Optional arguments.

[Return]
Returns number of characters which have been stored in the buffer.
(The last NULL character is not counted.)

[Description]
Stores a series of formatted data in a buffer. Each arguments (if exist) are stored with
conversion according to the format specification in "format". Formats of "format" are
same as ones of "printf". See "printf" for details of "format" and "argument".

- 132 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.15 Read formatted data from memory. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
sscanf

[Syntax]
#include <stdio.h>
int sscanf( const char *buffer, const char *format
[, argument]... ) ;

[Arguments]
buffer Stored data.
format Format control string.
Argument Optional arguments.

[Return]
Returns a number of fields converted successfully. This does not includes fields which
has been read and not converted. Returns EOF if the end of string is detected. Return
value zero means that no fields have been converted.

[Description]
Reads formatted data to arguments (if exist) from a buffer.
"argument" are pointer to variables whose types are same as type specification in "format".
Formats of "format" are same as "scanf".
See "scanf" for details of "format" and "argument".

- 133 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.16 Print formatted data to a file using variable arguments.<Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
vfprintf

[Syntax]
#include <stdio.h>
#include <stdarg.h>
int vfprintf( FILE *stream, const char *format, va_list argptr ) ;

[Arguments]
stream Pointer to a FILE structure.
format Format control string.
argptr Pointer to a list of arguments.

[Return]
Returns number of characters which have been output. If any error, returns negative value.

[Description]
Outputs a series of formatted data to a stream. Each arguments are output with conversion
according to the format specification in "format". "argptr" is a pointer of va_list type
defined in stdarg.h. It points a list of arguments to be converted and output according
to format specifications of "format". Formats of "format" are same as ones of "printf".
See "printf" for details of "format" and "argument".
This function use the library supplied together with the compiler.
For information on how to use it, see Section 2.5, “Using compiler libraries” in II,
“PROGRAMMING” earlier.

- 134 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.17 Print formatted data to standard output using variable arguments. <Main>
------------------------------------------------------------------------------

[Name]
vprintf

[Syntax]
#include <stdio.h>
#include <stdarg.h>
int vprintf( const char *format, va_list argptr ) ;

[Arguments]
format Format control string.
argptr Pointer to a list of arguments.

[Return]
Returns number of characters which have been output. (The last NULL character is not
counted.) If any error, returns negative value.

[Description]
Outputs a series of formatted data to the standard output. Each arguments are output
with conversion according to the format specification in "format". "argptr" is a pointer
of va_list type defined in stdarg.h. It points a list of arguments to be converted and
output according to format specifications of "format".
Formats of "format" are same as ones of "printf". See "printf" for details of "format"
and "argument".
This function use the library supplied together with the compiler.
For information on how to use it, see Section 2.5, “Using compiler libraries” in II,
“PROGRAMMING” earlier.

- 135 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.18 Print formatted data to memory using variable arguments. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
vsprintf

[Syntax]
#include <stdio.h>
#include <stdarg.h>
int vsprintf( char *buffer, const char *format, va_list argptr ) ;

[Arguments]
buffer Buffer in which string is stored.
format Format control string.
argptr Pointer to a list of arguments.

[Return]
Returns number of characters which have been stored. (The last NULL character is not
counted.) If any error, returns negative value.

[Description]
Stores a series of formatted data in a buffer pointed "buffer". Each arguments are stored
with conversion according to the format specification in "format". "argptr" is a pointer
of va_list type defined in stdarg.h. It points a list of arguments to be converted and
output according to format specifications of "format". Formats of "format" are same as
ones of "printf". See "printf" for details of "format" and "argument".
This function use the library supplied together with the compiler.
For information on how to use it, see Section 2.5, “Using compiler libraries” in II,
“PROGRAMMING” earlier.

- 136 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.19 Read a character from a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fgetc

[Syntax]
#include <stdio.h>
int fgetc( FILE *stream ) ;

[Arguments]
stream Pointer to a FILE structure.

[Return]
Returns a read character. Returns EOF if any error if any error or the end of file is
detected. Use "feof" and "ferror" functions to distinguish an error from EOF.

[Description]
Reads a character from a file linked to "stream". A character is returned with conversion
to int. A file pointer is incremented to point the next character. This function is same
as "getc" function and is not a macro but a function.

- 137 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.20 Read a strings from a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fgets

[Syntax]
#include <stdio.h>
char *fgets( char *string, int n, FILE *stream ) ;

[Arguments]
string Buffer in which data is stored.
n Buffer size.
stream Pointer to a FILE structure.

[Return]
Returns "string" if successful. Returns NULL if any error or the end of file is detected.
Use "feof" and "ferror" functions to distinguish an error from EOF.

[Description]
Reads characters from a file linked to "stream" and stores them in "string". Reading
is repeated until newline character('\n') is detected, the end of the stream is detected,
or a length of read character become equivalent to "n-1". The result is stored in "string"
adding NULL character('\0'). If "n" is 1, "string" is empty (""). This function is similar
to "gets" function, but "gets" replaces a newline character to a NULL character.

- 138 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.21 Write a character to a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fputc

[Syntax]
#include <stdio.h>
int putc( int c, FILE *stream ) ;

[Arguments]
c Character to be written.
stream Pointer to a FILE structure.

[Return]
Returns a written character. If any error, returns EOF.

[Description]
Writes a character specified by "c" to an output stream. This function is similar to
"putc" function, buf this is a function, not a macro.

- 139 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.22 Write a string to a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fputs

[Syntax]
#include <stdio.h>
int fputs( const char *string, FILE *stream ) ;

[Arguments]
string String to be output.
stream Pointer to a FILE structure.

[Return]
Returns "non-negative value" if successful. If any error, returns EOF.

[Description]
Write "strings" to a stream. The terminating character, NULL character ('\0'), is not
output.

- 140 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.23 Read a character from a stream. <Main>
------------------------------------------------------------------------------

[Name]
getc

[Syntax]
#include <stdio.h>
int getc( FILE *stream ) ;

[Arguments]
stream Current stream.

[Return]
Returns a read character. Returns EOF if any error or the end of file is detected. Use
"feof" and "ferror" functions to distinguish an error from EOF.

[Description]
Reads a character from a file linked to "stream". A file pointer is incremented to point
the next character. This function is same as "fgetc" function and is not a function but
a macro.

- 141 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.24 Read a character from standard input. <Main>
------------------------------------------------------------------------------

[Name]
getchar

[Syntax]
#include <stdio.h>
int getchar( void ) ;

[Arguments]
------

[Return]
Returns a character read from the standard input. Returns EOF if any error or the end
of file is detected. Use "feof" and "ferror" functions to distinguish an error from EOF.

[Description]
Reads a character from the standard input. This is same as "getc" function. This function
is same as "_fgetchar" function but is a macro.

- 142 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.25 Read a line string from standard input. <Main>
------------------------------------------------------------------------------

[Name]
gets

[Syntax]
#include <stdio.h>
char *gets( char *buffer ) ;

[Arguments]
buffer Pointer to a buffer in which input characters are stored.

[Return]
Returns address of a buffer specified in argument. Returns NULL if any error or the end
of file is detected. Use "feof" and "ferror" functions to distinguish an error from EOF.

[Description]
Reads a line from the standard input stream (stdin) and stores it in "buffer". A line
is composed of all characters until the first newline character('\n'). A newline
character is replaced with a NULL character('\0'). This function is similar to "fgets"
function, buf "fgets" doesn't replace a newline character.

- 143 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.26 Write a character to a stream. <Main>
------------------------------------------------------------------------------

[Name]
putc

[Syntax]
#include <stdio.h>
int putc( int c, FILE *stream ) ;

[Arguments]
c Character to be written.
stream Pointer to a FILE structure.

[Return]
Returns a written character. If any error, returns EOF.

[Description]
Writes a character "c" to an output stream. Any integer value whatever can be specified,
but the only lower 8 bits are written.

- 144 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.27 Write a character to standard output. <Main>
------------------------------------------------------------------------------

[Name]
putchar

[Syntax]
#include <stdio.h>
int putchar( int c ) ;

[Arguments]
c Character to be written.

[Return]
Returns a written character. If any error, returns EOF.

[Description]
Writes a character "c" to the standard output (stdout). This is same as "putc( c,
stdout )".

- 145 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.28 Write a string to standard output. <Main>
------------------------------------------------------------------------------

[Name]
puts

[Syntax]
#include <stdio.h>
int puts( const char *string ) ;

[Arguments]
string String to be written.

[Return]
Returns "non-positive value" if successful. If any error, returns EOF.

[Description]
Writes "string" to the standard output (stdout). The last character of the string, NULL
character('\0'), is replaced with a newline character('\n').

- 146 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.29 Put a character into a steam. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
ungetc

[Syntax]
#include <stdio.h>
int ungetc( int c, FILE *stream ) ;

[Arguments]
c Character to be pushed.
stream Pointer to a FILE structure.

[Return]
Returns a character "c" if successful. Returns EOF if nothing has been read from the
stream or the specified character has not be able to pushed into the stream.

[Description]
Pushes a character "c" into the stream and clears the end of file indicator. The stream
must be opened with "Read mode". The next reading from the stream is processed from "c".
If "c" is EOF, it is ignored. The pushed character into the stream will be cleared befer
it is read from the stream by calling "fflush", "fseek", "fsetpos" or "rewind" functions.
The file position indicator is not changed by this function. If "ungetc" function is
used for any text stream, the file pointer is undefined until all pushed characters are
read or cleared. If "ungetc" function is used for any binary stream, the file point
indicator is set to the previous position. In the case that the value of the file point
indicator was zero before calling this function, the value after calling is not warranted.
When "ungetc" function is calling twice continuously without any reading, the result
is unstable. After calling of "fscanf" function, "ungetc" function will be unsuccessful
unless one more reading procedure. (Because "fscanf" function calls "ungetc" function
itself.)

- 147 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.30 Read data from a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fread

[Syntax]
#include <stdio.h>
size_t fread( void *buffer, size_t size, size_t count,
FILE *stream ) ;

[Arguments]
buffer Pointer to a data buffer.
size Item size in byte.
count Maximum number of item to be read.
stream Pointer to a FILE structure.

[Return]
Returns number of items which has been read actually. If this value is less than "count",
any error or the end of file before reading "count" times might be detected. If any error,
the file pointer is undefined. The value read partially is undefined. Use "feof" and
"ferror" functions to distinguish an error from EOF. If "size" or "count" is zero, returns
zero and doesn't change contents of buffer.

[Description]
Reads "count" elements of "size" bytes item from an input stream, and stores into "buffer".
The file pointer linked to "stream" (if exists) is incremented by bytes number which
has been read actually. If the specified stream is opened with text mode, a pair of
carriage return and line feed (CR+LF) is replaced with a line feed character (LF). This
conversion doesn't affect the file pointer and the return value.

- 148 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.31 Write data to a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fwrite

[Syntax]
#include <stdio.h>
size_t fwrite( void *buffer, size_t size, size_t count,
FILE *stream ) ;

[Arguments]
buffer Pointer to a data buffer.
size Item size in byte.
count Maximum number of item to be written.
stream Pointer to a FILE structure.

[Return]
Returns number of items which has been written actually. If this value is less than "count",
any error might be detected. If any error, the file pointer is undefined.

[Description]
Writes "count" elements of "size" bytes item from "buffer" to a output stream. The file
pointer linked to "stream" (if exists) is incremented by bytes number which has been
written actually. If the specified stream is opened with text mode, a line feed
character(LF) is replaced with a pair of carriage return and line feed (CR+LF). This
conversion doesn't affect the return value.

- 149 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.32 Get the current file position of a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fgetpos

[Syntax]
#include <stdio.h>
int fgetpos( FILE *stream, fpos_t *pos ) ;

[Arguments]
stream Pointer to a FILE structure.
pos Pointer to a position indicator to be stored.

[Return]
Returns zero if successful. If not, returns non-zero value and sets an one of following
values, which are defined in stdio.h, in a global variable "errno".

Symbol Meaning
EBADF File handle linked to the specified stream is invalid, or cannot be accessed.
EINVAL Specified stream is invalid.

[Description]
Gets a file position indicator of the specified stream, and stores it in the buffer pointed
by "pos". It is able to restore the pointer of the stream at calling "fgetpos" function
by "fsetpos" function using an information stored in "pos". Data format of "pos" is
internal one, it is used only by "fgetpos" and "fsetpos" functions.

- 150 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.33 Move the current file pointer. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fseek

[Syntax]
#include <stdio.h>
int fseek( FILE *streem, long offset, int orign ) ;

[Arguments]
stream Pointer to a FILE structure.
offset Offset from origin in byte.
orign Origin position.

[Return]
Returns zero if successful. If not, returns non-zero value. For non-seekable devices,
returns unstable value.

[Description]
Moves a file pointer (if exists) linked to the stream to "offset" bytes position from
"orign". The following operations to the stream are performed at this new position. It
is possible to both read and write as the next operation to the streams which are opened
with updating mode. It is possible to move the pointer to any arbitrary position, also
beyond the end of file. Calling this function clears the end of file indicator. "orign"
is one of the following constants which are defined in stdio.h.

Symbol Meaning
SEEK_CUR Current position.
SEEK_END End of file.
SEEK_SET Beginning of file.

- 151 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.34 Set the current file position of stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
fsetpos

[Syntax]
#include <stdio.h>
int fsetpos( FILE *stream, fpos_t *pos ) ;

[Arguments]
stream Pointer to a FILE structure.
pos Pointer to a position indicator to be stored.

[Return]
Returns zero if successful. If not, returns non-zero value and sets an one of following
values, which are defined in stdio.h, in a global variable "errno".

Symbol Meaning
EBADF File handle linked to the specified stream is invalid, or cannot be accessed.
EINVAL Specified stream is invalid.

[Description]
Restores a file position indicator of the specified stream to "pos" which has been gotten
by the previous "fgetpos" function. This function clears the end of file indicator and
cancels the result of "ungetc" function to the stream. Data format of "pos" is internal
one, it is used only by "fgetpos" and "fsetpos" functions.

- 152 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.35 Get the current file pointer. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
ftell

[Syntax]
#include <stdio.h>
long ftell( FILE *stream ) ;

[Arguments]
stream Pointer to a FILE structure.

[Return]
Returns the current file pointer. If any error, returns -1L and sets an one of following
values, which are defined in stdio.h, in a global variable "errno".

Symbol Meaning
EBADF File handle linked to the specified stream is invalid, or cannot be accessed.
EINVAL Specified stream is invalid.

For non-seekable devices or not opened files, returns unstable value.

[Description]
Gets the current file pointer linked to the stream. This value is a offset from the
beginning of stream. A file pointer of a stream which is opened with text mode may not
coincide with the physical offset, because a pair of carriage return and line feed (CR+LF)
is replaced with a line feed character(LF) in text mode. The current file position of
the file which has been opened with appending mode is not the next writing position but
the last reading/writing
operation position. For example, if the last operation to the file which has been opened
with appending mode is reading, the file position is not the one in which the next writing
operation will be done but the next reading operation. In case that any reading/writing
operations have not been done to for appending mode file, the current file position is
the beginning of file.

- 153 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.36 Rewind the current file pointer to the top of file. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
rewind

[Syntax]
#include <stdio.h>
void rewind( FILE *stream ) ;

[Arguments]
stream Pointer to a FILE structure.

[Return]
------

[Description]
Rewind a file pointer linked to the stream to the beginning of file.
"rewind" function clears an error indicator of the stream, but "fseek" doesn't. "rewind"
is equivalent to the following "fseek" except above.

(void) fseek ( *stream, 0L, SEEK_SET ) ;

Both "rewind" and "fseek" functions clear the end of file indicator.
"fseek" function returns a value whether a pointer movement has been done successfully
or not, but "rewind" doesn't. It is possible to clear the keyboard buffer by calling
"rewind" function to the standard input stream (stdin) linked to the keyboard by default.

- 154 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.37 Reset error indicator of a stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
clearerr

[Syntax]
#include <stdio.h>
void clearerr( FILE *stream ) ;

[Arguments]
stream Pointer to a FILE structure.

[Return]
------

[Description]
Rests the error indicator and the end of file indicator. The error indicator is not cleared
automatically. If once the error indicator of specified stream is set, operations to
the stream return the error code until calling one of "clearerr", "fseek", "fsetpos"
and "rewind".

- 155 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.38 Test for end-of-file. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
feof

[Syntax]
#include <stdio.h>
int feof( FILE *stream ) ;

[Arguments]
stream Pointer to a FILE structure.

[Return]
Returns non-zero value if any input operations have been done beyond the end of file,
or zero if not. This function doesn't return any error code.

[Description]
Tests whether reaching to the end of stream or not. Any operations after once reaching
to the end of steam return the end of file indicator until the stream is closed or one
of "clearerr", "fseek", "fsetpos" and "rewind" is called.

- 156 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
6.39 Test for error on stream. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
ferror

[Syntax]
#include <stdio.h>
int ferror( FILE *stream ) ;

[Arguments]
stream Pointer to a FILE structure.

[Return]
Returns zero if no error on the stream, otherwise non-zero value.

[Description]
Test whether any read/write error occurs on a file linked to the stream. If once any
error has been occurred, the error indicator of the stream is still ON until the stream
is closed or one of "clearerr" and "rewind" functions is called.

- 157 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
6.40 Print error message. <Main>
------------------------------------------------------------------------------

[Name]
perror

[Syntax]
#include <stdio.h>
void perror( const char *string ) ;

[Arguments]
string Error message to be displayed.

[Return]
------

[Description]
Displays an error message to the standard error output (stderr)."string" is displayed
first, then a colon (':') and a system error message about the library call which has
been occurred the latest error, and last a newline is output. If "string" is NULL pointer
or a pointer to NULL string, only system error message is displayed. A error code is
stored in a global variable "errno" defined in errno.h. A system error message is read
from "sys_errlist", an array of messages sorted by error code. "perror" function uses
"errno" as a index of "sys_errlist" to display an error message. "sys_nerr" variable
is the maximum element number of "sys_errlist" array. It is necessary to call "perror"
function just after library error to display exactly. Otherwise, the following library
calls may overwrite "errno". Values which are stored in "errno" at error are original
ones of C Languege Executor. These are not compatible with any PCs (MS-DOS machines,
etc.) and may be changed in the future. So, programming that "errno" is handling is not
recommended because it may not works correctly in the future.

- 158 -
B-64303EN-3/01 PROGRAMMING 3.Function References

7. General utilities ( stdlib.h )

------------------------------------------------------------------------------
7.1 Convert string to int value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
atoi

[Syntax]
#include <stdlib.h>
int atoi( const char *nptr ) ;

[Arguments]
nptr Pointer to a string.

[Return]
Returns a converted value of int type.

[Description]
Converts a strings pointed by "nptr" to integer value.
Format of strings is as follows.

(whitespaces)(+,-)numeric_characters

- 159 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.2 Convert string to long value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
atol

[Syntax]
#include <stdlib.h>
long atol( const char *nptr ) ;

[Arguments]
nptr Pointer to a string.

[Return]
Returns a converted value of long type.

[Description]
Converts a strings pointed by "nptr" to long integer value.
Format of strings is as follows.

(whitespaces)(+,-)numeric_characters

- 160 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
7.3 Convert string to long value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strtol

[Syntax]
#include <stdlib.h>
long strtol( const char *nptr, char **endptr, int base ) ;

[Arguments]
nptr Pointer to a string.
endptr Pointer which points the position where reading is stopped.
base Base number.

[Return]
Returns a converted value of long type. If overflow, returns LONG_MAX or LONG_MIN and
sets ERANGE in a global variable "errno".

[Description]
Converts a string pointed by "nptr" to long integer value using "base" as a base number
of conversion.
Format of strings is as follows.

(whitespaces)(+,-)(0)(x,X)(numeric_characters)

A pointer which points the position where reading is stopped is stored in "endptr". If
"endptr" is NULL, nothing is stored. If a base number is between 2 and 36, conversion
is performed using it. If a base number is zero, the top characters decide a base number
as follows.

if (0)+(0 - 7) then octal


else if (0)+(x or X) then hexadecimal
else if (1 - 9) then decimal

- 161 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.4 Convert string to unsigned long value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strtoul

[Syntax]
#include <stdlib.h>
unsigned long strtoul( const char *nptr, char **endptr, int base ) ;

[Arguments]
nptr Pointer to a string.
endptr Pointer which points the position where reading is
stopped.
base Base number.

[Return]
Returns a converted value of unsigned long type. If overflow, returns ULONG_MAX and
sets ERANGE in a global variable "errno".

[Description]
Converts a string pointed by "nptr" to unsigned long integer value using "base" as a
base number of conversion.
Format of strings is as follows.

(whitespaces)(+,-)(0)(x,X)(numeric_characters)

A pointer which points the position where reading is stopped is stored in "endptr". If
"endptr" is NULL, nothing is stored. If a base number is between 2 and 36, conversion
is performed using it.
If a base number is zero, the top characters decide a base number as follows.

if (0)+(0 - 7) then octal


else if (0)+(x or X) then hexadecimal
else if (1 - 9) then decimal

- 162 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
7.5 Generate pseudo-random number. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
rand

[Syntax]
#include <stdlib.h>
int rand( void ) ;

[Arguments]
------

[Return]
Returns a pseudo random number.

[Description]
Returns a pseudo random number between 0 and 32767. "srand" function initializes a series
of random number.

- 163 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.6 Seed pseudo-random number generator. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
srand

[Syntax]
#include <stdlib.h>
void srand( unsigned int seed ) ;

[Arguments]
seed Number of new series.

[Return]
------

[Description]
Initializes a series of random number generated by "rand" function.

- 164 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
7.7 Allocate memory block initialized by 0. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
calloc

[Syntax]
#include <stdlib.h>
void *calloc( size_t num, size_t size ) ;

[Arguments]
num Number of elements.
size Byte size of element.

[Return]
Returns pointer to the allocated space. To get other type pointer than (void *), cast
the return value. If insufficient memory, returns NULL.

[Description]
Allocates a memory block initialized by zero. That memory block is composed of "num"
elements whose size is "size" bytes. Each element is initialized by zero. Test always
the return value even if requested memory size is small.

- 165 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.8 Free memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
free

[Syntax]
#include <stdlib.h>
void free( void *memblock ) ;

[Arguments]
memblock Memory block already allocated. If NULL, it is
ignored.

[Return]
------

[Description]
Frees allocated memory block. "memblock" is a memory block which was already allocated
by "calloc", "malloc" or "realloc" function. Byte size to be freed is one which was
specified at memory allocation. Deallocated memory block will be used for the next memory
allocations. If any invalid pointer is specified, any error may occur in the future
allocations. "Invalid pointer" is one which was set without correct allocations.

- 166 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
7.9 Allocate memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
malloc

[Syntax]
#include <stdlib.h>
void *malloc( size_t size ) ;

[Arguments]
size Byte size to be allocated.

[Return]
Returns a void pointer to the allocated memory block. A return value can align with any
object type. To get other type pointer than (void *), cast the return value. If
insufficient memory, returns NULL.

[Description]
Allocates a memory block whose size is "size" bytes at least. More free space than "size"
bytes is used for allocation because of a alignment and management information. Test
always the return value even if requested memory size is small.

- 167 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.10 Reallocate memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
realloc

[Syntax]
#include <stdlib.h>
void *realloc( void *memblock, size_t size ) ;

[Arguments]
memblock Memory block already allocated.
size Byte size to be allocated.

[Return]
Returns a void pointer to the reallocated memory block. A return value can align with
any object type. To get other type pointer than (void *), cast the return value. If "size"
is zero and "memblock" is not NULL, the current block is freed and the return value is
NULL. If insufficient memory for reallocation, the current block is kept and the return
value is NULL.

[Description]
Reallocates the memory block. This changes size of already allocated memory block. If
a new block is placed in the other position, contents in the original block is kept.
If "memblock" is NULL, "realloc" function works as same as "malloc" function, allocates
a new block of "size" bytes. If "size" is not NULL, it must be a pointer which was returned
by "calloc", "malloc" or "realloc" function before. If any invalid pointer is specified,
any errors may occur by incorrect allocation.

- 168 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
7.11 Perform binary search. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
bsearch

[Syntax]
#include <stdlib.h>
void *bsearch( const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)( const void *, const void *) ) ;

[Arguments]
key Data to be searched.
base Pointer to the top of the array.
nmemb Element number of the array.
size Size of an element of the array.
compar Pointer to the user definition function which compares two elements.

[Return]
Returns a pointer to the matching element. If not found, returns NULL.

[Description]
Searches the specified data in the specified array. The array must be already sorted.
"bsearch" function calls "compar" function for searching. The return value of "compar"
function must follow the following rule.

Return Comparison result


less than 0 1st arg. < 2nd arg.
equal to 0 1st arg. = 2nd arg.
greater than 0 1st arg. > 2nd arg.

- 169 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.12 Perform quick sort. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
qsort

[Syntax]
#include <stdlib.h>
void qsort( const void *base, size_t nmemb, size_t size,
int (*compar)( const void *, const void *) ) ;

[Arguments]
base Pointer to the top of the array (its order will be
changed by sorting.)
nmemb Element number of the array.
size Size of an element of the array.
compar Pointer to the user definition function which
compares two elements.

[Return]
------

[Description]
Performs quick sorting of the specified array. "qsort" function calls "compar" function
for searching. The return value of "compar" function must follow the following rule.

Return Comparison result


less than 0 1st arg. < 2nd arg.
equal to 0 1st arg. = 2nd arg.
greater than 0 1st arg. > 2nd arg.

- 170 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
7.13 Get absolute value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
abs

[Syntax]
#include <stdlib.h>
int abs( int j ) ;

[Arguments]
j Value which is converted to absolute.

[Return]
Returns the absolute value of "j".

[Description]
Returns the absolute value of integer "j".

- 171 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.14 Get quotient and remainder. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
div

[Syntax]
#include <stdlib.h>
struct div_t {
int quot ;
int rem ;
} *div( int numer, int denum ) ;

[Arguments]
numer Dividend.
denum Divisor.

[Return]
Returns a structure "div_t".

[Description]
Divides integer value "number" by integer value "denum", and returns the quotient and
reminder. Zero value as "denum" causes a system error. Check values before calling this.

- 172 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
7.15 Get absolute value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
labs

[Syntax]
#include <stdlib.h>
long labs( long j ) ;

[Arguments]
j Value which is converted to absolute.

[Return]
Returns the absolute value of "j".

[Description]
Returns the absolute value of long integer "j".

- 173 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.16 Get quotient and remainder. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
ldiv

[Syntax]
#include <stdlib.h>
struct ldiv_t {
long quot ;
long rem ;
} *ldiv( long numer, long denum ) ;

[Arguments]
numer Dividend.
denum Divisor.

[Return]
Returns a structure "ldiv_t".

[Description]
Divides long integer value "number" by long integer value "denum", and returns the
quotient and remander. Zero value as "denum" causes a system error. Check values before
calling this.

- 174 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
7.17 Convert string to double value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
atof

[Syntax]
#include <stdlib.h>
double atof( const char *nptr ) ;

[Arguments]
nptr Pointer to a string.

[Return]
Returns a converted value of double type.

[Description]
Converts a strings pointed by "nptr" to double type value.
Format of strings is as follows.

(whitespaces)(+,-)num(.num)((d,D,e,E )(+,-)num)
num: numeric_characters

- 175 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
7.18 Convert string to double value. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strtod

[Syntax]
#include <stdlib.h>
double strtod( const char *nptr, char **endptr ) ;

[Arguments]
nptr Pointer to a string.
endptr Pointer which points the position where reading is stopped.

[Return]
Returns a converted value of double type. If overflow, returns +/-HUGE_VAL. If underflow,
returns 0. In both case, sets ERANGE in a global variable "errno".

[Description]
Converts a string pointed by "nptr" to double type value.
Format of strings is as follows.

(whitespaces)(+,-)num(.num)((d,D,e,E )(+,-)num)
num: numeric_characters

A pointer which points the position where reading is stopped is stored in "endptr". If
"endptr" is NULL, nothing is stored.

- 176 -
B-64303EN-3/01 PROGRAMMING 3.Function References

8. String handling ( string.h )

------------------------------------------------------------------------------
8.1 Copy a memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
memcpy

[Syntax]
#include <string.h>
void *memcpy( void *s1, const void *s2, size_t n ) ;

[Arguments]
s1 Pointer to the destination.
s2 Pointer to the source.
n Byte count.

[Return]
Returns a pointer as same as "s1".

[Description]
Copies "n" byte data from the location specified by "s2" to the location specified by
"s1". If the source and the destination are overlapped, the result is undefined. In this
case, use "memmove" function.

- 177 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.2 Move a memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
memmove

[Syntax]
#include <string.h>
void *memmove( void *s1, void *s2, size_t n ) ;

[Arguments]
s1 Pointer to the destination.
s2 Pointer to the source.
n Byte count.

[Return]
Returns a pointer as same as "s1".

[Description]
Moves "n" byte data from the location specified by "s2" to the location specified by
"s1". The memory block is copied correctly even if the source and the destination are
overlapped.

- 178 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.3 Copy a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strcpy

[Syntax]
#include <string.h>
char *strcpy( char *s1, const char *s2 ) ;

[Arguments]
s1 Pointer to the destination.
s2 Pointer to the source.

[Return]
Returns a pointer as same as "s1".

[Description]
Copies a string pointed by "s2" to the location pointed by "s1". If the source and the
destination are overlapped, the result is undefined.

- 179 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.4 Copy a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strncpy

[Syntax]
#include <string.h>
char *strncpy( char *s1, const char *s2, size_t n ) ;

[Arguments]
s1 Pointer to the destination.
s2 Pointer to the source.
n Character count.

[Return]
Returns a pointer as same as "s1".

[Description]
Copies a string of "n" characters pointed by "s2" to the location pointed by "s1". If
the length of "s2" string is longer than "n", a NULL character is not added to the copied
string. If the length of "s2" is shorter than "n", NULL characters are added to the copied
string until "n" bytes in total. If the source and the destination are overlapped, the
result is undefined.

- 180 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.5 Concatenate a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strcat

[Syntax]
#include <string.h>
char *strcat( char *s1, const char *s2 ) ;

[Arguments]
s1 Pointer to the destination string.
s2 Pointer to the string to be concatenated.

[Return]
Returns a pointer as same as "s1".

[Description]
Concatenates a strings pointed by "s2" to the last of a string pointed by "s1". A NULL
character is added at last.

- 181 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.6 Concatenate a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strncat

[Syntax]
#include <string.h>
char *strncat( char *s1, const char *s2, size_t n ) ;

[Arguments]
s1 Pointer to the destination string.
s2 Pointer to the string to be concatenated.
n Character count to be concatenated.

[Return]
Returns a pointer as same as "s1".

[Description]
The strncat function adds as many characters as specified by argument n of the string
specified by argument s2 to the end of the string specified by argument s1. When the
number of characters in the string specified by argument s2 is greater than the number
specified by argument n, the copied characters is followed by the NULL character. When
the number of characters in the string specified by argument s2 is less than the number
specified by argument n, all characters in the string specified by s2 are added and the
characters are followed by the NULL character. The pointer specified by s1 is returned.

- 182 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.7 Compare two memory blocks. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
memcmp

[Syntax]
#include <string.h>
int memcmp( const void *s1, const void *s2, size_t n ) ;

[Arguments]
s1 Pointer to a memory block to be compared.
s2 Pointer to a memory block to be compared.
n Byte count to be compared.

[Return]
Returns the comparison result.

Return Comparison result


<0 s1 < s2
=0 s1 = s2
>0 s1 > s2

[Description]
Compare "n" byte data in the location pointed by "s1" with one by "s2".

- 183 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.8 Compare two strings. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strcmp

[Syntax]
#include <string.h>
int strcmp( const char *s1, const char *s2 ) ;

[Arguments]
s1 Pointer to a string to be compared.
s2 Pointer to a string to be compared.

[Return]
Returns the comparison result.

Return Comparison result


<0 s1 < s2
=0 s1 = s2
>0 s1 > s2

[Description]
Compares a string pointed by "s1" with one by "s2".

- 184 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.9 Compare two strings. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strncmp

[Syntax]
#include <string.h>
int strncmp( const char *s1, const char *s2, size_t n ) ;

[Arguments]
s1 Pointer to a string to be compared.
s2 Pointer to a string to be compared.
n Character count to be compared.

[Return]
Returns the comparison result.

Return Comparison result


<0 s1 < s2
=0 s1 = s2
>0 s1 > s2

Compares "n" characters of a string pointed by "s1" with one by "s2".

- 185 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.10 Find a character in a memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
memchr

[Syntax]
#include <string.h>
void *memchr( const void *s, int c, size_t n ) ;

[Arguments]
s Pointer to a memory block in which data is searched.
c Data to be searched.
n Character count to be searched.

[Return]
Returns a pointer to the first matching data. If not found, returns NULL.

[Description]
Searches "c" in "n" bytes of the memory block specified by "s", and returns the location
of the first matching data. "c" is converted to "unsigned char".

- 186 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.11 Find a character in a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strchr

[Syntax]
#include <string.h>
char *strchr( const char *s, int c ) ;

[Arguments]
s Pointer to a string in which a character is searched.
c Character to be searched.

[Return]
Returns a pointer to the first matching location. If not found, returns NULL.

[Description]
Searches "c" in a string pointed by "s", and returns the location of the first matching
character. "c" is converted to "char".

- 187 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.12 Get string length which doesn't include a character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strcspn

[Syntax]
#include <string.h>
size_t strcspn( const char *s1, const char *s2 ) ;

[Arguments]
s1 Pointer to a string.
s2 Pointer to a string.

[Return]
Returns length from the top of "s1" to the part in which any characters of "s2" are not
contained.

[Description]
Returns length from the top of string "s1" to the part of "s1" in which any characters
included in "s2" are not contained.

- 188 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.13 Find a character position in a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strpbrk

[Syntax]
#include <string.h>
char *strpbrk( const char *s1, const char *s2 ) ;

[Arguments]
s1 Pointer to a string.
s2 Pointer to a string.

[Return]
Returns a pointer to the first position matching to the one of characters included in
string "s2". If not matching character, returns NULL.

[Description]
Searches one of characters included in string "s2" from the top of the string "s1", and
returns the first matching position.

- 189 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.14 Find the last character in a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strrchr

[Syntax]
#include <string.h>
char *strrchr( const char *s, int c ) ;

[Arguments]
s Pointer to a string in which a character is searched.
c Character to be searched.

[Return]
Returns a pointer to the last matching location. If not found, returns NULL.

[Description]
Searches "c" in a string pointed by "s", and returns the location of the last matching
character. "c" is converted to "char".

- 190 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.15 Get string length composed by specified character. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strspn

[Syntax]
#include <string.h>
size_t strspn( const char *s1, const char *s2 ) ;

[Arguments]
s1 Pointer to a string.
s2 Pointer to a string.

[Return]
Returns length from the top of "s1" to the part in which one of characters of "s2" is
contained.

[Description]
Returns length from the top of string "s1" to the part of "s1" in which one of characters
included in "s2" is contained.

- 191 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.16 Find a string in a string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strstr

[Syntax]
#include <string.h>
char *strstr( const char *s1, const char *s2 ) ;

[Arguments]
s1 Pointer to a string.
s2 Pointer to a string.

[Return]
Returns a pointer to the first matching location in the string "s1".
If not found, returns NULL.

[Description]
Searches a string "s1" in a string "s1", and returns the pointer to the first matching
location.

- 192 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.17 Get a token. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strtok

[Syntax]
#include <string.h>
char *strtok( char *s1, const char *s2 ) ;

[Arguments]
s1 Pointer to a string. (is changed by processing)
s2 Pointer to a string.

[Return]
Returns a pointer to the token. The token is a string terminated by a NULL character.
If no token, returns NULL.

[Description]
Divide a string "s1" into tokens using each characters of a string "s2" as delimiters.
At the first call, "strtok" searches the first token, and returns a pointer to it. If
the first character of the string is any token, "strtok" ignores it. At the following
calls, specify NULL as the argument "s1". Note that "strtok" function changes a string
"s1".

- 193 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
8.18 Fill data in a memory block. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
memset

[Syntax]
#include <string.h>
void *memset( void *s, int c, size_t n ) ;

[Arguments]
s Pointer to a memory block in where "c" is filled.
c Data to be filled.
n Byte count.

[Return]
Returns a pointer as same as "s".

[Description]
Fills "c" in the "n" byte space from "s".

- 194 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
8.19 Get string length. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
strlen

[Syntax]
#include <string.h>
size_t strlen( const char *s ) ;

[Arguments]
s Pointer to a string.

[Return]
Returns length of string "s".

[Description]
Returns length of string "s".

- 195 -
3.Function References PROGRAMMING B-64303EN-3/01

9. Date and time ( time.h )

------------------------------------------------------------------------------
9.1 Get the current time. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
clock

[Syntax]
#include <time.h>
clock_t clock( void ) ;

[Arguments]
------

[Return]
Returns the current system time counter.

[Description]
Returns the value of the current system time counter. The system time counter is the
accumulated count from the system start-up which is counted up every 8 msec.

(Note) The clock_t type of a return value is the long type, and the return value may
be negative depending on the time accumulated from the system start-up. The return
value must therefore be cast to the unsigned long type before an operation such
as a comparison can be performed on the value.

- 196 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
9.2 Convert local time to calendar time. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
mktime

[Syntax]
#include <time.h>
time_t mktime( struct tm *timeptr ) ;

[Arguments]
timeptr Pointer to a structure "tm".

[Return]
Returns a calendar time.

[Description]
Converts the local time data pointed by *timeptr to a calendar time.
The specified structure "tm" is converted to the standard setting.

- 197 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
9.3 Get the current time. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
time

[Syntax]
#include <time.h>
time_t time( time_t *timer ) ;

[Arguments]
timer Pointer to a time.

[Return]
Returns the current time.

[Description]
Returns the current time as the accumulated second from 1/1/1970 00:00:00. If "timer"
is not NULL, also stores the current time in "*timer".

The time returned by this function is read from the calendar clock of the CNC device.
If the calendar clock is not set correctly, -1L is returned.

- 198 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
9.4 Convert time to string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
asctime

[Syntax]
#include <time.h>
char *asctime( const struct tm *timeptr ) ;

[Arguments]
timeptr Pointer to a structure "tm".

[Return]
Returns a pointer to a converted string.

[Description]
Converts a time data pointed by "timeptr" to a string. The format of string is as follows.

"Sun Jan 01 00:00:00 1992¥n"


Newline
Year
Second
Minute
Hour
Date
Month
Day

Stored buffer for a converted string is the same static buffer as "ctime" function.

- 199 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
9.5 Convert time to string. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
ctime

[Syntax]
#include <time.h>
char *ctime( const time_t *timer ) ;

[Arguments]
timer Pointer to a timer.

[Return]
Returns a pointer to a converted string.

[Description]
Converts a time data pointed by "timer" to a string as the local time. The format of
string is as follows.

"Sun Jan 01 00:00:00 1992¥n"


Newline
Year
Second
Minute
Hour
Date
Month
Day

"ctime( timer )" is equivalent to "asctime( localtime( timer ) )".


Stored buffer for a converted string is the same static buffer as "asctime" function.

- 200 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
9.6 Convert time to Greenwich mean time. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
gmtime

[Syntax]
#include <time.h>
struct tm *gmtime( const time_t *timer ) ;

[Arguments]
timer Pointer to a timer.

[Return]
Returns a pointer to a converted structure "tm".

[Description]
Converts a timer pointed by "*timer" to a structure "tm" which represents the Greenwich
Mean Time. The second from 1/1/1970 00:00:00 is stored in "*timer". This value is usually
the return value of "time" function. The static buffer for the structure "tm" is shared
by "localtime" function.

- 201 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------
9.7 Convert time to local time. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
localtime

[Syntax]
#include <time.h>
struct tm *localtime( const time_t *timer ) ;

[Arguments]
timer Pointer to a timer.

[Return]
Returns a pointer to a converted structure "tm".

[Description]
Converts a timer pointed by "*timer" to a structure "tm" which represents the local time.
The second from 1/1/1970 00:00:00 is stored in "*timer". This value is usually the return
value of "time" function. The static buffer for the structure "tm" is shared by "gmtime"
function.

- 202 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------
9.8 Compute the difference between the two times. <Main,Alarm,Comm>
------------------------------------------------------------------------------

[Name]
difftime

[Syntax]
#include <time.h>
double difftime( time_t time1, time_t time2 ) ;

[Arguments]
time_1 Beginning time.
time_2 Ending time.

[Return]
Returns elapsed time in second between "time2" through "time1".

[Description]
Calculates the difference of time by subtracting "time1" from "time2".

- 203 -
3.Function References PROGRAMMING B-64303EN-3/01

3.2 MS-C extended C standard library

3.2.1 Lists of Functions

NAME FUNCTION
_chdrive Change the current drive.
_dos_findfirst Find the first file whose attributes match the specified ones.
_dos_findnext Find the next file whose attributes match the specified ones.
_dos_getdiskfree Get disk information’s.
_expand Change a memory block size.
_fcalloc Allocate an array initialized by 0 in memory.
_fexpand Change a memory block size.
_ffree Free a memory block.
_fmalloc Allocate a memory block.
_fmemchr Find a character in a memory block.
_fmemcmp Compare two memory blocks.
_fmemcpy Copy a memory block.
_fmemicmp Compare two memory blocks ignoring cases.
_fmemmove Move a memory block.
_fmemset Fill a memory block with a character.
_fmsize Get memory block size in heap.
_frealloc Reallocate memory block.
_fstrcat Concatenate a string.
_fstrchr Find a character in a string.
_fstrcmp Compare two strings.
_fstrcpy Copy a string.
_fstrcspn Get string length which doesn't include a character.
_fstricmp Compare two strings ignoring cases.
_fstrlen Get string length.
_fstrlwr Convert string to lowercase.
_fstrncat Concatenate a string.
_fstrncmp Compare two strings.
_fstrncpy Copy a string.
_fstrnicmp Compare two strings ignoring cases.
_fstrnset Fill a string with a character.
_fstrpbrk Find a character position in a string.
_fstrrchr Find the last character in a string.
_fstrrev Reverse characters in a string.
_fstrset Fill a string with a character.
_fstrspn Get string length composed by specified character.
_fstrstr Find a string in a string.
_fstrtok Get a token.

- 204 -
B-64303EN-3/01 PROGRAMMING 3.Function References

NAME FUNCTION
_fstrupr Convert string to uppercase.
_getdrive Get the current drive.
_lrotl Rotate an unsigned long left.
_lrotr Rotate an unsigned long right.
_msize Get memory block size in heap.
_rotl Rotate unsigned int left.
_rotr Rotate unsigned int right.
_tolower Convert to lowercase.
_toupper Convert to uppercase.
alloca Allocate a memory block in stack.
cabs Calculate the absolute value of complex number.
chdir Change the current directory.
close Close a file.
creat Create a file.
ecvt Convert double value to string.
eof Test the end of file.
fcvt Convert floating point value to string.
gcvt Convert floating point value and store it in a buffer.
getch Get a character from the console.
getcwd Get the current directory.
hypot Calculate the square root of the sum of two squares.
isascii Test for ASCII character.
itoa Convert an int value to a string.
kbhit Check inputting status of keyboard.
lseek Move the current file pointer.
ltoa Convert a long value to a string.
memicmp Compare two memory blocks ignoring cases.
mkdir Create a new directory.
open Open a file.
read Read data from a file.
rmdir Delete a directory.
stackavail Get available stack size.
strcmpi Compare two strings ignoring cases.
stricmp Compare two strings ignoring cases.
strlwr Convert string to lowercase.
strnicmp Compare two strings ignoring cases.
strnset Fill a string with a character.
strrev Reverse characters in a string.
strset Fill a string with a character.
strupr Convert string to uppercase.
swab Swap two bytes.
tell Get the current position of a file.

- 205 -
3.Function References PROGRAMMING B-64303EN-3/01

NAME FUNCTION
toascii Convert to a ASCII character.
ultoa Convert an unsigned long value to a string.
write Write data to a file.
Determine whether the character of interest is a half-size alphanumeric or katakana
btom
character.
chkctype Count characters.
hantozen Determine what the character type of the character of interest is.
isalkana Convert a 1-byte character to the corresponding 2-byte character.
Determine whether the character of interest is a half-size alphanumeric
isalnmkana
or katakana character
Determine whether the character of interest is a printable ASCII character (except a
isgrkana
half-size space).
Determine whether the character of interest is a printable half-size kana character (except
iskana
a half-size space).
iskanji Determine whether the character of interest is byte 1 of a 2-byte character.
iskanji2 Determine whether the character of interest is byte 2 of a 2-byte character.
iskmoji Determine whether the character of interest is a half-size katakana character.
iskpun Determine whether the character of interest is a half-size kana symbol.
ispnkana Determine whether the character of interest is a half-size symbol.
isprkana Determine whether the character of interest is a printable character.
jisalpha Determine whether the character of interest is a full-size alphabetic character.
jisdigit Determine whether the character of interest is a full-size numeric character.
jishira Determine whether the character of interest is a full-size hiragana character.
jiskata Determine whether the character of interest is a full-size katakana character.
jiskigou Determine whether the character of interest is a full-size symbol.
jisl0 Determine whether the character of interest is a JIS non-kanji character.
jisl1 Determine whether the character of interest is a JIS level 1 kanji character.
jisl2 Determine whether the character of interest is a JIS level 2 kanji character.
jislower Determine whether the character of interest is a full-size lowercase alphabetic character.
jisprint Determine whether the character of interest is a printable character.
jisspace Determine whether the character of interest is a full-size space.
jistojms Convert a JIS kanji code to the corresponding shifted JIS kanji code.
jisupper Determine whether the character of interest is a full-size uppercase alphabetic character.
jiszen Determine whether the character of interest is a 2-byte character.
jmstojis Convert a shifted JIS kanji code to the corresponding JIS kanji code.
jtohira Convert a full-size katakana character to the corresponding full-size hiragana character.
jtokata Convert a full-size hiragana character to the corresponding full-size katakana character.
Convert a full-size uppercase alphabetic character to the corresponding full-size
jtolower
lowercase alphabetic character.
Convert a full-size lowercase alphabetic character to the corresponding full-size
jtoupper
uppercase alphabetic character.
mtob Determine how many bytes are in a character string.

- 206 -
B-64303EN-3/01 PROGRAMMING 3.Function References

NAME FUNCTION
nthctype Determine what the character type of a character in a character string is.
zentohan Convert a 2-byte character to the corresponding 1-byte character.

Refer the function reference of MS-C for detail.

"getch" and "kbhit" functions are available in the Main task. The other functions are available
in the Main, the Alarm and the Communication tasks.

- 207 -
3.Function References PROGRAMMING B-64303EN-3/01

3.3 Graphic library

3.3.1 Usage of graphic functions

1. Kinds of the graphic display device.

C Language Executor for Series 0i-D supports the following graphic display device.
For details about the display device, see also Section 3.6, "CRT operation library" below
in Part II, "PROGRAMMING".

Device that can be connected 8.4-inch color LCD


10.4-inch color LCD
10.4-inch color LCD (with touch-panel)

(1) VGA Graphic.

This is the display device that is equipped with Series 0i-D.This name is derived from the
display control LSI (VGA compatible accelerator chip for PC) used for them.
The following 4 display modes are supported.

A. 640×400 dots, 16 colors for each dot, overlapped with the character screen
(80-column × 25-line).
B. 640×400 dots, 256 colors for each dot, not overlapped with the character screen.
C. 640×480 dots, 16 colors for each dot, overlapped with the character screen
(80-column × 30-line).
D. 640×480 dots, 256 colors for each dot, not overlapped with the character screen.

The application program can specify the graphic mode by calling"_setvideomode" function.
For details about the function, see "52. _setvideomode" below in Subsection 3.3.3, "Function
reference".

2. Kinds of the graphic functions.

C Language Library provides the following two kinds of the graphic functions.

(1) MS-C compatible graphic functions

These are the compatible functions with the graphic functions


included in the MS-C Library.

(2) C Language Executor original graphic functions

These are the original graphic functions for C Language Executor.

- 208 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3. Open and close graphics.

Call the crt_opengr function before calling of the other graphic functions in the user
application.Call the crt_closegr function after a series of graphic drawings. The flow of
the processing is as follows.

:
if ( crt_opengr() ) { /* open graphics */
/* initialize graphic screen */
_setvideomode( _98RESSCOLOR ) ;
:
}
:
: /* graphic drawings */
:
crt_closegr() ; /* close graphic */
:

The graphic drawings are not done without execution of the crt_opengr function.(_GRNOOUTPUT
status will be returned.) The screen switching is inhibited during opening graphics. It is
enabled to switch the screen by the execution of the crt_setswt( CRT_SWT_GREN ) function
before opening graphics, however, the graphics is closed by the screen switching during
opening graphics and graphic drawings are not done until the crt_opengr function will be
called again even if graphic functions are called.
The screen switching request during opening graphics (such as the screen selection by MDI
key) is being pending state until the graphics will be closed, and the pending screen switching
will be performed when the crt_closegr function is called.

(*) For an explanation of the crt_opengr, crt_closegr, and crt_setswt functions, see Section
3.6, "CRT operation library" below in Part II, "PROGRAMMING".

4. Multi-window display.

The multi-window displaying is not available for graphics. The graphic screen is always
displayed on the full screen even if the multi-windows of character are being displayed.

- 209 -
3.Function References PROGRAMMING B-64303EN-3/01

3.3.2 Lists of MS-C compatible functions

C Language Executor supports the following MS-C compatible graphic functions.

ITEM NAME FUNCTION


1 _arc Draw an arc or an elliptic arc.
2 _clearscreen Clear screen.
3 _ellipse Draw a circle or an ellipse.
4 _floodfill Paint the closed region.
5 _getactivepage Get the current active page number.
6 _getarcinfo Get the information of the previous arc or pie.
7 _getbkcolor Get the current back ground color.
8 _getcolor Get the current fore ground color.
9 _getcurrentposition Get the current position in the view coordinate.
10 _getfillmask Get the current fill mask pattern.
11 _getfontinfo Get the current font information.
12 _getgtextextent Get the text extent by pixel unit.
13 _getgtextvector Get the output vector of text.
14 _getimage Get screen image.
15 _getkanji Get the font pattern of Kanji character.
16 _getlinestyle Get the current line style.
17 _getphyscoord Convert view coordinate into physical.
18 _getpixel Get color number the pixel.
19 _gettextposition Get the current output position of text.
20 _gettextwindow Get the text window border.
21 _getvideoconfig Get the graphic configuration.
22 _getviewcoord Convert physical coordinate into view.
23 _getvisualpage Get the current visual page number.
24 _getwritemode Get the current writing mode.
25 _grstatus Get the return status of graphic function.
26 _imagesize Get image buffer size.
27 _kanjisize Get font pattern size of Kanji character.
28 _lineto Draw a line.
29 _moveto Move the current graphic output position.
30 _outgtext Draw a text string using the current font.
31 _outmem Draw a text string in a memory.
32 _outtext Output a text string on the current position.
33 _pie Draw a pie figure.
34 _polygon Draw a polygon.
35 _putimage Put image data on the screen.
36 _rectangle Draw a rectangle.
37 _registerfonts Register font file.

- 210 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ITEM NAME FUNCTION


38 _remapallpalette Map colors into all color palette.
39 _remappalette Map a color into a color palette.
40 _setactivepage Set the current active page number.
41 _setbkcolor Set the current back ground color.
42 _setcliprgn Set the clipping region.
43 _setcolor Set the current fore ground color.
44 _setfillmask Set the current fill mask pattern.
45 _setfont Set the current font.
46 _setgtextvector Set the current output vector of text.
47 _setlinestyle Set the current line style.
48 _setpixel Draw a pixel.
49 _settextposition Set the current output position of text.
50 _settextrows Set the text row number.
51 _settextwindow Set the text window.
52 _setvideomode Set the screen video mode.
53 _setvideomoderows Set the screen video mode and text row number.
54 _setvieworg Set the origin of the view port.
55 _setviewport Set the clipping region and the view coordinate.
56 _setvisualpage Set the current visual page number.
57 _setwritemode Set the current writing mode.
58 _unregisterfonts Delete registered font file.
59 _wrapon Enable/disable line wrapping.

- 211 -
3.Function References PROGRAMMING B-64303EN-3/01

3.3.3 Function Reference

In the following section, the differences from the graphic functions of MS-C are mainly explained.
Refer the function reference manual of MS-C for the details of each functions. The concrete
behaviors of each functions which are not clearly mentioned in the reference manual of MS-C are
described in "<MS-C Compatible Specification>" part of "[Compatibility]" section.

------------------------------------------------------------------------------------------
1. Draw an arc or an elliptic arc. <Main>
------------------------------------------------------------------------------------------

[Name]
_arc

[Syntax]
#include <graph.h>
short _arc( short rsx, short rsy, short rex, short rey,
short vsx, short vsy, short vex, short vey ) ;

[Description]
Draws an arc or an elliptic arc.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The following status is not returned by "_grstatus" function after the execution of this
function.

The output is clipped by view port. : _GRCLIPPED

In this case, the same graphic status is return as _GRNOOUTPUT, and the return value of this
function is always "0". (Could not draw normally)

(2) There may be the difference from specified rectangle by the drawing precision of this
function.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Executed in text mode : _GRNOTINPROPERMODE
Invalid parameters : _GRINVALIDPARAMETER
Not drawn in clipping region : _GRNOOUTPUT

- 212 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
2. Clear screen. <Main>
-------------------------------------------------------------------------------------------

[Name]
_clearscreen

[Syntax]
#include <graph.h>
void _clearscreen( short area ) ;

[Description]
Clears specified region and paint it by the current back ground color.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) "_GWINDOW" is not supported for screen specification because MS-C graphic functions for
window are not supported.

- 213 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
3. Draw a circle or an ellipse. <Main>
-------------------------------------------------------------------------------------------

[Name]
_ellipse

[Syntax]
#include <graph.h>
short _ellipse( short fill, short rsx, short rsy,
short rex, short rey ) ;

[Description]
Draws a circle or an ellipse.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The following status is not returned by "_grstatus" function after the execution of this
function.

The output is clipped by view port. : _GRCLIPPED

In this case, the same graphic status is return as _GRNOOUTPUT, and the return value
of this function is always "0".(Could not draw normally) However, the right value is
not returned in case of the _GFILLINTERIOR attribute is specified.

(2) The logical operation of "_setwritemode" is not effective to this function in MS-C, but
effective in C Language Executor. Therefore, the outline (border line) may not be drawn
by specified logical color in case that _GFILLINTERIOR is specified and _GPSET is not
specified in this function.

(3) There may be the difference from specified rectangle by the drawing precision of this
function.

(4) The painting operation may not be done correctly in case that _GFILLINTERIOR is specified
in this function.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Executed in text mode : _GRNOTINPROPERMODE
Invalid parameters : _GRINVALIDPARAMETER
Not painted due to insufficient memory : _GRINSUFFICIENTMEMORY
Not drawn in clipping region : _GRNOOUTPUT

- 214 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
4. Paint the closed region. <Main>
------------------------------------------------------------------------------------------

[Name]
_floodfill

[Syntax]
#include <graph.h>
short _floodfill( short sx, short sy, short boundary ) ;

[Description]
Paints the region, where is enclosed by specified border color, by the current fill mask
pattern.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The error status is not returned in case that the start point is specified out of clipping
region.

(2) The painting may not be executed correctly in case that the same color region as the
current color exists in the enclosed region.

- 215 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
5. Get the current active page number. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getactivepage

[Syntax]
#include <graph.h>
short _getactivepage( void ) ;

[Description]
Gets the page number of the plane to be drawn.

[Compatibility]
This function is compatible with the "_getactivepage" function of MS-C.

- 216 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
6. Get the information of the previous arc or pie. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getarcinfo

[Syntax]
#include <graph.h>
short _getarcinfo( struct _xycoord *start, struct _xycoord *end,
struct _xycoord *fillpoint ) ;

[Description]
Gets the view port coordinates of the arc or pie which has been drawn just previously,
and gets the start coordinate to paint a pie.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) This function gets the actual drawing start and end coordinates.

(2) The painting start coordinate may be different from what MS-C calculates because the
calculation method is different between C Language Executor and MS-C.

<MS-C Compatible Specification>

(1) The start point to paint a pie is calculated by supposing the closed region of the arc
which is drawn by the start and end points as same as MS-C.

- 217 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
7. Get the current back ground color. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getbkcolor

[Syntax]
#include <graph.h>
long _getbkcolor( void ) ;

[Description]
Gets the current back ground color.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) In MS-C, the value of palette 0 or index is returned.

(2) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed in text mode : _GRNOTINPROPERMODE

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK

- 218 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
8. Get the current fore ground color. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getcolor

[Syntax]
#include <graph.h>
short _getcolor( void ) ;

[Description]
Gets the palette number of the current fore ground color.

[Compatibility]
This function is compatible with the "_getcolor" function of MS-C.

- 219 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
9. Get the current position in the view coordinate. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getcurrentposition

[Syntax]
#include <graph.h>
struct _xycoord _getcurrentposition( void ) ;

[Description]
Gets the current position in the view coordinate.

[Compatibility]
This function is compatible with the "_getcurrentposition" function of MS-C.

- 220 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
10. Get the current fill mask pattern. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getfillmask

[Syntax]
#include <graph.h>
unsigned char *_getfillmask( unsigned char *mask ) ;

[Description]
Gets the current fill mask pattern.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) In C Language Executor, "_setfillmask" sets the fill mask pattern as the default status
when the mask data is "full(-1)" for the painting performance. Therefore, this function
may return NULL as the return value if any fill mask pattern is registered.

- 221 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
11. Get the current font information. <Main>
------------------------------------------------------------------------------------------

[Name]
_getfontinfo

[Syntax]
#include <graph.h>
short _getfontinfo( struct _fontinfo *fontbuffer ) ;

[Description]
Gets the current font information and stores it in the buffer.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) Font name.


This function returns the font name of ANK character set.
When Kanji character set is defined, this returns "standard".

(2) Font filename.


This function returns the font name.

- 222 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
12. Get the text extent by pixel unit. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getgtextextent

[Syntax]
#include <graph.h>
short _getgtextextent( unsigned char *text ) ;

[Description]
Gets the extent of the specified font by pixel unit on the current font information

[Compatibility]
This function is compatible with the "_getgtextextent" function of MS-C.

- 223 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
13. Get the output vector of text. <Main>
------------------------------------------------------------------------------------------

[Name]
_getgtextvector

[Syntax]
#include <graph.h>
struct _xycoord _getgtextvector( void ) ;

[Description]
Gets the output vector of the font text.

[Compatibility]
This function is compatible with the "_getgtextvector" function of MS-C.

- 224 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
14. Get screen image. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getimage

[Syntax]
#include <graph.h>
void _getimage( short rsx, short rsy,
short rex, short rey, char *image ) ;

[Description]
Gets the screen image and stores it in memory.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The maximum image size is 64K bytes because "huge" data is unavailable in C Language
Executor.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Could not store the image : _GRERROR
Executed in text mode : _GRNOTINPROPERMODE
The left-top and the right-bottom : _GRPARAMETERALTERED
coordinates are exchanged.

- 225 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
15. Get the font pattern of Kanji character. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getkanji

[Syntax]
#include <graph.h>
short _getkanji( unsigned short code, unsigned char *image ) ;

[Description]
Gets the font pattern of the specified Kanji character.

[Compatibility]
The character pattern format of MS-C for PC-9800 series and for PC-AT are different each
other. This function adopts the PC-9800 format.
The storing order of the character pattern array is as follows.

1) 10.4-inch color LCD

First the left half is stored, and then the right half is stored.
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
□□□□□□□□ □□□□□□□□
□□□□□□□■ □□□■□□□□
□■■□□■■■ ■■■■■■□□
□□□■□□□■ □□□■□□□□
□□□□□□■■ ■■■■■□□□
□■■□□□■□ □■□□■□□□
□□□■□□■■ ■■■■■□□□
□□□□□□□□ □■□□□□□□
□□□■□□■■ ■■■■■□□□
□□□■□□□□ □■□□□□□□
□□□■□■■■ ■■■■■■□□
□□■□□□□□ ■□■□□□□□
□□■□□□□■ □□□■□□□□
□■■□□■■□ □□□□■■□□
□□□□□□□□ □□□□□□□□
□□□□□□□□ □□□□□□□□

Binary data stored actually.


0x10,0x10,
0x00,0x01,0x67,0x11,0x03,0x62,0x13,0x00,
0x13,0x10,0x17,0x20,0x21,0x66,0x00,0x00,
0x00,0x10,0xfc,0x10,0xf8,0x48,0xf8,0x40,
0xf8,0x40,0xfc,0xa0,0x10,0x0c,0x00,0x00

- 226 -
B-64303EN-3/01 PROGRAMMING 3.Function References

2) 8.4-inch color LCD

Data is stored from left to right.


7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
□□□□□□□■ ■□□□□□■■ ■□■■■□□□ □□□□□□□□
□□□□□□□□ ■■□□□□□■ ■□□■■□□□ ■■□□□□□□
□□□□□□□□ ■■□■■■■■ ■■■■■■■■ ■■■□□□□□
□□□□□□□□ □□□□□□□■ ■□□■■□□□ □□□□□□□□
□□□□□□□□ □□□□□□□■ ■□□■■□□□ □□□□□□□□
□□□□□□□□ □□■□■□□□ □□□□□□■■ □□□□□□□□
□□□□□■■□ □□■□■■■■ ■■■■■■■■ ■□□□□□□□
□□□□□□■■ □□■□■■□□ □■■□□□■■ □□□□□□□□
□□□□□□■■ □■■□■■□□ □■■□□□■■ □□□□□□□□
□□□□□□□□ □■□□■■■■ ■■■■■■■■ □□□□□□□□
□□□□□□□□ □■□□□□□□ □■■□□□□□ □□□□□□□□
□□□□□□□□ ■■□□□□□□ □■■□□□■■ □□□□□□□□
□□□□□□□□ ■■□■■■■■ ■■■■■■■■ ■□□□□□□□
□□□□□□□■ ■□□□□□□□ □■■□□□□□ □□□□□□□□
□□□□□□□■ ■□□□□□□□ □■■□□□□■ ■□□□□□□□
□□□□□■■■ □□■■■■■■ ■■■■■■■■ ■■□□□□□□
□□□□□□■■ □□□□□□□□ ■■■□□□□□ □□□□□□□□
□□□□□□□■ □□□□□□□■ ■□■■□□□□ □□□□□□□□
□□□□□□□■ □□□□□□■■ □□□■■□□□ □□□□□□□□
□□□□□□■■ □□□□□■■□ □□□□■■■■ □□□□□□□□
□□□□□□■■ □□□■■■□□ □□□□□□■■ ■■■□□□□□
□□□□□□□□ □■■■□□□□ □□□□□□□□ ■■□□□□□□
□□□□□□□□ □□□□□□□□ □□□□□□□□ □□□□□□□□
□□□□□□□□ □□□□□□□□ □□□□□□□□ □□□□□□□□
□□□□□□□□ □□□□□□□□ □□□□□□□□ □□□□□□□□

Binary data stored actually.


0x19,0x20,
0x01,0x00,0x00,0x00,0x00,0x00,0x06,0x03,
0x03,0x00,0x00,0x00,0x00,0x01,0x01,0x07,
0x03,0x01,0x01,0x03,0x03,0x00,0x00,0x00,
0x00,
0x83,0xc1,0xdf,0x01,0x01,0x28,0x2f,0x2c,
0x6c,0x4f,0x40,0xc0,0xdf,0x80,0x80,0x2f,
0x00,0x01,0x03,0x06,0x1c,0x70,0x00,0x00,
0x00,
0xb8,0x98,0xff,0x98,0x98,0x03,0xff,0x63,
0x63,0xff,0x60,0x63,0xff,0x60,0x61,0xff,
0xe0,0xb0,0x18,0x0f,0x03,0x00,0x00,0x00,
0x00,
0x00,0xc0,0xe0,0x00,0x00,0x00,0x80,0x00,
0x00,0x00,0x00,0x00,0x80,0x00,0x80,0xc0,
0x00,0x00,0x00,0x00,0xe0,0xc0,0x00,0x00,
0x00

- 227 -
3.Function References PROGRAMMING B-64303EN-3/01

[Remarks]
(1) Use "crt_reguserchar" function to register the font pattern.

(2) With a 8.4-inch color LCD, there is a limit on character types for which font patterns
can be read in reduced display mode.
Only 128 one-byte characters of character codes 0x20 to 0x5F and 0xA0 to 0xDF can be
handled in reduced display mode.

- 228 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
16. Get the current line style. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getlinestyle

[Syntax]
#include <graph.h>
unsigned short _getlinestyle( void ) ;

[Description]
Gets the current line style.

[Compatibility]
This function is compatible with the "_getlinestyle" function of MS-C.

- 229 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
17. Convert view coordinate into physical. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getphyscoord

[Syntax]
#include <graph.h>
struct _xycoord _getphyscoord( short x, short y ) ;

[Description]
Converts the view coordinate into the physical coordinate.

[Compatibility]
This function is compatible with the "_getphyscoord" function of MS-C.

- 230 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
18. Get color number the pixel. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getpixel

[Syntax]
#include <graph.h>
short _getpixel( short x, short y ) ;

[Description]
Gets the color number of the specified pixel.

[Compatibility]
This function is compatible with the "_getpixel" function of MS-C.

- 231 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
19. Get the current output position of text. <Main>
-------------------------------------------------------------------------------------------

[Name]
_gettextposition

[Syntax]
#include <graph.h>
struct _rccoord _gettextposition( void ) ;

[Description]
Gets the current output position of the text.

[Compatibility]
This function is compatible with the "_gettextposition" function of MS-C.

- 232 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
20. Get the text window border. <Main>
-------------------------------------------------------------------------------------------

[Name]
_gettextwindow

[Syntax]
#include <graph.h>
void _gettextwindow( short *r1, short *c1, short *r2, short *c2 ) ;

[Description]
Gets the window border of the current text window.

[Compatibility]
This function is compatible with the "_gettextwindow" function of MS-C.

- 233 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
21. Get the graphic configuration. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getvideoconfig

[Syntax]
#include <graph.h>
struct videoconfig *_getvideoconfig(
struct videoconfig *config ) ;

[Description]
Gets the information of the hardware about the graphic environment.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The installation status of VRAM for analog mode.


_98EGA(4000H) is set as fixed value for PC-98's video mode.
_VGA(0008H) is set as fixed value for the VGA Graphic and PC-AT's video mode.

- 234 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
22. Convert physical coordinate into view. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getviewcoord

[Syntax]
#include <graph.h>
struct _xycoord _getviewcoord( short x, short y ) ;

[Description]
Converts the physical coordinate into the view coordinate.

[Compatibility]
This function is compatible with the "_getviewcoord" function of MS-C.

- 235 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
23. Get the current visual page number. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getvisualpage

[Syntax]
#include <graph.h>
short _getvisualpage( void ) ;

[Description]
Gets the page number of the currently displayed page.

[Compatibility]
This function is compatible with the "_getvisualpage" function of MS-C.

- 236 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
24. Get the current writing mode. <Main>
-------------------------------------------------------------------------------------------

[Name]
_getwritemode

[Syntax]
#include <graph.h>
short _getwritemode( void ) ;

[Description]
Gets the current logical writing mode.

[Compatibility]
This function is compatible with the "_getwritemode" function of MS-C.

- 237 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
25. Get the return status of graphic function. <Main>
------------------------------------------------------------------------------------------

[Name]
_grstatus

[Syntax]
#include <graph.h>
short _grstatus( void ) ;

[Description]
Gets the status of the graphic function which has been executed just before.

[Compatibility]
This function is compatible with the "_grstatus" function of MS-C.

- 238 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
26. Get image buffer size. <Main>
-------------------------------------------------------------------------------------------

[Name]
_imagesize

[Syntax]
#include <graph.h>
long _imagesize( short rsx, short rsy, short rex, short rey ) ;

[Description]
Returns the required buffer size for storing the specified image data by byte unit.

[Compatibility]
This function is compatible with the "_imagesize" function of MS-C.

- 239 -
3.Function References PROGRAMMING B-64303EN-3/01

-------------------------------------------------------------------------------------------
27. Get font pattern size of Kanji character. <Main>
-------------------------------------------------------------------------------------------

[Name]
_kanjisize

[Syntax]
#include <graph.h>
short _kanjisize( short code ) ;

[Description]
Returns the required buffer size for storing the specified font pattern by byte unit.

[Compatibility]
This function is compatible with the "_kanjisize" function of MS-C.

- 240 -
B-64303EN-3/01 PROGRAMMING 3.Function References

-------------------------------------------------------------------------------------------
28. Draw a line. <Main>
-------------------------------------------------------------------------------------------

[Name]
_lineto

[Syntax]
#include <graph.h>
short _lineto( short x, short y ) ;

[Description]
Draws a line from the current pixel cursor to the specified coordinate.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The following status is not returned by "_grstatus" function after the execution of this
function.

The output is clipped by view port. : _GRCLIPPED

In this case, the same graphic status is return as _GRNOOUTPUT, and the return value
of this function is always "0". (Could not draw normally)

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Executed in text mode : _GRNOTINPROPERMODE
Not drawn in clipping region : _GRNOOUTPUT

- 241 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
29. Move the current graphic output position. <Main>
------------------------------------------------------------------------------------------

[Name]
_moveto

[Syntax]
#include <graph.h>
struct xycoord _moveto( short x, short y ) ;

[Description]
Moves the current graphic output position to the specified coordinate.

[Compatibility]
This function is compatible with the "_moveto" function of MS-C.

- 242 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
30. Draw a text string using the current font. <Main>
------------------------------------------------------------------------------------------

[Name]
_outgtext

[Syntax]
#include <graph.h>
void _outgtext( unsigned char *text ) ;

[Description]
Draws a text string on the specified pixel position of the screen using the current font.

[Compatibility]
This function is compatible with the "_outgtext" function of MS-C.

- 243 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
31. Draw a text string in a memory. <Main>
------------------------------------------------------------------------------------------

[Name]
_outmem

[Syntax]
#include <graph.h>
void _outmem( char *text, short length ) ;

[Description]
Draws a text string of the specified length stored in the specified memory buffer.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The text string is displayed using text character. The graphic output is not used.

(2) The control code for only '\n' is processed in the text window. The other control code
such as '\t' is not processed.

(3) Nothing is done in case of graphic mode.

- 244 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
32. Output a text string on the current position. <Main>
------------------------------------------------------------------------------------------

[Name]
_outtext

[Syntax]
#include <graph.h>
void _outtext( char *text ) ;

[Description]
Outputs a text string on the current text position.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The text string is displayed using text character. The graphic output is not used.

(2) The control code for only '\n' is processed in the text window. The other control code
such as '\t' is not processed.

(3) Nothing is done in case of graphic mode.

- 245 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
33. Draw a pie figure. <Main>
------------------------------------------------------------------------------------------

[Name]
_pie

[Syntax]
#include <graph.h>
short _pie( short fill, short rsx, short rsy, short rex, short rey,
short vsx, short vsy, short vex, short vey ) ;

[Description]
Draws a pie figure.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The following status is not returned by "_grstatus" function after the execution of this
function.

The output is clipped by view port. : _GRCLIPPED

In this case, the same graphic status is return as _GRNOOUTPUT, and the return value
of this function is always "0". (Could not draw normally) However, the right value is
not returned in case of the _GFILLINTERIOR attribute is specified.

(2) The logical operation of "_setwritemode" is not effective to this function in MS-C, but
effective in C Language Executor.Therefore, the outline (border line) may not be drawn
by specified logical color in case that _GFILLINTERIOR is specified and _GPSET is not
specified in this function.

(3) There may be the difference from specified rectangle by the drawing precision of this
function.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Executed in text mode : _GRNOTINPROPERMODE
Invalid parameters : _GRINVALIDPARAMETER
Not painted due to insufficient memory : _GRINSUFFICIENTMEMORY
Not drawn in clipping region : _GRNOOUTPUT

- 246 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
34. Draw a polygon. <Main>
------------------------------------------------------------------------------------------

[Name]
_polygon

[Syntax]
#include <graph.h>
short _polygon( short fill, struct xycoord *points,
short numpoints ) ;

[Description]
Draws a polygon or paints it.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The following status is not returned by "_grstatus" function after the execution of this
function.

The output is clipped by view port. : _GRCLIPPED

In this case, the same graphic status is return as _GRNOOUTPUT, and the return value
of this function is always "0". (Could not draw normally) However, the right value is
not returned in case of the _GFILLINTERIOR attribute is specified.

(2) The maximum number of apexes which is available in this function is 1024.

(3) The painting operation is not performed even if _GFILLINTERIOR is specified in this
function.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Executed in text mode : _GRNOTINPROPERMODE
Invalid parameters : _GRINVALIDPARAMETER
Not painted due to insufficient memory : _GRINSUFFICIENTMEMORY
Not drawn in clipping region : _GRNOOUTPUT

- 247 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
35. Put image data on the screen. <Main>
------------------------------------------------------------------------------------------

[Name]
_putimage

[Syntax]
#include <graph.h>
void _putimage( short sx, short sy, char *image, short action ) ;

[Description]
Reads image data from the memory and draws it on the screen.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The following status is not returned by "_grstatus" function after the execution of this
function.

The output is clipped by view port. : _GRCLIPPED

In this case, the same graphic status is return as _GRNOOUTPUT, and the return value
of this function is always "0". (Could not draw normally)

(2) If a part of the specified graphic image protrudes out of the clipping region, this
function draws only image data in the clipping region.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Executed in text mode : _GRNOTINPROPERMODE
Invalid parameters : _GRINVALIDPARAMETER
Not executed due to insufficient memory : _GRINSUFFICIENTMEMORY
Not drawn in clipping region : _GRNOOUTPUT

- 248 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
36. Draw a rectangle. <Main>
------------------------------------------------------------------------------------------

[Name]
_rectangle

[Syntax]
#include <graph.h>
short _rectangle( short fill, short rsx, short rsy,
short rex, short rey ) ;

[Description]
Draws a rectangle or paints it.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The following status is not returned by "_grstatus" function after the execution of this
function.

The output is clipped by view port. : _GRCLIPPED

In this case, the same graphic status is return as _GRNOOUTPUT, and the return value
of this function is always "0". (Could not draw normally) However, the right value is
not returned in case of the _GFILLINTERIOR attribute is specified.

(2) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

The left-top and the right-bottom : _GRPARAMETERALTERED


coordinates are exchanged.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Executed in text mode : _GRNOTINPROPERMODE
Invalid parameters : _GRINVALIDPARAMETER
Not painted due to insufficient memory : _GRINSUFFICIENTMEMORY
Not drawn in clipping region : _GRNOOUTPUT

- 249 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
37. Register font file. <Main>
------------------------------------------------------------------------------------------

[Name]
_registerfonts

[Syntax]
#include <graph.h>
short _registerfonts( unsigned char *pathname ) ;

[Description]
Registers font file and initializes the font library.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) This function doesn't check the specified file pathname. Therefore, the return value
of the "_grstatus" function is always "_GROK". The return value of this function is always
"1".

(2) This function doesn't actually register the font file.

<MS-C Compatible Specification>

(1) It is required to call this function before outputting text strings using "_outgtext"
function. If this function has not been called, "_outgtext" output nothing.

- 250 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
38. Map colors into all color palette. <Main>
------------------------------------------------------------------------------------------

[Name]
_remapallpalette

[Syntax]
#include <graph.h>
short _remapallpalette( long *colors ) ;

[Description]
Changes color values of all color palettes.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) In MS-C, "Abnormal ended" never occurred. This function sets the suitable number of the
color palettes provided on the current video mode.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK

[Remarks]
When the video mode is "_98RES16COLOR(101)", the number of the color palette is 256 in
C Language Executor, but this function changes only 16 palettes for compatibility with
MS-C.

- 251 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
39. Map a color into a color palette. <Main>
------------------------------------------------------------------------------------------

[Name]
_remappalette

[Syntax]
#include <graph.h>
long _remappalette( short index, long color ) ;

[Description]
Changes color value of the specified color palette.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) Actual operation does not match a description in the MS-C reference manual. When the
value of pallet 0 is changed by the back color setting, this function returns the value.

(2) In MS-C, the return value for successfully execution is always previous set color value
regardless of the current video mode, but this function always returns the color value
just before execution of this function in C Language Executor. That is, this function
doesn't return 0 but the initial setting value for the 1st calling.

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK


Invalid palette number : _GRINVALIDPARAMETER

- 252 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
40. Set the current active page number. <Main>
------------------------------------------------------------------------------------------

[Name]
_setactivepage

[Syntax]
#include <graph.h>
short _setactivepage( short page ) ;

[Description]
Sets the graphic plane to be drawn.

[Compatibility]
This function is compatible with the "_setactivepage" function of MS-C.

- 253 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
41. Set the current back ground color. <Main>
------------------------------------------------------------------------------------------

[Name]
_setbkcolor

[Syntax]
#include <graph.h>
long _setbkcolor( long color ) ;

[Description]
Sets the current back ground color.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) Actual operation does not match a description in the MS-C reference manual. When the
value of pallet 0 is changed by the back color setting, this function returns the value.

(2) The following status is not returned by "_grstatus" function after the execution of this
function.

_GRPARAMETERALTERED

<MS-C Compatible Specification>

(1) The following graphic statuses are returned by the "_grstatus" function after the
execution of this function.

Executed successfully : _GROK

- 254 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
42. Set the clipping region. <Main>
------------------------------------------------------------------------------------------

[Name]
_setcliprgn

[Syntax]
#include <graph.h>
void _setcliprgn( short rsx, short rsy, short rex, short rey ) ;

[Description]
Sets the clipping region for the graphic output.

[Compatibility]
This function is compatible with the "_setcliprgn" function of MS-C.

- 255 -
3.Function References PROGRAMMING B-64303EN-3/01

-----------------------------------------------------------------------------------------
43. Set the current fore ground color. <Main>
-----------------------------------------------------------------------------------------

[Name]
_setcolor

[Syntax]
#include <graph.h>
short _setcolor( short color ) ;

[Description]
Sets the color which is corresponding to the specified palette number
as the current color.

[Compatibility]
This function is compatible with the "_setcolor" function of MS-C.

- 256 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
44. Set the current fill mask pattern. <Main>
------------------------------------------------------------------------------------------

[Name]
_setfillmask

[Syntax]
#include <graph.h>
void _setfillmask( unsigned char *mask ) ;

[Description]
Sets the current fill mask pattern.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) In C Language Executor, this function sets the fill mask pattern as the default status
when the mask data is "full(-1)" for the painting performance.

- 257 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
45. Set the current font. <Main>
------------------------------------------------------------------------------------------

[Name]
_setfont

[Syntax]
#include <graph.h>
short _setfont( unsigned char *options ) ;

[Description]
Sets the current font for "_outgtext" function.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) Only option "t" (Set fontname) is supported.

(2) Specify the typename placed in single quotation marks ('') after the option "t".

The available typenames are as follows.

Typename Character set


standard ANK character set (Standard)
graph1 ANK character set (Graphic 1)
graph2 ANK character set (Graphic 2)
graph3 ANK character set (Graphic 3)
large ANK character set (Large character)
micro ANK character set (Small character)
fanuc Kanji character set (FANUC Kanji set)

(3) The return code is always "1".

- 258 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
46. Set the current output vector of text. <Main>
------------------------------------------------------------------------------------------

[Name]
_setgtextvector

[Syntax]
#include <graph.h>
struct _xycoord _setgtextvector( short x, short y ) ;

[Description]
Sets the current output vector of the font text.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) In MS-C, it is possible to specify such as 45[deg](1,1), but impossible in C Language


Executor. "_GRERROR" is returned by "_grstatus" function for the invalid setting values
which are not described in the reference manual.

The available output directions are as follows.


Only "sign" of value has a significance.

( x, y ) Output direction
( 0, 0 ) Not changed.
( 1, 0 ) Horizontal. (default)
( 0, 1 ) Rotated 90[deg] to CCW.
(-1, 0 ) Rotated 180[deg].
( 0,-1 ) Rotated 247[deg] to CCW.

- 259 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
47. Set the current line style. <Main>
------------------------------------------------------------------------------------------

[Name]
_setlinestyle

[Syntax]
#include <graph.h>
void _setlinestyle( unsigned short mask ) ;

[Description]
Sets the current line style.

[Compatibility]
This function is compatible with the "_setlinestyle" function of MS-C.

- 260 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
48. Draw a pixel. <Main>
------------------------------------------------------------------------------------------

[Name]
_setpixel

[Syntax]
#include <graph.h>
short _setpixel( short x, short y ) ;

[Description]
Draws a pixel in specified position by the current color.

[Compatibility]
This function is compatible with the "_setpixel" function of MS-C.

- 261 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
49. Set the current output position of text. <Main>
------------------------------------------------------------------------------------------

[Name]
_settextposition

[Syntax]
#include <graph.h>
struct _rccoord _settextposition( short row, short column ) ;

[Description]
Move the current position for outputting text.

[Compatibility]
This function is compatible with the "_settextposition" function of MS-C.

- 262 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
50. Set the text row number. <Main>
------------------------------------------------------------------------------------------

[Name]
_settextrows

[Syntax]
#include <graph.h>
short _settextrows( short rows ) ;

[Description]
Sets the text row number.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The maximum line number of each video mode is set for every specification.

<MS-C Compatible Specification>

(1) The maximum line number of the video mode is set by specifying "_MAXTEXTROWS(-1)".

(2) "_grstatus" function returns "_GRINVALIDPARAMETER" if "rows" is negative.

(3) "_grstatus" function returns "_GRPARAMETERALTERED" if the correct parameter is specified


or the current video mode is not text mode.

- 263 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
51. Set the text window. <Main>
------------------------------------------------------------------------------------------

[Name]
_settextwindow

[Syntax]
#include <graph.h>
void _settextwindow( short r1, short c1, short r2, short c2 ) ;

[Description]
Sets the current text window.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) It is impossible to scroll the contents of the text window.

[Remarks]
The "crt_setmode" function makes the current text window ineffective.

- 264 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
52. Set the screen video mode. <Main>
------------------------------------------------------------------------------------------

[Name]
_setvideomode

[Syntax]
#include <graph.h>
short _setvideomode( short mode ) ;

[Description]
Selects the display mode of the screen.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) Specify one of the following video modes.


The setting depends on the display unit.

(A) 10.4-inch color LCD

When any mode including parentheses is specified, this function returns "0" (error),
but the initialization of graphic screen is done correctly. (In this case, the
"_grstatus()" function returns "_GRMODENOTSUPPORTED".)

VGA Graphic
Mode Size(Text) Palette (Color mode)
_98RESS16COLOR
_98RESS8COLOR 640×400 (80×25) 16 colors (PC-98)
(_98RESSCOLOR)
_98RES16COLOR
_98RES8COLOR 640×400 256 colors (PC-98)
(_98RESCOLOR)
_VRES16COLOR
640×480 (80×30) 16 colors (PC-AT)
_VRES16EXCOLOR
_VRES256COLOR 640×480 256 colors (PC-AT)
_98TEXT80
Text mode (80×25) 16 colors
_TEXTC80

- 265 -
3.Function References PROGRAMMING B-64303EN-3/01

This function sets the following modes for "_DEFAULTMODE", "_MAXCOLORMODE" or


"_MAXRESMODE".

Mode VGA Graphic


_DEFAULTMODE _98TEXT80,_TEXTC80
_MAXCOLORMODE _VRES256COLOR
_MAXRESMODE _VRES16COLOR

(B) 8.4-inch color LCD

When a mode shown in parentheses is specified, this function returns "0" (error), but
the initialization of a graphic screen is done correctly. (In this case, the "_grstatus"
function returns "_GRMODENOTSUPPORTED".)

VGA Graphic
Mode Size (Text) Palette (Color mode)
_98RESS16COLOR
_98RESS8COLOR 640×400 (40×16) 16 colors (PC-98)
(_98RESSCOLOR)
_98RES16COLOR
_98RES8COLOR 640×400 256 colors (PC-98)
(_98RESCOLOR)
_VRES16COLOR
640×480 (40×19) 16 colors (PC-AT)
_VRES16EXCOLOR
_VRES256COLOR 640×480 256 colors (PC-AT)
_98TEXT80
Text mode (40×16) 16 colors
_TEXTC80

(2) Use "_CEXERES16COLOR" mode for arbitrary plane size and text mode.
Symbol "_CEXERES16COLOR" is defined in "graph.h".

For the setting of this mode, the function syntax is changed as follows.

#include <crt.h>
#include <graph.h>
short _setvideomode( _CEXERES16COLOR, short origin,
short height, short TXmode ) ;

origin The origin of the graphic plane in Y direction.


height The origin of the graphic plane in X direction.
TXmode The text mode.

- 266 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Specify one of following mode for the text mode.


・10.4-inch color LCD and 8.4-inch color LCD (reduced display mode)

MODE SIZE
CRT_MODE_V25_0 80-column × 25-line (starting line: 1)
CRT_MODE_V25_1 80-column × 25-line (starting line: 2)
CRT_MODE_V25_2 80-column × 25-line (starting line: 3)
CRT_MODE_V25_3 80-column × 25-line (starting line: 4)
CRT_MODE_V25_4 80-column × 25-line (starting line: 5)
CRT_MODE_V25_5 80-column × 25-line (starting line: 6)
CRT_MODE_V30 80-column × 30-line

・8.4-inch color LCD (standard display mode)

MODE SIZE
CRT_MODE_V16_0 40-column × 16-line (starting line: 1)
CRT_MODE_V16_1 40-column × 16-line (starting line: 2)
CRT_MODE_V16_2 40-column × 16-line (starting line: 3)
CRT_MODE_V16_3 40-column × 16-line (starting line: 4)
CRT_MODE_V19 40-column × 19-line

These text mode symbols are defined in "crt.h".


"_CEXERES16COLOR" mode is similar to "_VRES16COLOR" mode except the variable display
size.

(3) If non-supported mode is specified, "_GRMODENOTSUPPORTED" is returned by the "_grstatus"


function. This is originally the return value when the analog video mode is specified
without analog VRAM system.

(4) The cursor current position is initialized and moved to the home position after the
execution of this function.

If the text screen mode (column or line number in the screen) is changed by this function,
the text screen environment is initialized (as same as "crt_setmode" does), and all
setting about text screen are set as initial state. Set the text screen environment
(cursor display mode, character set, etc.) if necessary.

[Remarks]
(1) Use "crt_setmode" function or "_setvideomode( _CEXRES16COLOR,.. )" to change the
text mode.
(2) With a 8.4-inch color LCD, there is a limit on character types that can be displayed
in reduced display mode.
Only 128 one-byte characters of character codes 0x20 to 0x5F and 0xA0 to 0xdf can
be displayed in reduced display mode. When a lowercase letter is output to a screen,
it is converted to an uppercase letter on the screen display.

- 267 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
53. Set the screen video mode and text row number. <Main>
------------------------------------------------------------------------------------------

[Name]
_setvideomoderows

[Syntax]
#include <graph.h>
short _setvideomoderows( short mode, short rows ) ;

[Description]
Sets the video mode for the text operation and sets the text row
number.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The details of the video mode are different from MS-C's. Refer "_setvideomode" function
for more information. "_CEXERES16COLOR" mode is not allowed in this function.

(2) The text row number is always set as the maximum line number of the specified video mode
even if any "rows" is specified.

(3) If non-supported mode is specified, "_GRMODENOTSUPPORTED" is returned by the "_grstatus"


function. This is originally the return value when the analog video mode is specified
without analog VRAM system.

(4) The cursor current position is initialized and moved to the home position after the
execution of this function.

[Remarks]
Use "crt_setmode" function to change the text mode.

- 268 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
54. Set the origin of the view port. <Main>
------------------------------------------------------------------------------------------

[Name]
_setvieworg

[Syntax]
#include <graph.h>
struct xycoord _setvieworg( short x, short y ) ;

[Description]
Moves the origin of the view port to the specified physical position.

[Compatibility]
This function is compatible with the "_setvieworg" function of MS-C.

- 269 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
55. Set the clipping region and the view coordinate. <Main>
------------------------------------------------------------------------------------------

[Name]
_setviewport

[Syntax]
#include <graph.h>
void _setviewport( short rsx, short rsy, short rex, short rey ) ;

[Description]
Restricts to the graphic output in the specified region on the
screen and sets the origin of the viewport coordinate on its
left-upper corner.

[Compatibility]
This function is compatible with the "_setviewport" function of MS-C.

- 270 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
56. Set the current visual page number. <Main>
------------------------------------------------------------------------------------------

[Name]
_setvisualpage

[Syntax]
#include <graph.h>
short _setvisualpage( short page ) ;

[Description]
Set the page number of the currently displayed page.

[Compatibility]
This function is compatible with the "_setvisualpage" function of MS-C.

- 271 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
57. Set the current writing mode. <Main>
------------------------------------------------------------------------------------------

[Name]
_setwritemode

[Syntax]
#include <graph.h>
short _setwritemode( short action ) ;

[Description]
Sets the current logical writing mode.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) The effectivity of the logical writing mode is different between PC-98's MS-C and PC-AT's.
In C Language Executor, the effectivity of the logical writing mode is as follows.

NAME FUNCTION DRAWING PAINTING


_setpixel Draw a pixel. ○ -
_arc Draw an arc or an elliptic arc. ○ -
_linto Draw a line. ○ -
_ellipss Draw a circle or an ellipse. ○ ×
_pie Draw a pie figure. ○ ×
_polygon Draw a polygon. ○ -
_rectangle Draw a rectangle. ○ ○
_floodfill Paint the closed region. - ×

( ○: effective, ×: ineffective, -: N/A )


----------------------------------------------------------------------------------

- 272 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
58. Delete registered font file. <Main>
------------------------------------------------------------------------------------------

[Name]
_unregisterfonts

[Syntax]
#include <graph.h>
void _unregisterfonts( void ) ;

[Description]
Delete registered font file and free the font library memory.

[Compatibility]

<MS-C Non-Compatible Specification>

(1) This function doesn't actually delete font file.

<MS-C Compatible Specification>

(1) "_outgtext" function outputs nothing after calling this function.


"_registerfonts" function must be called to output text string by "_outgtext" function
again.

- 273 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
59. Enable/disable line wrapping. <Main>
------------------------------------------------------------------------------------------

[Name]
_wrapon

[Syntax]
#include <graph.h>
short _wrapon( short option ) ;

[Description]
Enable or disable wrapping of the text line.

[Compatibility]
This function is compatible with the "_wrapon" function of MS-C.

- 274 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.3.4 MS-C graphic function compatibility list

"○" mark: Available "×" mark: NOT available

NAME FUNCTION VGA


_arc Draw an arc or an elliptic arc. ○
_clearscreen Clear screen. ○
_displaycursor Enable/disable the cursor. ×
_ellipse Draw a circle or an ellipse. ○
_floodfill Paint the closed region. ○
_getactivepage Get the current active page number. ○
_getarcinfo Get the information of the previous arc or pie. ○
_getbkcolor Get the current back ground color. ○
_getcolor Get the current fore ground color. ○
_getcurrentposition Get the current position in the view coordinate. ○
_getfillmask Get the current fill mask pattern. ○
_getfontinfo Get the current font information. ○
_getgtextextent Get the text extent by pixel unit. ○
_getgtextvector Get the output vector of text. ○
_getimage Get screen image. ○
_getkanji Get the font pattern of Kanji character. ○
_getlinestyle Get the current line style. ○
_getphyscoord Convert view coordinate into physical. ○
_getpixel Get color number the pixel. ○
_gettextcolor Get the current text color. ×
_gettextcursor Get the current cursor attribute. ×
_gettextposition Get the current output position of text. ○
_gettextwindow Get the text window border. ○
_getvideoconfig Get the graphic configuration. ○
_getviewcoord Convert physical coordinate into view. ○
_getvisualpage Get the current visual page number. ○
_getwritemode Get the current writing mode. ○
_grstatus Get the return status of graphic function. ○
_imagesize Get image buffer size. ○
_kanjisize Get font pattern size of Kanji character. ○
_lineto Draw a line. ○
_moveto Move the current graphic output position. ○
_outgtext Draw a text string using the current font. ○
_outmem Draw a text string in a memory. ○
_outtext Output a text string on the current position. ○
_pie Draw a pie figure. ○
_polygon Draw a polygon. ○
_putimage Put image data on the screen. ○

- 275 -
3.Function References PROGRAMMING B-64303EN-3/01

NAME FUNCTION VGA


_rectangle Draw a rectangle. ○
_registerfonts Register font file. ○
_remapallpalette Map colors into all color palette. ○
_remappalette Map a color into a color palette. ○
_scrolltextwindow Scroll the contents in the text window. ×
_setactivepage Set the current active page number. ○
_setbkcolor Set the current back ground color. ○
_setcliprgn Set the clipping region. ○
_setcolor Set the current fore ground color. ○
_setfillmask Set the current fill mask pattern. ○
_setfont Set the current font. ○
_setgtextvector Set the current output vector of text. ○
_setlinestyle Set the current line style. ○
_setpixel Draw a pixel. ○
_settextcolor Set the current text color. ×
_settextcursor Set the current cursor attribute. ×
_settextposition Set the current output position of text. ○
_settextrows Set the text row number. ○
_settextwindow Set the text window. ○
_setvideomode Set the screen video mode. ○
_setvideomoderows Set the screen video mode and text row number. ○
_setvieworg Set the origin of the view port. ○
_setviewport Set the clipping region and the view coordinate. ○
_setvisualpage Set the current visual page number. ○
_setwritemode Set the current writing mode. ○
_unregisterfonts Delete registered font file. ○
_wrapon Enable/disable line wrapping. ○

- 276 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.3.5 Lists of C Language Executor original graphic functions

C Language Executor graphic library supports the following original graphic functions in addition
to MS-C compatible functions.

ITEM NAME FUNCTION


1 gr_displaychar Draw a standard size character.
2 gr_displayfourlarge Draw a quad size character.
3 gr_displaysixlarge Draw a hex size character.
4 _putpattern Put monochrome image data.
5 _getpattern Get monochrome image data.
6 gr_dispstr Draw a standard size string.
7 gr_disp6str Draw a hex size string.
8 gr_bitblt Copy image data.
9 gr_disp4str Draw a quad size string.
10 gr_displaysmlchar Draw a small size character.
11 gr_dispsstr Draw a small size string.
12 gr_displayfchar Draw a FANUC character.
13 gr_dispfstr Draw a FANUC character string.
14 gr_disp9ifchar Draw 9-inch font character.
15 gr_disp9ifstr Draw 9-inch font character string.
16 mmc_line_b Draw a line between specified two points.
17 mmc_polyline Draw a polyline.
18 mmc_circle_b Draw a circle.
19 mmc_ellipse_b Draw an ellipse.
20 mmc_pie_b Draw a pie figure.
21 mmc_arc_b Draw an arc.
22 mmc_gettext Get character in the specified area.
23 mmc_puttext Put character data on memory to text screen.
24 mmc_textsize Get required byte size for getting character.

- 277 -
3.Function References PROGRAMMING B-64303EN-3/01

3.3.6 Function Reference

------------------------------------------------------------------------------------------
1. Draw a standard size character. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_displaychar

[Syntax]
#include <graph.h>
void gr_displaychar( int code, short cx, short cy,
short fg, short bg ) ;

[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws the specified character whose size is same as the text's one (i.e. 8 × 16 dots,
16 x 16 dots for Kanji character) on the graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color.

When specifying a 2-byte character code with the argument code, store the first byte
in the upper byte. When drawing, for example, (SHIFT-JIS code 8ABF), specify as
follows.gr_displaychar (0x8ABF, ...)

- 278 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2. Draw a quad size character. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_displayfourlarge

[Syntax]
#include <graph.h>
void gr_displayfourlarge( int code, short cx, short cy,
short fg, short bg ) ;

[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws the specified character whose dot matrix is 16 × 32 dots on the graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color. This function
can't draw 2-byte characters such as Japanese Kanji characters. It can draw only half-size
characters whose codes are 0x20 to 0x7F.

- 279 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
3. Draw a hex size character. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_displaysixlarge

[Syntax]
#include <graph.h>
void gr_displaysixlarge( int code, short cx, short cy,
short fg, short bg ) ;

[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws the specified hex size character whose dot matrix is 24 × 32 dots on the graphic
screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color. This function
can draw only 'SPACE','0'-'9', 'A'-'Z', '.' and '-'.

- 280 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
4. Put monochrome image data. <Main>
------------------------------------------------------------------------------------------

[Name]
_putpattern

[Syntax]
#include <graph.h>
void _putpattern( short x, short y, void *image, short action,
short fg, short bg ) ;

[Arguments]
x, y Coordinate of the left-upper corner at where the monochrome image is
put.
image Buffer in where monochrome image is stored.
action Logical writing mode.
fg Foreground color.
bg Background color.

[Return]
------

[Description]
Puts the monochrome image pattern stored in "image" in the rectangle regtion whose
left-upper corner is "x,y" on the graphic screen.

Specify the logical writing mode, monochrome image data in buffer and image data on the
screen are operated according to this command, in "action". The logical writing mode
is defined in "graph.h".

Specify the character color and the background color using palette index number. Only
image data is drawn if -32768 (0x8000) is specified as the background color.

The image buffer size must be specified by word (2-byte) unit.


The buffer size (for monochrome image data) is calculated by the next equation.

Size(byte) = ([WIDTH]+15)/16×2×[HEIGHT]+4

The maximum image size that is available for this function is 4K bytes.

- 281 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]

The following monochrome image data (19x8 dots) is drawn.


The leading 2-word data in the buffer are the height and the width of the image pattern
data.

19 dots

f e d c b a 9 8 7 6 5 4 3 2 1 0 7 6 5
0 □□□□□□□□□□□□□□□□ □□□
1 □■■■■□□■■■■□□■□□ □■□
2 □■□□□■□■□□□■□■■□ ■■□
3 □■□□□■□■□□□■□■□■ □■□ 8 dots
4 □■■■■□□■■■■□□■□□ □■□
5 □■□□□□□■□□□□□■□□ □■□
6 □■□□□□□■□□□□□■□□ □■□
7 □□□□□□□□□□□□□□□□ □□□

The following program draws the above monochrome image data.

#include <graph.h>

#define Blue 1
#define White 7

unsigned short image_rpm[18] = {


0x0013,0x0008 /* 19×8 Dot */
,0x0000,0x0000
,0x79e4,0x4000
,0x4516,0xc000
,0x4515,0x4000
,0x79e4,0x4000
,0x4904,0x4000
,0x4504,0x4000
,0x0000,0x0000
} ;

void example( short x, short y )


{
char *image ;
image = (char *)&image_rpm[0] ;
_putpattern( x, y, image, _GPSET, Blue, White ) ;
return ;
}

- 282 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
5. Get monochrome image data. <Main>
------------------------------------------------------------------------------------------

[Name]
_getpattern

[Syntax]
#include <graph.h>
void _getpattern( short rsx, short rsy, short rex, short rey,
void *image, short color ) ;

[Arguments]
rsx, rsy, Coordinate of the rectangle region from where the
rex, rey monochrome image data is got.
image Buffer in where the monochrome image data is stored.
color Color to be searched.

[Return]
------

[Description]
Gets the monochrome image data, whose color is same as the specified color palette index
number, in the specified rectangle region. And stores it in the "image".

The buffer size muse be enough big to store the image data.
The buffer size is calculated by the next equation.

Size(byte) = ([WIDTH]+15)/16×2×[HEIGHT]+4

The maximum image size that is available for this function is 4K bytes.

- 283 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program displays a cursor.

#include <graph.h>
#include <malloc.h>

void example( short rsx, short rsy, short ch_num, short OldColor,
short ForColor, short BakColor )
{
char *image ;
long image_size ;
short w, h ;
w = ch_num*8 ;
h = 16 ;
image_size = ( w+15 ) / 16 * 2 * h + 4 ;
if ( image_size > 4096L ) return ;
image = malloc( (short)image_size ) ;
if ( image == NULL ) return ;
_getpattern( rsx, rsy, rsx+w-1, rsy+h-1, image, OldColor ) ;
_putpattern( rsx, rsy, image, _GPSET, ForColor, BakColor ) ;
free( image ) ;
return ;
}

- 284 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
6. Draw a standard size string. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_dispstr

[Syntax]
#include <graph.h>
void gr_dispstr( char *str, short cx, short cy,
short fg, short bg ) ;

[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws character string (also Kanji character is available) on the graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color.

- 285 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
7. Draw a hex size string. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_disp6str

[Syntax]
#include <graph.h>
void gr_disp6str( char *str, short cx, short cy,
short fg, short bg ) ;

[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the
character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws large-size character (24x32 dots) string on the graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color. This function
can draw only 'SPACE','0'-'9', 'A'-'Z', '.' and '-'.

- 286 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
8. Copy image data. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_bitblt

[Syntax]
#include <graph.h>
void gr_bitblt( short rsx, short rsy, short rex, short rey,
short cx, short cy ) ;

[Arguments]
rsx, rsy, Coordinate of the source rectangle.
rex, rey
cx, cy Destination (upper-left) coordinate.

[Return]
------

[Description]
Copys the image data in the specified rectangle region to the specified destination on
the screen.

- 287 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
9. Draw a quad size string. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_disp4str

[Syntax]
#include <graph.h>
void gr_disp4str( char *str, short cx, short cy,
short fg, short bg ) ;

[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws quad-size (16×32 dots) character string on the graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color. This function
can't draw 2-byte characters such as Japanese Kanji characters. It can draw only half-size
characters whose codes are 0x20 to 0x7F.

- 288 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
10. Draw a small size character. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_displaysmlchar

[Syntax]
#include <graph.h>
void gr_displaysmlchar( int code, short cx, short cy,
short fg, short bg ) ;

[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws small size (8×8 dots) character on the graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color. This function
draws only characters whose codes are 0x20 - 0x5F. If lowercase character is specified,
the converted uppercase character is drawn instead.

Dot size of drawn character is as follows.

Display mode Dot size


CRT_MODE_V25_0 8 × 8
CRT_MODE_V25_1 8 × 8
CRT_MODE_V25_2 8 × 8
CRT_MODE_V25_3 8 × 8
CRT_MODE_V25_4 8 × 8
CRT_MODE_V25_5 8 × 8
CRT_MODE_V30 8 × 8

- 289 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
11. Draw a small size string. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_dispsstr

[Syntax]
#include <graph.h>
void gr_dispsstr( char *str, short cx, short cy,
short fg, short bg ) ;

[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws small size (8×8 dots) character string on the graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color. This function
draws only characters whose codes are 0x20 - 0x5F.If lowercase character is specified,
the converted uppercase character is drawn instead.

Dot size of drawn character is as follows.

Display mode Dot size


CRT_MODE_V25_0 8 × 8
CRT_MODE_V25_1 8 × 8
CRT_MODE_V25_2 8 × 8
CRT_MODE_V25_3 8 × 8
CRT_MODE_V25_4 8 × 8
CRT_MODE_V25_5 8 × 8
CRT_MODE_V30 8 × 8

- 290 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
12. Draw a FANUC character. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_displayfchar

[Syntax]
#include <graph.h>
void gr_displayfchar( unsigned int code, short cx, short cy,
short fg, short bg ) ;

[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws a character which is specified by FANUC character code on the graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color.

- 291 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
13. Draw a FANUC character string. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_dispfstr

[Syntax]
#include <graph.h>
void gr_dispfstr( unsigned int *code, unsigned int len,
short cx, short cy, short fg, short bg ) ;

[Arguments]
code Array of FANUC character code (0x0000 - 0xFFFF).
len Length of character string.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws a character string which is specified by FANUC character code on the graphic screen.

Store FANUC code (16-bit) of drawn character in each element of the array "code".
Store character length in "len".

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color.

- 292 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
14. Draw 9-inch font character. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_disp9ifchar

[Syntax]
#include <graph.h>
void gr_disp9ifchar( int code, short cx, short cy,
short fg, short bg) ;

[Arguments]
code Character code to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws 8.4-inch font character (16×25 dots or 32×25 dots for Kanji character) on the
graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color.

[Remarks]
Specified character is drawn using FANUC character-generator and FANUC Kanji-set.

- 293 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
15. Draw 9-inch font character string. <Main>
------------------------------------------------------------------------------------------

[Name]
gr_disp9ifstr

[Syntax]
#include <graph.h>
void gr_disp9ifstr( unsigned char *str, short cx, short cy,
short fg, short bg) ;

[Arguments]
str Character string to be drawn.
cx, cy Coordinate of the left-upper corner at where the character is drawn.
fg Character color.
bg Background color.

[Return]
------

[Description]
Draws 8.4-inch font character (16×25 dots or 32×25 dots for Kanji character) on the
graphic screen.

Specify the character color and the background color using palette index number. Only
character is drawn if -32768 (0x8000) is specified as the background color.

[Remarks]
Specified character is drawn using FANUC character-generator and FANUC Kanji-set.

- 294 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
16. Draw a line between specified two points. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_line_b

[Syntax]
#include <fgraph.h>
short mmc_line_b( short x1, short y1, short x2, short y2 ) ;

[Arguments]
x1, y1 View port coordinates of line start point.
x2, y2 View port coordinates of line end point.

[Return]
Returns non-0 value if successful, or 0 if any error.

[Description]
Draws a line between specified two points.

- 295 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
17. Draw a polyline. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_polyline

[Syntax]
#include <fgraph.h>
void mmc_polyline( const struct _xycoord *points, short numpoints ) ;

[Arguments]
points Array of view port coordinates of apexes.
numpoints Number of apexes of polyline.

[Return]
------

[Description]
Draws a polyline.

- 296 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
18. Draw a circle. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_circle_b

[Syntax]
#include <fgraph.h>
short mmc_circle_b( short control, short xc, short yc, short r ) ;

[Arguments]
control Control flag.
xc, yc View port coordinates of the circle center.
r Radius.

[Return]
Returns non-0 value if successful, or 0 if any error.

[Description]
Draws a circle.

Specify one of the following symbols for "Control flag".

Symbol Purpose
_GFILLINTERIOR Fills inside of the object with the current fill mask pattern.
_GBORDER Draws only border line, not fills inside.

- 297 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
19. Draw an ellipse. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_ellipse_b

[Syntax]
#include <fgraph.h>
short mmc_ellipse_b( short control, short xc, short yc, short xr,
short yr ) ;

[Arguments]
control Control flag.
xc, yc View port coordinate of the ellipse center.
xr X-directional radius.
yr Y-directional radius.

[Return]
Returns non-0 value if successful, or 0 if any error.

[Description]
Draws an ellipse.

Specify one of the following symbols for "Control flag".

Symbol Purpose
_GFILLINTERIOR Fills inside of the object with the current fill mask pattern.
_GBORDER Draws only border line, not fills inside.

- 298 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
20. Draw a pie figure. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_pie_b

[Syntax]
#include <fgraph.h>
short mmc_pie_b( short control, short xc, short yc, short xr,
short yr, short d1, short d2 ) ;

[Arguments]
control Control flag.
xc, yc View port coordinate of the circle center.
xr X-directional radius.
yr Y-directional radius.
d1 Angle of drawing start point (-3600..3600 [0.1 deg])
d2 Angle of drawing end point (-3600..3600 [0.1 deg])

[Return]
Returns non-0 value if successful, or 0 if any error.

[Description]
Draws a pie figure.

Specify one of the following symbols for "Control flag".

Symbol Purpose
_GFILLINTERIOR Fills inside of the object with the current fill mask pattern.
_GBORDER Draws only border line, not fills inside.

- 299 -
3.Function References PROGRAMMING B-64303EN-3/01

"Angles" are specified as follows.


Unit of angles is 0.1 degree.
"Start angle" <= "End angle".
Allowed range to command is -3600..3600 (-360[deg]..360[deg]).
The origin of angle is + direction of X axis.
Angle increases counter clock wise.

(Y) (Y)

90[deg] -270[deg]
0[deg] -360[deg]
(X) (X)
180[deg] 360[deg] -180[deg] 0[deg]

270[deg] -90[deg]

Pie figure is drawn counter clock wise (CCW) from the start point to the end point. When
the start point is same as the end point, pie figure is not drawn but only a line which
connects the circle center and start/end point is drawn.

- 300 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
21. Draw an arc. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_arc_b

[Syntax]
#include <fgraph.h>
short mmc_arc_b( short xc, short yc, short xr, short yr, short d1,
short d2 ) ;

[Arguments]
xc, yc View port coordinate of the circle center.
xr X-directional radius.
yr Y-directional radius.
d1 Angle of drawing start point (-3600..3600 [0.1 deg])
d2 Angle of drawing end point (-3600..3600 [0.1 deg])

[Return]
Returns non-0 value if successful, or 0 if any error.

[Description]
Draws an arc.

"Angles" are specified as follows.


Unit of angles is 0.1 degree.
"Start angle" <= "End angle".
Allowed range to command is -3600..3600 (-360[deg]..360[deg]).
The origin of angle is + direction of X axis.
Angle increases counter clock wise.

(Y) (Y)

90[deg] -270[deg]
0[deg] -360[deg]
(X) (X)
180[deg] 360[deg] -180[deg] 0[deg]

270[deg] -90[deg]

Arc is drawn counter clock wise (CCW) from the start point to the end point. When the
start point is same as the end point, arc is not drawn but only a pixel is drawn at the
start/end point.

- 301 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
22. Get character in the specified area. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_gettext

[Syntax]
#include <fgraph.h>
short mmc_gettext( short x1, short y1, short x2, short y2,
_MCHRBUF *chr_buf ) ;

[Arguments]
x1,y1,x2,y2 Screen area (left-upper, right-lower)
chr_buf Buffer memory in where data are stored.

[Return]
0 Successful.
-1 Warning. (Out of screen)
2 Error. (No work memory)

- 302 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads characters in the specified screen area to the memory.

Specify screen area to read as left-upper point of screen (Home position) is (1,1).The
first character is read at the start point (left-upper position),and continuously reads
rightward, jumps to the next line at the right end, the last character is read at the
right-lower position. The required byte size to read is calculated by "mmc_textsize()"
function. Character code and attribute are stored by internal format. The structure of
output buffer is as follows.

0 Column size

2 Line size

4 1st character - code


data for one character
6 1st character - attribute

m n-th character - code

m+2 n-th character - attribute

If the specified area overruns the screen like below, SPACE character and WHITE attribute
is stored in the overruned region and "Warning" is returned as result.

(1,1)

Screen
Area to be read
(x1,y1)

(80,30)

(x2,y2)

If the start position is at the right-half of double-sized character, only lower byte
of the character code is read. If the end position is at the left-half of double-sized
character, only upper byte of the character code is read. In these case, operation is
done successfully.

- 303 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
23. Put character data on memory to text screen. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_puttext

[Syntax]
#include <fgraph.h>
short mmc_puttext( short x, short y, _MCHRBUF *chr_buf ) ;

[Arguments]
x, y Start position to write.
chr_buf Buffer memory in where data are stored.

[Return]
0 Successful.
-1 Warning. (Out of screen)
2 Error. (No work memory)

[Description]
Writes characters stored on memory to the text screen.

This function writes character data on memory which has been read by "mmc_gettext()"
function. Specify screen area to write as left-upper point of screen (Home position)
is (1,1). If the specified area overruns the screen, the overruned region is not written.

- 304 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
24. Get required byte size for getting character. <Main>
------------------------------------------------------------------------------------------

[Name]
mmc_textsize

[Syntax]
#include <fgraph.h>
short mmc_textsize( short x1, short y1, short x2, short y2 ) ;

[Arguments]
x1,y1,x2,y2 Screen area (left-upper, right-lower)

[Return]
Required byte size to read the specified area.

[Description]
Returns the required byte size to read the specified area.

The required byte size is calculated by the following formula.

Byte size = (Column size × Line size) × 4 + 4 [byte]


Column size = x2 - x1 + 1
Line size = y2 - y1 + 1

(Example) For reading whole screen (80 × 30).

(80 × 30) × 4 + 4 = 9604 byte

- 305 -
3.Function References PROGRAMMING B-64303EN-3/01

3.4 CNC/PMC window library

3.4.1 Lists of Functions

1. CNC window library

ITEM NAME FUNCTION


1.1 cnc_sysinfo Read CNC system information.
1.2 cnc_dwnstart Start output of NC program to be registered.
1.3 cnc_download Output NC program to be registered.
1.4 cnc_dwnend Stop output NC program to be registered.
1.5 cnc_vrfstart Start output NC program to be compared.
1.6 cnc_verify Output NC program to be compared.
1.7 cnc_vrfend Stop output NC program to be compared.
1.8 cnc_upstar Start input NC program.
1.9 cnc_upload Input NC program.
1.10 cnc_upend Stop input NC program.
1.11 cnc_search Search specified program.
1.12 cnc_delall Delete all programs.
1.13 cnc_delete Delete specified program.
1.14 cnc_rdprogdir Read program directory.
1.15 cnc_rdproginfo Read program information.
1.16 cnc_rdprgnum Read program number in executing.
1.17 cnc_rdseqnum Read sequence number in executing.
1.18 cnc_actf Read actual feed rate of controlled axes.
1.19 cnc_acts Read actual spindle speed.
1.20 cnc_absolute Read absolute position.
1.21 cnc_machine Read machine position.
1.22 cnc_relative Read relative position.
1.23 cnc_distance Read distance to go.
1.24 cnc_skip Read skipped position.
1.25 cnc_srvdelay Read servo delay amount.
1.26 cnc_accdecdly Read acceleration/deceleration delay amount.
1.27 cnc_rddynamic Read dynamic data.
1.28 cnc_statinfo Read CNC status information.
1.29 cnc_alarm Read alarm status.
1.30 cnc_rdalminfo Read alarm information.
1.31 cnc_rdtofs Read tool offset amount.
1.32 cnc_wrtofs Write tool offset amount.
1.33 cnc_rdtofsr Read tool offset amount (range specified).
1.34 cnc_wrtofsr Write tool offset amount (range specified).
1.35 cnc_rdzofs Read work origin offset.
1.36 cnc_wrzofs Write work origin offset.

- 306 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ITEM NAME FUNCTION


1.37 cnc_rdzofsr Read work origin offset (range specified).
1.38 cnc_wrzofsr Write work origin offset (range specified).
1.39 cnc_rdparam Read parameter.
1.40 cnc_wrparam Write parameter.
1.41 cnc_rdparar Read parameters (range specified).
1.42 cnc_wrparas Write parameters (multiple output).
1.43 cnc_rdset Read setting parameter.
1.44 cnc_wrset Write setting parameter.
1.45 cnc_rdsetr Read setting parameters (range specified).
1.46 cnc_wrsets Write setting parameters (multiple output).
1.47 cnc_rdpitchr Read pitch error compensation data (range specified).
1.48 cnc_wrpitchr Write pitch error compensation data (range specified).
1.49 cnc_rdmacro Read custom macro variable.
1.50 cnc_wrmacro Write custom macro variable.
1.51 cnc_rdmacror Read custom macro variables (range specified).
1.52 cnc_wrmacror Write custom macro variables (range specified).
1.53 cnc_rdpmacro Read P-code macro variable.
1.54 cnc_wrpmacro Write P-code macro variable.
1.55 cnc_rdpmacror Read P-code macro variables (range specified).
1.56 cnc_wrpmacror Write P-code macro variables (range specified).
1.57 cnc_diagnoss Read modal data.
1.58 cnc_diagnosr Read diagnostics data.
1.59 cnc_adcnv Read diagnostics data (range specified).
1.60 cnc_rdopmsg Read A/D conversion data.
1.61 cnc_setpath Read operator's message.
1.62 cnc_getpath Set path index (2-path system (T series)).
1.63 cnc_settimer Get path index (2-path system (T series)).
1.64 cnc_rdspload Set calendar timer of CNC.
1.65 cnc_rdexecprog Read load information of serial spindle.
1.66 cnc_rdmovrlap Read executing program.
1.67 cnc_getfigure Read manual overlapped motion value.
Read the maximum number of significant figures and the number of
1.68 cnc_rdtofsinfo
decimal places.
1.69 cnc_seqsrch Read tool offset information.
1.70 cnc_wrrelpos Search for sequence number.
1.71 cnc_acts2 Clear or preset relative position of controlled axis.
Read actual spindle speed (S) (multiple spindles allowed, read of
1.72 cnc_rdwkcdshft
specified axis) (2).
1.73 cnc_wrwkcdshft Read workpiece coordinate system shift.
1.74 cnc_rdpdf_drive Write workpiece coordinate system shift.
1.75 cnc_rdpdf_inf Read program storage drive information.
1.76 cnc_rdpdf_curdir Read program storage file information.

- 307 -
3.Function References PROGRAMMING B-64303EN-3/01

ITEM NAME FUNCTION


1.77 cnc_wrpdf_curdir Read current folder information.
1.78 cnc_rdpdf_subdir Set current folder.
1.79 cnc_rdpdf_alldir Read subfolder information.
1.80 cnc_pdf_add Read file list information.
1.81 cnc_pdf_del Create folder or file.
1.82 cnc_pdf_rename Delete folder or file.
1.83 cnc_pdf_slctmain Rename folder or file.
1.84 cnc_pdf_cond Select main program.
1.85 cnc_wrpdf_attr Consolidate programs.
1.86 cnc_rdpdf_subdirn Change attribute of folder or file.
1.87 cnc_pdf_rdmain Get the number of folders and files in specified folder.
1.88 cnc_information Get main program information.
1.89 cnc_rdsyssoft3 Get CNC information.
1.90 cnc_dwnstart4 Read series and edition of CNC system software (3).
1.91 cnc_download4 Start output of NC program to be registered (4).
1.92 cnc_dwnend4 Output NC program to be registered (4).
1.93 cnc_upstart4 Stop output of NC program to be registered (4).
1.94 cnc_upload4 Start reading NC program (4).
1.95 cnc_upend4 Read NC program (4).
1.96 cnc_rdpitchinfo Stop reading NC program (4).
1.97 cnc_rdmacroinfo Read pitch error compensation data information.
1.98 cnc_rdsetinfo Read custom macro variable information.
1.99 cnc_rddiaginfo Read setting parameter information.
1.100 cnc_rdparanum Read diagnostics data information.
Read the minimum parameter number, maximum parameter number,
1.101 cnc_rdsetnum
and total number of parameters.
Read the minimum setting parameter number, maximum setting
1.102 cnc_rddiagnum
parameter number, and total number of setting parameters.
Read the minimum diagnostics data number, maximum diagnostics data
1.103 cnc_rdnspdl
number, and total number of diagnostics data items.
1.104 cnc_rdprogdir2 Read the number of spindles.
1.105 cnc_rdaxisname Read program directory (2).
1.106 cnc_rdposition Read axis name.
1.107 cnc_rdspeed Read position information.
1.108 cnc_rdsvmeter Read speed information.
1.109 cnc_rdspmeter Read servo load meter.
1.110 cnc_rdgcode Read spindle load meter.
1.111 cnc_rdcommand Read modal G code.
1.112 cnc_alarm2 Read command value.
1.113 cnc_rdopmsg2 Read alarm status (2).
1.114 cnc_rdopmsg3 Read operator's message (2).
1.115 cnc_rdspdlname Read operator's message (3).

- 308 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ITEM NAME FUNCTION


1.116 cnc_rdprogdir3 Read spindle name.
1.117 cnc_rdtofsinfo2 Read program directory (3).
1.118 cnc_rdmacror2 Read tool offset information (2).
1.119 cnc_wrmacror2 Read custom macro variables (double-precision floating point).
1.120 cnc_rdaxisdata Write custom macro variables (double-precision floating point).
1.121 cnc_dncstart2 Read controlled axis/spindle-related data.
1.122 cnc_dnc2 Start output of NC program for operation (2).
1.123 cnc_dncend2 Output NC program for operation (2).
1.124 cnc_loadtorq Stop output of NC program for operation (2).
1.125 cnc_rdsyshard Read abnormal load torque data.
1.126 cnc_sysinfo_ex Read CNC hardware configuration information.
1.127 cnc_machine3 Read CNC system information (2).
1.128 cnc_rdjogdrun Read machine position of controlled axis (3).
1.129 cnc_rdpmacror2 Read jogging speed or dry run speed.
1.130 cnc_wrpmacror2 Read P-code macro variables (double-precision floating point).
1.131 cnc_rdalmmsg Write P-code macro variables (double-precision floating point).
1.132 cnc_rdalmmsg2 Read all alarm messages at once.
1.133 cnc_rdprogdir4 Read alarm message (extended message string).
1.134 cnc_stopophis Read program directory (4).
1.135 cnc_startophis Stop history data sampling.
1.136 cnc_rdophisno Resume history data sampling.
1.137 cnc_rdophisno3 Read the number of operation history data items.
1.138 cnc_rdophistry4 Read the number of operation history data items (3).
1.139 cnc_clearophis Read operation history data (4).
1.140 cnc_rdhissgnl3 Clear history data.
1.141 cnc_wrhissgnl3 Read signal to be included in operation history (3).
1.142 cnc_rdalmhisno3 Set signal to be included in operation history (3).
1.143 cnc_rdalmhistry5 Read the number of alarm history data items (3).
1.144 cnc_rdomhisno Read alarm history data (5).
1.145 cnc_rdomhistry2 Read the number of external operator's message history data items.
1.146 cnc_rdgrpid Read external operator's message history data (2).
1.147 cnc_rdngrp Read tool life management data (tool group number).
1.148 cnc_rdntool Read tool life management data (number of tool groups).
1.149 cnc_rdlife Read tool life management data (number of tools).
1.150 cnc_rdcount Read tool life management data (tool life).
1.151 cnc_rd1length Read tool life management data (tool life counter).
1.152 cnc_rd2length Read tool life management data (tool length compensation number 1).
1.153 cnc_rd1radius Read tool life management data (tool length compensation number 2).
1.154 cnc_rd2radius Read tool life management data (tool radius compensation number 1).
1.155 cnc_t1info Read tool life management data (tool radius compensation number 2).
1.156 cnc_t2info Read tool life management data (tool information 1).
1.157 cnc_toolnum Read tool life management data (tool information 2).

- 309 -
3.Function References PROGRAMMING B-64303EN-3/01

ITEM NAME FUNCTION


1.158 cnc_rdtoolrng Read tool life management data (tool number).
Read tool life management data (number of tools, tool life, life
1.159 cnc_rdtoolgrp
counter)(range specified).
1.160 cnc_wrcountr Read all tool life management data in group at once.
1.161 cnc_wrtoolgrp Write tool life management data (life counter) (range specified).
1.162 cnc_wrlife Register tool life management data (tool group).
1.163 cnc_wrcount Write tool life management data (tool life).
1.164 cnc_wrcnttype Write tool life management data (life counter).
1.165 cnc_wr1length Write tool life management data (life counter type).
1.166 cnc_wr2length Write tool life management data (tool length compensation number 1).
1.167 cnc_wr1radius Write tool life management data (tool length compensation number 2).
1.168 cnc_wr2radius Write tool life management data (tool radius compensation number 1).
1.169 cnc_wrt1info Write tool life management data (tool radius compensation number 2).
1.170 cnc_wrt2info Write tool life management data (tool information 1).
1.171 cnc_wrtoolnum Write tool life management data (tool information 2).
1.172 cnc_rdcnttype Write tool life management data (tool number).
1.173 cnc_rdusegrpid Read tool life management data (tool life counter type).
Read tool life management data (number of tool group being used or to
1.174 cnc_rdmaxgrp
be used).
Read tool life management data (maximum number of tool groups that
1.175 cnc_rdmaxtool
can be registered).
Read tool life management data (maximum number of tools that can be
1.176 cnc_rdusetlno
registered in group).
Read tool life management data (ordinal number of tool to be used in
1.177 cnc_rd1tlifedata
group).
1.178 cnc_rd1tlifedat2 Read tool life management data (tool data 1).
1.179 cnc_rd2tlifedata Read tool life management data (tool data 1) (2).
1.180 cnc_wr1tlifedata Read tool life management data (tool data 2).
1.181 cnc_wr1tlifedat2 Write tool life management data (tool data 1).
1.182 cnc_wr2tlifedata Write tool life management data (tool data 1) (2).
1.183 cnc_rdgrpinfo Write tool life management data (tool data 2).
1.184 cnc_rdgrpinfo4 Read tool life management data (tool group information).
1.185 cnc_wrgrpinfo Read tool life management data (tool group information 4).
1.186 cnc_deltlifegrp Write tool life management data (tool group information).
1.187 cnc_instlifedt Delete tool life management data (tool group information).
1.188 cnc_deltlifedt Add tool life management data (tool data).
1.189 cnc_clrcntinfo Delete tool life management data (tool data).
Clear tool life management data (life counter, tool information) (range
1.190 cnc_rdtlinfo
specified).
Read tool life management data (maximum number of groups that can
1.191 cnc_rdtlgrp be registered/maximum number of tools that can be registered in
group/maximum tool life value).

- 310 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ITEM NAME FUNCTION


1.192 cnc_rdtltool Read tool life management data (tool group information).
1.193 cnc_rdgrpid2 Read tool life management data (tool information).
1.194 cnc_rdcntover Read tool life management data (tool group number) (2).
1.195 cnc_getdtailerr Read tool life management data (count override).
1.196 cnc_wrmdiprog Get CNC error details.
1.197 cnc_rdmdipntr Write MDI program.
1.198 cnc_wrmdipntr Read execution pointer for MDI operation.
1.199 cnc_statinfo2 Write execution pointer for MDI operation.
1.200 cnc_rdparainfo Read CNC status information (2).
1.201 cnc_rdpdf_line Read parameter data information.
1.202 cnc_wrpdf_line Read program on a line-by-line basis.
1.203 cnc_pdf_delline Write program on a line-by-line basis.
1.204 cnc_pdf_rdactpt Delete program on a line-by-line basis.
1.205 cnc_pdf_wractpt Get program execution pointer.

- 311 -
3.Function References PROGRAMMING B-64303EN-3/01

2. PMC window library

ITEM NAME FUNCTION


2.1 pmc_rdpmcrng Read arbitrary PMC data (range specified).
2.2 pmc_wrpmcrng Write arbitrary PMC data (range specified).
2.3 pmc_rdpcmsg Read PMC message.
2.4 pmc_get_current_pmc_unit Get the unit type of PMC currently being operated.
2.5 pmc_get_number_of_pmc Get the number of PMC paths.
2.6 pmc_get_pmc_unit_types Get PMC unit types.
2.7 pmc_select_pmc_unit Select PMC unit to be operated.
2.8 pmc_getpmcptr Get PMC memory address information.
2.9 pmc_isvalidpmcptr Validate PMC memory address information.
2.10 pmc_rdpmcchar Read 1-byte signed data from PMC memory.
2.11 pmc_rdpmcshort Read 2-byte signed data from PMC memory.
2.12 pmc_rdpmclong Read 4-byte signed data from PMC memory.
2.13 pmc_wrpmcchar Write 1-byte signed data to PMC memory.
2.14 pmc_wrpmcshort Write 2-byte signed data to PMC memory.
2.15 pmc_wrpmclong Write 4-byte signed data to PMC memory.
2.16 pmc_rdpmcinfo Get PMC address information.

- 312 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.4.2 Return values of data window functions

1. CNC window return values

Return value Meaning


EW_VERSION(-7) Version mismatch between the CNC/PMC and library.
EW_SYSTEM(-5) System error.
EW_RESET(-2) Request for a reset or stop.
EW_BUSY(-1) Busy.
EW_OK(0) Successful.
EW_FUNC(1) The function is not executed, or is disabled.
EW_LENGTH(2) Error in the data block length or number of data items.
EW_NUMBER(3) Data number error.
EW_ATTRIB(4) Data attribute error.
Data error (the specified program is not found when you are going to delete the
EW_DATA(5)
program, when you search for the program, or when you start entering NC data).
EW_NOOPT(6) No CNC option.
EW_PROT(7) Write protection.
EW_OVRFLOW(8) CNC memory overflow.
EW_PARAM(9) CNC parameter error.
EW_BUFFER(10) The buffer is empty or full.
EW_PATH(11) Path number error.
EW_MODE(12) CNC mode error.
EW_REJECT(13) CNC processing is rejected.
EW_DTSRVR(14) Data server error.
EW_ALARM(15) Alarm state.
EW_STOP(16) Stopped state.
EW_PASSWD(17) Data protection state.

2. PMC window return values

Return value Meaning


EW_VERSION(-7) Version mismatch between the CNC/PMC and library.
EW_SYSTEM(-5) System error.
EW_OK(0) Successful.
EW_NOPMC(1) No PMC.
EW_LENGTH(2) Error in the data block length or number of data items.
EW_RANGE(3) Address range error.
EW_TYPE(4) Error in the address type or data type.
EW_DATA(5) Data error.
EW_NOOPT(6) No CNC option.
EW_BUFFER(10) The buffer is empty or full.
EW_PASSWD(17) Data protection state.

- 313 -
3.Function References PROGRAMMING B-64303EN-3/01

3.4.3 Function Reference

1. CNC window library

------------------------------------------------------------------------------------------
1.1 Read CNC system information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_sysinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_sysinfo( struct odbsys *buf ) ;

struct odbsys {
int dummy[2] ; /* Not used. */
char cnc_type[2] ; /* Kind of CNC (ASCII string). */
char mt_type[2] ; /* Kind of M/T/TT (ASCII string). */
char series[4] ; /* Series number (ASCII string). */
char version[4] ; /* Version number (ASCII string). */
char axes[2] ; /* Amount of controllable axes */
} ; /* (ASCII string). */

[Arguments]
buf Buffer in which system information is stored.

[Return]
A main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads system information such as kind of CNC (for example, "0" as series name), kind
of CNC system such as Machining(M) or Turning(T)/Turning with 2-path control(TT), series
and version number of CNC system software in ROM and an amount of controllable axes.
Use this function to confirm compatibility of CNC's system software and PMC's software
or to get an amount of controllable axes before reading axis coordinate data such as
absolute, machine or skipped position.
Note that a null character ('\x00') is not added at the end of each strings.

- 314 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following informations are gotten by execution of this function on Series 0i-D
(D4F1-01) system with 5-axis.

buf.cnc_type = "0"
buf.mt_type = " M"
buf.series = "D4F1"
buf.version = "0001"
buf.axes = "5 "

- 315 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.2 Start output of NC program to be registered. <Main,Alarm>
-------------------------------------------------------------------------------------------

[Name]
cnc_dwnstart

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_dwnstart( void ) ;

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_PROT( 7) Tape memory of CNC is protected.
EW_BUSY(-1) Start command for output of NC program to be registered has been
rejected.
This code is returned if any of the following conditions exists when
this command is executed.
- The CNC is performing other command processing
(downloading, collating, uploading, or program number list reading).
- Background editing is in progress or the MDI mode has been entered.
- Alarm PW0000 or alarm PS0101 is issued.

[Description]
Requests CNC to start registering of NC program (downloading).

[Example]
See example of "Output NC program to be registered(cnc_download)".

- 316 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.3 Output NC program to be registered. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_download

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_download( char *data, short number ) ;

[Arguments]
data NC program data (ASCII string).
number Character number of NC program data (1 - 256).

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for registering NC program has not been
completed, or no start-up command has been commanded.
EW_LENGTH( 2) Incorrect character number "number".
EW_DATA( 5) Incorrect NC program data. This code is returned under one of following
conditions.
- The same program number is already registered.
- A character which is unavailable for NC program is detected.
- When TV check is effective, a block which includes odd characters
(including 'LF' at the end of the block) is detected.
- No more programs can be registered because there is no space for them.
EW_PROT( 7) Write protection.
Any of CNC parameters No. 8000 to No. 8999 or No. 9000 to No. 9999 for
protection or encryption is write-protected.
EW_OVRFLOW( 8) No more NC program can be stored because program memory of CNC is full.

- 317 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]

Outputs (downloads) an NC program to be registered.


The following shows the download procedure.

cnc_dwnstart() Downloading is started.


(Be sure to execute the function.)

cnc_download() Downloaded data is output.

Yes
Is there data yet to be output?

No

cnc_dwnend() Downloading is completed.


(Be sure to execute the function.)

NC program format

NC program to be registered to CNC is a string composed of ASCII characters as following


format.

LF Oxxxx LF Block1 LF Block2 LF ... LF Mxx LF %

LF 0x0A ('\n').
Oxxxx Program number.
Mxx M code at the end of the program (M02,M30,etc.).

'LF' must be placed at the top of the whole program, and '%' at the end. Data before
'LF' at the top are ignored. Address 'O' and program number must be placed in the program
to be registered.
For example, to register a program such as

O1234 ;
G1 F0.3 W10. ;
M30 ;
%

send a following string using cnc_download function.

"\nO1234\nG1F0.3W10.\nM30\n%"

- 318 -
B-64303EN-3/01 PROGRAMMING 3.Function References

The string data can be sent by multiple cnc_download functions.


For above example, the program can be sent block by block like this.

"\n"
"O1234\n"
"G1F0.3W10.\n"
"M30\n"
"%"

And more, it is possible to send one block by multiple cnc_downloadfunctions.


It is possible also to send multiple programs continuously as follows.

"\n"
"O1234\nG1F0.3W10.\nM30\n"
"O5678\nM3S1200\nT11\nG0X10.Z0\nM30\n"
"%"

[Example]
The following program registers the next NC program to CNC.

O1234 ;
M3 S1200 ;
G0 Z0 ;
G0 X0 Y0 ;
G1 F500 X120. Y-30. ;
M30 ;

#include <data.h>
#include <fwindow.h>

short example( void )


{
char *prg[] = {
"\n",
"O1234\n",
"M3 S1200\n",
"G0 Z0\n",
"G0 X0 Y0\n",
"G1 F500 X120. Y-30.\n",
"M30\n",
"%"
} ;
short ret, idx ;
ret = cnc_dwnstart() ;
if ( ret ) return ( ret ) ;
for ( idx = 0 ; idx < sizeof(prg)/sizeof(char *) ; idx++ ) {
ret = cnc_download( prg[idx], strlen( prg[idx] ) ) ;
if ( ret ) {

- 319 -
3.Function References PROGRAMMING B-64303EN-3/01

cnc_dwnend() ;
return ( ret ) ;
}
}
ret = cnc_dwnend() ;
return ( ret ) ;
}

- 320 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.4 Stop output NC program to be registered. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_dwnend

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_dwnend( void ) ;

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for registering NC program has not been
completed, or no start-up command has been commanded.
EW_DATA( 5) Incorrect NC program data in previous output.
This code is returned under one of following conditions.
- The same program number is already registered.
- A character which is unavailable for NC program is detected.
- When TV check is effective, a block which includes odd characters
(including 'LF' at the end of the block) is detected.
- No more programs can be registered because there is no space for them.
EW_PROT( 7) Write protection. Any of CNC parameters No. 8000 to No. 8999 or No. 9000
to No. 9999 for protection or encryption is write-protected.
EW_OVRFLOW( 8) NC programs which have been output previously could not registered
because program memory of CNC is full.

[Description]
Notifies the CNC of the completion of NC program registration.
(This function must always be used after downloading has been completed.)

This function may return a cnc_download function error (such as EW_DATA or EW_OVRFLOW).
Control is not returned from this function until registration of data output by the
cnc_download function has been completed.

[Example]
See example of "Output NC program to be registered(cnc_download)".

- 321 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.5 Start output NC program to be compared. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_vrfstart

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_vrfstart( void ) ;

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_BUSY(-1) Start command for output of NC program to be compared has been rejected.
This code is returned if any of the following conditions exists when
this command is executed.
- The CNC is performing other command processing
(downloading, collating, uploading, or program number list reading).
- Background editing is in progress or the MDI mode has been entered.
- Alarm PW0000 or alarm PS0101 is issued.

[Description]
Requests CNC to start comparing of NC program.

It is possible to compare already registered NC program in CNC and a program which is


output by the application program.

[Example]
See example of "Output NC program to be compared(cnc_verify)".

- 322 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.6 Output NC program to be compared. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_verify

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_verify( char *data, int number ) ;

[Arguments]
data NC program data (ASCII string).
number Character number of NC program data (1 - 256).

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for comparing NC program
has not been completed, or no start-up command has been
commanded.
EW_LENGTH( 2) Incorrect character number "number".
EW_DATA( 5) Incorrect NC program data. This code is returned under one of following
conditions.
- Any difference has been detected during comparing process.
- A CNC-side program to be compared has been selected in foreground
processing.
- A character which is unavailable for NC program is detected.
- When TV check is effective, a block which includes odd characters
(including 'LF' at the end of the block) is detected.

[Description]
Outputs NC program to be compared with already registered one to CNC.

NC program output is a string of ASCII code characters.

"Start output of NC program to be compared(cnc_vrfstart)" must be called before


outputting NC program to be compared to CNC, and "Stop output NC program to be
compared(cnc_vrfend)" after outputting.

Format of NC program to be compared is same as one of "Output NC program to be


registered(cnc_download)" Refer description of "cnc_download" function for format of
output data, etc.

- 323 -
3.Function References PROGRAMMING B-64303EN-3/01

The following shows the comparison procedure.

cnc_vrfstart() Comparison is started.


(Be sure to execute the function.)

cnc_verify() Data to be compared is output.

Yes
Is there data yet to be output?

No

cnc_vrfend() Comparison is completed.


(Be sure to execute the function.)

[Example]
The following program compares the next NC program and "O1234" which is already
registered in CNC.

O1234 ;
M3 S1200 ;
G0 Z0 ;
G0 X0 Y0 ;
G1 F500 X120. Y-30. ;
M30 ;

#include <data.h>
#include <fwindow.h>

short example( void )


{
char *prg[] = {
"\n",
"O1234\n",
"M3 S1200\n",
"G0 Z0\n",
"G0 X0 Y0\n",
"G1 F500 X120. Y-30.\n",
"M30\n",
"%"
} ;
short ret, idx ;
ret = cnc_vrfstart() ;
if ( ret ) return ( ret ) ;
for ( idx = 0 ; idx < sizeof(prg)/sizeof(char *) ; idx++ ) {

- 324 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ret = cnc_verify( prg[idx], strlen( prg[idx] ) ) ;


if ( ret ) {
cnc_vrfend() ;
return ( ret ) ;
}
}
ret = cnc_vrfend() ;
return ( ret ) ;
}

- 325 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.7 Stop output NC program to be compared. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_vrfend

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_vrfend( void ) ;

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for comparing NC program has not been
completed, or no start-up command has been commanded.
EW_DATA( 5) The previously output NC program data is incorrect.
This code is returned under one of following conditions.
- Any difference has been detected during comparing process.
- A CNC-side program to be compared has been selected in foreground
processing.
- A character which is unavailable for NC program is detected.
- When TV check is effective, a block which includes odd characters
(including 'LF' at the end of the block) is detected.

[Description]
Notices the end of comparison of NC program to CNC.
'%' must be output as NC program data before calling this function.
5 or 8 which has been issued during processing of "Output NC program to be compared"
may be returned.
This function doesn't return until the comparing process of CNC is completed.
The comparing process is completed even if the return code is not "0".

[Example]
See example of "Output NC program to be compared(cnc_verify)".

- 326 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.8 Start input NC program. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_upstart

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_upstart( long number ) ;

[Arguments]
number Program number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 1) Unavailable.
EW_DATA( 5) The specified NC program is not registered in CNC.
EW_BUSY(-1) Start command for input of NC program to be uploaded has been rejected.
This code is returned under one of following conditions.
- CNC is executing other requested command (downloading, comparing,
uploading or reading program directory).
- An NC program is running (automatic operation signal OP<F000#7> is
on).
- Background editing is in progress or the MDI mode has been selected.
- Alarm PW0000 or alarm PS0101 is issued.

[Description]
Requests CNC to start reading of NC program (uploading).
(This function must always be executed before uploading can be performed.)

[Example]
See example of "Input NC program(cnc_upload)".

- 327 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.9 Input NC program. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_upload

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_upload( struct odbup *buf, short *number ) ;

struct odbup {
short dummy[2] ; /* Not used. */
char data[N] ; /* NC program data (ASCII string). */
} ; /* N: max 256 */

[Arguments]
buf Buffer in which NC program data are stored.
number Size of the above buffer, amount of characters included in input NC
command data characters.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for reading NC program has not been
completed, or no start-up command has been commanded.
EW_LENGTH( 2) Incorrect buffer size "number".

- 328 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads (uploads) NC command data registered in the CNC program memory.

The following shows the upload procedure.

cnc_upstart() Uploading is started.


(Be sure to execute the function.)

cnc_upload() NC program data is input.

No
Is last character '%' reached?

Yes

cnc_upend() Uploading is completed.


(Be sure to execute the function.)

Format of input data

NC program which is read from CNC is a string composed of ASCII characters as following
format.

% LF Oxxxx LF Block1 LF Block2 LF ... LF Mxx LF %

LF 0x0A ('\n').
Oxxxx Program number.
Mxx M code at the end of the program (M02,M30, etc.).

A null character ('\x00') is not added at the end of each strings stored in the buffer.
The last character of read NC program is '%'.
Only '%' can be read by attempting to read more data beyond this last '%'.
For example, when you read the following NC program using this function,

O1234 ;
G1 F0.3 W10. ;
M30 ;
%

you will get the following strings.

In case of fully large buffer.


1st time "%\nO1234\nG1F0.3W10.\nM30\n%" (24 chars)
2nd and after "%" (1 char)

- 329 -
3.Function References PROGRAMMING B-64303EN-3/01

And in case that the buffer size is less than 24 bytes, you will get the following strings.

In case that the buffer size is 10 bytes.


1st time "%\nO1234\nG1" (10 characters)
2nd time "F0.3W10.\nM" (10 characters)
3rd time "30\n%" (4 characters)
4th and after "%" (1 character)

[Example]
The following program reads the specified NC program registered in CNC, and displays
its contents on the screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#define BUFSIZE 40

/* prgnum is NC program number to be read. */


short example( long prgnum )
{
char buf[BUFSIZE+4] ;
short ret, number ;
ret = cnc_upstart( prgnum ) ;
if ( ret ) return ( ret ) ;
for (;;) {
number = BUFSIZE - 1 ;
ret = cnc_upload( (struct odbup *)(&buf), &number ) ;
if ( ret ) {
cnc_upend() ;
return ( ret ) ;
}
buf[4+number] = '\x00' ;
printf( "%s", &buf[4] ) ;
if ( buf[4+number-1] == '%' ) break ;
}
putchar( '\n' ) ;
ret = cnc_upend() ;
return ( ret ) ;
}

- 330 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.10 Stop input NC program. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_upend

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_upend( void ) ;

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The start-up procedure of CNC for reading NC program
has not been completed, or no start-up command has been commanded.

[Description]
Notifies the library of the completion of NC program reading (uploading).
(This function must always be executed after uploading has been completed.)

[Example]
See example of "Input NC program(cnc_upload)".

- 331 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.11 Search specified program. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_search

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_search( long number ) ;

[Arguments]
number Program number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) Unavailable.
EW_DATA( 5) The specified NC program is not registered in CNC.
EW_PROT( 7) Tape memory of CNC is protected.
EW_BUSY(-1) The program search command was rejected.
This code is returned if any of the following conditions exists when
this command is executed.
- The CNC is performing other window command processing
(downloading, collating, uploading, or program number list reading).
- In the EDIT or memory mode, the automatic operation signal
OP<F000 #7> is on.
- In the EDIT or memory mode, alarm PW0000 or alarm PS0101 is issued.

[Description]
Searches the NC program already registered in CNC.

- 332 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program searches the program whose program number is same as specified
one, and displays the result.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

/* num is program number to be searched. */


void example( long num )
{
short ret ;
ret = cnc_search( num ) ;
switch ( ret ) {
case 0:
printf( "PROGRAM O%d has been searched.\n", num ) ;
break ;
case 5:
printf( "PROGRAM O%d doesn't exist.\n", num ) ;
break ;
case 7:
printf( "PROTECTED.\n" ) ;
break ;
case -1:
printf( "REJECTED.\n" ) ;
break ;
}
}

- 333 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.12 Delete all programs. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_delall

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_delall( void ) ;

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_PROT( 7) Tape memory of CNC is protected, or the target program is protected.
EW_BUSY(-1) In the CNC, the all-program delete command was rejected.
This code is returned if any of the following conditions exists when
this command is executed.
- The CNC is performing other window command processing
(downloading, collating, uploading, or program number list reading).
- An NC program is running (automatic operation signal OP<F000#7>
is on).
- Alarm PW0000, alarm PS0101, or BG alarm is issued.

[Description]
Deletes all NC programs registered in CNC.
This function is equivalent to deletion by "O-9999" in a CNC operation.
Protected programs are not deleted.

- 334 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program deletes all programs and displays the result.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
short ret ;
ret = cnc_delall() ;
switch ( ret ) {
case 0:
printf( "ALL PROGRAMS has been deleted.\n") ;
break ;
case 7:
printf( "PROTECTED.\n" ) ;
break ;
case -1:
printf( "REJECTED.\n" ) ;
break ;
}
}

- 335 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.13 Delete specified program. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_delete

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_delete( long number ) ;

[Arguments]
number Program number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) Unavailable.
EW_DATA( 5) The specified NC program is not registered in CNC.
EW_PROT( 7) Tape memory of CNC is protected, or the target program is protected.
EW_BUSY(-1) In the CNC, the specified-program delete command was rejected.
This code is returned if any of the following conditions exists when
this command is executed.
- The CNC is performing other window command processing
(downloading, collating, uploading, or program number list reading).
- An NC program is running (automatic operation signal OP<F000#7>
is on).
- Alarm PW0000, alarm PS0101, or BG alarm is issued.

[Description]
Deletes the specified NC program registered in CNC.

If the specified program is used for the current automatic operation, it can't be deleted.
The program cannot also be deleted if it is protected.

- 336 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program deletes the program whose program number is same as specified one,
and displays the result.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

/* num is program number to be deleted. */


void example( long num )
{
short ret ;
ret = cnc_delete( num ) ;
switch ( ret ) {
case 0:
printf( "PROGRAM O%d has been deleted.\n", num ) ;
break ;
case 5:
printf( "PROGRAM O%d doesn't exist.\n", num ) ;
break ;
case 7:
printf( "PROTECTED.\n" ) ;
break ;
case -1:
printf( "REJECTED.\n" ) ;
break ;
}
}

- 337 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.14 Read program directory. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdprogdir

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdprogdir( short type, long datano_s, long datano_e,
short length, struct prgdir *buf ) ;

struct prgdir {
char prg_data[N] ; /* Contents of directory (ASCII */
} ; /* string). N: max 256 */

[Arguments]
type Format of program list (0,1,2).
datano_s Start program number to be read.
datano_e End program number to be read.
length Size of the following buffer for the program directory.
buf Buffer in which the program directory list is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect buffer size "length".
EW_NUMBER( 3) Data number error.
Incorrect program number "datano_s" or "datano_e".
EW_ATTRIB( 4) Incorrect format "type".

- 338 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the list of program numbers (program directory) of all NC programs registered in
CNC.

Program numbers, comments and character numbers of programs included in specified program
number range are read with ASCII string format.
Specify the start program number to be read in "datano_s" and the end one in "datano_e".
Store "datano_s=1" and "datano_e"=9999 to read all programs. Specify the format of
program list in "type".

Format of input data

The program directory list which is read from CNC is a string composed of ASCII characters
as following format.

type=0 Oxxxx Oxxxx ... %

type=1 % LF Oxxxx (COMMENT) LF Oxxxx (COMMENT) LF ... LF %

type=2 Oxxxx (COMMENT) CHAR_NUMBER Oxxxx (COMMENT) CHAR_NUMBER ... %

LF 0x0A ('\n')
Oxxxx Program number. This is a ASCII string
without the leading '0' of numeric
part sorted in numeric order. ("O1" -"O9999")
CHAR_NUMBER Character number of the program.
This is a ASCII string without the leading '0'.
The number is raised to 80-character unit.
COMMENT The comment which is written just after the program
number is stored.
The maximum character number of the comment body is
48. (50 for the body and the before and the behind
parentheses.)
Only beginning 48 characters are stored for the comment
which is longer than 48 characters.
If the program has no comment, only parentheses ("()")
are stored.

- 339 -
3.Function References PROGRAMMING B-64303EN-3/01

For all cases, when no program is registered or there is no program in the specified
range, only '%' is stored.

A null character ('\x00') is not added at the end of each strings stored in the buffer.

For example, when the next programs are registered in CNC, the result of this function,
in case that datano_s=1 and datano_e=9999, is as follows.

Program number (COMMENT) Character number


-------------------------------+----------------
O0012 (TEST) ; 420
O0200 (WORK1) ; 352
O0201 ; 537
O9001 (SUB-PRO1) ; 781

type Contents to be read.


-------+-----------------------------------------------------------
0 "O12O200O201O9001%"
1 "%\nO12(TEST)\nO200(WORK1)\nO201()\nO9001(SUB-PRO1)\n%"
2 "O12(TEST)420O200(WORK1)352O201()537O9001(SUB-PRO1)781%"

If the buffer size is less than 15 bytes, the result is as follows.

type Contents to be read.


-------+-----------------------------------------------------------
0 "O12O200O201O900"
1 "%\nO12(TEST)\nO20"
2 "O12(TEST)420O20"

- 340 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program reads the registration information of NC program included specified
by the arguments, and displays program number list.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <string.h>
#define BUFSIZE 256

/* start/end specify program number range. */


short example( long start, long end )
{
char buf[BUFSIZE] ;
short ret, idx ;
memset( buf, '\x00', BUFSIZE ) ;
ret = cnc_rdprogdir( 0, start, end, BUFSIZE-1,
(struct prgdir *)(&buf) ) ;
if ( ret ) {
printf( "ERROR: %d\n", ret ) ;
return ( ret ) ;
}
for ( idx = 0 ; idx < strlen( buf ) ; idx++ ) {
if ( buf[idx] == 'O' ) putchar( '\n' ) ;
putchar( buf[idx] ) ;
}
putchar( '\n' ) ;
}

- 341 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.15 Read program information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdproginfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdproginfo( short type, short length, struct odbnc *buf ) ;

struct odbnc {
union {
struct {
short reg_prg ; /* Number of registered programs. */
short unreg_prg ;/* Number of unregistered programs. */
long used_mem ; /* Used memory area (number of characters). */
long unused_mem ;/* Unused memory area (number of characters). */
} bin ;
char asc[31] ; /* Buffer for ASCII string format. */
} u ;
} ;

[Arguments]
type Data type ( =0(binary), 1(ASCII) ).
length Data block length ( =16(binary), 35(ASCII) ).
buf Buffer in which the program information is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect data type "type".

[Description]
Reads the management data of NC programs already registered in CNC.

The management data of NC program are


Number of registered programs,
Number of registerable programs,
Used memory area (number of characters),
Remaining available memory area (number of characters).

- 342 -
B-64303EN-3/01 PROGRAMMING 3.Function References

This function returns these data with binary format or ASCII string format. These
informations are same as ones which are displayed in PROGRAM/LIB screen (in EDIT mode)
of CNC.

Output format
type = 0:
Values are stored in "buf" members in binary format.
buf.bin.reg_prg Number of registered programs.
buf.bin.unreg_prg Number of unregistered programs.
buf.bin.used_mem Used memory area (number of characters).
buf.bin.unused_mem Unused memory area (number of characters).
type = 1:
ASCII strings are stored in "buf.u.asc" in the following format.

% LF d1 LF d2 LF d3 LF d4 LF %

LF 0x0A ('\n').
d1 Number of registered programs.
d2 Number of unregistered programs (number of remaining
registerable programs).
d3 Used memory area (number of characters).
d4 Unused memory area (remaining available memory area) (number
of characters).
d1 - d4 are ASCII strings without the leading '0'.

[Example]
The following program reads the management data of NC program, and displays them.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct odbnc buf ;
short ret ;
ret = cnc_rdproginfo( 0, 16, &buf ) ;
if ( ret )
printf( "ERROR: %d\n", ret ) ;
else {
printf( "Registered program number = %d\n",
buf.u.bin.reg_prg ) ;
printf( "Registerable program number = %d\n",
buf.u.bin.unreg_prg ) ;
printf( "Used memory = %ld\n",
buf.u.bin.used_mem ) ;
printf( "Free memory = %ld\n",
buf.u.bin.unused_mem ) ;
}
}

- 343 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.16 Read program number in executing. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdprgnum

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdprgnum( struct odbpro *buf ) ;

struct odbpro {
short dummy[2] ; /* Not used. */
long data ; /* Program number in executing. */
long mdata ; /* Program number of the main
program. */
} ;

[Arguments]
buf Buffer in which program numbers are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) Unavailable.

[Description]
Reads program number of the program which is being currently executed in CNC.

If that program is a sub-program, the program number of the main program of it is also
read. The program number which can be read is one of the root program. If the program
in executing is not a sub-program, the main program number is set as 0.

This function is used for management of NC programs in CNC by the application program,
etc.

The program numbers are stored in "buf.data" and 'buf.mdata" with unsigned binary format.

- 344 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The next program displays "CURRENT(O9876) MAIN(O1234)" while the block "O9876/N210"
of the following NC program is being executed.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct odbpro buf ;
cnc_rdprgnum( &buf ) ;
printf( "CURRENT(O%d) MAIN(O%d)\n", buf.data, buf.mdata ) ;
}

O1234 ; O5678 ; O9876 ;


N10 M98 P5678 ; N110 M98 P9876 ; N210 M45 ;
N20 M30 ; N120 M99 ; N220 M99 ;

- 345 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.17 Read sequence number in executing. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdseqnum

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdseqnum( struct odbact *buf ) ;

struct odbact {
short dummy[2] ; /* Not used. */
long data ; /* Sequence number in executing. */
} ;

[Arguments]
buf Buffer in which sequence number is stored.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the sequence number of the NC program which is being currently executed in CNC.

If the NC program has no sequence numbers in its all blocks, the sequence number of the
last executed block is read.

This function is used for watch the block being executed or the current process by the
application program, or only displaying the current sequence number.

The sequence number is stored in "buf.data" with unsigned binary format.

- 346 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program displays "CURRENT N30" while the block "O1234/N30" of the following
NC program is being executed.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct odbact buf ;
cnc_rdseqnum( &buf ) ;
printf( "CURRENT N%ld\n", buf.data ) ;
}

O1234 ;
N10 M3 S1500 ;
N20 T12 ;
N30 G0 X110. ;
N40 ...

- 347 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.18 Read actual feed rate of controlled axes. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_actf

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_actf( struct odbact *buf ) ;

struct odbact {
short dummy[2] ; /* Not used. */
long data ; /* Actual feed rate (F). */
} ;

[Arguments]
buf Buffer in which the actual feed rate (F) is stored.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the actual feed rate of the controlled axes of CNC.

[Example]
The message "CURRENT F=1200" is displayed if the following program is executed while
the O1234/N20 block in the following NC program is being executed (on the assumption
that the lathe is running in the metric input mode).

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct odbact buf ;
cnc_actf( &buf ) ;
printf( "CURRENT F=%ld\n", buf.data ) ;
}

O1234 ;
N10 G98 F1200 ;
N20 G1 U10. W200.
N30 ...

- 348 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.19 Read actual spindle speed. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_acts

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_acts( struct odbact *buf ) ;

struct odbact {
short dummy[2] ; /* Not used. */
long data ; /* Actual spindle speed. */
} ;

[Arguments]
buf Buffer in which the actual spindle speed is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_PARAM( 9) CNC parameter error.

[Description]
Reads the actual rotational speed of the spindle connected to CNC.

The actual spindle speed data is stored in "buf.data" with unsigned binary format.

[Example]
The following program displays "CURRENT S=2470" while the actual rotational speed of
the main spindle is 2470.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct odbact buf ;
cnc_acts( &buf ) ;
printf( "CURRENT S=%ld\n", buf.data ) ;
}

- 349 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.20 Read absolute position. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_absolute

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_absolute( short axis, short length, struct iodbaxis *buf ) ;

struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Absolute position data of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/

[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4×(Number of axes for which data
is to be read) ).
buf Buffer in which the absolute position data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.

- 350 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the absolute position data of the controlled axis of CNC.

This absolute position data is identical to that in the absolute


coordinate system displayed on the current position display screen of the CNC.
Therefore, the data is affected by the settings of bits 6 (DAL) and 7 (DAC) of CNC parameter
No. 3104. Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the
parameter.

This function is used for displaying the absolute positions of the controlled axes of
CNC by the application program, etc. Specify one of (1,..,amount of controlled axes)
for each axis or –1 for all axes as axis number in "axis".

The absolute position data is stored in "buf.data" with signed binary format. (The
negative value is represented as 2's complement.) The absolute position data of specified
axis is stored in "buf.data[0]" in case of reading one axis's data.

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─
n = maximum number of controlled axes

- 351 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program displays
1: 120005
2: -50119
3: 80
while the absolute position data for each axes are
The 1st axis 120.005
The 2nd axis -50.119
The 3rd axis 0.080
in 3-axis system.
(in case of "mm input" and "IS-B".)

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct iodbaxis buf ;
cnc_absolute( -1, 4+4*3, &buf ) ;
printf( "1:%8ld\n2:%8ld\n3:%8ld\n", buf.data[0], buf.data[1],
buf.data[2] ) ;
}

- 352 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.21 Read machine position. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_machine

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_machine( short axis, short length, struct iodbaxis *buf ) ;

struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Machine position data of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/

[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4×(Number of axes for which data
is to be read) ).
buf Buffer in which the machine position data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.

- 353 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the machine position data of the controlled axis of CNC.

This machine position data is identical to that in the machine coordinate system displayed
on the current position display screen of the CNC.
Therefore, the data is affected by the setting of bit 0 (MCN) of CNC parameter No. 3104.
Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the parameter.

This function is used for displaying the machine positions of the controlled axes of
CNC by the application program, etc.

Specify one of (1,..,amount of controlled axes) for each axis or –1 for all axes as axis
number in "axis".
The machine position data is stored in "buf.data" with signed binary format. (The negative
value is represented as 2's complement.) The machine position data of specified axis
is stored in "buf.data[0]"in case of reading one axis's data.

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─

n = maximum number of controlled axes

- 354 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program displays "MACHINE 2: -265593" while the machine position data of
the 2nd axis is -26.5593. (in case of "inch output" and "IS-B".)

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct iodbaxis buf ;
cnc_machine( 2, 4+4*1, &buf ) ;
printf( "MACHINE 2:%8ld\n", buf.data[0] ) ;
}

- 355 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.22 Read relative position. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_relative

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_relative( short axis, short length, struct iodbaxis *buf ) ;

struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Relative position data of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/

[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4×(Number of axes for which data
is to be read) ).
buf Buffer in which the relative position data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.

- 356 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the relative position data of the controlled axis of CNC.

This relative position data is identical to that in the relative coordinate system
displayed on the current position display screen of the CNC.
The position data is identical to the relative position data in the relative coordinate
system displayed on the current position display screen of the CNC. Therefore, the data
is affected by the settings of bit 4 (DRL) and bit 5 (DRC) of CNC parameter No. 3104
for the M series. The data is affected by the settings of bit 0 (DRP) of CNC parameter
No. 3104 (M series) / the settings of bits 0 (DRP) of No. 3129 and bits 5 (DRC) of No.
3104 (T series). Refer to "Parameter Manual" (B-64310EN) of the CNC for details about
the parameter.

This function is used for displaying the relative positions of the controlled axes of
CNC by the application program, etc.

Specify one of (1,..,amount of controlled axes) for each axis or –1 for all axes as axis
number in "axis".

The relative position data is stored in "buf.data" with signed binary format. (The
negative value is represented as 2's complement.) The relative position data of specified
axis is stored in "buf.data[0]" in case of reading one axis's data.

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─

n = maximum number of controlled axes

- 357 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program displays "RELATIVE 4: 900051" while the relative position data
of the 4th axis(rotation axis) is 90.0051.(in case of "IS-C".)

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct iodbaxis buf ;
cnc_relative( 4, 4+4*1, &buf ) ;
printf( "RELATIVE 4:%8ld\n", buf.data[0] ) ;
}

- 358 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.23 Read distance to go. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_distance

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_distance( short axis, short length, struct iodbaxis *buf ) ;

struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Amount of distance to go of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/

[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4×(Number of axes for which data
is to be read) ).
buf Buffer in which the amounts of distance to go are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.

[Description]
Reads the amount of distance to go of the controlled axis of CNC.

This amount of distance to go is same as one which is displayed on the current position
screen of CNC.

This function is used for displaying the amount of distance to go of the controlled axes
of CNC by the application program, etc.

Specify one of (1,..,amount of controlled axes) for each axis or –1 for all axes as axis
number in "axis".
The amount of distance to go is stored in "buf.data" with signed binary format. (The
negative value is represented as 2's complement.) The amount of distance to go of
specified axis is stored in "buf.data[0]" in case of reading one axis's data.

- 359 -
3.Function References PROGRAMMING B-64303EN-3/01

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─

n = maximum number of controlled axes

- 360 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.24 Read skipped position. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_skip

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_skip( short axis, short length, struct iodbaxis *buf ) ;

struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Skipped position data of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/

[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4×(Number of axes for which data
is to be read) ).
buf Buffer in which the skipped position data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.

[Description]
Reads the skipped position of the axis specified by "axis".

The skipped position data is stored in "buf.data[0]".

The data of all axes can be read at once by setting -1 in "axis".


The skipped position data of each axis is stored in the "data" array in "buf".
The decimal point position in the skipped position data can be obtained with the “1.67
cnc_getfigure function”.

Specify one of (1,..,amount of controlled axes) for each axis or -1


for all axes as axis number in "axis".
The skipped position data is stored in "buf.data" with signed binary format.

- 361 -
3.Function References PROGRAMMING B-64303EN-3/01

(The negative value is represented as 2's complement.)

The skipped position data of specified axis is stored in "buf.data[0]" in case of reading
one axis's data.

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─
n = maximum number of controlled axes

[Example]
The following program displays the skipped position of the 1st and 2nd axes.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct iodbaxis buf ;
unsigned int idx ;
cnc_skip( 1, 4+4*1, &buf ) ;
printf( "SKIP 1:%8ld\n", buf.data[0] ) ;
cnc_skip( 2, 4+4*1, &buf ) ;
printf( "SKIP 2:%8ld\n", buf.data[0] ) ;
}

- 362 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.25 Read servo delay amount. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_srvdelay

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_srvdelay( short axis, short length, struct iodbaxis *buf ) ;

struct iodbaxis {
short dummy ; /* Not used. */
hort type ; /* Axis number. */
long data[N] ; /* Servo delay amount of */
} ; /* controlled axis. */
/* N is a maximum controlled axis number.*/

[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4×(Number of axes for which data
is to be read) ).
buf Buffer in which the servo delay amounts are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.

[Description]
Reads the servo delay amount of the axis specified by "axis".

The servo delay amount data is stored in "buf.data[0]".

The data of all axes can be read at once by setting -1 in "axis".


The servo delay amount data of each axis is stored in the "data" array in "buf".

The decimal point position in the servo delay amount data can be obtained with the “1.67
cnc_getfigure function”.

As an axis number in "axis", specify one of the values in the range from 1 to the number
of controlled axes for reading data of one axis or -1 for reading data of all axes.

- 363 -
3.Function References PROGRAMMING B-64303EN-3/01

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─

n = number of controlled axes

[Example]
The following program displays the servo delay amount of all axes (amount of axes = MAX).

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct iodbaxis buf ;
unsigned int idx ;
cnc_srvdelay( -1, 4+4*MAX, &buf ) ;
for ( idx = 0 ; idx < MAX ; idx++ )
printf( "%u:%8ld\n", idx, buf.data[idx] ) ;
}

- 364 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.26 Read acceleration/deceleration delay amount. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_accdecdly

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_accdecdly( short axis, short length, struct iodbaxis *buf ) ;

struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Acceleration/deceleration delay */
} ; /* amount of controlled axis. */
/* N is a maximum controlled axis number.*/

[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4×(Number of axes for which data
is to be read) ).
buf Buffer in which the acceleration/deceleration delay
amounts are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.

- 365 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the acceleration/deceleration delay amount of the axis specified by "axis".

The acceleration/deceleration delay amount data is stored in "buf.data[0]".

The data of all axes can be read at once by setting -1 in "axis".


The acceleration/deceleration delay amount data of each axis is stored in the "data"
array in "buf".

The decimal point position in the acceleration/deceleration delay amount data can be
obtained with the “1.67 cnc_getfigure function”.

As an axis number in "axis", specify one of the values in the range from 1 to the number
of controlled axes for reading data of one axis or -1 for reading data of all axes.

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─

n = number of controlled axes

[Example]
The following program displays the acceleration/deceleration delay amount of all axes
(amount of axes = MAX).

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct iodbaxis buf ;
unsigned int idx ;
cnc_accdecdly( -1, 4+4*MAX, &buf ) ;
for ( idx = 0 ; idx < MAX ; idx++ )
printf( "%u:%8ld\n", idx, buf.data[idx] ) ;
}

- 366 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.27 Read dynamic data. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rddynamic

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rddynamic( short axis, short length, struct odbdy *buf ) ;

struct odbdy {
short dummy ; /* Not used. */
short axis ; /* Axis number. */
short alarm ; /* Alarm status. */
long prgnum ; /* Program number in executing. */
long prgmnum ; /* Program number of the main prog. */
long seqnum ; /* Sequence number. */
long actf ; /* Actual feed rate. */
long acts ; /* Actual spindle speed. */
union {
struct {
long absolute[32] ; /* Absolute position */
/* data of controlled axis.*/
long machine[32] ; /* Machine position */
/* data of controlled axis.*/
long relative[32] ; /* Relative position */
/* data of controlled axis. */
long distance[32] ; /* Amount of distance*/
/* to go of */
/* controlled axis. */
} faxis ; /* For all axes. */
struct {
long absolute ; /* Absolute position */
/* data of controlled axis. */
long machine ; /* Machine position */
/* data of controlled axis. */
long relative ; /* Relative position */
/* data of controlled axis. */
long distance ; /* Amount of distance*/
/* to go of */
/* controlled axis. */
} oaxis ; /* For one axis. */
} pos ;
} ;

- 367 -
3.Function References PROGRAMMING B-64303EN-3/01

[Arguments]
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
(This is effective to only data who have axis attribute.)
length Data block length ( =22+4×4×(Number of axes for which
data is to be read) ).
buf Buffer in which the dynamic data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.

[Description]
Reads various data which are changing every second while NC program is executing at the
same time.

This function is used for getting data to display the current position screen or the
monitoring screen, etc.

This function reads the following data.

Function used for reading


Data
individually
Alarm status cnc_alarm
Program number in executing cnc_rdprgnum
Program number of the main program cnc_rdprgnum
Sequence number cnc_rdseqnum
Actual feed rate cnc_actf
Actual spindle speed cnc_acts
Absolute position data of controlled axis cnc_absolute
Machine position data of controlled axis cnc_machine
Relative position data of controlled axis cnc_relative
Amount of distance to go of controlled axis cnc_distance

The formats of each data are same as "Function used for reading individually". Refer
each functions for formats of data, etc.
Specify one of (1,..,amount of controlled axes) for each axis or –1 for all axes as axis
number in "axis".
The array size of each member of odbdy.pos.faxis, which is used to read data related
to all axes at a time, is fixed at 32 no matter how high the maximum controlled-axis
number is. If the maximum controlled-axis number is lower than 32, no data is stored
to the members that correspond to axis Nos. "maximum controlled-axis number + 1" to 32.

- 368 -
B-64303EN-3/01 PROGRAMMING 3.Function References

"length" specifies the data block length (size of "buf").

- One axis - All axes


buf 0┌───┐ ─ buf 0┌───┐ ─
│dummy │ ↑ │dummy │ ↑
2├───┤ │ 2├───┤ │
│axis │ │ │axis │ │
4├───┤ │ 4├───┤ │
│alarm │ │ │alarm │ │
6├───┤ │ 6├───┤ │
│ │ │ │ │ │
8├───┴───┐│ 8├───┴───┐│
│ prgnum ││ │ prgnum ││
12├───────┤│ 12├───────┤│
│ prgmnum length th │ prgmnum length
16├───────┤│ 16├───────┤│
│ seqnum ││ │ seqnum ││
20├───────┤│ 20├───────┤│
│ actf ││ │ actf ││
24├───────┤│ 24├───────┤│
│ acts ││ │ acts ││
28├───────┤│ 28├───────┤│
│ absolute ││ │ absolute[0] ││
32├───────┤│ 32├───────┤│
│ machine ││ ~ ~│
36├───────┤│ 28+4×(n-1)├───────┤│
│ relative ││ │ absolute[n-1]││
40├───────┤│ 28+4×n├───────┤│
│ distance │↓ │ machine[0] ││
44└───────┘─ 28+4×(n+1)├───────┤│
~ ~│
28+4×(2n-1)├───────┤│
│ machine[n-1] ││
28+4×2n├───────┤│
│ relative[0] ││
28+4×(2n+1)├───────┤│
~ ~│
28+4×(3n-1)├───────┤│
│ relative[n-1]││
28+4×3n├───────┤│
│ distance[0] ││
28+4×(3n+1)├───────┤│
~ ~│
28+4×(4n-1)├───────┤│
│ distance[n-1]│↓
28+4×4n└───────┘─
n = maximum number of controlled axes (the data of the
current number of controlled axes is valid)

- 369 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads the dynamic data of all axes (amount of axes = MAX) and
displays them on the screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct odbdy buf ;
unsigned int idx ;
cnc_rddynamic( -1, sizeof(buf), &buf ) ;
printf( "Current program = %d Main program = %d\n",
buf.prgnum, buf.prgmnum ) ;
printf( "Sequence number = %ld\n", buf.seqnum ) ;
printf( "actf = %ld acts = %ld\n", buf.actf, buf.acts ) ;
printf( "Alarm status = %d\n", buf.alarm ) ;
printf( "AXIS Absolute Relative Machine Distance\n" ) ;
printf( "----+---------+---------+---------+--------\n" ) ;
for ( idx = 0 ; idx < MAX ; idx++ )
printf( " %u %8ld %8ld %8ld %8ld\n", idx,
buf.pos.faxis.absolute[idx],
buf.pos.faxis.relative[idx],
buf.pos.faxis.machine[idx],
buf.pos.faxis.distance[idx] ) ;
}

- 370 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.28 Read CNC status information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_statinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_statinfo( struct odbst *buf ) ;

struct odbst {
short dummy[2]; /* Not used */
short aut; /* OPERATION mode selection */
short run; /* Status of automatic operation */
short motion; /* Status of axis movement, dwell */
short mstb; /* Status of M,S,T,B function */
short emergency; /* Status of emergency stop, rest */
short alarm; /* Status of alarm */
short edit; /* Status of program editing */
} ;

[Arguments]
buf For a 2-path system (T series (2-path control)), all statuses are
provided for each path.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the status informations of CNC which are displayed in the bottom of the NC's screen.

This function reads the following status informations.

(1) Operation mode (aut)

Value Display Description


-------+-------+-----------------------------------
0 MDI Manual data input mode
1 MEM Automatic operation mode
2 **** Not used
3 EDIT Memory editing mode
4 HND Manual handle feed mode
5 JOG Jog feed mode

- 371 -
3.Function References PROGRAMMING B-64303EN-3/01

6 TJOG TEACH IN JOG mode


7 THND TEACH IN HANDLE mode
8 INC Manual incremental feed mode
9 REF Manual reference position return mode
10 RMT Automatic operation (part program operation) mode

(2) Automatic operation status (run)

Value Display Description


-------+-------+-----------------------------------
0 **** Reset
1 STOP Automatic operation stopped
2 HOLD Automatic operation suspended
3 STRT Automatic operation started

(3) Axis moving/dwelling status (motion)

Value Display Description


-------+-------+-----------------------------------
0 *** Axis neither moving nor dwelling
1 MTN Axis moving
2 DWL Axis dwelling

(4) M, S, T, or B function status (mstb)

Value Display Description


-------+-------+-----------------------------------
0 *** FIN signal not awaited.
1 FIN Auxiliary function being executed (FIN signal awaited)

(5) Emergency stop or reset status (emergency)


Value Display Description
-------+-------+-----------------------------------
0 Not Neither at emergency stop nor at reset displayed
1 --EMG-- At emergency stop
2 -RESET- At reset

(6) Alarm status (alarm)

Value Display Description


-------+-------+-----------------------------------
0 *** No alarm/warning
1 ALM Alarm
2 BAT Low battery voltage

- 372 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(7) Program editing status (edit)

- Machining center system

Value Display Description


-------+-------+-----------------------------------
0 Not Editing not in progress displayed
1 EDIT Editing (such as insertion or updating) in progress
2 SRCH Search in progress
3 OUTPUT Data output in progress
4 INPUT Data input in progress
5 COMPARE Data comparison in progress
6 LSK Label skip at data input
7 RSTR Program restart in progress
8 (Unused)
9 (Unused)
10 (Unused)
11 (Unused)
12 (Unused)
13 HANDLE Handle interruption in progress
14 (Unused)
15 (Unused)
16 AICC AI contour control operation in progress
17 MECHK Tape memory check in progress
18 (Unused)
19 (Unused)
20 (Unused)
21 (Unused)
22 (Unused)
23 (Unused)
24 (Unused)
25 (Unused)
26 (Unused)
27 (Unused)
28 (Unused)
39 (Unused)
40 (Unused)
41 (Unused)
42 APC Advanced preview control in progress

- 373 -
3.Function References PROGRAMMING B-64303EN-3/01

- Lathe system

Value Display Description


-------+-------+-----------------------------------
0 Not Editing not in progress displayed
1 EDIT Editing (such as insertion or updating) in progress
2 SRCH Search in progress
3 OUTPUT Data output in progress
4 INPUT Data input in progress
5 COMPARE Data comparison in progress
6 LSK Label skip at data input
7 (Unused)
8 WSFT Workpiece shift write mode
9 STR Program restart in progress
10 (Unused)
11 (Unused)
12 (Unused)
13 (Unused)
14 (Unused)
15 (Unused)
16 (Unused)
17 MECHK Tape memory check in progress
18 (Unused)
19 (Unused)
23 (Unused)
24 (Unused)
25 (Unused)
26 (Unused)
27 (Unused)
28 (Unused)
29 (Unused)
31 (Unused)
39 (Unused)
40 (Unused)
41 (Unused)
42 APC Advanced preview control in progress

- 374 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.29 Read alarm status. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_alarm

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_alarm( struct odbapb *buf ) ;

struct odbapb {
short dummy[2] ; /* Not used. */
short data ; /* Alarm status. */
} ;

[Arguments]
buf Buffer in which the alarm status is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_PARAM( 9) CNC parameter error.

[Description]
Reads the alarm status of CNC. Various types of information items are stored in
"buf.data".

This function is used for watching CNC's alarm status, displaying he maintenance
information or guidance of how to reset the alarm, etc.

However, the status of a system alarm cannot be obtained.

- 375 -
3.Function References PROGRAMMING B-64303EN-3/01

The alarm status is stored in each bits of "buf.data" as follows.


buf.data
bit0 The parameter write switch is on. (SW)
bit1 A parameter that requires turning off the
power was input. (PW)
bit2 I/O error (IO)
bit3 Foreground P/S (PS)
bit4 Overtravel/external data input error (OT)
bit5 Overheat (OH)
bit6 Servo alarm (SV)
bit7 Data input/output error (SR)
bit8 Macro alarm (MC)
bit9 Spindle alarm (SP)
bit10 OT alarm that will not lead to a PS alarm (DS)
bit11 Alarm related to malfunction prevention (IE)
bit12 Background P/S (BG)
bit13 Synchronization error too high (SN)
bit14 Reserved
bit15 External alarm message (EX)

- 376 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.30 Read alarm information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdalminfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdalminfo( short type, short alm_type, short length,
struct alminfo *buf ) ;

struct alminfo {
union {
struct {
struct {
long axis ; /* Axis information. */
short alm_no ; /* Alarm number. */
} alm[N] ; /* N is number of messages to be read. */
long data_end ;
} alm1 ;
struct {
struct {
long axis ; /* Axis information. */
short alm_no ; /* Alarm number. */
short msg_len ; /* Message length. */
char alm_msg[32] ; /* Alarm message. */
} alm[N] ; /* N is number of messages to be read. */
long data_end ;
}alm2 ;
} u ;
} ;

[Arguments]
type Data format ( =0(without message), 1(with message) ).
alm_type Kind of alarm ( =0,..,31 ).
length Data block length ( =4+6*N(without message),
4+40*N(with message) ).
buf Buffer in which the alarm information is stored.

- 377 -
3.Function References PROGRAMMING B-64303EN-3/01

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect data format type "type".
EW_ATTRIB( 4) Incorrect alarm type "alm_type".

[Description]
Reads the detail informations of currently arising CNC alarms.

This function is used for displaying the alarm numbers or messages of


the currently arising alarms by the application program, etc.

Specify the kind of alarm to be read in "alm_type".

alm_type Kind of alarm


---------------+-----------------------------------------------
0 The parameter write switch is on. (SW)
1 A parameter that requires turning off the
power was input. (PW)
2 I/O error (IO)
3 Foreground P/S (PS)
4 Overtravel/external data input error (OT)
5 Overheat (OH)
6 Servo alarm (SV)
7 Data input/output error (SR)
8 Macro alarm (MC)
9 Spindle alarm (SP)
10 OT alarm that will not lead to a PS alarm (DS)
11 Alarm related to malfunction prevention (IE)
12 Background P/S (BG)
13 Synchronization error too high (SN)
14 Reserved
15 External alarm message (EX)
16 External alarm message (EX2)
17 External alarm message (EX3)
18 External alarm message (EX4)
19 PMC error (PC)
20 Not used
:
31 Not used

- 378 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Specify data format in "type".


type Contents of read data
-------+-------------------------------------------------
0 Axis information and alarm number
1 Axis information, alarm number and alarm message
"length" specifies the data block length (size of "buf").
u.alm1 0┌───────────┐ ─
│ alm[0] │ ↑
8├───────────┤ │
~ ~ │
8×(N-1)├───────────┤length
│ alm[N-1] │ │
8×N├───────────┤ │
│ data_end │ ↓
8×N+4└───────────┘ ─
u.alm1.alm 0┌───────────┐
│ │
2├ axis ┤
│ │
4├───────────┤
│ alm_no │
6├───────────┤
│ │
8└───────────┘
u.alm2 0┌───────────┐ ─
│ alm[0] │ ↑
40├───────────┤ │
~ ~ │
40×(N-1)├───────────┤length
│ alm[N-1] │ │
40×N├───────────┤ │
│ data_end │ ↓
40×N+4└───────────┘ ─
u.alm2.alm 0┌───────────┐
│ │
2├ axis ┤
│ │
4├───────────┤
│ alm_no │
6├───────────┤
│ msg_len │
8├─────┬─────┘
│alm_msg[0]│
9├─────┤
~ ~
39├─────┤
│alm_msg[31]
40└─────┘ N is the number of alarm information items
to be read.

- 379 -
3.Function References PROGRAMMING B-64303EN-3/01

Axis information is set in "axis". Occurrence of an alarm for each axis is indicated
by turning on or off the corresponding bit. For an alarm that is not of axis-type, all
bits are turned off.

#5 : The 5th axis alarm


#4 : The 4th axis alarm
:
#01 : The 2nd axis alarm
#00 : The 1st axis alarm

"1" of each bit indicates any alarm is arising the corresponding axis. When all
bits are "0", the alarm is not axis-type one but any ordinary one. When the same
alarm is arising for the multiple axes, the corresponding multiple bits of the
axis information are set as "1".

"Alarm number" is the alarm number (binary format).

"Message length" is a length of the alarm message. A value between 0 and 32 is stored
with binary format.

"Alarm message" the alarm message. It is ASCII string which is same as one displayed
in the CNC's alarm screen.

When no alarms which belong to specified kind arise, only "End of data" is stored.

- 380 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.31 Read tool offset amount. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtofs

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtofs( short number, short type, short length,
struct odbtool *buf ) ;

struct odbtool {
short datano ; /* Offset number. */
short type ; /* Offset type. */
long data ; /* Offset data. */
} ;

[Arguments]
number Offset number.
type Offset type.
length Data block length ( =8 ).
buf Buffer in which the offset amount is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect offset number "number".
(This return code is returned in case that any value except 1,.,(maximum
number of offset) was specified in offset number "number".
EW_ATTRIB( 4) Incorrect offset type "type".

- 381 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the tool offset amount of the number specified by "number" having the type specified
by "type".

The offset amount data is stored in "data" in "buf" in signed binary format.
The unit of the offset amount can be obtained with "1.67 cnc_getfigure function".

"number" specifies the number of an offset to be read.

"type" specifies the type of an offset to be read (see the table below).

- Machining center system

Tool Tool Virtual


radius length tool tip
Wear 0 2 6
Geometry 1 3 7

If no distinction is made between tool radius compensation and tool length


compensation, specify tool radius compensation. If no distinction is made
between wear compensation and geometry compensation, specify wear compensation.

- Lathe system

Tool-nose Virtual tool


X-axis Z-axis Y-axis
radius tip
Wear 0 2 4 6 8
Geometry 1 3 5 7 9

If no distinction is made between wear compensation and geometry compensation,


specify wear compensation.

- Second geometry compensation amount in lathe system

X-axis Z-axis Y-axis


Geometry 100 101 102

- 382 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program reads the wear offset amount for an axis related to each specified
tool number. (Lathe series)

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

/* tidx is tool index. */


void example( short tidx )
{
struct odbtool buf ;
short ret ;
ret = cnc_rdtofs( tidx, 0, 8, &buf ) ;
if ( !ret ) printf( "X(%d) = %ld\n", tidx, buf.data ) ;
ret = cnc_rdtofs( tidx, 2, 8, &buf ) ;
if ( !ret ) printf( "Z(%d) = %ld\n", tidx, buf.data ) ;
ret = cnc_rdtofs( tidx, 8, 8, &buf ) ;
if ( !ret ) printf( "Y(%d) = %ld\n", tidx, buf.data ) ;
}

- 383 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.32 Write tool offset amount. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrtofs

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrtofs( short number, short type, short length, long data ) ;

[Arguments]
number Offset number.
type Offset type.
length Data block length ( =8 ).
data Offset data.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect offset number "number".
(This return code is returned in case that any valueexcept 1,
,(maximum number of offset) was specified in offset number "number".
EW_ATTRIB( 4) Incorrect offset type "type".

- 384 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Rewrites the tool offset amount of the number specified by "number" having the type
specified by "type", with the value specified by "data".
The offset amount data is stored in "data" in signed binary format.

The unit of the offset amount can be obtained with “1.67 cnc_getfigure function”.

"number" specifies the number of an offset to be rewritten.


"type" specifies the type of an offset to be rewritten (see the table below).

- Machining center system

Tool Tool Virtual


radius length tool tip
Wear 0 2 6
Geometry 1 3 7

If no distinction is made between tool radius compensation and tool length compensation,
specify tool radius compensation. If no distinction is made between wear compensation
and geometry compensation, specify wear compensation.

- Lathe system

Tool-nose Virtual tool


X-axis Z-axis Y-axis
radius tip
Wear 0 2 4 6 8
Geometry 1 3 5 7 9

If no distinction is made between wear compensation and geometry compensation, specify


wear compensation.

- Second geometry compensation amount in lathe system

X-axis Z-axis Y-axis


Geometry 100 101 102

[Example]
The following program rewrites an offset amount having a specified number.
(Machining center series)

#include <data.h>
#include <fwindow.h>

/* tidx is tool index. */


/* offset is new offset value. */
short example( short tidx, long offset )
{

- 385 -
3.Function References PROGRAMMING B-64303EN-3/01

short ret ;
ret = cnc_wrtofs( tidx, 0, 8, offset ) ;
return ( ret ) ;

- 386 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.33 Read tool offset amount (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtofsr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtofsr( short s_number, short type, short e_number,
short length, struct iodbto *buf ) ;

struct iodbto {
short datano_s; /* Start offset number. */
short type; /* Offset type. */
short datano_e; /* End offset number. */
union {
long m_ofs[N]; /* M Series individual. */
long m_ofs_a[N]; /* M Series Memory A all. */
long m_ofs_b[2*N]; /* Unused. */
long m_ofs_c[4*N]; /* M Series Memory C all. */
struct {
short tip ;
long data[1] ;
} m_ofs_at[N] ; /* M Series Memory A all + virtual tool tip direction */
struct {
short tip ;
long data[2] ;
} m_ofs_bt[N] ; /* Unused. */
struct {
short tip ;
long data[4] ;
} m_ofs_ct[5] ; /* M Series Memory C all + virtual tool tip direction */
short t_tip[N]; /* T Series individual, */
/* direction of imaginary */
/* tool nose. */
long t_ofs[N]; /* T Series individual. */
struct {
short tip;
long data[4];
} t_ofs_a[N]; /* T Series Memory A all. */
struct {
short tip;
long data[8];
} t_ofs_b[N]; /* Unused. */
long t_ofs_2g[3*N]; /* T Series second figure all */
struct {
long data[2];

- 387 -
3.Function References PROGRAMMING B-64303EN-3/01

} t_ofs_ex[N];
} u ;
} ; /* N is number of the offset amounts to be read. */

* Memory C is assumed when bit 6 (NGW) of parameter No. 8136 is 0 or Memory A is assumed when
bit 6 is 1.
* "Memory A" in the T series indicates that tool geometry/wear compensation is disabled (bit
6 (NGW) of parameter No. 8136 is 1).
"Memory B" indicates that tool geometry/wear compensation is enabled (bit 6 (NGW) of parameter
No. 8136 is 0).

[Arguments]
s_number Start offset number.
type Offset type.
e_number End offset number.
length Data block length.
buf Buffer in which the offset amounts are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect offset number "s_number" or "e_number".
(This return code is returned in case that any valueexcept 1,
(maximum number of offset) was specified in offset number "s_number"
or "e_number".
EW_ATTRIB( 4) Incorrect offset type "type".

- 388 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the tool offset amounts in the range specified by "s_number" and "e_number" having
the type specified by "type".

The offset amount data is stored in "tofsr" in signed binary format.


The offset amount units are the same as those of the cnc_rdtofs function. See an
explanation of that function.

The following lists the values for "type", the values for "length" (data block length),
the types of compensation amounts to be read, and the storage locations."

- Tool compensation memory A in machining center system (Parameter NGW(No.8136#6)="1")

type length Attribute Compensation type Storage location


0 8 + 4×N Individual Tool compensation tofsr.u.m_ofs[i]
9 8 + 2×N Individual Virtual tool tip direction tofsr.u.t_tip[i]
-1 8 + 4×N All Tool compensation tofsr.u.m_ofs_a[i]
Virtual tool tip direction tofsr.u.m_ofs_at[i].tip
-4 8 + 8×N All
Tool compensation tofsr.u.m_ofs_at[i].data[0]

- Tool compensation memory C in machining center system (Parameter NGW(No.8136#6)="0")

type length Attribute Compensation type Storage location


0 8 + 4×N Individual Tool length/geometry tofsr.u.m_ofs[i]
1 8 + 4×N Individual Tool length/wear tofsr.u.m_ofs[i]
2 8 + 4×N Individual Tool radius/geometry tofsr.u.m_ofs[i]
3 8 + 4×N Individual Tool radius/wear tofsr.u.m_ofs[i]
9 8 + 2×N Individual Virtual tool tip direction tofsr.u.t_tip[i]
Tool length/geometry tofsr.u.m_ofs_c[4×i + 0]
All Tool length/wear tofsr.u.m_ofs_c[4×i + 1]
-3 8 + 16×N All
All Tool radius/geometry tofsr.u.m_ofs_c[4×i + 2]
Tool radius/wear tofsr.u.m_ofs_c[4×i + 3]
Virtual tool tip direction tofsr.u.m_ofs_ct[i].tip
Tool length/geometry tofsr.u.m_ofs_ct[i].data[0]
-6 8 + 20×N All Tool length/wear tofsr.u.m_ofs_ct[i].data[1]
Tool radius/geometry tofsr.u.m_ofs_ct[i].data[2]
Tool radius/wear tofsr.u.m_ofs_ct[i].data[3]

- 389 -
3.Function References PROGRAMMING B-64303EN-3/01

- Tool compensation memory A in lathe system (Parameter NGW(No.8136#6)="1")

type length Attribute Compensation type Storage location


0 8 + 2×N Individual Virtual tool tip direction tofsr.u.t_tip[i]
1 8 + 4×N Individual X-axis compensation tofsr.u.t_ofs[i]
2 8 + 4×N Individual Y-axis compensation tofsr.u.t_ofs[i]
3 8 + 4×N Individual Z-axis compensation tofsr.u.t_ofs[i]
4 8 + 4×N Individual Tool-nose radius compensation tofsr.u.t_ofs[i]
Virtual tool tip direction tofsr.u.t_ofs_a[i].tip
X-axis compensation tofsr.u.t_ofs_a[i].data[0]
-1 8 + 20×N All Y-axis compensation tofsr.u.t_ofs_a[i].data[1]
Z-axis compensation tofsr.u.t_ofs_a[i].data[2]
Tool-nose radius compensation tofsr.u.t_ofs_a[i].data[3]

- Tool compensation memory B in lathe system (Parameter NGW(No.8136#6)="0")

type length Attribute Compensation type Storage location


0 8 + 2×N Individual Virtual tool tip direction tofsr.u.t_tip[i]
1 8 + 4×N Individual X-axis geometry compensation tofsr.u.t_ofs[i]
2 8 + 4×N Individual Y-axis geometry compensation tofsr.u.t_ofs[i]
3 8 + 4×N Individual Z-axis geometry compensation tofsr.u.t_ofs[i]
4 8 + 4×N Individual Tool-nose radius geometry compensation tofsr.u.t_ofs[i]
5 8 + 4×N Individual X-axis wear compensation tofsr.u.t_ofs[i]
6 8 + 4×N Individual Y-axis wear compensation tofsr.u.t_ofs[i]
7 8 + 4×N Individual Z-axis wear compensation tofsr.u.t_ofs[i]
8 8 + 4×N Individual Tool-nose radius wear compensation tofsr.u.t_ofs[i]
Virtual tool tip direction tofsr.u.t_ofs_b[i].tip
X-axis geometry compensation tofsr.u.t_ofs_b[i].data[0]
Y-axis geometry compensation tofsr.u.t_ofs_b[i].data[1]
Z-axis geometry compensation tofsr.u.t_ofs_b[i].data[2]
-2 8 + 36×N All Tool-nose radius geometry compensation tofsr.u.t_ofs_b[i].data[3]
X-axis wear compensation tofsr.u.t_ofs_b[i].data[4]
Y-axis wear compensation tofsr.u.t_ofs_b[i].data[5]
Z-axis wear compensation tofsr.u.t_ofs_b[i].data[6]
Tool-nose radius wear compensation tofsr.u.t_ofs_b[i].data[7]

- Second geometry in lathe system

type length Attribute Compensation type Storage location


100 8 + 2×N Individual X-axis geometry compensation tofsr.u.t_ofs[i]
101 8 + 4×N Individual Y-axis geometry compensation tofsr.u.t_ofs[i]
102 8 + 4×N Individual Z-axis compensation tofsr.u.t_ofs[i]
X-axis geometry compensation tofsr.u.t_ofs_2g[3×i + 0]
-100 8 + 36×N All Y-axis geometry compensation tofsr.u.t_ofs_2g[3×i + 1]
Z-axis geometry compensation tofsr.u.t_ofs_2g[3×i + 2]

N is the number of offsets to be read, and i is 0 to (N-1).

- 390 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program reads and displays the tool offset amounts for all tools on a lathe
(memory B/64 sets).

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
#define MAXTOOL 64

short example( void )


{
struct iodbto *buf ;
short ret, idx ;
buf = (struct iodbto *)malloc( 6+34*MAXTOOL ) ;
ret = cnc_rdtofsr( 1, -2, MAXTOOL, 6+34*MAXTOOL, buf ) ;
if ( !ret ) {
printf( "No X:wear Z:wear Y:wear X:geom "
"Z:geom Y:geom R:wear R:geom T\n" ) ;
printf( "---+-------+-------+-------+-------+"
"-------+-------+-------+------+-\n" ) ;
for ( idx = 0 ; idx < MAXTOOL ; idx++ ) {
printf( "%02d%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%2d\n",
idx, buf->u.t_ofs_b[idx].data[4],
buf->u.t_ofs_b[idx].data[5],
buf->u.t_ofs_b[idx].data[6],
buf->u.t_ofs_b[idx].data[0],
buf->u.t_ofs_b[idx].data[1],
buf->u.t_ofs_b[idx].data[2],
buf->u.t_ofs_b[idx].data[7],
buf->u.t_ofs_b[idx].data[3],
buf->u.t_ofs_b[idx].tip ) ;
}
}
free( buf ) ;
return ( ret ) ;
}

- 391 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.34 Write tool offset amount (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrtofsr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrtofsr( short length, struct iodbto *buf ) ;

struct iodbto {
short datano_s; /* Start offset number. */
short type; /* Offset type. */
short datano_e; /* End offset number. */
union {
long m_ofs[N]; /* M Series individual. */
long m_ofs_a[N]; /* M Series Memory A all. */
long m_ofs_b[2*N]; /* Unused. */
long m_ofs_c[4*N]; /* M Series Memory C all. */
struct {
short tip ;
long data[1] ;
} m_ofs_at[N] ; /* M Series Memory A all + virtual tool tip direction */
struct {
short tip ;
long data[2] ;
} m_ofs_bt[N] ; /* Unused. */
struct {
short tip ;
long data[4] ;
} m_ofs_ct[5] ; /* M Series Memory C all + virtual tool tip direction */
short t_tip[N]; /* T Series individual, */
/* direction of imaginary */
/* tool nose. */
long t_ofs[N]; /* T Series individual. */
struct {
short tip;
long data[4];
} t_ofs_a[N]; /* T Series Memory A all. */
struct {
short tip;
long data[8];
} t_ofs_b[N]; /* Unused. */
long t_ofs_2g[3*N]; /* T Series second figure all */
struct {
long data[2];
} t_ofs_ex[N];

- 392 -
B-64303EN-3/01 PROGRAMMING 3.Function References

} u ;
} ; /* N is number of the offset amounts to be read. */

* Memory C is assumed when bit 6 (NGW) of parameter No. 8136 is 0 or Memory A is assumed when
bit 6 is 1.
* “Memory A” in the T series indicates that tool geometry/wear compensation is disabled (bit
6 (NGW) of parameter No. 8136 is 1).
“Memory B” indicates that tool geometry/wear compensation is enabled (bit 6 (NGW) of parameter
No. 8136 is 0).

[Arguments]
length Data block length.
buf Buffer in which the offset amounts are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect offset number "buf.datano_s" or "buf.datano_e".
(This return code is returned in case that any value except 1,
,(maximum number of offset) was specified in offset number "s_number"
or "e_number".
EW_ATTRIB( 4) Incorrect offset type "buf.type".

[Description]
Rewrites the tool offset amounts in the range specified by "datano_s" and "datano_e"
having the type specified by "type".

The offset amount data is stored in "buf" in signed binary format.


The offset amount units and the ranges of data that can be set are the same as those
of the cnc_wrtofs function.
See an explanation of that function.

[Example]
The following program stores all tool offset amounts of Machining-Series(Memory A/64
sets).

#include <data.h>
#include <fwindow.h>
#include <stdlib.h>
#include <string.h>
#define MAXTOOL 64

/* offset is array of new offset value. */


short example( long *offset )
{

- 393 -
3.Function References PROGRAMMING B-64303EN-3/01

struct iodbto *buf ;


short ret ;
buf = (struct iodbto *)malloc( 6+4*MAXTOOL ) ;
buf->datano_s = 1 ;
buf->datano_e = MAXTOOL ;
buf->type = -1 ;
memcpy( &(buf->u.m_ofs_a[0]), offset, 4*MAXTOOL ) ;
ret = cnc_wrtofsr( 6+4*MAXTOOL, buf ) ;
free( buf ) ;
return ( ret ) ;
}

- 394 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.35 Read work origin offset. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdzofs

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdzofs( short number, short axis, short length,
struct iodbaxis *buf ) ;

struct iodbaxis {
short datano ; /* Offset number. */
short type ; /* Axis number. */
long data[N] ; /* Offset data. */
} ; /* N is a maximum controlled axis number.*/

[Arguments]
number Offset number ( 0, 1,..,6, 7,..,54 ).
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
length Data block length ( =4+4×(amount of axes to be read)).
buf Buffer in which the offset amount is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect of offset number "number". (Any data other
than 0,..,6 or 7,..,54 has been specified.)
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled
axes) has been specified.
EW_NOOPT( 6) There are no required functions.
The related functions;
- Work coordinate system ( G54 to G59 ) (Parameter NWZ(No.8136#0)="0")
- Work coordinate system 48 sets ( G54.1P1-P48 ) (M series only:
Parameter NWN(No.8136#2)="0")

- 395 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the workpiece origin offset amount of the number specified by "number" and the
axis specified by "axis".

The offset amount data is stored in "buf.data[0]" in signed binary format.

The data of all axes can be read at once by setting -1 in "axis".


The offset amount data of each axis is stored in the "data" array in "buf".

The decimal point position can be obtained with the cnc_getfigure function.

The decimal point position can be obtained with the "1.67 cnc_getfigure function".

"number" specifies the number of a workpiece origin offset to be read.


0 : External workpiece origin offset amount
1 to 6 : Workpiece origin offset amount of G54 to G59
7 to 54 : Workpiece origin offset amount of G54.1P1 to G54.1P48

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │data[0]:Axis 1││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│data[n-1]:Axis n↓
4+4×n└───────┘─

n = maximum number of controlled axes

- 396 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program displays the work origin offset amounts of the specified number
for all axes ( MAX (amount of axes = 32) ).

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

/* ofs is offset number to be displayed. */


void example( short ofs )
{
struct iodbaxis buf ;
unsigned int idx ;
cnc_rdzofs( ofs, -1, 4+4*MAX, &buf ) ;
for ( idx = 0 ; idx < MAX ; idx++ )
printf( "%u:%8ld\n", idx, buf.data[idx] ) ;
}

- 397 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.36 Write work origin offset. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrzofs

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrzofs( short length, struct iodbaxis *buf ) ;

struct iodbaxis {
short datano ; /* Offset number. */
short type ; /* Axis number. */
long data[N] ; /* Offset data. */
} ; /* N is a maximum controlled axis number.*/

[Arguments]
length Data block length ( =4+4×(amount of axes to be read)).
buf Buffer in which the offset amount is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect of offset number "number".
(Any data other than 0,..,6 or 7,..,54 has been specified.)
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.
EW_DATA( 5) The data in "data" is beyond a settable data range.
EW_NOOPT( 6) There are no required functions.
(See "Read work origin offset(cnc_rdzofs)" for details.)

- 398 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Rewrites the workpiece origin offset amount of the number specified by "datano" and the
axis specified by "type", with the value specified by "data".

The offset amount data is stored in "data[0]" in "buf" in signed binary format.

The data of all axes can be rewritten at once by setting -1 in "type".


The offset amount data of each axis is stored in the "data" array in "buf".

The offset amount units are the same as those of the cnc_rdzofs function. See an
explanation of that function.

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │data[0]:Axis 1││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│data[n-1]:Axis n↓
4+4×n└───────┘─
n = maximum number of controlled axes

"datano" specifies the number of a workpiece origin offset to be rewritten.


0 : External workpiece origin offset amount
1 to 6 : Workpiece origin offset amount of G54 to G59
7 to 54: Workpiece origin offset amount of G54.1P1 to G54.1P48

"type" specifies the number of an axis for which the data is to be rewritten.
-1 : All axes
1 to m: One axis (m: number of currently controlled axes)

- 399 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program alters the work origin offset amount of the specified offset number
and axis number.

#include <data.h>
#include <fwindow.h>

/* ofs is offset number to be altered. */


/* axis is the axis number, offset is new offset value. */
short example( short ofs, short axis, long offset )
{
struct iodbaxis buf ;
short ret ;
buf.datano = ofs ;
buf.type = axis ;
buf.data[0] = offset ;
ret = cnc_wrzofs( 4+4*1, &buf ) ;
return ( ret ) ;
}

- 400 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.37 Read work origin offset (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdzofsr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdzofsr( short s_number, short axis, short e_number,
short length, struct iodbzo *buf ) ;

struct iodbzo {
short datano_s ; /* Start offset number. */
short type ; /* Axis number. */
short datano_e ; /* End offset number. */
long data[32*M] ; /* Offset data. */
} ; /* M is number of work origin */
/* offset amounts to be read. */

[Arguments]
s_number Start offset number ( 0, 1,..,6, 7,..,54 ).
axis Axis number ( =(1,..,amount of controlled axes),or -1 ).
e_number End offset number
length Data block length ( =6+4×(amount of axes to be read)*
(number of offset to be read) ).
buf Buffer in which the offset amounts are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect of offset number "s_number" or "e_number".
(Any data other than 0,..,6 or 7,..,54 has been specified.)
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.
EW_NOOPT( 6) There are no required functions.
(See "Read work origin offset(cnc_rdzofs)" for details.)

- 401 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the workpiece origin offset amounts of the axis specified by "axis" in the range
specified by "s_number" and "e_number".

The offset amount data is stored in the "data" array in "buf" in signed binary format.

The data of all axes can be read at once by setting -1 in "axis".


The decimal point position can be obtained with the “1.67 cnc_getfigure function”.
The offset amount units are the same as those of the cnc_rdzofs function. See an
explanation of that function.

"s_number" specifies the workpiece origin offset number at which reading starts.
0 : External workpiece origin offset amount
1 to 6 : Workpiece origin offset amount of G54 to G59
7 to 54: Workpiece origin offset amount of G54.1P1 to G54.1P48

"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano_s ↑ │datano_s ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┤ │ 4├───┤ │
│datano_e │ │datano_e │
6├───┤ │ 6├───┤ │
│ │ │ │ │ │
8├───┴───┐│ 8├───┴───┐│┐
│ data[0] ││ │data[0]:Axis 1││Start
12├───────┤│ 12├───────┤│number
~ ~│ ~ ~│
8+4×(K-1)├───────┤│ 8+4×(n-1)├───────┤│
│ data[K-1] │↓ │data[n-1]:Axis n││
8+4×K└───────┘─ 8+4×n├───────┤│┘
~ ~│
8+4×n×(K-1)├───────┤│┐
│data[nx(K-1)] ││End
├───────┤│number
~ ~│
8+4×(n×K-1)├───────┤│
│data[nxK-1] │↓│
8+4×n×K└───────┘─┘

n = maximum number of controlled axes (the data of the


current number of axes is valid)
K = number of offsets to be read

- 402 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program reads and displays the work origin offset amounts of G54 to G59
for all the axes (up to 8 axes).

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>

short example( void )


{
struct iodbzo *buf ;
short ret, idx1, idx2 ;
buf = (struct iodbzo *)malloc( 6+4*8*6 ) ;
ret = cnc_rdzofsr( 1, -1, 6, 6+4*8*6, buf ) ;
if ( !ret ) {
for ( idx1 = 0 ; idx1 < 6 ; idx1++ ) {
printf( "G%d", idx1+54 ) ;
for ( idx2 = 0 ; idx2 < MAX ; idx2++ )
printf( " %8ld", buf->data[idx1*8+idx2] ) ;
putchar( '\n' ) ;
}
}
free( buf ) ;
return ( ret ) ;
}

- 403 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.38 Write work origin offset (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrzofsr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrzofsr( short length, struct iodbzo *buf ) ;

struct iodbzo {
short datano_s ; /* Start offset number. */
short type ; /* Axis number. */
short datano_e ; /* End offset number. */
long data[N*M] ; /* Offset data. */
} ; /* N is a maximum controlled axis number. */
/* M is number of work origin offset amounts */
/* to be written. */

[Arguments]
length Data block length ( =6+4×(amount of axes to be read)*
(number of offset to be written) ).
buf Buffer in which the offset amounts are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect of offset number "datano_s" or "datano_e".
(Any data other than 0,..,6 or 7,..,54 has been specified.)
EW_ATTRIB( 4) Incorrect axis number "type".
Any data other than -1 or (1,..,amount of controlled axes) has been
specified.
EW_DATA( 5) The data in "data" is beyond a settable data range.
EW_NOOPT( 6) There are no required functions.
(See "Read work origin offset(cnc_rdzofs)" for details.)

- 404 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Rewrites the workpiece origin offset amounts of the axis specified by "type" in the range
specified by "datano_s" and "datano_e". The offset amount data is stored in the "data"
array in "buf" in signed binary format.

The data of all axes can be rewritten at once by setting -1 in "type".


The offset amount units are the same as those of the cnc_rdzofs function. See an
explanation of that function.

"length" specifies the data block length (size of "buf").


One axis All axes
buf 0┌───┐ ─ 0┌───┐ ─
│datano_s ↑ │datano_s ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┤ │ 4├───┤ │
│datano_e │ │datano_e │
6├───┤ │ 6├───┤ │
│ │ │ │ │ │
8├───┴───┐│ 8├───┴───┐│┐
│ data[0] ││ │data[0]:Axis 1││Start
12├───────┤│ 12├───────┤│number
~ ~│ ~ ~│
8+4×(K-1)├───────┤│ 8+4×(n-1)├───────┤│
│ data[K-1] │↓ │data[n-1]:Axis n││
8+4×K└───────┘─ 8+4×n├───────┤│┘
~ ~│
8+4×n×(K-1)├───────┤│┐
│data[nx(K-1)] ││End
├───────┤│number
~ ~│
8+4×(n×K-1)├───────┤│
│data[nxK-1] │↓│
8+4×n×K└───────┘─┘

n = maximum number of controlled axes (the data of the


current number of axes is valid)
K = number of offsets to be rewritten

"datano_s" specifies the workpiece origin offset number at which rewriting starts.
0 : External workpiece origin offset amount
1 to 6 : Workpiece origin offset amount of G54 to G59
7 to 54: Workpiece origin offset amount of G54.1P1 to G54.1P48

"datano_e" specifies the workpiece origin offset number at which rewriting ends.

"type" specifies the number of an axis for which the data is to be rewritten.
-1 : All axes
1 to m: One axis (m: number of currently controlled axes)

- 405 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program alters the work origin offset amount of G54
through G59 for the specified axis.

#include <data.h>
#include <fwindow.h>
#include <string.h>

/* axis is axis index to be altered. */


/* offset is array of new offset value. */
short example( short axis, long *offset )
{
struct iodbzo buf ;
short ret ;
buf.datano_s = 1 ;
buf.datano_e = 6 ;
buf.type = axis ;
memcpy( &buf.data[0], offset, 4*6 ) ;
ret = cnc_wrzofsr( 6+4*1*6, &buf ) ;
return ( ret ) ;
}

- 406 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.39 Read parameter. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdparam

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdparam( short number, short axis, short length,
struct iodbpsd *buf ) ;

typedef struct realprm { /* real parameter */


long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
}
REALPRM;

struct iodbpsd {
short datano; /* parameter number */
short type; /* axis number */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[N]; /* bit/byte set. data with axis */
short idatas[N]; /* word set. data with axis */
long ldatas[N]; /* 2-word set. data with axis */
REALPRM rdatas[N]; /* real set. data with axis */
} u;
} ; N is a maximum controlled axis number.

[Arguments]
number Parameter number.
axis Axis number ( =(1,..,amount of controlled axes), or -1, 0 ).
length Data block length ( =4+(byte size of the parameter)×(MAX_AXIS) )
buf Buffer in which the parameter is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect parameter number "number".
EW_ATTRIB( 4) Incorrect axis number "axis".

- 407 -
3.Function References PROGRAMMING B-64303EN-3/01

Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.

[Description]
Reads the parameter of the number specified by "number" and the axis specified by "axis"
(only for an axis parameter).

Parameters each have their own data format. Byte, word, and 2-word parameters are
generally in signed binary format.

The data of all axes can be read at once by setting -1 in "axis". The parameter data
of each axis is stored in the "data" array in "buf".

Parameter type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real parameter and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real parameter with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

It is impossible to read any bit parameter bit by bit.


8 bits(i.e. 1 byte) which belong to the same parameter number are read at the same time.

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the parameters.

- 408 -
B-64303EN-3/01 PROGRAMMING 3.Function References

The following shows the data blocks for the parameter size of 4 bytes.
For the parameter size of 1, 2, or 8 bytes, the data size for each parameter (one axis)
is 1, 2, or 8 bytes.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐ │
│ ldata │↓ │ldatas[0]:Axis 1 │
8└───────┘─ 8├───────┤ │
~ ~ │
4+4×(n-1)├───────┤ │
│ldatas[n-1]:Axis n↓
4+4×n└───────┘ ─

n = maximum number of controlled axes

Spindle-related parameters are handled as axis parameters, and the data of the current
number of spindles is valid.

"datano" stores the number of a parameter that has been read.

"type" stores the axis number of a parameter that has been read.

axis Parameter type


-----------------------+------------------------------------
0 Ordinary (none axis type) parameter
-1 All axes data of axis type parameter
1,..,amount of One specified axis data of
controlled axis axis type parameter

"rdata" or "rdatas" stores a real parameter. "prm_val" stores the data and "dec_val"
stores the number of decimal places.

Real parameter = prm_val×10(-dec_val)

(Example) When prm_val is 12345 and dec_val is 3, a real parameter is 12.345.

- 409 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads axis names of all controlled axes and displays them.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>

void example( void )


{
struct iodbpsd buf ;
short ret, idx ;
ret = cnc_rdparam( 1020, -1, 4+10, &buf ) ; /* standard 10axes */
for ( idx = 0 ; idx < axno ; idx++ ) {
printf( "#%d", idx+1 ) ;
if ( buf.u.cdatas[idx] == 0 )
printf( "\033[7m%c\033[27m\n", idx+'1' ) ;
else
printf( "%c\n", buf.u.cdatas[idx] ) ;
}
}

- 410 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.40 Write parameter. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrparam

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrparam( short length, struct iodbpsd *buf ) ;

typedef struct realprm { /* real parameter */


long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
}
REALPRM;

struct iodbpsd {
short datano; /* parameter number */
short type; /* axis number */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[N]; /* bit/byte set. data with axis */
short idatas[N]; /* word set. data with axis */
long ldatas[N]; /* 2-word set. data with axis */
REALPRM rdatas[N]; /* real set. data with axis */
} u;
} ; N is a maximum controlled axis number.

[Arguments]
length Data block length ( =4+(byte size of the parameter)×(MAX_AXIS) )
buf Buffer in which the parameter is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect parameter number "datano".
EW_ATTRIB( 4) Incorrect axis number "type".
Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.
EW_PROT( 7 ) Write operation is prohibited.

- 411 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Rewrites the parameter of the number specified by "datano" and the axis specified by
"type" (only for an axis parameter).

Parameters each have their own data format. Byte, word, and 2-word parameters are
generally in signed binary format.

The data of all axes can be rewritten at once by setting -1 in "type". The parameter
data of each axis is stored in the array in "buf".

Parameter type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real parameter and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real parameter with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

Note that a bit parameter cannot be read bit by bit. The 8 bits (or 1 byte) that belong
to the same parameter number are read at once, the desired bit or bits are changed, and
the 8-bit data is rewritten.

For some parameters, alarm PW0000 "POWER MUST BE OFF" may be issued when the data is
rewritten.

- 412 -
B-64303EN-3/01 PROGRAMMING 3.Function References

If you try to rewrite a write-protected parameter, such as any of parameters No. 9000
to 9999, an error is returned (return value: EW_PROT).

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the parameters.

"length" specifies the data block length (size of "buf").

The following shows the data blocks for the parameter size of 4 bytes.
For the parameter size of 1, 2, or 8 bytes, the data size for each parameter
(one axis) is 1, 2, or 8 bytes.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐ │
│ ldata │↓ │ldatas[0]:Axis 1 │
8└───────┘─ 8├───────┤ │
~ ~ │
4+4×(n-1)├───────┤ │
│ldatas[n-1]:Axis n↓
4+4×n└───────┘ ─

n = maximum number of controlled axes

Spindle-related parameters are handled as axis parameters, and the data of the current
number of spindles is valid.

"datano" specifies the number of a parameter to be rewritten.


Refer to "Parameter Manual" (B-64310EN) of the CNC for information about the parameter
numbers that can be specified.

"type" specifies the axis number of a parameter to be rewritten.

buf.type Parameter type


-----------------------+------------------------------------
0 Ordinary (none axis type) parameter
-1 All axes data of axis type parameter
1,..,amount of One specified axis data of
controlled axis axis type parameter

"rdata" or "rdatas" specifies a real parameter to be rewritten. "prm_val" specifies the


data and "dec_val" specifies the number of decimal places.

Real parameter = prm_val×10(-dec_val)

(Example) To rewrite a real parameter 12.345, specify prm_val of 12345 and dec_val of
3.

- 413 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program rewrites the stroke limit setting for a specified axis.

#include <data.h>
#include <fwindow.h>

/* axis is axis index. */


/* plus and minus are plus and minus position of stroke limit. */
short example( short axis, logn plus, long minus )
{
struct iodbpsd buf ;
short ret ;
buf.datano = 1320 ;
buf.type = axis ;
buf.u.ldata = plus ;
ret = cnc_wrparam( 4+8*1, &buf ) ;
if ( ret ) return ( ret ) ;
buf.datano = 1321 ;
buf.type = axis ;
buf.u.ldata = minus ;
ret = cnc_wrparam( 4+8*1, &buf ) ;
return ( ret ) ;
}

- 414 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.41 Read parameters (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdparar

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdparar( short s_number, short axis, short e_number,
short length, struct iodbpsdr *buf ) ;

typedef struct realprm { /* real parameter */


long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
}
REALPRM;

struct iodbpsdr {
short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[N]; /* bit/byte set. data with axis */
short idatas[N]; /* word set. data with axis */
long ldatas[N]; /* 2-word set. data with axis */
REALPRM rdatas[N]; /* real set. data with axis */
} u;
} ; N is a maximum controlled axis number.

[Arguments]
s_number Start parameter number.
axis Axis number ( =(1,..,amount of controlled axes), or -1, 0 ).
e_number End parameter number.
length Data block length ( = Sum of [4+(byte size of the parameter)×
(MAX_AXIS)] )
buf Buffer in which the parameters are stored.

- 415 -
3.Function References PROGRAMMING B-64303EN-3/01

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect parameter number "s_number" or "e_number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.

[Description]
Reads the parameters of the axis specified by "axis" (only for axis parameters) in the
range specified by "s_number" and "e_number".

Parameters each have their own data format. Byte, word, and 2-word parameters are
generally in signed binary format.

The axis parameters of all axes in the specified range are read by setting -1 in "axis".

There are the following types of parameters with different type and axis attributes for
different parameter numbers.

Parameter type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real parameter and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real parameter with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

Note that a bit parameter cannot be read bit by bit.


The 8 bits (or 1 byte) that belong to the same parameter number are read at once.

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the parameters.

- 416 -
B-64303EN-3/01 PROGRAMMING 3.Function References

"s_number" specifies the parameter number at which reading starts.


The function returns the number of the first parameter that has actually been read.

Refer to "Parameter Manual" (B-64310EN) of the CNC for information about the parameter
numbers that can be specified.

"e_number" specifies the parameter number at which reading ends.


The function returns the number of the last parameter that has actually been read.

Parameters may be added because of, for example, addition of CNC software functions.
For example, if a parameter is added within the read range, an error may occur (return
value: EW_LENGTH) or the application program may not perform processing correctly. To
prevent these problems, specify a read range containing only a set of consecutive
parameter numbers.

"axis" specifies the number of an axis for which the data is to be read.

axis Parameter type


-----------------------+------------------------------------
0 Ordinary (none axis type) parameter
-1 All axes data of axis type parameter
1,..,amount of One specified axis data of
controlled axis axis type parameter

A non-axis parameter is read regardless of which value is specified for "axis". When
an axis parameter is included within the specified range, however, an error occurs (return
value: EW_ATTRIB) if 0 is specified for "axis".

"length" specifies the length of a data block needed to store the specified range of
parameters.

The data block for each parameter is as shown below. The specified number of data blocks
are arranged in order (ascending) of parameter number. "length" is the total length of
the data blocks.

The function returns the size of parameters that have actually been read. You can specify
a larger value for "length" than needed.

- 417 -
3.Function References PROGRAMMING B-64303EN-3/01

The following shows the data blocks for the parameter size of 2 bytes. If the parameter
size is 1 to 2 bytes and "length" for each parameter is not a multiple of 4, a dummy
area is required at the end. For the parameter size of 4 or 8 bytes, the data size for
each parameter (one axis) is 4 or 8 bytes, and no dummy area is required.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │length per │type │ length per
4├───┤parameter 4├───┤ parameter
│idata │ │ │idatas[0]:Axis 1 │
6├───┤ │ 6├───┤ │
│dummy │ ↓ ~ ~ │
8└───┘ ─ 4+2×(n-1)├───┤ │
│idatas[n-1]:Axis n│
4+2×n├───┤ │
│dummy(n is odd) ↓
└───┘ ─

n = maximum number of controlled axes

Spindle-related parameters are handled as axis parameters, and the data of the current
number of spindles is valid.

"datano" stores the number of a parameter that has been read.


"type" stores the attribute of a parameter that has been read.
Upper byte: Type attribute
0 : Bit
1 : Byte
2 : Word
3 : 2-word
4 : Real

Lower byte : Axis number


0 : Non-axis parameter
1 to m : Axis parameter, one axis (m: maximum number of controlled axes)
-1 : Axis parameter, all axes

"rdata" or "rdatas" stores a real parameter. "prm_val" stores the data and "dec_val"
stores the number of decimal places.

Real parameter = prm_val×10(-dec_val)

(Example) When prm_val is 12345 and dec_val is 3, a real parameter is 12.345.

- 418 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program reads parameters in a specified range for a specified axis and
displays them on the screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>

/* start/end are start/end number to be read, axis is axis number. */


short example( short start, short end, short axis )
{
struct odbsys info ;
struct iodbpsdr *buf, *ptr ;
short ret, idx1, idx2, axno, inc ;
cnc_sysinfo( &info ) ;
axno = atoi( info.axes ) ;
buf = (struct iodbpsdr *)calloc( 1, 1000 ) ;
ret = cnc_rdparar( start, axis, end, 1000, buf ) ;
ptr = buf ;
if ( !ret ) {
for ( idx1 = start ; idx1 <= end ; idx1++ ) {
if ( ( idx1 != 0 ) && ( ptr->datano == 0 ) ) break ;
printf( "No.%05d ", ptr->datano ) ;
switch ( ptr->type >> 8 ) {
case 0: printf( "BIT " ) ; break ;
case 1: printf( "BYTE" ) ; break ;
case 2: printf( "WORD" ) ; break ;
case 3: printf( "2WRD" ) ; break ;
}
switch ( ptr->type & 0xff ) {
case 0xff :
for ( idx2 = 0 ; idx2 < axno ; idx2++ ) {
printf( " #%d:", idx2+1 ) ;
switch ( ptr->type >> 8 ) {
case 0:
printf( "0x%02X",
(unsigned char)(ptr->u.cdatas[idx2]) ) ;
inc = 1 ; break ;
case 1:
printf( "%d", ptr->u.cdatas[idx2] ) ;
inc = 1 ; break ;
case 2:
printf( "%d", ptr->u.idatas[idx2] ) ;
inc = 2 ; break ;
case 3:
printf( "%ld", ptr->u.ldatas[idx2] ) ;
inc = 4 ; break ;

- 419 -
3.Function References PROGRAMMING B-64303EN-3/01

}
}
putchar( '\n' ) ;
ptr = (struct iodbpsdr *)(((char *)ptr)+4+8*inc) ;
break ;
/* to be continued on the next page... */
default :
printf( " #%d:", ptr->type & 0xff ) ;
case 0 :
switch ( ptr->type >> 8 ) {
case 0:
printf( " 0x%02X\n",
(unsigned char)(ptr->u.cdata) ) ;
inc = 1+1 ; break ;
case 1:
printf( " %d\n", ptr->u.cdata ) ;
inc = 1+1 ; break ;
case 2:
printf( " %d\n", ptr->u.idata ) ;
inc = 2 ; break ;
case 3:
printf( " %ld\n", ptr->u.ldata ) ;
inc = 4 ; break ;
}
ptr = (struct iodbpsdr *)(((char *)ptr)+4+inc) ;
break ;
}
}
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}

- 420 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.42 Write parameters (multiple output). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrparas

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrparas( short length, struct iodbpsdr *buf ) ;

typedef struct realprm { /* real parameter */


long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
}
REALPRM;

struct iodbpsdr {
short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[N]; /* bit/byte set. data with axis */
short idatas[N]; /* word set. data with axis */
long ldatas[N]; /* 2-word set. data with axis */
REALPRM rdatas[N]; /* real set. data with axis */
} u;
} ; N is a maximum controlled axis number.

[Arguments]
length Data block length ( = Sum of [4+(byte size of the parameter)×
(MAX_AXIS)] )
buf Buffer in which the parameters are stored.

- 421 -
3.Function References PROGRAMMING B-64303EN-3/01

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect parameter number "buf.datano".
EW_ATTRIB( 4) Incorrect axis number "buf.type".
Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.
EW_PROT( 7 ) Write operation is prohibited.

[Description]
Rewrites multiple parameters stored in "param".

Parameters each have their own data format. Byte, word, and 2-word parameters are
generally in signed binary format.

The data of all axes can be rewritten at once by setting -1 in "type".


The parameter data of each axis is stored in the array in "buf".

There are the following types of parameters with different type and axis attributes for
different parameter numbers.

Parameter type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real parameter and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real parameter with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

It is impossible to write any bit parameter bit by bit.


8 bits(i.e. 1 byte) which belong to the same parameter number are written at the same
time.

- 422 -
B-64303EN-3/01 PROGRAMMING 3.Function References

For some parameters, alarm PW0000 "POWER MUST BE OFF" may be issued when the data is
rewritten.

If a group of parameters stored in "param" includes a write-protected parameter, such


as any of parameters No. 9000 to 9999, an error occurs (return value: EW_PROT). However,
the other parameters are rewritten.

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the parameters.

"length" specifies the length of data blocks that store parameters to be rewritten.
The data block for each parameter is as shown below. The data blocks are arranged in
order (ascending) of parameter number. "length" is the total length of the data blocks.

The following shows the data blocks for the parameter size of 2 bytes. If the parameter
size is 1 to 2 bytes and "length" for each parameter is not a multiple of 4, a dummy
area is required at the end. For the parameter size of 4 or 8 bytes, the data size for
each parameter (one axis) is 4 or 8 bytes, and no dummy area is required.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │length per │type │ length per
4├───┤parameter 4├───┤ parameter
│idata │ │ │idatas[0]:Axis 1 │
6├───┤ │ 6├───┤ │
│dummy │ ↓ ~ ~ │
8└───┘ ─ 4+2×(n-1)├───┤ │
│idatas[n-1]:Axis n│
4+2×n├───┤ │
│dummy(n is odd) ↓
└───┘ ─
n = maximum number of controlled axes

Spindle-related parameters are handled as axis parameters, and the data of the current
number of spindles is valid.

"datano" specifies the number of a parameter to be rewritten.


Refer to "Parameter Manual" (B-64310EN) of the CNC for information about the parameter
numbers that can be specified.

"type" specifies the attribute of a parameter to be rewritten.


Upper byte: Type attribute
0 : Bit
1 : Byte
2 : Word
3 : 2-word
4 : Real

- 423 -
3.Function References PROGRAMMING B-64303EN-3/01

Lower byte : Axis number


0 : Non-axis parameter
1 to m: Axis parameter, one axis (m: maximum number of controlled axes)
-1 : Axis parameter, all axes

"rdata" or "rdatas" specifies a real parameter to be rewritten. "prm_val" specifies the


data and "dec_val" specifies the number of decimal places.

Real parameter = prm_val×10(-dec_val)

(Example) To rewrite a real parameter 12.345, specify prm_val of 12345 and dec_val of
3.

[Example]
The following program specifies that M code Nos. 6080 to 6089 be subjected to a macro
call.

#include <data.h>
#include <fwindow.h>
#include <stdlib.h>

/* mcode is 10 M-code values to be set. */


short example( short *mcode )
{
struct iodbpsdr *buf, *ptr ;
short ret, idx ;
buf = (struct iodbpsdr *)calloc( 1, 1000 ) ;
ptr = buf ;
for ( idx = 0 ; idx < 10 ; idx++ ) {
ptr->datano = 6080 + idx ;
ptr->type = 0 ;
ptr->u.cdata = mcode[idx] ;
ptr = (struct iodbpsdr *)(((char *)ptr)+6) ;
}
ret = cnc_wrparar( 6*10, buf ) ;
free( buf ) ;
return ( ret ) ;
}

- 424 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.43 Read setting parameter. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdset

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdset( short number, short axis, short length,
struct iodbpsd *buf ) ;

typedef struct realprm { /* real setting data */


long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
}
REALPRM;

struct iodbpsd {
short datano; /* setting data number */
short type; /* axis number */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[N]; /* bit/byte set. data with axis */
short idatas[N]; /* word set. data with axis */
long ldatas[N]; /* 2-word set. data with axis */
REALPRM rdatas[N]; /* real set. data with axis */
} u;
} ; N is a maximum controlled axis number.

[Arguments]
number Setting parameter number.
axis Axis number ( =(1,..,amount of controlled axes), or -1, 0 ).
length Data block length ( =4+(byte size of the setting parameter)×
(MAX_AXIS) )
buf Buffer in which the setting parameter is stored.

- 425 -
3.Function References PROGRAMMING B-64303EN-3/01

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect setting parameter number "number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.

[Description]
Reads the setting parameter of the number specified by "number" and the axis specified
by "axis" (only for an axis setting parameter).

Setting parameters each have their own data format. Byte, word, and 2-word setting
parameters are generally in signed binary format.

The data of all axes can be read at once by setting -1 in "axis".


The setting parameter data of each axis is stored in the "data" array in "buf".

There are the following types of setting parameters with different type and axis
attributes for different setting parameter numbers.

Setting data type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real setting data and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real setting data with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

It is impossible to read any bit setting data bit by bit.


8 bits(i.e. 1 byte) which belong to the same setting data number are
read at the same time.

- 426 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the setting
parameters.

"number" specifies the number of a setting parameter to be read.


Refer to "Parameter Manual" (B-64310EN) of the CNC for information about the setting
parameter numbers that can be specified.

"axis" specifies the number of an axis for which the data is to be read.
0 : Non-axis setting parameter
1 to m: Axis setting parameter, one axis (m: maximum number of controlled axes)
-1 : Axis setting parameter, all axes

"length" specifies the data block length (size of "buf").

The following shows the data blocks for the setting parameter size of 4 bytes. For the
setting parameter size of 1, 2, or 8 bytes, the data size for each setting parameter
(one axis) is 1, 2, or 8 bytes.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐ │
│ ldata │↓ │ldatas[0]:Axis 1 │
8└───────┘─ 8├───────┤ │
~ ~ │
4+4×(n-1)├───────┤ │
│ldatas[n-1]:Axis n↓
4+4×n└───────┘ ─
n = maximum number of controlled axes

Spindle-related setting parameters are handled as axis setting parameters, and the data
of the current number of spindles is valid.

"datano" stores the number of a setting parameter that has been read.
"type" stores the axis number of a setting parameter that has been read.

0 : Non-axis setting parameter


1 to m : Axis setting parameter, one axis
(m: maximum number of controlled axes)
-1 : Axis setting parameter, all axes

- 427 -
3.Function References PROGRAMMING B-64303EN-3/01

"rdata" or "rdatas" stores a real setting parameter. "prm_val" stores the data and
"dec_val" stores the number of decimal places.

Real setting parameter = prm_val×10(-dec_val)

(Example) When prm_val is 12345 and dec_val is 3, a real setting parameter is 12.345.

[Example]
The following program changes the input unit to inch.

#include <data.h>
#include <fwindow.h>

void example( void )


{
struct iodbpsd buf ;
cnc_rdset( 0, 0, 4+1*1, &buf ) ;
*buf.u.cdata |= 0x04 ;
cnc_wrset( 4+1*1, &buf ) ;
}

- 428 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.44 Write setting parameter. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrset

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrset( short length, struct iodbpsd *buf ) ;

typedef struct realprm { /* real setting data */


long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
}
REALPRM;

struct iodbpsd {
short datano; /* setting data number */
short type; /* axis number */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[N]; /* bit/byte set. data with axis */
short idatas[N]; /* word set. data with axis */
long ldatas[N]; /* 2-word set. data with axis */
REALPRM rdatas[N]; /* real set. data with axis */
} u;
} ; N is a maximum controlled axis number.

[Arguments]
length Data block length ( =4+(byte size of the setting parameter)×
(MAX_AXIS) )
buf Buffer in which the setting parameter is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect setting parameter number "datano".
EW_ATTRIB( 4) Incorrect axis number "type".
Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.

- 429 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Rewrites the setting parameter of the number specified by "datano" and the axis specified
by "type" (only for an axis setting parameter). Setting parameters each have their own
data format. Byte, word, and 2-word setting parameters are generally in signed binary
format.

The data of all axes can be rewritten at once by setting -1 in "type". The setting parameter
data of each axis is stored in the array in "buf".

There are the following types of setting parameters with different type and axis
attributes for different setting parameter numbers.

Setting data type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real setting data and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real setting data with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

It is impossible to write any bit setting data bit by bit.


8 bits(i.e. 1 byte) which belong to the same setting data number are
written at the same time.

This function is the same as the cnc_wrparam function, except that parameters for which
setting input is disabled cannot be rewritten.

- 430 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the setting
parameters.

"length" specifies the data block length (size of "buf").

The following shows the data blocks for the setting parameter size of 4 bytes. For the
setting parameter size of 1, 2, or 8 bytes, the data size for each setting parameter
(one axis) is 1, 2, or 8 bytes.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐ │
│ ldata │↓ │ldatas[0]:Axis 1 │
8└───────┘─ 8├───────┤ │
~ ~ │
4+4×(n-1)├───────┤ │
│ldatas[n-1]:Axis n↓
4+4×n└───────┘ ─

n = maximum number of controlled axes

Spindle-related parameters are handled as axis parameters, and the data of the current
number of spindles is valid.

"datano" specifies the number of a setting parameter to be rewritten.


Refer to "Parameter Manual" (B-64310EN) of the CNC for information about the setting
parameter numbers that can be specified.

"type" specifies the axis number of a setting parameter to be rewritten.

0 : Non-axis setting parameter


1 to m : Axis setting parameter, one axis (m: maximum number of controlled
axes)
-1 : Axis setting parameter, all axes

"rdata" or "rdatas" specifies a real setting parameter to be rewritten. "prm_val"


specifies the data and "dec_val" specifies the number of decimal places.

Real setting parameter = prm_val×10(-dec_val)

(Example) To rewrite a real parameter 12.345, specify prm_val of 12345 and dec_val of
3.

[Example]
See [Example] in "Read setting parameter (cnc_rdset)."

- 431 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.45 Read setting parameters (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdsetr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdsetr( short s_number, short axis, short e_number,
short length, struct iodbpsdr *buf ) ;

typedef struct realprm { /* real setting data */


long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
}
REALPRM;

struct iodbpsdr {
short datano; /* setting data number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[N]; /* bit/byte set. data with axis */
short idatas[N]; /* word set. data with axis */
long ldatas[N]; /* 2-word set. data with axis */
REALPRM rdatas[N]; /* real set. data with axis */
} u;
} ; N is a maximum controlled axis number.

[Arguments]
s_number Start setting parameter number.
axis Axis number ( =(1,..,amount of controlled axes), or -1, 0 ).
e_number End setting parameter number.
length Data block length (= Sum of [4+(byte size of the parameter)×
(MAX_AXIS)])
buf Buffer in which the setting parameters are stored.

- 432 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect setting parameter number "s_number" or "e_number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.

[Description]
Reads the setting parameters of the axis specified by "axis" (only for axis setting
parameters) in the range specified by "s_number" and "e_number".

Setting parameters each have their own data format. Byte, word, and 2-word setting
parameters are generally in signed binary format.

The axis setting parameters of all axes in the specified range are read by setting -1
in "axis".

There are the following types of setting parameters with different type and axis
attributes for different setting parameter numbers.

Setting data type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real setting data and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real setting data with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

It is impossible to read any bit setting data bit by bit.


8 bits(i.e. 1 byte) which belong to the same setting data number are
read at the same time.

This function is the same as the cnc_rdparar function described in "Read parameters (range
specified)," except that parameters for which setting input is disabled cannot be read.

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the parameters.

- 433 -
3.Function References PROGRAMMING B-64303EN-3/01

"s_number" is a pointer to the variable that specifies the setting parameter number at
which reading starts. The function returns the number of the first setting parameter
that has actually been read.

Refer to "Parameter Manual" (B-64310EN) of the CNC for information about the setting
parameter numbers that can be specified.

"e_number" is a pointer to the variable that specifies the setting parameter number at
which reading ends. The function returns the number of the last setting parameter that
has actually been read.

Setting parameters may be added because of, for example, addition of CNC software
functions. For example, if a setting parameter is added within the read range, an error
may occur (return value: EW_LENGTH) or the application program may not perform processing
correctly. To prevent these problems, specify a read range containing only a set of
consecutive setting parameter numbers.

"axis" specifies the number of an axis for which the data is to be read.
0 : Non-axis setting parameter
1 to m : Axis setting parameter, one axis (m: maximum number of controlled axes)
-1 : All axes

A non-axis setting parameter is read regardless of which value is specified for "axis".
When an axis setting parameter is included within the specified range, however, an error
occurs (return value: EW_ATTRIB) if 0 is specified for "axis".

"length" is a pointer to the variable that specifies the length of a data block needed
to store the specified range of setting parameters.

The data block for each setting parameter is as shown below. The specified number of
data blocks are arranged in order (ascending) of setting parameter number. "length" is
the total length of the data blocks.

The function returns the size of setting parameters that have actually been read. You
can specify a larger value for "length" than needed.

The following shows the data blocks for the setting parameter size of 2 bytes. If the
setting parameter size is 1 to 2 bytes and "length" for each setting parameter is not
a multiple of 4, a dummy area is required at the end.

- 434 -
B-64303EN-3/01 PROGRAMMING 3.Function References

For the setting parameter size of 4 or 8 bytes, the data size for each setting parameter
(one axis) is 4 or 8 bytes, and no dummy area is required.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │length per │type │ length per
4├───┤setting parameter 4├───┤ setting parameter
│idata │ │ │idatas[0]:Axis 1 │
6├───┤ │ 6├───┤ │
│dummy │ ↓ ~ ~ │
8└───┘ ─ 4+2×(n-1)├───┤ │
│idatas[n-1]:Axis n│
4+2×n├───┤ │
│dummy(n is odd) ↓
└───┘ ─
n = maximum number of controlled axes

Spindle-related setting parameters are handled as axis setting parameters, and the data
of the current number of spindles is valid.

"datano" stores the number of a setting parameter that has been read.
"type" stores the attribute of a setting parameter that has been read.
Upper byte: Type attribute
0 : Bit
1 : Byte
2 : Word
3 : 2-word
4 : Real
Lower byte : Axis number
0 : Non-axis setting parameter
1 to m: Axis setting parameter, one axis
(m: maximum number of controlled axes)
-1 : Axis setting parameter, all axes

"rdata" or "rdatas" stores a real setting parameter. "prm_val" stores the data and
"dec_val" stores the number of decimal places.

Real setting parameter = prm_val×10(-dec_val)

(Example) When prm_val is 12345 and dec_val is 3, a real setting parameter is 12.345.

[Example]
This function can be used in the same manner as described in "Read parameters (range
specified) (cnc_rdparar)." See [Example] in this section.

- 435 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.46 Write setting parameters (multiple output). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrsets

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrsets( short length, struct iodbpsdr *buf ) ;

typedef struct realprm { /* real setting data */


long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
}
REALPRM;

struct iodbpsdr {
short datano; /* setting data number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte setting data */
short idata; /* word setting data */
long ldata; /* 2-word setting data */
REALPRM rdata; /* real setting data */
char cdatas[N]; /* bit/byte set. data with axis */
short idatas[N]; /* word set. data with axis */
long ldatas[N]; /* 2-word set. data with axis */
REALPRM rdatas[N]; /* real set. data with axis */
} u;
} ; N is a maximum controlled axis number.

[Arguments]
length Data block length ( = Sum of [4+(byte size of the setting parameter)
×(MAX_AXIS)] )
buf Buffer in which the setting parameters are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect setting parameter number "buf.datano".

- 436 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_ATTRIB( 4) Incorrect axis number "buf.type".


Any data other than -1, 0 or (1,..,amount of
controlled axes) has been specified.

[Description]
Rewrites multiple setting parameters stored in "set".

Setting parameters each have their own data format. Byte, word, and 2-word setting
parameters are generally in signed binary format.

The data of all axes can be rewritten at once by setting -1 in "type". The setting parameter
data of each axis is stored in the array in "buf".

There are the following types of setting parameters with different type and axis
attributes for different setting parameter numbers.

Setting data type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real setting data and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real setting data with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

It is impossible to write any bit setting data bit by bit.


8 bits(i.e. 1 byte) which belong to the same setting data number are written at the same
time.

This function is the same as the cnc_wrparas function, except that parameters for which
setting input is disabled cannot be rewritten.

- 437 -
3.Function References PROGRAMMING B-64303EN-3/01

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the setting
parameters.

"length" specifies the length of data blocks that store setting parameters to be
rewritten.

The data block for each setting parameter is as shown below. The data blocks are arranged
in order (ascending) of setting parameter number. "length" is the total length of the
data blocks.

The following shows the data blocks for the setting parameter size of 2 bytes. If the
setting parameter size is 1 to 2 bytes and "length" for each setting parameter is not
a multiple of 4, a dummy area is required at the end. For the setting parameter size
of 4 or 8 bytes, the data size for each setting parameter (one axis) is 4 or 8 bytes,
and no dummy area is required.
No axis/one axis All axes
buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │length per │type │ length per
4├───┤setting parameter 4├───┤ setting parameter
│idata │ │ │idatas[0]:Axis 1 │
6├───┤ │ 6├───┤ │
│dummy │ ↓ ~ ~ │
8└───┘ ─ 4+2×(n-1)├───┤ │
│idatas[n-1]:Axis n│
4+2×n├───┤ │
│dummy(n is odd) ↓
└───┘ ─
n = maximum number of controlled axes
Spindle-related setting parameters are handled as axis setting parameters, and the data
of the current number of spindles is valid.

"datano" specifies the number of a setting parameter to be rewritten.


Refer to "Parameter Manual" (B-64310EN) of the CNC for information about the setting
parameter numbers that can be specified.

"type" specifies the attribute of a setting parameter to be rewritten.


Upper byte: Type attribute
0 : Bit
1 : Byte
2 : Word
3 : 2-word
4 : Real
Lower byte : Axis number
0 : Non-axis setting parameter
1 to m: Axis setting parameter, one axis
(m: maximum number of controlled axes)
-1 : Axis setting parameter, all axes

- 438 -
B-64303EN-3/01 PROGRAMMING 3.Function References

"rdata" or "rdatas" specifies a real setting parameter to be rewritten. "prm_val"


specifies the data and "dec_val" specifies the number of decimal places.

Real setting parameter = prm_val×10(-dec_val)

(Example) To rewrite a real parameter 12.345, specify prm_val of 12345 and dec_val
of 3.

[Example]
This function can be used in the same manner as described in "Write parameters (multiple
output) (cnc_wrparas)." See [Example] in this section.

- 439 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.47 Read pitch error compensation data (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpitchr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpitchr( short s_number, short e_number, short length,
struct iodbpi *buf ) ;

struct iodbpi {
short datano_s ; /* Start pitch error compensation */
/* data number. */
short dummy ; /* Not used. */
short datano_e ; /* End pitch error compensation */
/* data number. */
char data[N] ; /* Pitch error compensation data. */
} ; /* N is the amount of compensation */
/* data to be read. */

[Arguments]
s_number Start pitch error compensation number.
e_number End pitch error compensation number.
length Data block length ( =6+(number of compensation data to be read) )
buf Buffer in which the pitch error compensation data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect pitch error compensation number "s_number" or "e_number".
EW_NOOPT( 6) The stored pitch error compensation function is not added.
Enabled the stored pitch error compensation function (bit 0 (NPE) of
parameter No. 8135 is 0).

[Description]
Reads the pitch error compensation data in the range specified by "s_number" and
"e_number".

- 440 -
B-64303EN-3/01 PROGRAMMING 3.Function References

The compensation data is stored in the "data" array in "buf" in signed binary format.

Valid data range: -7 to 7

"length" specifies the data block length (size of "buf").

struct iodbpi 0┌─────┐ ─


│datano_s │ ↑
2├─────┤ │
│dummy │ │
4├─────┤ │
│datano_e │ │
6├──┬──┘length
│data[0] │
7├──┤ │
~ ~ │
6+(N-1)├──┤ │
│data[N-1] ↓
6+N└──┘ ─

N is the number of pitch error compensation data items to be read.

[Example]
The following program reads the pitch error compensation data within
the specified number range and displays them.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>

/* start/end are start/end number to be read. */


short example( short start, short end )
{
struct iodbpi *buf ;
short ret, idx ;
buf = (struct iodbpi *)malloc( 1024 ) ;
ret = cnc_rdpitchr( start, end, 6+(end-start+1), buf ) ;
if ( !ret )
for ( idx = 0 ; idx < end-start+1 ; idx++ )
printf( "#%04d %+d\n", idx+start, buf->data[idx] ) ;
free( buf ) ;
return ( ret ) ;
}

- 441 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.48 Write pitch error compensation data (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrpitchr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrpitchr( short length, struct iodbpi *buf ) ;

struct iodbpi {
short datano_s ; /* Start pitch error compensation */
/* number. */
short dummy ; /* Not used. */
short datano_e ; /* End pitch error compensation */
/* number. */
char data[N] ; /* Pitch error compensation data. */
} ; /* N is number of compensation data */
/* to be written. */

[Arguments]
length Data block length ( =6+(number of compensation data to be written) )
buf Buffer in which the pitch error compensation data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect pitch error compensation number "buf.datano_s" or
"buf.datano_e".
EW_DATA( 5) Data number error.
The pitch error compensation data in "data" is out of a settable data
range.
EW_NOOPT( 6) The stored pitch error compensation function is not added.
Enabled the stored pitch error compensation function (bit 0 (NPE) of
parameter No. 8135 is 0).

[Description]
Rewrites the pitch error compensation data in the range specified by "datano_s" and
"datano_e".

- 442 -
B-64303EN-3/01 PROGRAMMING 3.Function References

The compensation data is stored in the "data" array in "buf" in signed binary format.

Valid data range: -7 to 7

"length" specifies the data block length (size of "buf").

struct iodbpi 0┌─────┐ ─


│datano_s │ ↑
2├─────┤ │
│dummy │ │
4├─────┤ │
│datano_e │ │
6├──┬──┘length
│data[0] │
7├──┤ │
~ ~ │
6+(N-1)├──┤ │
│data[N-1] ↓
6+N└──┘ ─

N is the number of pitch error compensation data items to be rewritten.

"datano_s" specifies the pitch error compensation data number at which rewriting starts.
"datano_e" specifies the pitch error compensation data number at which rewriting ends.

[Example]
The following program alters the pitch error compensation data within the specified
number range.

#include <data.h>
#include <fwindow.h>
#include <stdlib.h>

/* start/end are start/end number to be written. */


/* data is array of value to be written. */
short example( short start, short end, char *data )
{
struct iodbpi *buf ;
short ret, idx ;
buf = (struct iodbpi *)malloc( 1024 ) ;
buf->datano_s = start ;
buf->datano_e = end ;
for ( idx = 0 ; idx < end-start+1 ; idx++ )
buf->data[idx] = data[idx] ;
ret = cnc_wrpitchr( 6+(end-start+1), buf ) ;
free( buf ) ;
return ( ret ) ;
}

- 443 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.49 Read custom macro variable. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdmacro

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmacro( short number, short length, struct odbm *buf ) ;

struct odbm {
short dummy ; /* Not used. */
short datano ; /* Custom macro variable number. */
long mcr_val ; /* Custom macro variable value. */
short dec_val ; /* Digit number after decimal point.*/
} ;

[Arguments]
number Custom macro variable number.
length Data block length ( =10 ).
buf Buffer in which the custom macro variable data is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect custom macro variable number "number".
EW_NOOPT( 6) There are no required functions.
The related functions;
- Custom macro. (Enabled when bit 5 (NMC) of parameter No. 8135 is 0.)
- Custom macro common variable addition (#100 to #199 and #500 to #999)
(Enabled when bit 6 (NCV) of parameter No. 8135 is 0.)

- 444 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the custom macro variable of the number specified by "number".

The data is stored in "buf" in signed binary format.

The types of custom macro variables that can be read are as follows.

Local variables (#1 to #33)


When the function is called, the local variable in the custom macro being executed at
that time is read.

1.Common variables (#100 to #999)


2. System variables (#1000 to #9999)
- Decimal floating-point type (data format = M×10(-E))

mcr_val : Variable value (= M)


4-byte signed binary format
(Valid range: 999999999 to -999999999)
dec_val : Number of decimal places (= E)
2-byte signed binary format
(Valid range: -128 to 127)

"mcr_val" is always returned with 9 digits, which are adjusted by the value of
"dec_val".

(Example) A variable value of 12.345 is read as shown below.


mcr_val = 123450000
dec_val = 7

A custom macro variable may have a special value "blank", which is represented as shown
below.
mcr_val = 0
dec_val = -1

Refer to "Common to Lathe System/Machining Center System User's Manual" (B-64304EN) of


the CNC for details about the custom macro variables.

"length" specifies the data block length (size of "buf" = 10).

buf 0┌─────┐ ─
│datano │ ↑
2├─────┤ │
│dummy │ │
4├─────┴─────┐length
│mcr_val │ │
8├─────┬─────┘ │
│dec_val │ ↓
10└─────┘ ─

- 445 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads the custom macro variable data of specified number and
displays it.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <string.h>

/* number is variable number to be read. */


short example( short number )
{
struct odbm buf ;
char strbuf[11] ;
short ret ;
ret = cnc_rdmacro( number, 10, &buf ) ;
if ( !ret ) {
sprintf( &strbuf[1], "%09ld", buf.mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1], 9 - buf.dec_val ) ;
strbuf[9-buf.dec_val] = '.' ;
printf( "%s\n", strbuf ) ;
}
else
printf( "**********\n" ) ;
return ( ret ) ;
}

- 446 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.50 Write custom macro variable. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrmacro

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrmacro( short number, short length, long mcr_val
, short dec_val ) ;

[Arguments]
number Custom macro variable number.
length Data block length ( =10 ).
mcr_val Custom macro variable value.
dec_val Digit number after decimal point.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect custom macro variable number "number".
EW_DATA( 5) Value of the custom macro variable is out of the limit.
EW_NOOPT( 6) There are no required functions.
The related functions;
- Custom macro. (Enabled when bit 5 (NMC) of parameter No. 8135 is 0.))
- Custom macro common variable addition (#100 to #199 and #500 to #999)
(Enabled when bit 6 (NCV) of parameter No. 8135 is 0.)

[Description]
Rewrites the custom macro variable of the number specified by "number".

The data is stored in "mcr_val" and "dec_val buf" in signed binary format.

The types of custom macro variables that can be rewritten are as follows. Local variables
cannot be rewritten.

1. Common variables (#100 to #999)


2. System variables (#1000 to #9999)
- Decimal floating-point type (data format = M×10(-E))
mcr_val : Variable value (= M)
4-byte signed binary format
(Valid range: 999999999 to -999999999)

- 447 -
3.Function References PROGRAMMING B-64303EN-3/01

dec_val : Number of decimal places (= E)


2-byte signed binary format
(Valid range: -128 to 127)

A custom macro variable may have a special value "blank", which is represented as shown
below.
mcr_val = 0
dec_val = -1

Refer to "Common to Lathe System/Machining Center System User's Manual" (B-64304EN) of


the CNC for details about the custom macro variables.

[Example]
The following program writes the specified value in the specified
custom macro variable.

#include <data.h>
#include <fwindow.h>

/* number is variable number to be written. */


/* value is value to be written. */
/* dec is decimal digit number. */
short example( short number, long value, short dec )
{
short ret ;
ret = cnc_wrmacro( number, 10, value, dec ) ;
return ( ret ) ;
}

- 448 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.51 Read custom macro variables (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdmacror

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmacror( short s_number, short e_number, short length,
struct iodbmr *buf ) ;

struct iodbmr {
short datano_s ; /* Start custom macro variable number.*/
short dummy ; /* Not used. */
short datano_e ; /* End custom macro variable number.*/
struct {
long mcr_val ; /* Custom macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} data[N] ; /* N is number of variables to be read. */
} ;

[Arguments]
s_number Start custom macro variable number.
e_number End custom macro variable number.
length Data block length ( =6+6×(number of variables to be read) )
buf Buffer in which the custom macro variable data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect custom macro variable number "datano_s" or "datano_e".
EW_NOOPT( 6) There are no required functions.
The related functions;
- Custom macro. (Enabled when bit 5 (NMC) of parameter No. 8135 is 0.))
- Custom macro common variable addition (#100 to #199 and #500 to #999)
(Enabled when bit 6 (NCV) of parameter No. 8135 is 0.)

[Description]
Reads the custom macro variables in the range specified by "s_number" and "e_number".

The data is stored in "buf" in signed binary format.

- 449 -
3.Function References PROGRAMMING B-64303EN-3/01

The types of custom macro variables that can be read are as follows.

1. Local variables (#1 to #33)


When the function is called, the local variable in the custom macro being
executed at that time is read.
2. Common variables (#100 to #999)
- Decimal floating-point type (data format = M×10(-E))
mcr_val : Variable value (= M)
4-byte signed binary format
(Valid range: 999999999 to -999999999)
dec_val : Number of decimal places (= E)
2-byte signed binary format
(Valid range: -128 to 127)

"mcr_val" is always returned with 9 digits, which are adjusted by the value of
"dec_val".

(Example) A variable value of 12.345 is read as shown below.


mcr_val = 123450000
dec_val = 7

A custom macro variable may have a special value "blank", which is represented as shown
below.
mcr_val = 0
dec_val = -1

Refer to "Common to Lathe System/Machining Center System User's Manual" (B-64304EN) of


the CNC for details about the custom macro variables.

- 450 -
B-64303EN-3/01 PROGRAMMING 3.Function References

"length" specifies the data block length (size of "buf").

buf 0┌─────┐ ─
│datano_s │ ↑
2├─────┤ │
│dummy │ │
4├─────┤ │
│datano_e │ │
6├─────┤ │
│ │ │
8├─────┴─────┐ │
│data[0].mcr_val │length
12├─────┬─────┘ │
│data[0].dec_val │
14├─────┤ │
│ │ │
16├─────┴─────┐ │
~ ~ │
8+8×(N-1)├─────┴─────┐ │
│data[N-1].mcr_val │ │
├─────┬─────┘ │
│data[N-1].dec_val │
├─────┤ │
│ │ ↓
8+8×N└─────┘ ─

N is the number of custom macro variables to be read.

[Example]
The following program reads the custom macro variables within the specified range and
displays them.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* start/end are start/end variable number to be read. */


short example( short start, short end )
{
struct odbmr *buf ;
char strbuf[11] ;
short ret, idx ;
buf = (struct iodbmr *)malloc( 1000 ) ;
ret = cnc_rdmacror( start, end, 1000, buf ) ;
if ( !ret )
for ( idx = 0 ; idx <= end-start ; idx++ ) {
sprintf( &strbuf[1], "%09ld",

- 451 -
3.Function References PROGRAMMING B-64303EN-3/01

buf->data[idx].mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1],
9 - buf->data[idx].dec_val ) ;
strbuf[9-buf->data[idx].dec_val] = '.' ;
printf( "#%04d %s\n", start+idx, strbuf ) ;
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}

- 452 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.52 Write custom macro variables (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrmacror

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrmacror( short length, struct iodbmr *buf ) ;

struct iodbmr {
short datano_s ; /* Start custom macro variable number. */
short dummy ; /* Not used. */
short datano_e ; /* End custom macro variable number. */
struct {
long mcr_val ; /* Custom macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} data[N] ; /* N is number of variables to be written. */
} ;

[Arguments]
length Data block length ( =6+6*(number of variables to be written) )
buf Buffer in which the custom macro variable data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect custom macro variable number "datano_s" or "datano_e".
EW_DATA( 5) Value of the custom macro variable is out of the limit.
EW_NOOPT( 6) There are no required functions.
The related functions;
- Custom macro. (Enabled when bit 5 (NMC) of parameter No. 8135 is 0.))
- Custom macro common variable addition (#100 to #199 and #500 to #999)
(Enabled when bit 6 (NCV) of parameter No. 8135 is 0.)

[Description]
Rewrites the custom macro variables in the range specified by "datano_s" and "datano_e".

The data is stored in "buf" in signed binary format.

- 453 -
3.Function References PROGRAMMING B-64303EN-3/01

The types of custom macro variables that can be rewritten are as follows. Local variables
cannot be rewritten.

1. Common variables (#100 to #999)


- Decimal floating-point type (data format = M×10(-E))
mcr_val : Variable value (= M)
4-byte signed binary format
(Valid range: 999999999 to -999999999)
dec_val : Number of decimal places (= E)
2-byte signed binary format
(Valid range: -128 to 127)

A custom macro variable may have a special value "blank", which is represented as shown
below.
mcr_val = 0
dec_val = -1

Refer to "Common to Lathe System/Machining Center System User's Manual" (B-64304EN) of


the CNC for details about the custom macro variables.

"length" specifies the data block length (size of "buf").

buf 0┌─────┐ ─
│datano_s │ ↑
2├─────┤ │
│dummy │ │
4├─────┤ │
│datano_e │ │
6├─────┤ │
│ │ │
8├─────┴─────┐ │
│data[0].mcr_val │length
12├─────┬─────┘ │
│data[0].dec_val │
14├─────┤ │
│ │ │
16├─────┴─────┐ │
~ ~ │
8+8×(N-1)├─────┴─────┐ │
│data[N-1].mcr_val │ │
├─────┬─────┘ │
│data[N-1].dec_val │
├─────┤ │
│ │ ↓
8+8×N└─────┘ ─
N is the number of custom macro variables to be rewritten.

- 454 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program writes the integer values into the custom macro variables within
the specified range.

#include <data.h>
#include <fwindow.h>
#include <stdlib.h>

/* start is start variable number to be written. */


/* value is array of value to be written. */
/* number is number of variable. */
short example( short start, long *value, short number )
{
struct odbmr *buf ;
short ret, idx ;
buf = (struct iodbmr *)malloc( 6+6*number ) ;
buf->datano_s = start ;
buf->datano_e = start + number - 1 ;
for ( idx = 0 ; idx < number ; idx++ ) {
buf->data[idx].mcr_val = value[idx] ;
buf->data[idx].dec_val = 0 ;
}
ret = cnc_wrmacror( 6+6*number, buf ) ;
free( buf ) ;
return ( ret ) ;
}

- 455 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.53 Read P-code macro variable. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpmacro

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpmacro( long number, struct odbpm *buf ) ;

struct odbpm {
long datano ; /* P-code macro variable number. */
short dummy ; /* Not used. */
union {
struct {
long mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p6 ;
struct {
short mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p2 ;
} u ;
} ;

[Arguments]
number P-code macro variable number. ( >= 10000 )
buf Buffer in which the P-code macro variable data is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect P-code macro variable number "number".
EW_NOOPT( 6) Macro executor option isn't added, or macro module isn't loaded.

- 456 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the P-code macro variable (macro executor variable) of the number specified by
"number".

The data is stored in "buf" in signed binary format.

- Decimal floating-point type (data format = M×10(-E))

mcr_val : Variable value (= M)


4-byte signed binary format
(Valid range: 999999999 to -999999999, with integer format of -32768
to 32767)

dec_val : Number of decimal places (= E)


2-byte signed binary format
(Valid range: -128 to 127, with integer format of 0)

"mcr_val" is always returned with 9 digits, which are adjusted by the value of "dec_val".
(Example) A variable value of 12.345 is read as shown below.
mcr_val = 123450000
dec_val = 7

A P-code macro variable may have a special value "blank", which is represented as shown
below.
mcr_val = 0
dec_val = -1

Refer to "Macro Compiler/Macro Executor Programming Manual" (B-64303EN-2) of the CNC


for details about the P-code macro variables.

[Example]
The following program reads and displays a P-code macro variable having a specified
number.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <string.h>

/* number is variable number to be read. */


short example( long number )
{
struct odbpm buf ;
char strbuf[11] ;
short ret ;
ret = cnc_rdpmacro( number, &buf ) ;
if ( !ret ) {
sprintf( &strbuf[1], "%09ld", buf.u.p6.mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1], 9 - buf.u.p6.dec_val ) ;

- 457 -
3.Function References PROGRAMMING B-64303EN-3/01

strbuf[9-buf.u.p6.dec_val] = '.' ;
printf( "%s\n", strbuf ) ;
}
else
printf( "**********\n" ) ;
return ( ret ) ;
}

- 458 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.54 Write P-code macro variable. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrpmacro

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrpmacro( long number, long mcr_val, short dec_val ) ;

[Arguments]
number P-code macro variable number. ( >= 10000 )
mcr_val P-code macro variable value.
dec_val Digit number after decimal point.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect P-code macro variable number "number".
EW_DATA( 5) Data error.
The P-code macro variable value is beyond a valid range.
EW_NOOPT( 6) Macro executor option isn't added, or macro module isn't loaded.

[Description]
Rewrites the P-code macro variable (macro executor variable) of the number specified
by "number".

The data is stored in "mcr_val" and "dec_val" in signed binary format.

- Decimal floating-point type (data format = M×10(-E))


mcr_val : Variable value (= M)
4-byte signed binary format
(Valid range (HSSB): no limit, with integer format of -32768 to 32767)
dec_val : Number of decimal places (= E)
2-byte signed binary format
(Valid range: -128 to 127, with integer format of 0)

A P-code macro variable may have a special value "blank", which is represented as shown
below.
mcr_val = 0
dec_val = -1

Refer to "Macro Compiler/Macro Executor Programming Manual" (B-64303EN-2) of the CNC


for details about the P-code macro variables.

- 459 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program writes the specified value in the specified P-code macro variable.

#include <data.h>
#include <fwindow.h>

/* number is variable number to be written. */


/* value is value to be written. */
/* dec is decimal digit number. */
short example( long number, long value, short dec )
{
short ret ;
ret = cnc_wrpmacro( number, value, dec ) ;
return ( ret ) ;
}

- 460 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.55 Read P-code macro variables (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpmacror

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpmacror( long s_number, long e_number, short length,
struct iodbpr *buf ) ;

struct iodbpr {
long datano_s ; /* Start P-code macro variable number. */
short dummy ; /* Not used. */
long datano_e ; /* End P-code macro variable number. */
union {
struct {
long mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p6_r ;
struct {
short mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p2_r ;
} pm_r[N] ; /* N is number of variables to be read. */
} ;

[Arguments]
s_number Start P-code macro variable number.
e_number End P-code macro variable number.
length Data block length ( =10+6*(number of variables to be read) )
buf Buffer in which the P-code macro variable data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect P-code macro variable number "s_number" or "e_number".
EW_NOOPT( 6) Macro executor option isn't added, or macro module isn't loaded.

- 461 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the P-code macro variables (macro executor variables) in the range specified by
"s_number" and "e_number".

The data is stored in "buf" in signed binary format.

- Decimal floating-point type (data format = M×10(-E))


mcr_val : Variable value (= M)
4-byte signed binary format
(Valid range: 999999999 to -999999999, with integer format of -32768
to 32767)
dec_val : Number of decimal places (= E)
2-byte signed binary format
(Valid range: -128 to 127, with integer format of 0)

"mcr_val" is always returned with 9 digits, which are adjusted by the value of
"dec_val".

(Example) A variable value of 12.345 is read as shown below.


mcr_val = 123450000
dec_val = 7

A P-code macro variable may have a special value "blank", which is represented as shown
below.
mcr_val = 0
dec_val = -1

Refer to "Macro Compiler/Macro Executor Programming Manual" (B-64303EN-2) of the CNC


for details about the P-code macro variables.

"length" specifies the data block length (size of "buf").

buf 0┌───────────┐ ─
│datano_s │ ↑
4├─────┬─────┘ │
│dummy │ │
6├─────┤ │
│ │ │
8├─────┴─────┐ │
│datano_e │ │
12├───────────┤ │
│pm_r[0].p6_r.mcr_val │ │length
16├─────┬─────┘ │
│pm_r[0].p6_r.dec_val │
18├─────┤ │
│ │ │
20├─────┴─────┐ │
~ ~ │

- 462 -
B-64303EN-3/01 PROGRAMMING 3.Function References

12+8×(N-1)├─────┴─────┐ │
│pm_r[N-1].p6_r.mcr_val│ │
├─────┬─────┘ │
│pm_r[N-1].p6_r.dec_val │
├─────┤ │
│ │ ↓
12+8×N└─────┘ ─

N is the number of P-code macro variables to be read.

"datano_s" stores the number of the first P-code macro variable that has actually been
read.

"datano_e" stores the number of the last P-code macro variable that has actually been
read.

[Example]
The following program reads and displays P code macro variables in a specified range.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* start/end are start/end variable number to be read. */


short example( long start, long end )
{
struct iodbpr *buf ;
char strbuf[11] ;
short length, ret ;
long idx ;
length = 10 + 6 * ( end - start + 1 ) ;
buf = (struct iodbpr *)malloc( length ) ;
ret = cnc_rdpmacror( start, end, length, buf ) ;
if ( !ret )
for ( idx = 0 ; idx <= end-start ; idx++ ) {
sprintf( &strbuf[1], "%09ld",
buf->pm_r[idx].p6_r.mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1],
9 - buf->pm_r[idx].p6_r.dec_val ) ;
strbuf[9-buf->pm_r[idx].p6_r.dec_val] = '.' ;
printf( "#%04ld %s\n", start+idx, strbuf ) ;
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}

- 463 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.56 Write P-code macro variables (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrpmacror

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrpmacror( short length, struct iodbpr *buf ) ;

struct iodbpr {
long datano_s ; /* Start P-code macro variable number. */
short dummy ; /* Not used. */
long datano_e ; /* End P-code macro variable number. */
union {
struct {
long mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p6_r ;
struct {
short mcr_val ; /* P-code macro variable value. */
short dec_val ; /* Digit number after decimal */
/* point. */
} p2_r ;
} pm_r[N] ; /* N is number of variables to be read. */
} ;

[Arguments]
length Data block length ( =10+6*(number of variables to be written) )
datano_s Start P-code macro variable number. ( >= 10000 )
datano_e End P-code macro variable number.
mcr_val P-code macro variable value.
dec_val Digit number after decimal point.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect P-code macro variable number "s_number"or "e_number".
EW_DATA( 5) Data error.
The P-code macro variable value is beyond a valid range.
EW_NOOPT( 6) Macro executor option isn't added, or macro module isn't loaded.

- 464 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Rewrites the P-code macro variables (macro executor variables) in the range specified
by "datano_s" and "datano_e".

The data is stored in "buf" in signed binary format.

- Decimal floating-point type (data format = M×10(-E))


mcr_val : Variable value (= M)
4-byte signed binary format
(Valid range: no limit, with integer format of -32768 to 32767)
dec_val : Number of decimal places (= E)
2-byte signed binary format
(Valid range: -128 to 127, with integer format of 0)

A P-code macro variable may have a special value "blank", which is represented as shown
below.
mcr_val = 0
dec_val = -1

Refer to "Macro Compiler/Macro Executor Programming Manual" (B-64303EN-2) of the CNC


for details about the P-code macro variables.

"length" specifies the data block length (size of "buf").

buf 0┌───────────┐ ─
│datano_s │ ↑
4├─────┬─────┘ │
│dummy │ │
6├─────┤ │
│ │ │
8├─────┴─────┐ │
│datano_e │ │
12├───────────┤ │
│pm_r[0].p6_r.mcr_val │ │length
16├─────┬─────┘ │
│pm_r[0].p6_r.dec_val │
18├─────┤ │
│ │ │
20├─────┴─────┐ │
~ ~ │
12+8×(N-1)├─────┴─────┐ │
│pm_r[N-1].p6_r.mcr_val│ │
├─────┬─────┘ │
│pm_r[N-1].p6_r.dec_val │
├─────┤ │
│ │ ↓
12+8×N└─────┘ ─

N is the number of P-code macro variables to be rewritten.

- 465 -
3.Function References PROGRAMMING B-64303EN-3/01

"datano_s" specifies the P-code macro variable number at which rewriting starts.

"datano_e" specifies the P-code macro variable number at which rewriting ends.

"mcr_val" specifies the variable value (mantissa) of the P-code macro variable.

"dec_val" specifies the number of decimal places (exponent) of the P-code macro variable.

[Example]
The following program writes the integer values into the P-code macro variables within
the specified range.

#include <data.h>
#include <fwindow.h>
#include <stdlib.h>

/* start is start variable number to be written. */


/* value is array of value to be written. */
/* number is number of variable. */
short example( long start, long *value, short number )
{
struct iodbpr *buf ;
short ret ;
long idx ;
buf = (struct iodbpr *)malloc( 10+6*number ) ;
buf->datano_s = start ;
buf->datano_e = start + number - 1 ;
for ( idx = 0 ; idx < number ; idx++ ) {
buf->pm_r[idx].p6_r.mcr_val = value[idx] ;
buf->pm_r[idx].p6_r.dec_val = 0 ;
}
ret = cnc_wrpmacror( 10+6*number, buf ) ;
free( buf ) ;
return ( ret ) ;
}

- 466 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.57 Read diagnostics data. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_diagnoss

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_diagnoss( short number, short axis, short length,
struct iodbpsd *buf ) ;

struct iodbpsd {
short datano; /* diagnosis number */
short type; /* axis number */
union {
char cdata; /* bit/byte diagnosis */
short idata; /* word diagnosis */
long ldata; /* 2-word diagnosis */
char cdatas[N]; /*bit/byte diagnosis with axis*/
short idatas[N]; /* word diagnosis with axis */
long ldatas[N]; /* 2-word diagnosis with axis */
} u ; /* N : max. controlled axes */
} ;

[Arguments]
number Diagnostic number.
axis Axis number ( =(1,..,amount of controlled axes), or -1, 0 ).
length Data block length
( =4+(byte size of the diagnostics data)×(amount of axes to be read) )
buf Buffer in which the diagnostics data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect diagnostic number "number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.
EW_NOOPT( 6) A function required to use data having a specified diagnose data
number has not been added.

- 467 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the diagnostics data of the number specified by "number" and the axis specified
by "axis" (only for axis diagnostics data).

Diagnostics data items each have their own data format. Byte, word, and 2-word diagnostics
data items are generally in signed binary format.

The data of all axes can be read at once by setting -1 in "axis". The diagnostics data
of each axis is stored in the array in "buf".

There are the following types of diagnostics data items with different type and axis
attributes for different diagnostics data numbers.

Diagnostics data type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real parameter and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real parameter with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

Note that bit diagnostics data cannot be read bit by bit. The 8 bits (or 1 byte) that
belong to the same diagnostics data number are read at once.

Refer to "Maintenance Manual" (B-64305EN) of the CNC for details about the diagnostics
data items.

- 468 -
B-64303EN-3/01 PROGRAMMING 3.Function References

"length" specifies the data block length (size of "buf").


The following shows the data blocks for the diagnostics data size of 4 bytes. For the
diagnostics data size of 1, 2, or 8 bytes, the data size for each diagnostics data item
(one axis) is 1, 2, or 8 bytes.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐ │
│ ldata │↓ │ldatas[0]:Axis 1 │
8└───────┘─ 8├───────┤ │
~ ~ │
4+4×(n-1)├───────┤ │
│ldatas[n-1]:Axis n↓
4+4×n└───────┘ ─
n = maximum number of controlled axes

"datano" stores the number of diagnostics data that has been read.

"type" stores the axis number of diagnostics data that has been read.

0 : Non-axis diagnostics data


1 to m : Axis diagnostics data, one axis (m: maximum number of controlled axes)
-1 : Axis diagnostics data, all axes

"rdata" stored real data.

In "rdatas", "dgn_val" stores the data and "dec_val" stores the number of decimal places.

Real data = dgn_val×10(-dec_val)

(Example) When dgn_val is 12345 and dec_val is 3, real data is 12.345.

- 469 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads information about what operation status the CNC is in and
displays the information on the screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
short dgn_no[] = { 0,1,2,3,4,5,6,10,11,12,13,14,15 } ;
char *dgn_msg[] = {
"WAITING FOR FIN SIGNAL",
"MOTION",
"DWELL",
"IN-POSITION CHECK",
"FEEDRATE OVERRIDE 0%",
"INTERLOCK/STARTLOCK",
"SPINDLE SPEED ARRIVAL CHECK",
"PUNCHING",
"READING",
"WAITING FOR (UN) CLAMP",
"JOG FEEDRATE OVERRIDE 0%",
"WAITING FOR RESET. ESP. RRW. OFF",
"EXTERNAL PROGRAM NUMBER SEARCH"
} ;
short idx, count = 0 ;
struct iodbpsd buf ;

printf( "\033[1;1H<< CNC DIAGNOSTICS >>\n\n" ) ;


for ( idx = 0 ; idx < sizeof(dgn_no)/sizeof(short) ; idx++ ) {
cnc_diagnoss( dgn_no[idx], 0, 4+1*1, &buf ) ;
if ( buf.u.cdata ) {
printf( "%03d %s\n", dgn_no[idx], dgn_msg[idx] ) ;
count++ ;
}
}
for ( idx = 0 ; idx < 10 - count ; idx++ )
printf( "\033[K\n" ) ;
}

- 470 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.58 Read diagnostics data (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_diagnosr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_diagnosr( short s_number, short axis, short e_number,
short length, struct iodbpsdr *buf ) ;

struct iodbpsdr {
short datano; /* diagnosis number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte diagnosis */
short idata; /* word diagnosis */
long ldata; /* 2-word diagnosis */
char cdatas[N]; /*bit/byte diagnosis with axis*/
short idatas[N]; /* word diagnosis with axis */
long ldatas[N]; /* N is a maximum controlled axis number. */
} u ;
} ;

[Arguments]
s_number Start diagnostic number.
axis Axis number ( =(1,..,amount of controlled axes), or 1, 0 ).
e_num End diagnostic number.
length Data block length
( = Sum of [4+(byte size of the diagnostics data)×
(amount of axes to be read)] )
buf Buffer in which the diagnostics data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect diagnostic number "s_number" or "e_number".
EW_ATTRIB( 4) Incorrect axis number "axis".
Any data other than -1, 0 or (1,..,amount of controlled axes) has been
specified.
EW_NOOPT( 6) A function required to use data having a specified diagnose data
number has not been added.

- 471 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the diagnostics data of the axis specified by "axis" (only for axis diagnostics
data) in the range specified by "s_number" and "e_number".
Diagnostics data items each have their own data format. Byte, word, and 2-word diagnostics
data items are generally in signed binary format.

The diagnostics data of all axes in the specified range is read by setting -1 in "axis".
There are the following types of diagnostics data items with different type and axis
attributes for different diagnostics data numbers.

Diagnostics data type Meaning Byte size


Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. (each axis) 1
Byte parameter 1-byte data is stored. 1
Byte parameter with axis 1-byte data is stored. (each axis) 1
Word parameter 2-byte data is stored. 2
Word parameter with axis 2-byte data is stored. (each axis) 2
2-Word parameter 4-byte data is stored. 4
2-Word parameter with axis 4-byte data is stored. (each axis) 4
4-byte data which indicates value of variable
Real parameter and 4-byte data which indicates number of 8
places of decimals are stored.
4-byte data which indicates value of variable
Real parameter with axis and 4-byte data which indicates number of 8
places of decimals are stored.(each axis)

Note that bit diagnostics data cannot be read bit by bit. The 8 bits (or 1 byte) that
belong to the same diagnostics data number are read at once.
Refer to "Maintenance Manual" (B-64305EN) of the CNC for details about the diagnostics
data items.

"s_number" specifies the diagnostics data number at which reading starts. The function
returns the number of the first diagnostics data that has actually been read.

"e_number" specifies the diagnostics data number at which reading ends. The function
returns the number of the last diagnostics data that has actually been read.

Diagnostics data may be added because of, for example, addition of CNC software functions.
For example, if diagnostics data is added within the read range, an error may occur (return
value: EW_LENGTH) or the application program may not perform processing correctly. To
prevent these problems, specify a read range containing only a set of consecutive
diagnostics data numbers.

- 472 -
B-64303EN-3/01 PROGRAMMING 3.Function References

"axis" specifies the number of an axis for which the data is to be read.
0 : Non-axis diagnostics data
1 to m : Axis diagnostics data, one axis
(m: maximum number of controlled axes)
-1 : Axis diagnostics data, all axes

Non-diagnostics data is read regardless of which value is specified for "axis". When
axis diagnostics data is included within the specified range, however, an error occurs
(return value: EW_ATTRIB) if 0 is specified for "axis".

"length" specifies the length of a data block needed to store the specified range of
diagnostics data. The data block for each diagnostics data item is as shown below. The
specified number of data blocks are arranged in order (ascending) of diagnostics data
number. "length" is the total length of the data blocks.

The function returns the size of diagnostics data that has actually been read. You can
specify a larger value for "length" than needed.

The following shows the data blocks for the diagnostics data size of 2 bytes.
If the diagnostics data size is 1 to 2 bytes and "length" for each diagnostics data item
is not a multiple of 4, a dummy area is required at the end. For the diagnostics data
size of 4 or 8 bytes, the data size for each diagnostics data item (one axis) is 4 or
8 bytes, and no dummy area is required.

No axis/one axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │length per │type │ length per
4├───┤diagnostics data item 4├───┤ diagnostics data item
│idata │ │ │idatas[0]:Axis 1 │
6├───┤ │ 6├───┤ │
│dummy │ ↓ ~ ~ │
8└───┘ ─ 4+2×(n-1)├───┤ │
│idatas[n-1]:Axis n│
4+2×n├───┤ │
│dummy(n is odd) ↓
└───┘ ─
n = maximum number of controlled axes

- 473 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads diagnose data in a specified range for a specified axis
and displays it on the screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>

/* start/end are start/end number to be read. */


/* axis is axis number. */
short example( short start, short end, short axis )
{
struct odbsys info ;
struct iodbpsdr *buf, *ptr ;
short ret, idx1, idx2, axno, inc ;
cnc_sysinfo( &info ) ;
axno = atoi( info.axes ) ;
buf = (struct iodbpsdr *)calloc( 1, 1000 ) ;
ret = cnc_diagnosr( start, axis, end, 1000, buf ) ;
ptr = buf ;
if ( !ret ) {
for ( idx1 = start ; idx1 <= end ; idx1++ ) {
if ( ( idx1 != 0 ) && ( ptr->datano == 0 ) ) break ;
printf( "No.%05d ", ptr->datano ) ;
switch ( ptr->type >> 8 ) {
case 0: printf( "BYTE" ) ; break ;
case 1: printf( "WORD" ) ; break ;
case 2: printf( "2WRD" ) ; break ;
}
switch ( ptr->type & 0xff ) {
case 0xff :
for ( idx2 = 0 ; idx2 < axno ; idx2++ ) {
printf( " #%d:", idx2+1 ) ;
switch ( ptr->type >> 8 ) {
case 0:
printf( "%02X", ptr->u.cdatas[idx2] ) ;
inc = 1 ; break ;
case 1:
printf( "%d", ptr->u.idatas[idx2] ) ;
inc = 2 ; break ;
case 2:
printf( "%ld", ptr->u.ldatas[idx2] ) ;
inc = 4 ; break ;
}
}
putchar( '\n' ) ;
ptr = (struct iodbpsdr *)(((char *)ptr)+4+8*inc) ;

- 474 -
B-64303EN-3/01 PROGRAMMING 3.Function References

break ;
/* to be continued on the next page... */

default :
printf( " #%d:", ptr->type & 0xff ) ;
case 0:
switch ( ptr->type >> 8 ) {
case 0:
printf( " %02X\n", ptr->u.cdata ) ;
inc = 2 ; break ;
case 1:
printf( " %d\n", ptr->u.idata ) ;
inc = 2 ; break ;
case 2:
printf( " %ld\n", ptr->u.ldata ) ;
inc = 4 ; break ;
}
ptr = (struct iodbpsdr *)(((char *)ptr)+4+inc) ;
break ;
}
}
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( buf ) ;
return ( ret ) ;
}

- 475 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.59 Read A/D conversion data. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_adcnv

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_adcnv( short inp_type, short av_type, struct odbad *buf ) ;

struct odbad {
short datano ; /* Kind of analog voltage. */
short type ; /* Input channel or controlled axis number. */
short data ; /* Voltage data. */
} ;

[Arguments]
inp_type Kind of analog voltage ( =0, 2 ).
av_type Controlled axis number of CNC.
( 1,..,(amount of controlled axes) )
buf Buffer in which the A/D conversion data is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Data number error.
Incorrect analog voltage input type "inp_type".
EW_ATTRIB( 4) Incorrect input channel or controlled axis number "av_type".

- 476 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reading the load information of the controlled axis of the CNC.

Reads the load current data of the controlled axis of the CNC which is converted into
analog voltage via A/D converter.

Specify "2" in "inp_type".


Specify the controlled axis number of the CNC whose load information is read in "av_type".

・When load information of the CNC controlled axis is specified

inp_type av_type Servo axis number Signal Connector


2 1 1st axis AMP1 JV1
2 2 2nd axis AMP2 JV2
2 3 3rd axis AMP3 JV3
2 4 4th axis AMP4 JV4
2 5 5th axis AMP5 JV5
2 6 6th axis AMP6 JV6
2 7 7th axis AMP7 JV7
2 8 8th axis AMP8 JV8

Specify the type of analog voltage input in "datano".

Specify the type of an analog voltage in "type" (connector specification).

Specify digital voltage data converted from an analog voltage by the A/D converter in
"data".

The load current is converted into a digital value and then stored in binary format.
The load current (A) can be calculated from this value by the following expression.

The load current = buf.data × N / 6554 [Apeak]

N = value of parameter No.2165


(If N is greater than 20, its ones place is rounded to zero.)

- 477 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.60 Read operator's message. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdopmsg

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdopmsg( short type , short length, struct msg *buf ) ;

struct msg {
short datano0 ; /* Operator's message number. */
short type ; /* Kind of operator's message. */
short char_num ; /* Message length. */
char data[N] ; /* Operator's message. */
} ; /* N is maximum length of string. */

[Arguments]
type Kind of the operator's message ( =0,1,2,3 ).
length Data block length ( =6+(maximum length of string) )
buf Buffer in which the operator's message is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
EW_ATTRIB( 4) Incorrect kind of the operator's message "type".
EW_NOOPT( 6) External message or option of external data input isn't added.

[Description]
Reads the contents of the CNC operator's message.

The operator's message is stored in "buf.data".

"type" specifies the type of the operator's message.


0: First message

- 478 -
B-64303EN-3/01 PROGRAMMING 3.Function References

"length" specifies the data block length (size of "buf").

0┌───────────┐ ──
│ datano │ ↑
2├───────────┤ │
│ type │ │
4├───────────┤ │
│ char_num │ │
6├─────┬─────┘length
│ data[0] │ │
7├─────┤ │
~ ~ │
6+255├─────┤ │
│ data[255]│ ↓
6+256└─────┘ ──

"datano" sets the number of the operator' message.


- The message is provided:
Without a number: 0
With a number : 2000 to 2099
- No message is provided : -1

"type" sets the type of the operator's message.


0: First message

"char_num" sets the number of characters in the operator's message.


1 to 256: Operator's message

"data" sets the string of the operator's message. The string is terminated by '\0'.
The message is obtained with any of the following character codes.

English ASCII
Japanese Shifted JIS
Chinese (traditional) Shifted JIS
Chinese (simplified) GB2312
Russian Code page 1251
Turkish Code page 1254
Other European language European character code

- 479 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads the operator's message and displays it.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
struct msg buf ;
cnc_rdopmsg( 0, 6+256, &buf ) ;
if ( buf.datano != -1 )
printf( "%04d %s\n", buf.datano, buf.data ) ;
else
printf( "No operator message.\n" ) ;
}

- 480 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.61 Set path index (2-path system (T series)). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_setpath

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_setpath( int path_no ) ;

[Arguments]
path_no Path number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_PATH(11) Incorrect path number "path_no".

[Description]
Selects the path number which is the target path in the 2-path system (T series (2-path
control)).

All Data window library functions input from/output to the CNC's path selected by this
function. CNC module configuration information is read.

"path_no" specifies the number of a path.


0 : (Path 1)
1 : Path 1
2 : Path 2

- 481 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program sets up a specified path and processing target path.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

/* path is new path number to be set. */


short example( short path )
{
short ret ;
ret = cnc_setpath( path ) ;
if ( !ret )
printf( "PATH #%d has been set as new target path.\n", path ) ;

else
printf( "ERROR!(%d)\n", ret ) ;
return ( ret ) ;
}

- 482 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.62 Get path index (2-path system (T series)). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_getpath

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_getpath( short *path_no, short *maxpath_no ) ;

[Arguments]
path_no Current selected path number.
maxpath_no Maximum path number.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the current selected path number which is the target path of the Data window
functions.

"path_no" specifies the number of a path.


0 : (Path 1)
1 : Path 1
2 : Path 2

"maxpath_no" specifies the address of a variable for obtaining the maximum path number.

[Example]
The following program reads and displays information about the current processing target
path.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
short path, max ;
cnc_getpath( &path, &max ) ;
printf( "Current target path is PATH #%d (max:%d).\n", path, max ) ;
}

- 483 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.63 Set calendar timer of CNC. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_settimer

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_settimer( struct iodbtimer *buf ) ;

struct iodbtimer {
short type ; /* Spec. of date or time. */
short dummy ; /* Not used. */
union {
struct {
short year ; /* Year. */
short month ; /* Month. */
short date ; /* Date. */
} date ;
struct {
short hour ; /* Hour. */
short minute ;/* Minute. */
short second ;/* Second. */
} time ;
} data ;
} ;

[Arguments]
buf Buffer in which the date or time data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect spec. of date or time "buf.type".
EW_DATA( 5) Incorrect date or time data.
EW_REJECT(13) Data could not be set in the calendar timer LSI.
The hardware may be defective.

- 484 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Sets the date or time data to the calendar timer device of the CNC unit.

CNC software and C Language Library read date and time from the calendar timer device
of the CNC unit. This function set the date and time data to that calendar timer device.

Specify one of following values in "buf.type". (It is impossible to set both date and
time simultaneously.)

buf.type Data to be set


0 Sets date
1 Sets time

Store the date value or time value in each member of "buf.data.date" or "buf.data.time"
with binary format as follows.

Member Setting data Range of value


buf.data.date.year Year 1987 - 2037
buf.data.date.month Month 1 - 12
buf.data.date.date Date 1 - 31
buf.data.time.hour Hour 0 - 23
buf.data.time.minute Minute 0 - 59
buf.data.time.second Second 0 - 59

That is, the time "00:00:00, Jan. 1, 1987" through "23:59:59, Dec. 31, 2037" can be set.

This function doesn't check strictly validity of date format (buf.data.date.*).


For example, "Feb. 31" can be set. In this case, "Mar. 3" is read by "time()" function
(not a leap year), "Feb. 31" is displayed in the setting screen of CNC.

[Example]
The following program sets the calendar/timer with the date and time entered using keys.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

short example( void )


{
struct iodbtimer buf ;
short ret, year, month, date, hour, minute, second ;
printf( "Year =" ) ;
scanf( "%d", &year ) ;
printf( "Month =" ) ;
scanf( "%d", &month ) ;
printf( "Date =" ) ;
scanf( "%d", &date ) ;
printf( "Hour =" ) ;
scanf( "%d", &hour ) ;
- 485 -
3.Function References PROGRAMMING B-64303EN-3/01

printf( "Minute=" ) ;
scanf( "%d", &minute ) ;
printf( "Second=" ) ;
scanf( "%d", &second ) ;
buf.type = 0 ;
buf.data.date.year = year ;
buf.data.date.month = month ;
buf.data.date.date = date ;
ret = cnc_settimer( &buf ) ;
if ( ret == 5 ) printf( "Error while writing DATE.\n" ) ;
buf.type = 1 ;
buf.data.time.hour = hour ;
buf.data.time.minute = minute ;
buf.data.time.second = second ;
ret = cnc_settimer( &buf ) ;
if ( ret == 5 ) printf( "Error while writing TIME.\n" ) ;
}

- 486 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.64 Read load information of serial spindle. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdspload

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdspload( short sp_no, struct odbspn *buf ) ;

struct odbspn {
short datano ; /* Spindle number. */
short type ; /* Not used. */
short data[2] ; /* Spindle load data. */
} ;

[Arguments]
sp_no Spindle number.
buf Buffer in which the spindle load data are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect spindle number "sp_no".
EW_NOOPT( 6) The required function (Spindle serial output) is not added.

[Description]
Reads serial spindle load information.

The serial spindle load information is stored in "data[0]" in "buf".


The data of all spindles can be read at once by setting -1 in "sp_no". The load information
of each serial spindle is stored in the "data" array in "buf".

"sp_no" specifies the number of a spidle for which the data is to be read.

ALL_SPINDLES : All spindles (-1)


1 to MAX_SPINDLES: One spindle
MAX_SPINDLES (maximum number of spindles): 3

- 487 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads information about the load on the first spindle and displays
the load ratio on the screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

short example( void )


{
struct iodbpsd prm ;
struct odbspn buf ;
short ret ;
long val ;
cnc_rdparam( 4127, 1, 4+2*1, &prm ) ;
ret = cnc_rdspload( 1, &buf ) ;
if ( !ret ) {
val = (long)buf.data[0] * prm.u.idata * 100 / 32767 ;
printf( "Current spindle load value is %ld [%]\n", val ) ;
}
else
printf( "ERROR!(%d)\n", ret ) ;
return ( ret ) ;
}

- 488 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.65 Read executing program. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdexecprog

[Syntax]
#include <fwindow.h>
short cnc_rdexecprog( unsigned short *length, short *blknum
, char *data ) ;

[Arguments]
length Size of the buffer for storing executing program,
character number of read executing program.
blknum Number of buffered blocks.
data Buffer in which executing program text is stored (ASCII string).

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect buffer size "length".
EW_NOOPT( 6) No option.

[Description]
Reads a specified number of characters from the contents of the program being executed.

"length" specifies the address of a variable for setting the number of characters to
be read.
In the variable specified by "length", set the number of characters to be read. After
reading has completed, the number of characters that have actually been read is set in
the variable specified by "length".

"blknum" specifies the address of a variable for storing the number of look-ahead blocks.
"data" specifies the address of a variable for storing the start address of the array
that stores the contents of the program being executed.

[Example]
The following program displays an NC program being currently executed on the screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <conio.h>

#define BUFLEN 200

- 489 -
3.Function References PROGRAMMING B-64303EN-3/01

void example( void )


{
short ret, blknum ;
unsigned short length, idx, lcount, num1, num2 ;
char ch, data[BUFLEN] ;

printf( "\033[2J\033[1;1H" ) ;
printf( "< cnc_rdexecprog > press [CAN] to exit" ) ;
for (;;) {
length = BUFLEN ;
ret = cnc_rdexecprog( &length, &blknum, data ) ;
printf( "\033[2;1Hret=%2d length=%3u blknum=%d\n\n",
ret, length, blknum ) ;
if ( length ) printf( "\033[33;7m" ) ;
lcount = num1 = num2 = 0 ;
for ( idx = 0 ; idx < length ; idx++ ) {
ch = data[idx] ;
if ( ( ch == '\n' ) || ( ch == '%' ) ) {
if ( ch == '\n' )
printf( " ;" ) ;
else
putchar( '%' ) ;
printf( "\033[0m\033[K\n" ) ;
lcount++ ;
if ( lcount < blknum ) printf( "\033[33m" ) ;
num1 = num2 = 0 ;
}
else {
if ( ( ( ch >= '0' ) && ( ch <= '9' ) )
|| ( ch == '.' ) || ( ch == '#' )
|| ( ch == '+' ) || ( ch == '-' )
|| ( ch == ']' ) )
num2 = 1 ;
else
num2 = 0 ;
if ( ( num1 == 1 ) && ( num2 == 0 ) )
putchar( ' ' ) ;
putchar( ch ) ;
num1 = num2 ;
}
}
if ( kbhit() ) {
ch = getch() ;
if ( ch == MDIKEY_CAN ) break ;
}
printf( "\033[J" ) ;
}
}

- 490 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.66 Read manual overlapped motion value. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdmovrlap

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmovrlap( short axis, short length, struct iodbovl *buf ) ;

struct iodbovl {
short datano ; /* Not used. */
short type ; /* Axis number. */
long data[2][N] ; /* Override amount. */
} ; /* N is a maximum controlled axis number. */

[Arguments]
axis Axis number ( =-1:for only all axes).
length Data block length ( =4+4×32×2 ).
buf Buffer in which the manual overlapped motion value are stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
EW_NOOPT( 6) There are no required functions (manual handle interrupt function).

[Description]
Reads the amount of a manual interruption move in input and output units.

The data of all axes can be read at once by setting -1 in "axis" (data of an individual
axis cannot be read). The manual interruption move amount of each axis is stored in the
"data" array in "buf".

The decimal point position in the manual interruption move amount data can be obtained
with the “1.67 cnc_getfigure function”.

"axis" specifies the number of an axis for which the data is to be read. You can only
specify all axes.
-1: All axes

- 491 -
3.Function References PROGRAMMING B-64303EN-3/01

"length" specifies the data block length (size of "buf").

All axes
struct iodbovl 0┌───┐ ─
│dummy │ ↑
2├───┤ │
│type │ length
4├───┴───┐│
│ data[0][0] ││
8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[0][n-1]││
4+4×n├───────┤│
│ data[1][0] ││
4+4×(n+1)├───────┤│
~ ~│
4+4×(2n-1)├───────┤│
│ data[1][n-1]│↓
4+4×2n└───────┘─

n = maximum number of controlled axes (the data of the current number of axes is valid)

"type" is the axis number (-1 only).

"data" is the manual interruption move amount.


Input unit : data[0][0] to data[0][n-1]
Output unit: data[1][0] to data[1][n-1]
Two types of manual interruption move amounts are obtained.

[Example]
In a 3-axis system, the manual interruption move amounts of the axes are set as shown
below.
Input unit Output unit
1st axis 4.7246 120.005
2nd axis -1.9732 -50.119
3rd axis 0.0031 0.080
Then, execute the following program.
0: 47246 120005
1: -19732 -50119
2: 31 80
The values shown above are displayed (assuming that the inch input, metric output, and
increment system of IS-B are used).

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

- 492 -
B-64303EN-3/01 PROGRAMMING 3.Function References

void example( void )


{
struct iodbovl buf ;
short idx;
cnc_rdmovrlap ( -1, 260, &buf ) ;
for ( idx = 0 ; idx < 3 ; idx ++ ) {
printf ( "%d:%8ld %8ld\n",
idx, buf.data[0][idx], buf.data[1][idx] ) ;
}
}

- 493 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.67 Read the maximum number of significant figures and the number of decimal places. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_getfigure

[Syntax]
#include <fwindow.h>
short cnc_getfigure( short data_type, short *valid_fig,
short *dec_fig_in, short *dec_fig_out ) ;

[Arguments]
data_type Data type.
0: Axis data
1: Tool offset
2: Custom macro
valid_fig Buffer in which the maximum number of significant digits is stored.
dec_fig_in Buffer in which the number of decimal places in the input unit is stored.
The array must be large enough to cover the maximum number of controlled
axes.
Define dec_fig_in[CEX_MAXS].
(For data other than axis data, only the start of the array is valid.)
dec_fig_out Buffer in which the number of decimal places in the output unit is
stored.
The array must be large enough to cover the maximum number of controlled
axes.
Define dec_fig_out[CEX_MAXS].
(For data other than axis data, only the start of the array is valid.)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_ATTRIB( 4) Incorrect data type "data_type".

[Description]
Reads the maximum number of significant digits and the number of decimal places in the
input and output units for various kinds of CNC data.

The values that can be read by the window library are the binary data in the increment
system in the CNC. You must therefore make settings for the display of the decimal point
position and other items with consideration given to the increment system.

- 494 -
B-64303EN-3/01 PROGRAMMING 3.Function References

This function is effective when any of the following functions is used:

Axis data Tool offset Custom macro


cnc_absolute cnc_rdtofs cnc_rdmacro
cnc_machine cnc_rdtofsr cnc_rdmacror
cnc_relative cnc_rdpmacro
cnc_distance cnc_rdpmacror
cnc_skip
cnc_srvdelay
cnc_accdecdly
cnc_rddynamic
cnc_rdmovrlap
cnc_rdzofs
cnc_rdzofsr
cnc_rdwkcdshft

This function returns the following values:

- Maximum number of significant digits


Axis data 9 digits
Tool offset 9 digits
Custom macro 8 digits

- Number of decimal places in the input and output units

1) Axis data

Linear axis Rotation axis


[mm] [inch] [deg]
IS-A 2 3 2
IS-B 3 4 3
IS-C 4 5 4

* The metric/inch setting is made according to the following CNC parameter:


For the input unit -> Input increment system (bit 2 (INI) of parameter No. 0000)
For the output unit -> Detection unit on the linear axis of the machine (bit
0 (INM) of parameter No. 1001)

- 495 -
3.Function References PROGRAMMING B-64303EN-3/01

2) Tool offset
For the output unit, the number of decimal places is invalid.

Parameter OFC Parameter OFA Linear axis Linear axis


(No.5042#1) (No.5042#0) Metric input [mm] Inch input [inch]
0 1 2 3
0 0 3 4
1 0 4 5

3) Custom macro
For the input unit, only the number of decimal places for the first axis is valid.
For the output unit, the number of decimal places is invalid.

[mm] [inch]
IS-A 2 3
IS-B 3 4
IS-C 4 5

- 496 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.68 Read tool offset information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtofsinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtofsinfo( struct odbtlinf *buf ) ;

struct odbtlinf {
short ofs_type ; /* Memory type. */
short use_no ; /* Number of available offsets. */
} ;

[Arguments]
buf Buffer in which the tool offset information is stored.

[Return]
Main return value is as follows. For information about other return values, see Subsection
3.4.2, "Return values of data window functions" above in Part II, "PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the tool offset memory type and the number of available offsets.

The data is stored in "buf.ofs_type" and "buf.use_no" in binary format.

buf.ofs_type Offset memory type


For lathe systems
0: Disables tool geometry/wear compensation. (Parameter
NGW(No.8136#6)="1")
1: Enables tool geometry/wear compensation. (Parameter
NGW(No.8136#6)="0")
For machining center systems
0: Tool offset memory A (Parameter NGW(No.8136#6)="1")
1: Not used.
2: Tool offset memory C (Parameter NGW(No.8136#6)="0")

buf.use_no Number of available offsets


Number of tool compensation settings in the M series: 32/400 sets
Number of tool compensation settings in the T series: 32/64sets/99
sets(Use option)
Number of tool compensation settings in the T series (2-path control):
32/128sets/200 sets(Use option)

- 497 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.69 Search for sequence number. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_seqsrch

[Syntax]
#include <fwindow.h>
short cnc_seqsrch( long seq_no ) ;

[Arguments]
seq_no Sequence number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) The specified sequence number does not exist.
EW_MODE(12) CNC mode error.
The function can be used only in MEM mode.
EW_REJECT(13) CNC processing is rejected.
- The CNC is in editing mode.
- No machining program is registered.

[Description]
Searches the machining program currently selected in the CNC for the sequence number
specified by "seq_no".

- 498 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.70 Clear or preset relative position of controlled axis. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrrelpos

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrrelpos( short length, struct idbwrr *buf ) ;

struct idbwrr {
short datano ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Preset data. */
} ; /* N is the maximum number of controlled axes. */

[Arguments]
length Data block length (= 4+4×(number of axes for which data is to be read)).
buf Buffer in which preset data of the controlled axis relative positions
is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_ATTRIB( 4) Incorrect axis number "type".
EW_DATA( 5) Data error.
The data is out of a range that can be specified.
EW_REJECT(13) NC processing is rejected.

- 499 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
"length" specifies the data block length (size of "buf").

One axis All axes


buf 0┌───┐ ─ 0┌───┐ ─
│datano│ ↑ │datano│ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─

n = maximum number of controlled axes

Presets (resets) the relative position of the axis specified by "buf.type".


The data is preset in "buf.data[0]".

When 0 is specified as the preset data, the origin is specified (the relative position
is cleared to 0).

The data of all axes can be preset at once by setting -1 in "buf.type".


The data of each axis is preset in the "buf.data" array.

type Specifies the number of an axis for which the data is to be preset.
1 to m: One axis (m: number of currently controlled axes)
-1 : All axes

data Specifies a value to be preset.


data[0] : One axis
data[0] to data[m-1]: All axes

- 500 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.71 Read actual spindle speed (S) (multiple spindles allowed, read of specified axis) (2).
<Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_acts2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_acts2( short sp_no, struct odbact2 *buf ) ;

struct odbact2 {
short datano ; /* Spindle number. */
short type ; /* Not used. */
long data[MAX_SPINDLES] ; /* Spindle data. */
} ; /* MAX_SPINDLES : Maximum number of spindles. */

[Arguments]
sp_no Number of a spindle for which the data is to be read.
ALL_SPINDLES : All spindles (ALL_SPINDLES: -1)
1 to MAX_SPINDLES: One spindle
MAX_SPINDLES is the maximum number of spindles.
buf Buffer in which the actual speed of each spindle is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER(3) Data number error.
Incorrect spindle number "sp_no".

[Description]
Reads the actual speed of a spindle in the CNC.

The actual spindle speed data is stored in "buf.data[0]".

The data of all spindles can be read at once by setting -1 in "sp_no". The actual speed
data of each spindle is stored in the "buf.data" array.

The cnc_acts function allows you only to obtain the actual speed of the selected spindle.
With the cnc_acts2 function, however, you can specify the spindle for which the actual
speed is to be obtained, and can also obtain the data of all spindles.

The following parameter is related to this function:


- Bit 2 (ASDs) of parameter No. 3799

- 501 -
3.Function References PROGRAMMING B-64303EN-3/01

Refer to "Parameter Manual" (B-64310EN) of the CNC for details about the parameters.

[Example]

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
short sp_no ;
struct odbact2 buf ;
int i ;

cnc_acts2( sp_no, &buf ) ;

for(i = 0; i < MAX_SPINDLES; i++ ){


printf( "SPINDLE DATA =%ld\n", buf.data[i] ) ;
}
}

- 502 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.72 Read workpiece coordinate system shift. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdwkcdshft

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdwkcdshft( short axis, short length,
struct iodbwcsf *wkcdshft );

struct iodbwcsf {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Workpiece coordinate system shift. */
} ;
/* N is the maximum number of controlled axes. */

[Arguments]
axis Axis number (= (1 to the maximum number of controlled axes), or -1)
1 to m: One axis (m: number of currently controlled axes)
-1 : All axes
length Data block length (= 4+4×(number of axes for which data is to be read)).
wkcdshft Buffer in which the workpiece coordinate system shift data is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The function is disabled.
The function cannot be used for the M series.
EW_LENGTH( 2) Incorrect data length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
EW_PARAM( 9) CNC parameter error.
Set bit 6 (NWS) of parameter No. 1201 to 0.

- 503 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the workpiece coordinate system shift of the axis specified by "axis".

"length" specifies the data block length (size of "wkcdshft").

One axis All axes


wkcdshft 0┌───┐ ─ 0┌───┐ ─
│dummy │ ↑ │dummy │ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─

n = number of controlled axes

The workpiece coordinate system shift data is stored in the "data" array in "wkcdshft"
in signed binary format.
The data of all axes can be read at once by setting -1 in "axis".

The decimal point position in the workpiece coordinate system shift data can be obtained
with the “1.67 cnc_getfigure function”.

- 504 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.73 Write workpiece coordinate system shift. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrwkcdshft

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrwkcdshft( short length, struct iodbwcsf *wkcdshft ) ;

struct iodbwcsf {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Workpiece coordinate system shift. */
} ;
N: maximum number of controlled axes

[Arguments]
length Data block length (=4+4×(number of axes for which data is to be read))
wkcdshft Buffer in which the workpiece coordinate system shift data is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The function is disabled.
The function cannot be used for the M series.
EW_LENGTH( 2) Incorrect data length "length".
EW_ATTRIB( 4) Incorrect axis number "axis".
EW_DATA( 5) Incorrect NC program data.
The workpiece coordinate system shift in "data" is out of a range that
can be specified.
EW_PROT( 7) Write protection.
Set bit 3 (WZO) of parameter No. 3290 to 0.
EW_PARAM( 9) CNC parameter error.
Set bit 6 (NWS) of parameter No. 1201 to 0.
EW_REJECT(13) CNC processing is rejected.
The automatic operation start signal STL <F000.5> is 1.

- 505 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Writes the workpiece coordinate system shift of the axis specified by "type".

The workpiece coordinate system shift data is set in the "data" array in "wkcdshft" in
signed binary format.

The data of all axes can be written at once by setting -1 in "type".

"length" specifies the data block length (size of "wkcdshft").

One axis All axes


wkcdshft 0┌───┐ ─ 0┌───┐ ─
│dummy │ ↑ │dummy │ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1)├───────┤│
│ data[n-1] │↓
4+4×n└───────┘─

n = number of controlled axes

"type" specifies the number of an axis for which the data is to be written.
1 to m: One axis (m: number of currently controlled axes)
-1 : All axes

"data" specifies a value to be written.


data[0] : One axis
data[0] to data[m-1]: All axes

The shift units are the same as those of the cnc_rdwkcdshft function described in "Reads
workpiece coordinate system shift". See an explanation of that function.

- 506 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.74 Read program storage drive information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpdf_drive

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpdf_drive ( struct odbpdfdrv *pdf_drv ) ;

struct odbpdfdrv {
short max_num; /* Maximum number of drives. */
short dummy;
char drive[16][12]; /* Drive name string. */
} ;

[Arguments]
pdf_drv Buffer in which the program storage drive information is stored.

[Return]
Main return value is as follows. For information about other return values, see Subsection
3.4.2, "Return values of data window functions" above in Part II, "PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the program storage drive information.

The execution of the function is delayed when the CNC is in editing mode (including
background editing state).

"max_num" is the maximum number of returned drive names.


Up to 16 drive names can be returned.

"drive" is the drive name string.


"max_num" strings (drive[0] to drive[max_num-1]) are valid.
A drive name string contains up to 8 characters and is null-terminated.

* "dummy" is not used.

- 507 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.75 Read program storage file information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpdf_inf

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpdf_inf(char *drive, short size_kind,
struct odbpdfinf *pdf_inf);

struct odbpdfinf {
long used_page; /* Program storage in use. */
long all_page; /* Total program storage. */
long used_dir; /* Number of folders (programs) in use. */
long all_dir; /* Total number of folders (programs). */
} ;

[Arguments]
drive Drive name string.
A drive name string contains up to 8 characters and is NULL-terminated.
size_kind Data units of "used_page" and "all_page".
0: Page
1: Byte
2 : Kbyte(1Kbyte=1024bytes)
3 : Mbyte(1Mbyte=1024Kbytes)
pdf_inf Buffer in which the program storage drive information is stored.
used_page Program storage in use.
all_page Total program storage.
The unused program storage is obtained by ("all_page" - "used_page").
used_dir Number of folders (programs) in use.
all_dir Total number of folders (programs).
The number of unused folders (programs) is obtained by ("all_dir" -
"used_dir").

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) The drive specified by the data "drive" does not exist.

- 508 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the information about the program storage file on the specified drive.

The execution of the function is delayed when the CNC is in editing mode (including
background editing state).

- 509 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.76 Read current folder information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpdf_curdir

[Syntax]
#include <fwindow.h>
short cnc_rdpdf_curdir(short dir_kind, char *dir_name) ;

[Arguments]
dir_kind Type of the current folder for which data is to be read.
1: Foreground
2: Background
dir_name Pointer for returning the current drive and folder string.
Although up to 210 characters are valid, the size of 212 bytes should
be provided.
The string is NULL-terminated.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_ATTRIB( 4) Incorrect data "dir_kind".

[Description]
Reads the current folder information.

The execution of the function is delayed when the CNC is in editing mode (including
background editing state).

- 510 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.77 Set current folder. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrpdf_curdir

[Syntax]
#include <fwindow.h>
short cnc_wrpdf_curdir(short dir_kind, char *dir_name) ;

[Arguments]
dir_kind Type of the current folder to be set.
1: Foreground
2: Background
dir_name Pointer for returning the current drive and folder string.
Although up to 210 characters are valid, the size of 212 bytes should
be provided.
The string is null-terminated.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_ATTRIB( 4) Incorrect data "dir_kind".
EW_DATA( 5) The folder specified by the data "dir_name" does not exist.
EW_REJECT(13) CNC processing is rejected.

[Description]
Sets the current folder.

The execution of the function is delayed when the CNC is in editing mode (including
background editing state).

- 511 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.78 Read subfolder information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpdf_subdir

[Syntax]
#include <data.h>
#include <fwindow.h>

short cnc_rdpdf_subdir( short *num_dir, struct idbpdfsdir *pdf_sdir_in,


struct odbpdfsdir *pdf_sdir_out);

struct idbpdfsdir {
/* input */
char path[212]; /* Path name string. */
short req_num; /* Request entry number. */
short dummy;
};

struct odbpdfsdir {
/* output */
short sub_exist; //* Whether a subfolder is included. */
short dummy;
char d_f[36]; /* Folder name string. */
};

[Arguments]
num_dir[in/out]
[in] : Specify the maximum number of folders for which the data is to be read.
[out]: The number of folders for which the data has actually been read is set.
pdf_sdir_in Buffer in which the folder setting is stored.
pdf_sdir_out Storage buffer to which the subfolder information is returned.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_BUSY(-1) The CNC is in use.
EW_NUMBER( 3) Data number error.
No subfolder exists for the data "req_num".
EW_DATA( 5) Data error.
Incorrect format for the folder name "path".
EW_PROT( 7) Protection.
The specified folder cannot be displayed.
EW_REJECT(13) CNC processing is rejected.

- 512 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the information about the subfolder in the specified folder.

The execution of the function is delayed when the CNC is in editing mode (including
background editing state).

If the creation, deletion, or any other subfolder editing operation is performed in the
period between the first request and the last request, the function returns the
information based on the data at the time when the function is called.

"path" sets the drive name and folder name string.


The string is null-terminated.

"req_num" sets the ordinal number of the subfolder for which you want to get information.
Normally, start the number with 0 and increment the number by 1.
(The number of the first subfolder is 0.)

"sub_exist" indicates whether a sub-subfolder is included in the subfolder for which


the data has been output.
0: Not included.
1: Included.

"d_f" is the subfolder name string. The string is NULL-terminated.

* "dummy" is not used.

- 513 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.79 Read file list information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpdf_alldir

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpdf_alldir( short *num_prog,
struct idbpdfadir *pdf_adir_in, struct odbpdfadir *pdf_adir_out);

struct idbpdfadir {
/* input */
char path[212]; /* Path name character string. */
short req_num; /* Required entry number. */
short size_kind; /* Size output format. */
short type; /* Program list type */
short dummy;
};
struct odbpdfadir {
/* output */
short data_kind; /* Kind of data. */
short year; /* Date and time of last editing (year). */
short mon; /* Date and time of last editing (month). */
short day; /* Date and time of last editing (day). */
short hour; /* Date and time of last editing (hour). */
short min; /* Date and time of last editing (minute). */
short sec; /* Date and time of last editing (second). */
short dummy;
long dummy2;
long size; /* Size. */
unsigned long attr; /* Attribute. */
char d_f[36]; /* Name character string.*/
char comment[52]; /* Comment. */
char o_time[12]; /* Machining time stamp. */
};

[Arguments]
num_prog
[in] : Specify the maximum number of programs to be read.
[out] : The number of programs actually read is set.
pdf_adir_in Buffer to which the folder setting is passed.
pdf_adir_out Buffer to which folder list information is returned.

- 514 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_BUSY(-1) Currently used by the NC.
EW_NUMBER( 3) Data number error.
There is no subfolder for the data (req_num).
EW_ATTRIB( 4) The specified size_kind or type value is invalid.
EW_DATA( 5) The path data is invalid.
EW_REJECT(13) CNC processing is rejected.

[Description]
Reads file list information in a folder.

When editing (including background editing) is being made on the CNC side, the execution
of this function is placed in the wait state.

When folder or file editing such as creation or deletion is performed during the time
from the first request until the last request, data is returned based on the data present
when a request is made.

Set a drive name and a folder name in path.


Set a NULL character at the end of the path.
The drive name of the memory card is "//MEMCARD/".
The drive name of the data server is "//DATA_SV/".
Specify the following paths for the program folder of the CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/"
Path 2:"//CNC_MEM/USER/PATH2/"

In req_num, set a number indicating a folder or file position in the order of


folders/files to request information about that folder or file.
Normally, numbers begin with 0 and are incremented by one.
(The first subfolder is assigned 0.)

size_kind sets the data unit of size.


0 : Page
1 : Byte
2 : K bytes(1K byte=1024 bytes)
3 : M bytes(1M bytes=1024K bytes)

type specifies the type of program list information to be read.


0 : Does not acquire the size, comment, and machining time stamp.
1 : Acquires the size, comment, and machining time stamp.
(Specifying 0 allows faster operation.)

data_kind indicates the kind of the data.


0 : Folder
1 : File

- 515 -
3.Function References PROGRAMMING B-64303EN-3/01

year indicates the date and time of last editing (year). It is valid only for files.

mon indicates the date and time of last editing (month). It is valid only for files.

day indicates the date and time of last editing (day). It is valid only for files.

hour indicates the date and time of last editing (hour). It is valid only for files.

min indicates the date and time of last editing (minute). It is valid only for files.

sec indicates the date and time of last editing (second). It is valid only for files.

size indicates the file size ("0" to "99999999"). It is valid only for files.
It is valid when the type argument is set to "1".

attr is the file/folder attribute.


Folder attribute
#0 : Editing disable attribute 0: Enabled, 1: Disabled
#1 : Editing/display disable attribute 0: Enabled, 1: Disabled
File attribute
#0 : Editing disable attribute 0: Enabled, 1: Disabled
#1 : Editing/display disable attribute 0: Enabled, 1: Disabled
#2 : Encryption attribute 0: OFF 1: ON
#8 to #10 : Change protection level
Numeric value from "0" to "7" where #10 is the MSB and #8
is the LSB
#12 to #14 : Output protection level
Numeric value from "0" to "7" where #14 is the MSB and #12
is the LSB
The bits other than the bits described above are ignored.

d_f is a folder/file name character string. It ends with a NULL character.

In comment, data recorded immediately after the program number is stored.


A comment consists of up to 48 characters (up to 50 characters when the parentheses before
and after the comment are included).
If a comment consisting of more than 48 characters is recorded, the 49th and subsequent
characters of the comment are not output.
When a program has no comment, only parentheses ("()") are stored.
The character string ends with a NULL character. comment is valid only for files.
comment is valid when the type argument is set to "1".

o_time stores the machining time stamp (a comment in the format of "(xxxHxxMxxS)")
recorded immediately after the program number.
The character string ends with a NULL character. o_time is valid only for files.
It is valid when the type argument is set to "1".

* dummy and dummy2 are not used.

- 516 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.80 Create folder or file. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_add

[Syntax]
#include <fwindow.h>
short cnc_pdf_add( char *file_path ) ;

[Arguments]
file_path Set a drive name, a folder character string, and a file name.
Up to 242 characters can be used. Set a NULL character at the end.
When specifying a folder name, place "/" at the end of the character
string.
If "/" is not present, a file name is assumed to be specified.
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Set the following paths when creating a file in the program folder of
the CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/xxxx" (xxxx is file name.)
Path 2:"//CNC_MEM/USER/PATH2/xxxx" (xxxx is file name.)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : File or folder name format error.
2 : The specified folder name is not found.
3 : The maximum allowable number of registered files is exceeded.
4 : The same file name is already present.
5 : The specified file or folder name is selected by the NC.
EW_PROT( 7) Write protection.
The specified file or folder is write-protected.
EW_OVRFLOW( 8) Memory overflow.
File or folder creation is impossible because of insufficient memory
space.
EW_REJECT(13) CNC processing is rejected.
The CNC is operating.

- 517 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Creates a folder or file in the specified folder for the memory card or data server.
A file is created in the CNC memory.
If editing (including background editing) is being made on the CNC side, execution is
put off.
A file with the same number or same name cannot be created.
A folder with the same name cannot be created.
If a folder is read-only, neither a file nor folder can be created in the folder.
A folder cannot be created in the CNC memory.

- 518 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.81 Delete folder or file. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_del

[Syntax]
#include <fwindow.h>
short cnc_pdf_del( char *file_path );

[Arguments]
file_path Set a drive name, a folder character string, and a file name.
Up to 242 characters can be used. Set a NULL character at the end.
When specifying a folder name, place "/" at the end of the character
string.
If "/" is not present, a file name is assumed to be specified.
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
When specifying a file in the program folder of the CNC memory, specify
the following paths.
Path 1:"//CNC_MEM/USER/PATH1/xxxx" (xxxx is file name.)
Path 2:"//CNC_MEM/USER/PATH2/xxxx" (xxxx is file name.)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : File or folder name format error.
2 : The specified folder name is not found.
5 : The specified file or folder name is selected by the NC.
Alternatively, when a folder is deleted, the folder is not
empty.
EW_PROT( 7) Write protection.
The specified file or folder is write-protected.
EW_REJECT(13) CNC processing is rejected.
The NC is operating.

- 519 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Creates a folder or file in the specified folder for the memory card or data server.
A file is created in the CNC memory.
If editing (including background editing) is being made on the CNC side, execution is
put off.
A specified file cannot be deleted when being operated or selected in the foreground.
It cannot also be deleted when protected.
A specified folder cannot be deleted when selected as the current folder.
It cannot also be deleted when not empty.

- 520 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.82 Rename folder or file. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_rename

[Syntax]
#include <fwindow.h>
short cnc_pdf_rename( char *file_path, char *d_d_f );

[Arguments]
file_path Set a drive name, a folder character string, and a file name.
Up to 242 characters can be used. Set a NULL character at the end.
When specifying a folder name, place "/" at the end of the character
string.
If "/" is not present, a file name is assumed to be specified.
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
When renaming the program folder of the CNC memory, specify the
following paths.
Path 1:"//CNC_MEM/USER/PATH1/xxxx" (xxxx is file name.)
Path 2:"//CNC_MEM/USER/PATH2/xxxx" (xxxx is file name.)
d_d_f Folder or file name character string after renaming.
Up to 33 characters can be used. Set a NULL character at the end.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : File or folder name format error.
2 : The specified folder name is not found.
4 : The same file name is already present.
5 : The specified file or folder name is selected by the NC.
EW_PROT( 7) Write protection.
The specified file or folder is write-protected.
EW_REJECT(13) CNC processing is rejected.
- The CNC is operating.
- The emergency stop state is present.

- 521 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Creates a folder or file in the specified folder for the memory card or data server.
A file is created in the CNC memory.
If editing (including background editing) is being made on the CNC side, execution is
put off.
A specified file cannot be renamed when being operated or selected in the foreground.
It cannot also be renamed when protected.
A specified file cannot be renamed when selected as the current folder or a folder above
the current folder.

- 522 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.83 Select main program. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_slctmain

[Syntax]
#include <fwindow.h>
short cnc_pdf_slctmain( char *file_path );

[Arguments]
file_path Set a drive name, a folder character string, and a file name.
Up to 242 characters can be used. Set a NULL character at the end.
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths when selecting a program in the program
folder of the CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/xxxx" (xxxx is file name.)
Path 2:"//CNC_MEM/USER/PATH2/xxxx" (xxxx is file name.)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : File or folder name format error.
2 : The specified folder name is not found.
EW_MODE(12) CNC mode error.
This function can be used only in the EDIT/MEM mode.

[Description]
Selects a file in a specified folder as the main program.

When editing (including background editing) is being made on the CNC side, the execution
of this function is placed in the wait state.

- 523 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.84 Consolidate programs. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_cond

[Syntax]
#include <fwindow.h>
short cnc_pdf_cond( char *file_path );

[Arguments]
file_path Set a drive name, a folder character string, and a file name.
Up to 242 characters can be used. Set a NULL character at the end.
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths when selecting the program folder of the
CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/xxxx" (xxxx is file name.)
Path 2:"//CNC_MEM/USER/PATH2/xxxx" (xxxx is file name.)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : File or folder name format error.
2 : The specified folder name is not found.
5 : The specified file or folder name is selected by the NC.
EW_PROT( 7) Write protection.
The specified file or folder is write-protected.
EW_REJECT(13) CNC processing is rejected.
The CNC is operating.

[Description]
Consolidates a file in a specified folder.

When editing (including background editing) is being made on the CNC side, the execution
of this function is placed in the wait state.
When a specified file is being used for operation or selected in the foreground,
consolidation is impossible. Also when the file is protected, consolidation is
impossible.

- 524 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.85 Change attribute of folder or file. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrpdf_attr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrpdf_attr( char *file_path, struct idbpdftdir *pdf_tdir );

struct idbpdftdir {
unsigned long slct; /* Selection. */
unsigned long attr; /* Setting. */
};

[Arguments]
file_path Set a drive name, a folder character string, and a file name.
Up to 242 characters can be used. Set a NULL character at the end.
When specifying a folder name, place "/" at the end of the string.
If "/" is not present, a file name is assumed to be specified.
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths when selecting a file in the program folder
of the CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/xxxx" (xxxx is file name.)
Path 2:"//CNC_MEM/USER/PATH2/xxxx" (xxxx is file name.)
pdf_tdir Buffer in which information about the folder or file to be changed is
stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : File or folder name format error.
2 : The specified folder name is not found.
5 : The specified file or folder name is selected by the NC.
EW_PROT( 7) Write protection.
The specified file or folder is write-protected.
Alternatively, the file or folder is protected with a protection level.
EW_REJECT(13) CNC processing is rejected.

- 525 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Changes the attribute of a folder or file in a specified folder.

When editing (including background editing) is being made on the CNC side, the execution
of this function is placed in the wait state.
When a specified folder is selected as the current folder, its attribute cannot be
changed.

In slct, set only the bit of the attribute to be changed to "1". Set bits other than
the described bits to "0".

attr sets attribute data applied after the change. The bit that is set to "1" in slct
is changed to the data set in attr.

Folder attribute
#0 : Editing disable attribute 0: Enabled, 1: Disabled
#1 : Editing/display disable attribute 0: Enabled, 1: Disabled

File attribute
#0 : Editing disable attribute 0: Enabled, 1: Disabled
#1 : Editing/display disable attribute 0: Enabled, 1: Disabled
#2 : Encryption attribute 0: OFF 1: ON
#8 to #10 : Change protection level
Numeric value from "0" to "7" where #10 is the MSB and #8
is the LSB
#12 to #14 : Output protection level
Numeric value from "0" to "7" where #14 is the MSB and #12
is the LSB

When changing the change protection level or output protection level, set all of the
relevant three bits in slct to "1".

- 526 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.86 Get the number of folders and files in specified folder. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpdf_subdirn

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdpdf_subdirn( char *dir_name, struct odbpdfnfil *pdf_nfil);

struct odbpdfnfil {
/* input */
short dir_num; /* Number of folders. */
short file_num; /* Number of files. */
} ;

[Arguments]

dir_name Set the current drive and folder character string.


Up to 210 characters can be used although a 212-byte area is prepared.
Set a NULL character at the end.
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths when selecting the program folder of the
CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/xxxx" (xxxx is file name.)
Path 2:"//CNC_MEM/USER/PATH2/xxxx" (xxxx is file name.)
pdf_nfil Buffer to which the number of folders and the number of files are passed.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : File or folder name format error.
2 : The specified folder name is not found.
EW_REJECT(13) CNC processing is rejected.
The NC is operating.

[Description]
Acquires the numbers of subfolders and files in a specified folder.

- 527 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.87 Get main program information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_rdmain

[Syntax]
#include <fwindow.h>
short cnc_pdf_rdmain( char *dir_name );

[Arguments]
dir_name Pointer to the current drive and a folder character string.
Up to 242 characters can be used although a 244-byte area is prepared.
A NULL character is set at the end.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_REJECT(13) CNC processing is rejected.

[Description]
Reads information about the file currently selected as the main program.

- 528 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.88 Get CNC information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_information

[Syntax]
#include <fwindow.h>
short cnc_information( long type, long *data );

[Arguments]
type Set the type of information to be acquired.
data Specify the area for storing acquired data.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) The value specified in type is invalid.

[Description]
Acquires CNC information.

When type = MDI_TYPE(1)


MDI_TYPE_STDA_T ( 8) :Standard type ONG MDI keyboard (T series)
MDI_TYPE_STDA_M ( 9) :Standard type ONG MDI keyboard (M series)
MDI_TYPE_SMLW_T (10) :Small horizontal type ONG MDI keyboard (T series)
MDI_TYPE_SMLW_M (11) :Small horizontal type ONG MDI keyboa (M series)
MDI_TYPE_SMLL_T (12) :Small vertical type ONG MDI keyboard (T series)
MDI_TYPE_SMLL_M (13) :Small vertical type ONG MDI keyboard (M series)
MDI_TYPE_OTHER (-1) :Other MDI keyboards

When type = ONUM_TYPE(2)


data = ONUM_TYPE_4D(1) : Four-digit program number display status

- 529 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.89 Read series and edition of CNC system software. (3) <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdsyssoft3

[Syntax]
#include <fwindow.h>
#include <data.h>
short cnc_rdsyssoft3( short s_id , short *read_num , short *all_num ,
struct odbsyss3 *syssoft3 ) ;

struct odbsyss3 {
short soft_id ; /* Software ID. */
char soft_series[5] ; /* Software series. */
char soft_edition[5] ; /* Software edition. */
};

[Arguments]
s_id Specify a starting ID of series and edition information to be read.
Information is acquired sequentially from a specified ID to greater
IDs.
To read all series and edition information, set s_id to 0 to acquire
data for the first time, and for the second and subsequent operations,
repeat execution while incrementing the s_id value by one (setting the
ID acquired last plus 1).
read_num Specify a pointer to the number of software products to be read.
Specify the number of software products before calling the function.
After the function is called, the number of software products actually
read is set in this argument.
A value ranging from 1 to 40 can be specified.
If no data item can be read, read_num = 0 is returned.
all_num The total number of software products is set.

syssoft3 Buffer in which CNC system software series and edition information is stored.
soft_id Software ID
A numeric value indicating the type of each software product is stored.
Main software IDs are listed below.
0101H : CNC basic software
0102H : CNC optional software A1
0103H : CNC optional software A2
0104H : CNC optional software A3
0111H : CNC language ROM English (Basic)
0112H : CNC language ROM Japanese
0113H : CNC language ROM German
0114H : CNC language ROM French
0115H : CNC language ROM Chinese (traditional characters)
0116H : CNC language ROM Italian

- 530 -
B-64303EN-3/01 PROGRAMMING 3.Function References

0117H : CNC language ROM Korean


0118H : CNC language ROM Spanish
0119H : CNC language ROM Dutch
011AH : CNC language ROM Danish
011BH : CNC language ROM Portuguese
011CH : CNC language ROM Polish
011DH : CNC language ROM Hungarian
011EH : CNC language ROM Swedish
011FH : CNC language ROM Czech
0120H : CNC language ROM Chinese (simplified characters)
0121H : CNC language ROM Russian
0122H : CNC language ROM Tuykish

0151H : BOOT software

0201H : PMC system software 1


0211H : PMC ladder 1(1st ladder)

0301H : Servo software 1


0302H : Servo software 2
0303H : Servo software 3
0304H : Servo software 4
0305H : Servo software 5
0306H : Servo software 6
0307H : Servo software 7
0308H : Servo software 8
0309H : Servo software 9
030AH : Servo software 10

0501H : 1st spindle software


0502H : 2nd spindle software
0503H : 3rd spindle software
0504H : 4th spindle software
0505H : 5th spindle software
0506H : 6th spindle software
0507H : 7th spindle software
0508H : 8th spindle software
050AH : 10th spindle software
050BH : 11th spindle software
050CH : 12th spindle software
050DH : 13th spindle software
050EH : 14th spindle software
050FH : 15th spindle software
0510H : 16th spindle software

0601H : Graphic software 1


0602H : Graphic software 2
0603H : Graphic software 3
0604H : Graphic software 4 (font data)

- 531 -
3.Function References PROGRAMMING B-64303EN-3/01

0701H : Macro executor 1


0702H : Macro executor 2
0703H : Macro executor 3
0704H : Macro executor 4
0705H : Macro executor 5
0706H : Macro executor 6
0707H : Macro executor 7
0708H : Macro executor 8
0709H : Macro executor 9
070AH : Macro executor 10
070BH : Macro executor 11
070CH : Macro executor 12
070DH : Macro executor 13
070EH : Macro executor 14
070FH : Macro executor 15
0710H : Macro executor 16
0711H : Macro executor 17
0712H : Macro executor 18
0713H : Macro executor 19
0714H : Macro executor 20

075AH : MANUAL GUIDE i


(Macro executor for M series)
075BH : MANUAL GUIDE i
(Macro executor for T series)
075CH : TURN MATE i
(T series execution macro)
075DH : MANUAL GUIDE 0i
(M series execution macro)
075EH : MANUAL GUIDE 0i
(M series conversational macro)
075FH : MANUAL GUIDE 0i
(T series execution macro)
0760H : MANUAL GUIDE 0i
(T series conversational macro)

0801H : C Language Library


0802H : Application program for C Language Executor
0811H : Library for MANUAL GUIDE i
0812H : System software for MANUAL GUIDE i

0820H : C Language Executor data file 0


0821H : C Language Executor data file 1
0822H : C Language Executor data file 2
0823H : C Language Executor data file 3
0824H : C Language Executor data file 4
0825H : C Language Executor data file 5
0826H : C Language Executor data file 6

- 532 -
B-64303EN-3/01 PROGRAMMING 3.Function References

0827H : C Language Executor data file 7


0828H : C Language Executor data file 8
0829H : C Language Executor data file 9

0901H : Network management


0911H : Embedded Ethernet
0921H : PROFIBUS 1
0922H : PROFIBUS 2
0927H : PROFIBUS 3
0931H : Data server

soft_series Software series.


The software series used is stored in ASCII code (4 bytes +
NULL character).
soft_edition Software edition
The software edition used is stored in ASCII code (4 bytes +
NULL character).

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the series and editions of CNC system software products.

Information is stored in members of syssoft3.


The series and editions of usable system software products can be read.
There is no path-dependent data.

- 533 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.90 Start output of NC program to be registered (4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_dwnstart4

[Syntax]
#include <fwindow.h>
short cnc_dwnstart4( short type, char *file_name ) ;

[Arguments]
type Specify the type of CNC data to be registered.
0 : NC program
1 : Tool offset
2 : Parameter
3 : Pitch error compensation amount
4 : Custom macro variable
5 : Work origin offset
file_name Drive name and folder name (up to 241 characters) of a program.
Valid only when type = "0".
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths when selecting the program folder of the
CNC memory.
Path 1:"//CNC_MEM/USR/PATH1/"
Path 2:"//CNC_MEM/USR/PATH2/"

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_BUSY(-1) Processing for requesting the start of the output of an NC program to
be compared is rejected.
The cnc_dwnstart4 function (cnc_vrfstart function) has already been
executed.
Use the cnc_dwnend4 function (cnc_vrfend function) to end the previous
output operation.
EW_ATTRIB( 4) The specified type is invalid.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : Folder name error
EW_NOOPT( 6) A required function is not provided.

- 534 -
B-64303EN-3/01 PROGRAMMING 3.Function References

When registering a custom macro variable, workpiece origin offset, or


pitch error, enable the custom macro, workpiece coordinate system, or
stored pitch error compensation, respectively.
EW_PARAM( 9) CNC parameter error.
When parameter data is registered, parameter writing must be enabled
by setting.
EW_MODE(12) CNC mode error.
- When registering tool offset or custom macro variable data, set the
MDI mode or the emergency stop state.
- When registering parameter, pitch error, or work origin offset data,
set the emergency stop state.
- When background editing (NC program) is being performed in the CNC,
end background editing in the CNC.
EW_REJECT(13) CNC processing is rejected.
The CNC is operating. Registration of data except NC programs is not
permitted during operation.
EW_ALARM(15) Alarm state.
Alarm PW0000 or alarm PS0101 is issued in the CNC. Release the alarm
in the CNC.

[Description]
Requests the CNC to start registering (downloading) NC data (such as an NC program, tool
offsets, or parameters). (This function must be executed before downloading is
performed.)

If the cnc_download4 or cnc_dwnend4 function is executed without executing this function,


EW_FUNC is returned.

The basic downloading procedure is shown below.

cnc_dwnstart4

= EW_OK

Reexecute
Output NC data.
= EW_RESET cnc_download4 = EW_BUFFER

= EW_OK

Is any data left?


Yes
No

cnc_dwnend4

Specify a program with a folder and a file name.


So, it is impossible to download more than one program by specifying a range.

- 535 -
3.Function References PROGRAMMING B-64303EN-3/01

When data is to be output to a memory card or data server, the full path of an output
destination folder must be set in the 'file_name' argument of the cnc_dwnstart4 function.
To access a data server, specify and execute the function as shown in the following
example:
Example) Output to DATA_SV
ret = cnc_dwnstart4(0, "//DATA_SV/") ;

- 536 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.91 Output NC program to be registered (4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_download4

[Syntax]
#include <fwindow.h>
short cnc_download4( long *length, char *data );

[Arguments]
length Specify a pointer to a long variable that holds the number of NC data
characters to be output.
When control is returned from this function, the number of characters
actually output is set.
When the specified number of output characters is 0 or a smaller value,
EW_LENGTH is returned.
data Specify the starting address of an area in which NC data to be output
is set.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_RESET(-2) The CNC has been reset.
Call the cnc_dwnend4 function.
EW_FUNC( 1) The CNC does not complete start processing for outputting an NC program
to be registered. Alternatively, the cnc_dwnstart4 function has not
been executed.
EW_LENGTH( 2) The specified data length is invalid.
A negative value is specified as the number of output characters.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : Syntax error in NC data.
2 : When the TV check is enabled, a block that consists of an
odd number of characters (including LF at the end of the block)
is detected
3 : The maximum allowable number of registered NC programs is
exceeded.
4 : The same program number is already registered.
5 : The same program number is selected by the NC.

- 537 -
3.Function References PROGRAMMING B-64303EN-3/01

EW_PROT( 7) Write protection.


CNC parameters (protection or encryption of programs in the eight or
nine thousands) are write-protected. For the timing of the occurrence
of this error, see [Description].
EW_OVRFLOW( 8) The program memory area of the CNC becomes full, so data cannot be
registered any more. For the timing of the occurrence of this error,
see [Description].
EW_BUFFER(10) The buffer is full.
The buffer is full. Retry.
For the timing of the occurrence of this error, see [Description].

[Description]
Outputs (downloads) NC data to be registered.

This function outputs as many characters as specified in *length. If the available space
in the buffer for data transfer to the CNC is insufficient for the specified number of
characters, data as much as the available space is output, and the number of the
characters of the output data is set in *length.
If even one character cannot be output, EW_BUFFER is returned. When this value is returned,
the function must be called again.

Because priority is given to the speed of data transfer to the CNC, an error (such as
EW_DATA or EW_OVRFLOW) is generally returned with delay. This means that an error output
at a certain point of time is sometimes due to data that was output in several data output
operations preceding that point. An error that occurs in several data output operations
preceding the end of the function is returned by cnc_dwnend4.

Output data format

NC data registered in the CNC consists of ASCII strings in the following format:

LF block-1 LF block-2 LF ... LF block-n LF %


where, LF = 0x0A ('\n')

Add LF to the beginning of the entire data and % to the end. Data preceding the beginning
LF is ignored.

When the data to be output is an NC program, be sure to specify a program number following
address "0" at the beginning of the program to be registered.
For example, when registering the following program:
O1234 ;
G1 F0.3 W10. ;
M30 ;
%

Transfer the following by using the cnc_download4 function.

"\nO1234\nG1F0.3W10.\nM30\n%"

- 538 -
B-64303EN-3/01 PROGRAMMING 3.Function References

It is also possible to divide data into several parts and transfer them separately.
The data shown in the above example may also be transferred on a block-by-block basis
as follows:
"\n"
"O1234\n"
"G1F0.3W10.\n"
"M30\n"
"%"

Furthermore, it is also possible to divide one block into several parts and transfer
them separately.

- 539 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.92 Stop output of NC program to be registered (4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_dwnend4

[Syntax]
#include <fwindow.h>
short cnc_dwnend4( void );

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The CNC does not complete start processing for outputting an NC program
to be registered. Alternatively, the cnc_dwnstart4 function has not
been executed.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : Syntax error in NC data.
2 : When the TV check is enabled, a block that consists of an
odd number of characters (including LF at the end of the block)
is detected
3 : The maximum allowable number of registered NC programs is
exceeded.
4 : The same program number is already registered.
5 : The same program number is selected by the NC.
EW_PROT( 7) Write protection.
CNC parameters (protection or encryption of programs in the eight or
nine thousands) are write-protected. For the timing of the occurrence
of this error, see [Description].
EW_OVRFLOW( 8) The program memory area of the CNC becomes full, so data cannot be
registered any more. For the timing of the occurrence of this error,
see [Description].

[Description]
Notifies the CNC of the end of NC data registration. (This function must be used after
downloading ends.)

- 540 -
B-64303EN-3/01 PROGRAMMING 3.Function References

An error (such as EW_DATA or EW_OVRFLOW) in the cnc_download4 function may be returned


by this function. Control is not returned from this function until the registration of
data output by the cnc_download4 function is completed.

- 541 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.93 Start reading NC program (4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_upstart4

[Syntax]
#include <fwindow.h>
shortcnc_upstart4( short type, char *file_name );

[Arguments]
type Specify the type of CNC data to be read.
0 : NC program
1 : Tool offset
2 : Parameter
3 : Pitch error compensation amount
4 : Custom macro variable
5 : Work origin offset
7 : Operation history data
file_name Drive name, folder name, and file name (up to 241 characters) of a
program.
Valid only when type = "0".
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths when selecting the program folder of the
CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/"
Path 2:"//CNC_MEM/USER/PATH2/"

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_BUSY(-1) Processing for requesting the start of the output of an NC program to
be compared is rejected.
The cnc_upstart4 function has already been executed. Use the cnc_upend4
function to end the previous output operation.
EW_ATTRIB( 4) The specified type is invalid.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
1 : File or folder name error
EW_NOOPT( 6) A required function is not provided.
When registering a custom macro variable, workpiece origin offset, or
pitch error, enable the corresponding function.

- 542 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_MODE(12) CNC mode error.


Set the CNC mode to other than the MDI mode.
End background editing in the CNC.
EW_REJECT(13) CNC processing is rejected.
The CNC is operating. Registration of data except NC programs is not
permitted during operation.
EW_ALARM(15) Alarm state.
Alarm PW0000 or alarm PS0101 is issued in the CNC. Release the alarm
in the CNC.

[Description]
Requests the CNC to start reading (uploading) NC data (such as an NC program, tool offsets,
or parameters) specified with a path name and file name. (This function must be executed
before uploading is performed.)

If the cnc_upload4 function or cnc_upend4 function is executed without executing this


function, EW_FUNC is returned.

The basic uploading procedure is shown below.

cnc_upstart4

= EW_OK

Reexecute
Read NC data.
= EW_RESET cnc_upload4 = EW_BUFFER

= EW_OK

Is last data '%'?


No
Yes

cnc_upend4

Specify a program with a folder and a file name. So, it is impossible to upload more
than one program by specifying a range.

When data is to be read from a memory card or data server, the full path of a program
name must be set in the 'file_name' argument of the cnc_upstart4 function.
To access a data server, specify and execute the function as shown in the following
example:

Example) Read program O1234:


ret = cnc_upstart4(0, "//DATA_SV/O1234") ;

- 543 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.94 Read NC program (4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_upload4

[Syntax]
#include <fwindow.h>
short cnc_upload4( long *length, char *data );

[Arguments]
length Specify the address of a variable for specifying the number of
characters to be read.
In this variable (*length), set the number of characters to be input
by one read operation.
The number of characters must be a multiple of 256.
After the end of a read operation, the number of characters actually
read is set in this variable (*length) again.
If a value smaller than 256 is specified as the number of characters
to be read, EW_LENGTH is returned.
data Specify a starting address of the NC data storage destination.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_RESET(-2) The CNC has been reset. Call the cnc_upend4 function.
EW_FUNC( 1) The CNC does not complete start processing for outputting an NC program
to be registered. Alternatively, the cnc_upstart4 function has not been
executed.
EW_LENGTH( 2) The specified data length is invalid. The specified number of NC data
characters to be read (*length) is less than 256.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
2 : No program is registered within a specified range.
3 : The NC program area is destroyed.
EW_PROT( 7) Write protection.
CNC parameters (protection or encryption of programs in the eight or
nine thousands) are read-protected. For the timing of the occurrence
of this error, see [Description].
EW_BUFFER(10) The buffer is empty or full. Retry.
For the timing of the occurrence of this error, see [Description].

- 544 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads (uploads) NC data.

This function inputs as many characters as specified in *length. When the CNC data
processing is delayed, and so data that can be read is shorter than the specified number
of characters, the data that can be read is read, and the number of the characters of
the read data is set in *length.

If even one character cannot be read, EW_BUFFER is returned. When this value is returned,
the function must be called again.
Because priority is given to the speed of data transfer to the CNC, an error (such as
EW_DATA) is generally returned with delay. This means that an error output at a certain
point of time is sometimes due to data that was output in several data output operations
preceding that point. An error that occurs in several data output operations preceding
the end of the function is returned by cnc_upend4 function.

Input data format

NC data read from the CNC consists of ASCII strings in the following format:

% LF block-1 LF block-2 LF ... LF block-n LF %


where, LF = 0x0A ('\n')

Alternatively,

% LF CR CR block-1 LF CR CR ... LF CR CR block-n LF CR CR %


where, CR = 0x0D ('\r') and LF = 0x0A ('\n')

The format to be used is determined by the setting of bit 3 (NCR) of NC parameter No.
0100.
Because of the TV check, a space (' ') may be added before LF.
For details, refer to Section, "PROGRAM SECTION CONFIGURATION" in "Common to Lathe
System/Machining Center System User's Manual" (B-64304EN) of the CNC.

A NULL character ('\x00') is not added at the end of the character string written in
the buffer. When read, NC data ends with '%'. Use this character, '%', as the condition
for ending a read operation. When an attempt is made to perform a read operation further
after '%' is received, the function ends with an error (EW_RESET).

- 545 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.95 Stop reading NC program (4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_upend4

[Syntax]
#include <fwindow.h>
short cnc_upend4( void );

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The CNC does not complete start processing for outputting an NC program
to be registered. Alternatively, the cnc_upstart4 function has not been
executed.
EW_DATA( 5) Data error.
To obtain more detailed information about this return value, execute
the cnc_getdtailerr function. The function sets the following detailed
status in err_no, which is a member of the odberr structure:
2 : No program is registered within a specified range.
3 : The NC program area is destroyed.
EW_PROT( 7) Write protection.
CNC parameters (protection or encryption of programs in the eight or
nine thousands) are write-protected.
For the timing of the occurrence of this error, see [Description].

[Description]
Posts the end of reading (uploading) of NC data.
(This function must be executed after uploading.)

An error (such as EW_DATA) in the cnc_upload4 function may be returned by this function.

- 546 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.96 Read pitch error compensation data information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpitchinfo

[Syntax]
#include <fwindow.h>
short cnc_rdpitchinfo( short* use_no ) ;

[Arguments]
use_no [ out ] Specify the number of pitch error compensation data items to
be read.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NOOPT( 6) A required function is not provided.
The stored pitch error compensation function is required. (Parameter
NPE(No.8135#0)="0")

[Description]
Reads the number of usable pitch error compensation data items. It is stored in *use_no
in binary form.

- 547 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.97 Read custom macro variable information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdmacroinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmacroinfo( struct odbmvinf *mvinf );

struct odbmvinf {
short use_no1 ; /* Number of local variables. */
short use_no2 ; /* Common variable range. */
} ;

[Arguments]
mvinf [out] Buffer to which custom macro variable information is returned.
A pointer to mvinf to which custom macro variable information is
returned.
use_no1 The number of available local variables is stored.
33 is set at any time.
use_no2 A value indicating the range of available common variables is stored.
0 : "100" to "149", "500" to "531"
1 : "100" to "199", "500" to "999"
2 : "100" to "199", "500" to "599"

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NOOPT( 6) A required function is not provided.
The custom macro function is required. (Parameter NMC(No.8135#5)="0")

[Description]
Reads the number of custom macro local variables and the number of custom macro common
variables.
These numbers are stored in use_no1 and use_no2 of mvinf in binary form.

- 548 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.98 Read setting parameter information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdsetinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdsetinfo( short s_number, unsigned short read_no,
struct odbsetif *setif ) ;

struct odbsetif {
unsigned short info_no ; /* Number of setting parameters. */
short prev_no ; /* Previous setting parameter number. */
short next_no ; /* Next setting parameter number. */
struct {
short set_no ; /* Setting parameter number. */
short set_type ; /* Setting parameter attribute. */
} info[N] ; /* N : Number of setting parameter information items */
/* to be read. */
} ;

[Arguments]
s_number [in] Specify a starting setting parameter number.
read_no [in] Specify the number of setting parameter information items to
be read.
setif [out] Buffer to which setting parameter information is returned.
A pointer to setif to which setting parameter information is
returned.
info_no Number of setting parameter information items.
Number of setting parameter information items actually read.
prev_no Previous setting parameter number.
Valid number before the setting parameter information read
first.
next_no Next setting parameter number.
Valid number after the setting parameter information read last.
info[N].set_no Setting parameter number.
Setting parameter number actually present.

- 549 -
3.Function References PROGRAMMING B-64303EN-3/01

info[N].set_type Setting parameter attributes.


The following attributes are set:
#0, #1: Type attribute
0 : Bit
1 : Byte
2 : Word
3 : 2-word or real number
#2 : Axis attribute
0 : Axis not present
1 : Axis present
#3 : Sign
0 : Signed
1 : Unsigned
#4 : Setting
(Always) 1 : Enabled
#5 : Write protection
(Always) 0 : Enabled
#6 : Necessity of power-off/on after writing
(Always) 0 : Unnecessary
#7 : Reading
(Always) 0 : Enabled
#8 : Spindle parameters
0 : Other than spindle parameters
1 : Spindle
#9 to #11 : (Reserved)
#12 : When type attribute is set to 3:
0 : Other than real numbers
1 : Real numbers
#13 to #15: (Reserved)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) The specified starting setting parameter number (s_number ) is invalid.

[Description]
Reads CNC setting parameter information specified with s_number and read_no.

Basically, CNC setting parameters are distributed discontinuously, and their types,
sizes, and other attributes vary according to their numbers. This function is used to,
for example, display setting parameters.

- 550 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.99 Read diagnostics data information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rddiaginfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rddiaginfo( short s_number, unsigned short read_no,
struct odbdiagif *diagif ) ;

struct odbdiagif {
unsigned short info_no ;/* Number of diagnostics data information items. */
short prev_no ; /* Previous diagnostics data number. */
short next_no ; /* Next diagnostics data number. */
struct {
short diag_no ; /* Diagnostics data number. */
short diag_type ;/* Diagnostics data attribute. */
} info[N] ;/* N : Number of diagnostics data information items to be read. */
} ;

[Arguments]
s_number [ in ] Specify a starting diagnostics data number.
read_no [in] Specify the number of diagnostics data information items to be read.
diagif [out] Buffer to which diagnostics data information is returned.
A pointer to diagif to which diagnostics data information is returned.
info_no Number of diagnostics data information items.
Number of diagnostics data information items actually read.
prev_no Previous diagnostics data number.
Valid number before the diagnostics data information read first.
next_no Next diagnostics data number.
Valid number after the diagnostics data information read last.
info[N].diag_no Diagnostics data number (number of diagnostics data actually present).

- 551 -
3.Function References PROGRAMMING B-64303EN-3/01

info[N].diag_type Diagnostics data attributes.


The following attributes are set:
#0, #1 : Type attribute (valid when bit 3 = "0")
0 : Bit (8 bits)
1 : Byte
2 : Word
3 : 2-word or real number
#2 : Axis attribute
0 : Axis not present
1 : Axis present
#3 : Type attribute
1 : Bit (1 bit)
#7 : Sign
0 : Signed
1 : Unsigned
#8 : Spindle parameters
0 : Other than spindle parameters
1 : Spindle
#9 to #11 : (Reserved)
#12 : When type attribute is set to 3:
0 : Other than real numbers
1 : Real numbers
#13 to #15: (Reserved)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) The specified starting diagnostics data number (s_number) is invalid.

[Description]
Reads CNC diagnostics data information specified with s_number and read_no.

Basically, CNC diagnostics data is discontinuous, and the type, size, and other
attributes vary according to the individual numbers. This function is used to, for
example, display diagnostics data.

- 552 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.100 Read the minimum parameter number, maximum parameter number, and total number of parameters.
<Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdparanum

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdparanum( struct odbparanum *paranum ) ;

struct odbparanum {
unsigned short para_min ; /* Minimum parameter number. */
unsigned short para_max ; /* Maximum parameter number. */
unsigned short total_no ; /* Total number of parameters. */
} ;

[Arguments]
paranum [out] Buffer to which the maximum parameter number, the minimum parameter
number, and the total number of parameters are returned.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the minimum CNC parameter number, the maximum CNC parameter number, and the total
number of CNC parameters.

The distribution of CNC parameters varies from model to model, and additional parameters
may be provided by function expansion.

- 553 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.101 Read the minimum setting parameter number, maximum setting parameter number, and total
number of setting parameters. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdsetnum

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdsetnum( struct odbsetnum *setnum ) ;

struct odbsetnum {
unsigned short set_min ; /* Minimum setting parameter number. */
unsigned short set_max ; /* Maximum setting parameter number. */
unsigned short total_no ; /* Total number of setting parameters. */
} ;

[Arguments]
setnum [out] Buffer to which the maximum setting parameter number, the minimum
setting parameter number, and the total number of setting parameters
are returned.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the minimum CNC setting parameter number, the maximum CNC setting parameter number,
and the total number of CNC setting parameters.

The distribution of CNC setting parameters varies from model to model, and additional
parameters may be provided by function expansion.

- 554 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.102 Read the minimum diagnostics data number, maximum diagnostics data number, and total number
of diagnostics data items. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rddiagnum

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rddiagnum( struct odbdiagnum *diagnum);

struct odbdiagnum {
unsigned short diag_min ; /*Minimum diagnostics data number.*/
unsigned short diag_max ; /*Maximum diagnostics data number.*/
unsigned short total_no ; /*Total number of diagnostics data items.*/
} ;

[Arguments]
diagnum [out] Buffer to which the maximum diagnostics data number, the minimum
diagnostics data number, and the total number of diagnostics data items
are returned.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the minimum CNC diagnostics data number, the maximum CNC diagnostics data number,
and the total number of CNC diagnostics data items.

The distribution of CNC diagnostics data varies from model to model, and additional data
may be provided by function expansion.

- 555 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.103 Read the number of spindles. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdnspdl

[Syntax]
#include <fwindow.h>
short cnc_rdnspdl( short *spdl );

[Arguments]
spdl [out] Specify the starting address of a variable for holding the number of
spindles.
"0" to "3"

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the number of spindles that can be controlled by the CNC. This number does not
mean the number of installed spindles.

- 556 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.104 Read program directory (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdprogdir2

[Syntax]
#include <data.h>
#include <fwindow.h>

short cnc_rdprogdir2( short type, long *top_prog, short *num_prog,


struct prgdir2 *buf);

struct prgdir2 {
long number;
long length;
char comment[51];
char dummy;
} ;

[Arguments]
type [in] Specify the type of data to be read.
0 : Program numbers only
1 : Program numbers and comments
2 : Program numbers, comments, and the numbers of characters
used
top_prog [in/out] Specify a pointer to a starting program number.
After the function is called, the starting program number
actually read is set.
num_prog [in/out] Specify a pointer to the number of programs to be read.
After the function is called, the number of programs actually
read is set.
buf [out] Buffer to which a program directory is returned.

- 557 -
3.Function References PROGRAMMING B-64303EN-3/01

[Return]
Main return value are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) Function is disabled.
EW_LENGTH( 2) The specified data length is invalid.
The number of programs to be read (num_prog) is invalid.
EW_NUMBER( 3) Data number error.
The starting program number (top_prog) is invalid.
EW_ATTRIB( 4) Data attribute error.
The output format (type) is invalid.

[Description]
Reads the program numbers of all machining programs registered in the CNC.
As many program numbers as specified, starting with a specified program number, and their
comments and numbers of characters used are read.

This function is a revised function of the cnc_rdprogdir function and is intended to


allow the user to specify the number of programs to be read and obtain results with a
fixed length.

number represents a program number. A program number is returned.

length represents a program size. A program size is returned. This is valid when the
type argument is set to "2".

comment represents a comment. A comment recorded immediately after a program number is


stored. A comment body consists of up to 48 characters (up to 50 characters when the
parentheses before and after the comment are included). When a comment consisting of
more than 48 characters is recorded, the 49th and subsequent characters are not output.
When a program has no comment, only parentheses ("()") are output. The character string
ends with a NULL character.
comment is valid when the type argument is set to "1" or "2". In either case, when there
is no program registered, or when there is no program in a specified range, num_prog
is set to "0".

- 558 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.105 Read axis name. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdaxisname

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdaxisname( short *data_num, struct odbaxisname *axisname );

struct odbaxisname {
char name ; /* Axis name. */
char suff ; /* Axis name suffix. */
} ;

[Arguments]
data_num [in/out] Specify a pointer to a variable that holds the number of axes
to be read.
After the function ends, the number of axes actually read is
set.
axisname [out] Buffer to which an axis name is returned.
name An axis name is returned.
suff The suffix of an axis name is returned.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The number of axes (*data_num) is "0" or less.

[Description]
Reads as many axis names as the number of axes specified in (*data_num), starting with
the first axis.

If (*data_num) is greater than the current number of controlled axes, the number of
actually read axes (the number of the controlled axes) is set in (*data_num). If
(*data_num) is smaller than the current number of controlled axes, data for the number
of axes specified in (*data_num) is read.

axisname areas must be prepared as many as the number of axes specified in (*data_num).

This function is affected by the following parameters.


Parameter Nos. 1020 and 3131
For details of parameters, refer to "Parameter Manual" (B-64310EN) of the CNC.

- 559 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.106 Read position information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdposition

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdposition( short type, short *data_num,
struct odbpos *position );

struct odbpos {
POSELM abs; /* Absolute coordinates. */
POSELM mach; /* Machine coordinates. */
POSELM rel; /* Relative coordinates. */
POSELM dist; /* Distance to go. */
} ;

typedef struct poselm {


long data; /* Coordinate value. */
short dec; /* Decimal point position of coordinate value. */
short unit; /* Unit of coordinate value. */
short disp; /* Display status. */
char name; /* Axis name. */
char suff; /* Axis name suffix. */
} POSELM;

[Arguments]
type [in] Specify the type of data to be read.
0 : Absolute coordinates
1 : Machine coordinates
2 : Relative coordinates
3 : Distance to go
-1 : All types
data_num [in/out] Specify a pointer to a variable that holds the number of axes
to be read.
After the function ends, the number of axes actually read is
set.
position [out] Buffer to which a coordinate value is returned.
abs POSELM structure to which an absolute coordinate value is
returned.
mach POSELM structure to which a machine coordinate value is
returned.
rel POSELM structure to which a relative coordinate value is
returned.
dist POSELM structure to which the distance to go is returned.

- 560 -
B-64303EN-3/01 PROGRAMMING 3.Function References

A POSELM structure contains the following:


Data Coordinate value
Dec Decimal point position of coordinate value
Unit Unit of coordinate value
0 : mm
1 : inch
2 : degree
disp Display status
0 : Not displayed on the CNC screen
1 : Displayed on the CNC screen
name Axis name (ASCII)
suff Axis name suffix (ASCII)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The number of axes (*data_num) is "0" or less.
EW_ATTRIB( 4) Data attribute error.
The specified type of coordinate values (type) is invalid.

[Description]
Reads as many coordinate values as the number of axes specified in (*data_num), starting
with the first axis.

If (*data_num) is greater than the current number of controlled axes, the number of
actually read axes (the number of the controlled axes) is set in (*data_num).
If (*data_num) is smaller than the current number of controlled axes, data for the number
of axes specified in (*data_num) is read.

position areas must be prepared as many as the number of axes specified in (*data_num).

- 561 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.107 Read speed information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdspeed

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdspeed( short type, struct odbspeed *speed );

struct odbspeed {
SPEEDELM actf; /* Composite speed. */
SPEEDELM acts; /* Spindle speed. */
} ;

typedef struct speedelm {


long data; /* Speed */
short dec; /* Decimal point position of speed. */
short unit; /* Unit of speed. */
short reserve; /* Not used. */
char name; /* Name. */
char suff; /* Name suffix */
} SPEEDELM;

[Arguments]
type [ in ] Specify the type of data to be read/
0 : Composite speed
1 : Spindle speed
-1 : All
speed [ out ] Buffer to which speed data is returned.
actf SPEEDELM structure to which the composite speed is returned.
acts SPEEDELM structure to which the spindle speed is returned.

- 562 -
B-64303EN-3/01 PROGRAMMING 3.Function References

A SPEEDELM structure contains the following:

Data Speed
Dec Decimal point position of speed
Unit Unit of speed
0 : mm/min
1 : inch/min
2 : rpm
3 : mm/rev
4 : inch/rev
name Name (ASCII)
Composite speed : "F"
Spindle speed : "S"
suff Name suffix (ASCII)
When multi-spindle control is enabled for spindle speed, the
number (ASCII) of a position coder selected is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_ATTRIB( 4) Data attribute error.
The specified data type (type) is invalid.

[Description]
Obtains a composite speed and a spindle speed.

The spindle speed obtained by this function is the speed of the main spindle indicated
on the CNC position display screen.

- 563 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.108 Read servo load meter. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdsvmeter

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdsvmeter( short *data_num, struct odbsvload *loadmeter );

struct odbsvload {
LOADELM svload; /* Servo load meter. */
} ;

typedef struct loadelm {


long data; /* Load meter value. */
short dec; /* Decimal point position of load meter value. */
short unit; /* Unit of load meter value. */
char name; /* Axis name. */
char suff1; /* Axis name suffix 1. */
char suff2; /* Axis name suffix 2. */
char reserve;/* Not used. */
} LOADELM;

[Arguments]
data_num [in/out] Specify a pointer to a variable that holds the number of axes
to be read.
After the function ends, the number of axes actually read is
set.
loadmeter [out] Buffer to which load meter values are returned.

A LOADELM structure contains the following:


data Load meter value
dec Decimal point position of load meter value
unit Unit of load meter value. 0 (= % ) is set at any time.
name Axis name (ASCII)
suff1 Axis name suffix (ASCII)
uff2 Not used.

- 564 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The number of axes (*data_num) is "0" or less.

[Description]
Reads as many servo load meter values as the number of axes specified in (*data_num),
starting with the first axis.

If (*data_num) is greater than the current number of servo axes, the number of actually
read axes (the number of servo axes) is set in (*data_num).
If (*data_num) is smaller than the current number of servo axes, data for the number
of axes specified in (*data_num) is read.

svload areas must be prepared as many as the number of axes specified in (*data_num).

- 565 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.109 Read spindle load meter. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdspmeter

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdspmeter( short type, short *data_num,
struct odbspload *loadmeter );

struct odbspload {
LOADELM spload; /* Spindle load meter value. */
LOADELM spspeed; /* Spindle motor speed. */
} ;

typedef struct loadelm {


long data; /* Load meter value or motor speed. */
short dec; /* Decimal point position of data. */
short unit; /* Unit of data. */
char name; /* Spindle name. */
char suff1; /* Spindle name suffix 1. */
char suff2; /* Spindle name suffix 2. */
char reserve;/* Not used. */
} LOADELM;

[Arguments]
type [in] Specify the type of data to be read.
0 : Spindle load meter value
1 : Spindle motor speed
-1 : All types
data_num.[in/out] Specify a pointer to a variable that holds the number of
spindles to be read.
After the function ends, the number of spindles actually read
is set.
loadmeter [out] Buffer to which a load meter value is returned.
svload LOADELM structure to which a spindle load meter value is
returned.

- 566 -
B-64303EN-3/01 PROGRAMMING 3.Function References

spspeed LOADELM structure to which a spindle motor speed is returned.

A LOADELM structure contains the following:


data Load meter value or motor speed
dec Decimal point position of data
unit Unit of data
0 : %
1 : rpm
ame Spindle name (ASCII)
ASCII code 'S' is stored.

suff1 Spindle name suffix 1 (ASCII)


A spindle number ("1", "2", ...) is stored.

suff2 Spindle name suffix 2 (ASCII)


When the spindle switch function is provided, the following
ASCII code is stored:
Main spindle : "1"
Subspindle : "2"
When the spindle switch function is not provided, a NULL
character ("\0") is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Data block error.
The number of spindles (data_num) is "0" or less.
EW_ATTRIB( 4) Data attribute error.
The specified data type (type) is invalid.

[Description]
Reads spindle load meter values and spindle motor speeds.

If (data_num) is greater than the current number of spindles, the number of actually
read spindles is set in (data_num).
If (data_num) is smaller than the current number of spindles, data for the number of
spindles specified in (data_num) is read.

loadmeter areas must be prepared as many as the number of spindles specified in


(*data_num).

- 567 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.110 Read modal G code.<Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdgcode

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdgcode( short type, short block, short *num_gcd,
struct odbgcd *g_code );

struct odbgcd {
short group ; /* G code group. */
short flag ; /* Additional information. */
char code[8] ; /* G code. */
} ;

[Arguments]
type [in] Specify a G code group to be read.
0 to 36 : Read a modal G code
-1 : Read modal G codes at a time
100 to 103: Read a one-shot G code
-2 : Read one-shot G codes at a time
block [in] Specify a target block for reading.
0 : Previous block
1 : Currently executed block
2 : Next block
num_gcd [in/out] Specify a pointer to the number of G codes to be read.
After the function is called, the number of G codes actually
read is set.
g_code [out] Buffer to which G code data is returned.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The number of G codes to be read (*num_gcd) is invalid.
EW_NUMBER( 3) Data number error.
The specified G code group (type) is invalid.
EW_ATTRIB( 4) Data attribute error.
The specified block (block) is invalid.

- 568 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads G code information specified on the CNC side.

Information is stored in members of g_code.


Data that can be read is modal G codes and one-shot G codes.

Prepare one g_code when reading one G code. When reading G codes at a time, prepare as
many g_code areas as the number of G codes to be read (*num_gcd).

(1) Reading modal G code

- Reading a modal G code


When "1" is specified in the data area pointed to by num_gcd, and a group number
("0" to "36") is specified in type, a modal G code selected in a block specified
in the block argument is read.

The following G code groups can be specified in type:

G code for machining G code for lathe


type
center System A System B System C
G00 G00 G00 G00
G01 G01 G01 G01
G02 G02 G02 G02
G03 G03 G03 G03
G33 G32 G33 G33
0
G75 G90 G77 G20
G77 G92 G78 G21
G78 G94 G79 G24
G79 - - -
- G34 G34 G34
G17 G97 G97 G97
- G96 G96 G96
1
G19 - - -
G18 - - -
G90 - G90 G90
2
G91 - G91 G91
G23 G69 G69 G69
3
G22 G68 G68 G68
G94 G98 G94 G94
4 G95 G99 G95 G95
G93 - - -
G20 G20 G20 G70
5
G21 G21 G21 G71
G40 G40 G40 G40
6 G41 G41 G41 G41
G42 G42 G42 G42
G49 G25 G25 G25
7 G43 G26 G26 G26
G44 - - -
G80 G23 G23 G23
G81 G22 G22 G22
8
G82 - - -
G83 - - -

- 569 -
3.Function References PROGRAMMING B-64303EN-3/01

G code for machining G code for lathe


type
center System A System B System C
G84 - - -
G85 - - -
G86 - - -
G87 - - -
G88 - - -
8 G89 - - -
G73 - - -
G74 - - -
G76 - - -
G84.2 - - -
G84.3 - - -
G98 G80 G80 G80
G99 G83 G83 G83
- G84 G84 G84
- G85 G85 G85
- G87 G87 G87
9 - G88 G88 G88
- G89 G89 G89
- G81 G81 G81
- G82 G82 G82
- G83.1 G83.1 G83.1
- G84.2 G84.2 G84.2
G50 - G98 G98
10
G51 - G99 G99
G67 G67 G67 G67
11
G66 G66 G66 G66
G97 - - -
12
G96 - - -
G54(G54.1) G54 G54 G54
G55 G55 G55 G55
G56 G56 G56 G56
13
G57 G57 G57 G57
G58 G58 G58 G58
G59 G59 G59 G59
G64 G64 G64 G64
G61 G61 G61 G61
14
G62 - - -
G63 G63 G63 G63
G69 G17 G17 G17
G68 - - -
15
- G18 G18 G18
- G19 G19 G19
G15 - - -
16
G16 - - -
G40.1 - - -
17 G41.1 - - -
G42.1 - - -
G160 G50.2 G50.2 G50.2
19
G161 G51.2 G51.2 G51.2
- G13.1(G113) G13.1(G113) G13.1(G113)
20
- G12.1(G112) G12.1(G112) G12.1(G112)
G50.1 - - -
21
G51.1 - - -

- 570 -
B-64303EN-3/01 PROGRAMMING 3.Function References

group The group number (the value specified in type) of a read G code is set.

flag The following flags are set:


#3 = 1 : The G code is different from the previous block.
(This flag is valid only when the block argument is set to 1
(currently executed block). If the block argument is set to
0 or 2, this flag is always set to 0.)
#7 = 1 : The G code is specified in a specified block.

code The read modal G code is set with a character string.


A NULL character ("\0") is set at the end of the character string.

For example, when this function is executed during execution of block N100 in
the following machining program, the results shown below are obtained:

N090 G18 ;
N100 G01 Z100. ;
N110 G17 G02 X10. Y-20. R12. ;

type block code flag Modal state


0 1 G01¥0 0x0080 G01 is specified.
0 2 G02¥0 0x0080 G02 is specified.
1 1 G18¥0 0x0000 G18 mode (no specification)
1 2 G17¥0 0x0080 G17 is specified.

- Reading modal G codes at a time:


When "-1" is specified in type, modal G codes selected in a block specified
in the block argument, as many as the number of groups specified in num_gcd
are read. To read modal G codes of all groups, specify "21" in the data area
pointed to by num_gcd. After the function is called, the number of data items
actually read is set in the data area pointed to by num_gcd.

(2) Reading one-shot G code

- Reading a one-shot G code:


When "1" is specified in the data area pointed to by num_gcd, and a group number
("100" to "103") is specified in type, a one-shot G code specified in a block
specified in the block argument is read. If no one-shot G code is specified
in the specified block, "0" is set in the data area pointed to by num_gcd.

- 571 -
3.Function References PROGRAMMING B-64303EN-3/01

The following G code groups can be specified in type:

G code for machining G code for lathe


type
center System A System B System C
G04 G04 G04 G04
G10 G27 G27 G27
- G28 G28 G28
- G03 G03 G03
G27 G30 G30 G30
G28 G50 G92 G92
G29 G70 G70 G72
G30 G71 G71 G73
- G72 G72 G74
G39 G73 G73 G75
- G74 G74 G76
- G75 G75 G77
G76 G76 G78
- G10 G10 G10
G92 - - -
- G37 G37 G37
G31 G31 G31 G31
G60 G65 G65 G65
G65 - - -
100 - G11 G11 G11
- G07.1(G107) G07.1(G107) G07.1(G107)
G52 G52 G52 G52
G53 G53 G53 G53
G37 - - -
G07.1(G107)
- G50.3 G92.1 G92.1
- G08 G08 G08
- G39 G39 G39
G92.1 - - -
- G09 G09 G09
G05.1 - - -
- G05.4 G05.4 G05.4
G05.4 - - -
- G50.4 G50.4 G50.4
- G50.5 G50.5 G50.5
- G50.6 G50.6 G50.6
- G51.4 G51.4 G51.4
- G51.5 G51.5 G51.5
- G51.6 G51.6 G51.6
G09 G09 G09 G09
- G96.1 G96.1 G96.1
101 - G96.2 G96.2 G96.2
- G96.3 G96.3 G96.3
- G96.4 G96.4 G96.4
102 G53 G53 G53 G53
G45 - - -
G46 - - -
103
G47 - - -
G48 - - -

- 572 -
B-64303EN-3/01 PROGRAMMING 3.Function References

group The group number (the value specified in type) of a read one-shot G code
is set.

flag The following flags are set:


#3 = 1 : The G code is different from the previous block.
(This flag is valid only when the block argument is set to 1
(currently executed block). If the block argument is set to
0 or 2, this flag is always set to 0.)
#4 = 1 : Decimal point used
(One-shot G code with a decimal point such as G30.1)
#5 = 1 : Negative data
#6 = 1 : One-digit data
(One-shot G code of which numeric part consists of one digit,
such as G04)
#7 = (Always) 1: The G code is specified in a specified block.

code The read one-shot G code is set with a character string.


A NULL character ("\0") is set at the end of the character string.

- Reading one-shot G codes at a time:


When "-2" is specified in type, one-shot G codes specified in a block specified
in the block argument, as many as the number of groups specified in num_gcd
are read. To read one-shot G codes of all groups, specify "4" in the data area
pointed to by num_gcd. After the function is called, the number of data items
actually read is set in the data area pointed to by num_gcd.

- 573 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.111 Read command value. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdcommand

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdcommand( short type, short block, short *num_cmd,
struct odbcmd *command );

struct odbcmd {
char adrs ; /* Command address. */
char num ; /* M code number or axis number. */
short flag ; /* Additional information. */
long cmd_val ; /* Command value data. */
long dec_val ; /* Number of decimal positions in the command value.*/
} ;

[Arguments]
type [in] Specify the type of a command value.
0 to 29 : Read a modal code other than G codes
-1 : Read modal codes other than G codes at a time
100 to 129 : Read a command value
-2 : Read command values at a time
200 to 223 : Read an axis command value
-3 : Read axis command values at a time
block [in] Specify a target block for reading.
0 : Previous block
1 : Currently executed block
2 : Next block
num_cmd [in/out] Specify a pointer to the number of data items to be read.
After the function is called, the number of data items actually
read is set.
command [out] Buffer to which command value data is returned.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The number of data items to be read (*num_cmd) is invalid.

- 574 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NUMBER( 3) Data number error.


The specified command value type (type) is invalid.
EW_ATTRIB( 4) Data attribute error.
The specified block (block) is invalid.

[Description]
Reads a command value.

Information is stored in members of command. Data that can be read is modal data other
than G codes, and command values.
Prepare one command area when reading one command value. When reading command values
at a time, prepare as many command areas as the number of data items to be read (*num_cmd).

(1) Reading modal codes other than G codes

Values specified with "D", "E", "F", "H", "L", "M", "N", "O", "S", "T", and the
second auxiliary function ("A", "B", "C", "U", "V", or "W" specified in parameter
No. 3460) are read.

- Reading a modal code:


When "1" is specified in the data area pointed to by num_cmd, and a command
address ("0" to "29") is specified in type, a modal code other than G codes
in a block specified in the block argument is read.

The following values can be specified in type:

type Command address type Command address


0 A (2nd auxiliary function) 15 P (Not usable)
1 B (2nd auxiliary function) 16 Q (Not usable)
2 C (2nd auxiliary function) 17 R (Not usable)
3 D 18 S
4 E 19 T
5 F 20 U (2nd auxiliary function)
6 G (Not usable) 21 V (2nd auxiliary function)
7 H 22 W (2nd auxiliary function)
8 I (Not usable) 23 X (Not usable)
9 J (Not usable) 24 Y (Not usable)
10 K (Not usable) 25 Z (Not usable)
11 L 26 M (2nd M code)
12 M 27 M (2nd M code)
13 N 28 M (2nd M code)
14 O 29 M (2nd M code)

- 575 -
3.Function References PROGRAMMING B-64303EN-3/01

adrs The read modal command address is set in ASCII form.

num When M (="77") is set in adrs, the following value is set:


1 : First M code
2 : Second M code
3 : Third M code
4 : Fourth M code
5 : Fifth M code

flag The following flags are set:


#3 = 1 : Command different from the previous block
(This flag is valid only when the block argument is set to 1
(currently executed block). If the block argument is set to
0 or 2, this flag is always set to 0.)
#4 = 1 : Decimal point used
#5 = 1 : Negative data
#6 = 1 : One-digit data
#11 = 1 : Specified after the CNC is reset.
#15 = 1 : Specified in a specified block.

cmd_val Command value data is set.

dec_val The number of decimal positions in the command value is set.

- Reading modal codes at a time:


When "-1" is specified in type, modal data items other than G codes in a block
specified in the block argument, as many as the number specified in num_cmd
are read.
To read all modal data other than G codes, specify the value indicated in the
table below in the data area pointed to by num_cmd.
After the function is called, the number of data items actually read is set
in the data area pointed to by num_cmd. When more than one M command is present
in one block, the same M code may be read more than once depending on the CNC
operation status.

With 2nd auxiliary Without 2nd auxiliary


function function
Multiple M commands in
15 14
one block
Multiple M commands
11 10
not in one block

(2) Reading command values

- Reading a command value:


When "1" is specified in the data area pointed to by num_cmd, and a command
address "100" to "129" is specified in type, a command value specified in a
block specified in the block argument is read.

- 576 -
B-64303EN-3/01 PROGRAMMING 3.Function References

When the specified address is not specified in the specified block, "0" is set
in the data area pointed to by num_cmd.

The following values can be specified in type:

type Command address type Command address


100 A 115 P
101 B 116 Q
102 C 117 R
103 D 118 S
104 E 119 T
105 F 120 U
106 G (Not usable) 121 V
107 H 122 W
108 I 123 X
109 J 124 Y
110 K 125 Z
111 L 126 M (2nd M code)
112 M 127 M (3rd M code)
113 N 128 M (4th M code)
114 O 129 M (5th M code)

adrs The read modal command address is set in ASCII form.

num When M (="77") is set in adrs, the following value is set:


1 : First M code
2 : Second M code
3 : Third M code
4 : Fourth M code
5 : Fifth M code

flag The following flags are set:


#4 = 1 : Decimal point used
#5 = 1 : Negative data
#6 = 1 : One-digit data
#11 = (Always) 1 : Specified after the CNC is reset.
#15 = (Always) 1 : Specified in a specified block.

cmd_val Command value data is set.

dec_val The number of decimal positions in the command value is set.

- 577 -
3.Function References PROGRAMMING B-64303EN-3/01

- Reading command values at a time:


When "-2" is specified in type, command values specified in a block specified
in the block argument, as many as a number specified in num_cmd are read.
To read all command values, specify the value indicated below in the data area
pointed to by num_cmd.
After the function is called, the number of data items actually read is set
in the data area pointed to by num_cmd.
Multiple M commands specified in one block: "29"
Multiple M commands not specified in one block: "25"

(3) Reading axis command values

- Reading an axis command value:


When "1" is specified in the data area pointed to by num_cmd, and an axis ("200"
to "223") is specified in type, an axis command value specified in a block
specified in the block argument is read.
When the specified axis is not specified in the specified block, "0" is set
in the data area pointed to by num_cmd.

The following values can be specified in type:

type Axis
200 1st axis
201 2nd axis
: :
206 7th axis
207 8th axis

adrs The read modal command address is set in ASCII form.

num An axis number ("1" to the maximum number of controlled axes) is set
in binary form.

flag The following flags are set:


#3 = 1 : Command different from the previous block
(This flag is valid only when the block argument is set to 1
(currently executed block). If the block argument is set to
0 or 2, this flag is always set to 0.)
#4 = 1 : Decimal point used
#5 = 1 : Negative data
#6 = 1 : One-digit data
#11 = (Always) 1 : Specified after the CNC is reset.
#15 = (Always) 1 : Specified in a specified block.

- 578 -
B-64303EN-3/01 PROGRAMMING 3.Function References

cmd_val Command value data is set.

dec_val The number of decimal positions in the command value is set.

- Reading axis command values at a time:


When "-3" is specified in type, axis command values specified in a block
specified in the block argument, as many as the number specified in num_cmd
are read.
To read all axis command values, specify the value indicated below in the data
area pointed to by num_cmd.
After the function is called, the number of data items actually read is set
in the data area pointed to by num_cmd.
MAX_AXIS = 8: "8"

- 579 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.112 Read alarm status (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_alarm2

[Syntax]
#include <fwindow.h>
short cnc_alarm2( long *alarm );

[Arguments]
alarm [ out ] Specify the address of a variable for acquiring alarm status
information.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads the alarm status when the CNC is placed in the alarm status.

When the CNC alarm status is monitored with an application program, this function is
used to display maintenance information and guidance information about how to release
alarms. When the CNC is in the system alarm state, communication is disabled entirely,
so no alarm status can be acquired.
When the CNC is in the system alarm state, no data can be transferred between the MMC
and the CNC, so no alarm status can be acquired.

The following addresses are assigned to variables for acquiring alarm status
information:

#00 : Parameter writing switch on (SW)


#01 : Parameter input that requires power-off (PW)
#02 : I/O error (IO)
#03 : PS for foreground (PS)
#04 : Overtravel/external data input error (OT)
#05 : Overheat (OH)
#06 : Servo alarm (SV)
#07 : Data I/O error (SR)
#08 : Macro alarm (MC)
#09 : Spindle alarm (SP)
#10 : Other alarms (DS)
#11 : Alarm related to malfunction prevention function (IE)
#12 : PS for background (BG)
#13 : Excessive synchronization error (SN)

- 580 -
B-64303EN-3/01 PROGRAMMING 3.Function References

#14 : Reserved
#15 : External alarm message (EX)
#16 : Reserved
#17 : Reserved
#18 : Reserved
#19 : PMC error (PC)
#20 to #31 : (Not used)

- 581 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.113 Read operator's message (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdopmsg2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdopmsg2( short type,short length,struct opmsg2 *opmsg );

struct opmsg2 {
short datano ; /* Operator's message number. */
short type ; /* Operator's message type. */
short char_num ; /* Number of message characters. */
char data[MSG_SIZE] ; /* Operator's message character string. */
} ; /* MSG_SIZE: Number of message characters. */

[Arguments]
type [ in ] Specify the type of an operator's message.
0 : First message
1 : Second message
2 : Third message
3 : Fourth message
-1 : All messages
length [ in ] Specify the data block length (opmsg size).
Single message (first to fourth message)
All messages
opmsg [ out ] Buffer to which an operator's message is returned.
The operator's message is stored in data in opmsg.
datano An operator's message number is set.
- Message found:
With no number: "0"
With number: "2000" to "2099"
- No message found: "-1"
type The type of an operator's message is set.
0 to 3 : First to fourth message
char_num The number of operator's message characters is set.
1 to 64 : Operator's message
The number of characters includes "\0" placed at the end.
data An operator's message character string is set.
An ASCII string is set. Character "\0" is set at the end.

- 582 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The size (length) in opmsg is invalid.
EW_ATTRIB( 4) Data attribute error.
The specified operator's message type (type) is invalid.
EW_PARAM( 9) CNC parameter error.
Bit 0 (PCC) of parameter No. 11931 is set to "0".
EW_NOOPT( 6) A required function is not present.
External message
External data input

[Description]
Reads operator's messages of the CNC.

length specifies the data block length (opmsg size).

Single message (first to fourth message)

0┌───────────┐ ──
│ datano │ ↑
2├───────────┤ │
│ type │ │
4├───────────┤ │
│ char_num │ │
6├─────┬─────┘length
│ data[0] │ │
7├─────┤ │
~ ~ │
6+63├─────┤ │
│ data[63] │ ↓
6+64└─────┘ ──

All messages
0┌───────────┐ ──
│ 1st message │ ↑
70├───────────┤ │
│ 2nd message │ │
140├───────────┤length
│ 3rd message │ │
210├───────────┤ │
│ 4th message │ ↓
280└───────────┘ ──

Operator's messages are stored in data in opmsg.

- 583 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.114 Read operator's message (3). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdopmsg3

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdopmsg3( short type, short *number, struct opmsg3 *opmsg );

struct opmsg3 {
short datano ; /* Operator's message number. */
short type ; /* Operator's message type. */
short char_num ; /* Number of message characters. */
char data[MSG_SIZE] ; /* Operator's message character string. */
} ; /* MSG_SIZE: Number of message characters. */

[Arguments]
type [in] Specify the type of an operator's message.
0 : First message
1 : Second message
2 : Third message
3 : Fourth message
4 : Macro message
-1 : All messages
number [in/out] Specify the number of messages to be read.
The number of data items actually read is set in *number.
When type = "0" to "4", specify "1".
When type = "-1", specify "5".
opmsg [out] Buffer to which operator's messages are returned.
Operator's messages are stored in data in opmsg.
datano An operator's message number is set.
- Message found:
With no number: "0"
* For one operator's message
With number: "2100" to "2199"
* For four operator's messages
- No message found: "-1"
type The type of an operator's message is set.
0 to 3 : First to fourth message
4 : Macro message
char_num The number of operator's message characters is set.
The number of characters includes "\0" placed at the end.
data An operator's message character string is set.
An ASCII string is set. Character "\0" is set at the end.

- 584 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the number of messages (number).
EW_ATTRIB( 4) Data attribute error.
The specified operator's message type (type) is invalid.
EW_NOOPT( 6) A required function is not present.
External message
External data input

[Description]
Reads operator's messages of the CNC.

Operator's messages are stored in data in opmsg.

- 585 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.115 Read spindle name. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdspdlname

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdspdlname( short *data_num, struct odbspdlname *spdlname );

struct odbspdlname {
char name ; /* Spindle name. */
char suff1 ; /* Spindle name suffix 1. */
char suff2 ; /* Spindle name suffix 2. */
char suff3 ; /* Not used. */
} ;

[Arguments]
data_num [in/out] Specify a pointer to a variable that holds the number of spindles to
be read.
After the function ends, the number of spindles actually read is set.
spdlname [out] Buffer to which a spindle name is returned.
name Spindle name (ASCII).
ASCII code 'S' is stored.
suff1 Spindle name suffix 1 (ASCII).
A spindle number ("1", "2", ...) is stored.
suff2 Spindle name suffix 2 (ASCII).
When the spindle switch function is provided, the following ASCII
code is stored:
Main spindle : "1"
Subspindle : "2"
When the spindle switch function is not provided, a NULL character
('\0') is stored.
[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The number of spindles (*data_num) is "0" or less.

- 586 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads as many spindle names as the number specified in (*data_num), starting with the
first spindle. When (*data_num) is greater than the current total number of spindles,
the number of spindles actually read (the total number of spindles) is set in (*data_num).
When (*data_num) is smaller than the current total number of spindles, data items as
many as the number specified in (*data_num) are read.

spdlname areas must be prepared as many as the number specified in (*data_num).

- 587 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.116 Read program directory (3). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdprogdir3

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdprogdir3( short type, long *top_prog, short *num_prog,
struct prgdir3 *buf );

struct prgdir3 {
long number;
long length;
long page;
char comment[52];
struct{
short year;
short month;
short day;
short hour;
short minute;
short dummy;
} mdate;
struct{
short year;
short month;
short day;
short hour;
short minute;
short dummy;
} cdate;
} ;

[Arguments]
type [in] Specify the type of a directory of programs to be read.
0 : Program numbers only
1 : Program numbers and comments
2 : Program numbers, comments, and the numbers of characters used
top_prog [in/out] Specify a pointer to a starting program number.
After the function is called, the starting program number actually
read is set.
num_prog [in/out] Specify a pointer to the number of programs to be read.
After the function is called, the number of programs actually read
is set.
buf [out] Buffer to which a program directory is returned.

- 588 -
B-64303EN-3/01 PROGRAMMING 3.Function References

number Program number.


A program number is returned.

length Program size (number of characters).


The program size in characters is returned.
This argument is valid when the type argument is set to "2".
page Not used.
comment Comment.
A comment recorded immediately after the program number is stored.
A comment consisting of up to 48 characters is stored.
When the recorded comment consists of more than 48 characters (more
than 50 characters when the parentheses before and after the comment
are included), the 49th and subsequent characters are not output.
When a program has no comment, only parentheses ("()") are stored.
The character string ends with a NULL character.
This argument is valid when the type argument is set to "1" or "2".
mdate Date of update.
The date of program update is returned.
This argument is valid when the type argument is set to "2".
mdate contains the following data:
year : 4-digit year
month : Month
day : Day
hour : Hour
minute : Minute
cdate Not used.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The number of programs to be read (num_prog) is invalid.
EW_NUMBER( 3) Data number error.
The starting program number (top_prog) is invalid.
EW_ATTRIB( 4) Data attribute error.
The output format (type) is invalid.

[Description]
Reads a directory of the program numbers of all machining programs registered in the
CNC.

As many program numbers as specified, starting with a specified program number, and their
comments, dates (dates of creation and dates of update), and program sizes are read.

In any case, if no program is registered, or if there is no program in a specified range,


num_prog is set to "0".

- 589 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.117 Read tool offset information (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtofsinfo2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtofsinfo2( struct odbtlinf2 *tlinf2 );

struct odbtlinf2 {
short ofs_type; /* Memory type. */
short use_no; /* Number of offsets that can be used. */
short ofs_enable ; /* Type of offsets that can be used. */
} ;

[Arguments]
tlinf2 [out] Buffer to which tool offset information is returned.
Binary data is stored in ofs_type and use_no of tlinf2.
ofs_type Offset memory type.
- Machining center:
0 : Memory type A
1 : Memory type B
2 : Memory type C
- Lathe:
0 : No tool geometry and wear compensation performed.
1 : Tool geometry and wear compensation performed.
use_no Number of usable offsets. 0 to 999 sets
ofs_enable Type of usable offsets (Enabled only for the T series. These are set
to 0 for the M series.)
#0 : X-axis offset. Usable = "1"/not usable = "0"
#1 : Y-axis offset. Usable= "1"/not usable = "0"
#2 : Z-axis offset. Usable= "1"/not usable = "0"
#3 : Tool-nose radius compensation. Usable= "1"/not usable =
"0"
#4 : Virtual tool tip. Usable= "1"/not usable = "0"
#5 to #15 : (Not used.)

- 590 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NOOPT( 6) A required function is provided.
M series Number of tool offsets: 32/400 sets
Tool offset memory A/C
Tool radius and tool-nose radius compensation
T series Number of tool offsets: 32/64/99/128/200 sets
Tool geometry and wear compensation
Tool radius and tool-nose radius compensation

[Description]
Reads the tool offset memory type and the number of usable offsets.

This function is related to the following parameters:


Bit 5 (TIP) of parameter No. 5009 (for the M series only) and parameter No. 5024
For details of parameters, refer to "Parameter Manual" (B-64310EN) of the CNC.

- 591 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.118 Read custom macro variables (double-precision floating point). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdmacror2

[Syntax]
#include <fwindow.h>
short cnc_rdmacror2( unsigned long s_no, unsigned long *num,
double *data );

[Arguments]
s_no [in] Specify a starting custom macro variable number with which reading starts.
num [in/out] Specify a pointer to the number of custom macro variables to be read.
After the function is called, the number of custom macro variables
actually read is set.
data [out] Specify a pointer to custom macro data to be read.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Data number error.
The specified custom macro variable number (s_no) is invalid.
EW_DATA( 5) Data error.
A custom macro variable value is beyond the valid range.
EW_NOOPT( 6) A required function is not provided. Enable the custom macro function
(bit 5 (NMC) of parameter No. 8135 = 0).

[Description]
Reads as many custom macro variables as specified in num, starting with a custom macro
having a number specified in s_no.

Data is stored in data in the double format. It is not affected by the setting of
cnc_setmactype.

The following types of custom macro variables can be read:

(1) Local variables (#1 to #33)


The local variables of a custom macro that is being executed at the time of reading.

(2) Common variables (#100 to #999)


For the range of common variables to be read, see the description of the
cnc_rdmacroinfo function.

- 592 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Custom macro variables may have a special value, "empty". This value is represented as
follows:

0xFFFFFFFFFFFFFFFF

For details of custom macro variables, refer to "Common to Lathe System/Machining Center
System User's Manual" (B-64304EN) of the CNC.

- 593 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.119 Write custom macro variables (double-precision floating point). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrmacror2

[Syntax]
#include <fwindow.h>
short cnc_wrmacror2( unsigned long s_no, unsigned long *num,
double *data );

[Arguments]
s_no [in] Specify a starting custom macro variable number with which writing starts.
num [in/out] Specify a pointer to the number of custom macro variables to which data
is to be written.
After the function is called, the number of custom macro variables to which
data has actually been written is stored.
data [in] Specify a pointer to custom macro data to be written.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Data number error.
The specified custom macro variable number (s_no) is invalid.
EW_DATA( 5) Data error.
A custom macro variable value is beyond the valid range.
EW_NOOPT( 6) A required function is not provided. Enable the custom macro function
(bit 5 (NMC) of parameter No. 8135 = 0).

[Description]
Rewrites as many custom macro variables as specified in num, starting with a custom
macro variable having a number specified in s_no.

Data is stored in data in the double format. It is not affected by the setting of
cnc_setmactype.

The following types of custom macro variables can be rewritten:

Local variables (#1 to #33) cannot be rewritten.

(1) Common variables (#100 to #999)


For the write range, see the description of the cnc_rdmacroinfo function.

- 594 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Custom macro variables may have a special value, "empty". This value is represented as
follows:

0xFFFFFFFFFFFFFFFF

For details of custom macro variables, refer to "Common to Lathe System/Machining Center
System User's Manual" (B-64304EN) of the CNC.

- 595 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.120 Read controlled axis/spindle-related data. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdaxisdata

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdaxisdata( short cls, short* type, short num, short* len,
struct odbaxdt *axdata );
struct odbaxdt {
char name[4]; /* Axis name. */
long data; /* Data. */
short dec; /* Decimal point position of data. */
short unit; /* Unit of data. */
short flag; /* Flag. */
short reserve; /* Not used. */
} ;

[Arguments]
cls [in] Specify the class of data to be read.
1 : Coordinates
2 : Servo
3 : Spindle
4 : Spindle currently selected
5 : Speed
type [in] Pointer to an array that specifies the type of data to be read.
The following values can be specified according to the value of cls:
- cls = "1" (Coordinate value)
0 : Absolute coordinate value
1 : Machine coordinate value
2 : Relative coordinate value
3 : Distance to go
4 : Handle interrupt amount (input unit)
5 : Handle interrupt amount (output unit)
6 : Program restart position
7 : Distance to go at the time of program restart
8 : Block restart position
9 : Distance to go at the time of block restart
10 : Absolute coordinate value (for offset and graphic screens)
11 : Relative coordinate value (for offset and graphic screens)

- 596 -
B-64303EN-3/01 PROGRAMMING 3.Function References

- cls= "2" (servo)


0: Servo load meter
1: Load current (%)
2: Load current (A)
- cls= "3" (spindle)
0: Spindle load meter
1: Spindle motor speed
2: Spindle speed (value set according to bit 2 (ASDs) of parameter
No. 3799)
3 : Spindle speed (value obtained from the spindle motor speed)
4 : Spindle load meter (average of values obtained every 250 ms)
- cls = "4" (spindle being selected)
* (To be specified in the same way as when cls = "3")
- cls = "5" (speed)
0 : Composite feedrate (F)
1 : Spindle speed (S)
2 : Jog feedrate/dry run feedrate
num [in] Specify the number of type arrays.
len [in/out] Specify a pointer to a variable that holds the number of axes to be
read.
After the function ends, the number of axes actually read is set.
axdata [out] Buffer to which data is returned.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length. Alternatively, the number of axes (*len)
is "0" or less.
EW_NUMBER( 3) Data attribute error.
The specified data class (cls) is invalid.
EW_ATTRIB( 4) Data attribute error.
The specified data type (type) is invalid.
Alternatively, the number of types (num) exceeds 4.
EW_NOOPT( 6) A required function is not provided.

[Description]
This function is a revised function of the cnc_rdposition, cnc_rdspeed, cnc_rdsvmeter,
cnc_rdspmeter, and cnc_rdhndintrpt functions and is intended to support the axis name
extension function. The function reads axis- and spindle-related data.

Specify the class of data to be read in the cls argument, and specify the type of data
to be read in a short array (type[]). The number of arrays is specified in the num argument.
Up to four types of data can be read at a time. If an attempt is made to read more than
four types of data, the EW_ATTRIB error results.

- 597 -
3.Function References PROGRAMMING B-64303EN-3/01

The number of axes to be read is specified in the (*len) argument. According to the value
of data class cls, (*len) is set as follows:

1. When cls is set to a coordinate value (=1), servo (=2), or spindle (=3)
Data for as many axes as specified in (*len), starting with the first axis is
read.
After the function is executed, if (*len) is greater than the number of currently
valid axes, the number of actual axes is set in (*len).
If (*len) is smaller than the number of currently valid axes, data for as many
axes as specified in (*len) is read.

2.When cls is set to the spindle being selected (=4) or speed (=5)
Data for one axis is read at any time. When the spindle being selected is
specified, however, if there is no spindle being selected, "0" is set in (*len).
The read data is stored in an array of the odbaxdt structure specified in the
axdata[] argument. This argument must have the size for num × (*len). The read
data is stored in units of the size specified in (*len) in the order specified
in type[] as follows:

type[0] data : axdata[ 0] to axdata[ (*len)-1]


type[1] data : axdata[ (*len)] to axdata[ 2×(*len)-1]
type[2] data : axdata[ 2×(*len)] to axdata[ 3×(*len)-1]
type[3] data : axdata[ 3×(*len)] to axdata[ 4×(*len)-1]

Even if the number specified in (*len) is smaller than the actual number of
axes, data is stored according to the value specified in (*len) when the function
is called.

axdata must have the size specified by num × (*len).

name An axis name is stored in ASCII form.


The character string ends with a NULL character ('\0').

data Data.

dec Decimal point position of the data.


When the unit explained below is rpm or %, there is no data in decimal positions,
and 0 is always stored.

unit Unit of data.


0 : Millimeter (coordinate value)
1 : Inch (coordinate value)
2 : Degree (coordinate value)
3 : Millimeter/minute (composite feedrate, jog/dry run feedrate)
4 : Inch/minute (composite feedrate, jog/dry run feedrate)
5 : rpm (spindle speed, spindle motor speed)
6 : Millimeter/time (composite feedrate, jog/dry run feedrate)
7 : Inch/time (composite feedrate, jog/dry run feedrate)
8 : % (load meter, load current)

- 598 -
B-64303EN-3/01 PROGRAMMING 3.Function References

9 : Ampere (load current)

flag Flags.
Flags are set according to the cls value as follows:
- cls ="1" (coordinate value)
#0 : Display status
1 = Displayed on the CNC screen
0 = Not displayed on the CNC screen
#1 : Axis detachment
1 = Enabled
0 = Disabled
#2 : Interlock
1 = Enabled
0 = Disabled
#3 : Machine lock
1 = Enabled
0 = Disabled
#4 : Servo off
1 = Enabled
0 = Disabled
#5 : In-position check
1 = Not in the in-position check state
0 = In the in-position check state
#6 : Mirror image
1 = Enabled
0 = Disabled
#7 to #15 : Not used

- cls ="5" (speed)


#0 : Spindle speed
1 = Spindle present
0 = Spindle not present
#1 : Jog feedrate/dry run feedrate
1 = Dry run feedrate
0 = Jog feedrate
#2 to #15 : Not used

- Others: Not used

This function is related to the following parameters:


Parameter Nos. 1020
Parameter Nos. 3131, 3132, and 3133
Bits 0, 4, 5, 6, and 7 (MCN, DRL, DRC, DAL, and DAC) of parameter No. 3104
Bits 0 and 1 (NDPx and NDAx) of parameter No. 3115
Bit 2 (ASDs) of parameter No. 3799
For details of parameters, refer to "Parameter Manual" (B-64310EN) of the CNC.

- 599 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.121 Start output of NC program for operation (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_dncstart2

[Syntax]
#include <fwindow.h>
short cnc_dncstart2( char *filename );

[Arguments]
filename [out] Specify the starting address of an area for storing a program number
for operation posted by the CNC.
When the CNC requires a program for a DNC operation, only a null
character is set as the program number.
The area for storing a program number for operation must be at least
16 bytes long. If a 16-byte area is not allocated, the operation of this
function is not guaranteed.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_BUSY(-1) The cnc_dncstart2 function has already been executed.
Use the cnc_dncend2 function to end the previous output operation.
EW_REJECT(13) The CNC does not start a DNC operation.
EW_PARAM( 9) Parameter error.

[Description]
Executing this function shows whether the CNC has started a DNC operation or not.

(Note) Execution of M198 is not permitted.

- 600 -
B-64303EN-3/01 PROGRAMMING 3.Function References

When the CNC has started a DNC operation, this function returns EW_OK. When EW_OK is
returned, the program number requested by the CNC (or a NULL character in case of a DNC
operation) is acquired. Then, use the cnc_dnc2 function to output a program for the DNC
operation.

When the CNC has not started a DNC operation, this function returns EW_REJECT.

When the cnc_dnc2 or cnc_dncend2 function is executed without executing this function,
EW_FUNC is returned.

The basic procedure for performing a DNC operation is shown below.

1) Set to the MEM mode. [Ladder]


2) Set DMMC signal <G042.7> to 1. (Set to the RMT mode.) [Ladder]
3) Execute cnc_dncstart2 function. [C Language Executor]
4) Start automatic operation. [Ladder]
5) Send the NC command by cnc_dnc2 function. [C Language Executor]
6) Reset when the program ends.
(if M code in which the program end is shown is output.) [Ladder]
7) Execute cnc_dncend2 function. [C Language Executor]
8) Set DMMC signal <G042.7> to 0. [Ladder]

It is processing flow of C Language Executor as follows.

cnc_dncstart2() retry
=EW_REJECT
=EW_OK

retry
Output NC program
for DNC operation
cnc_dnc2() =EW_BURRER

=EW_OK

Is there data
left?
Yes
No

cnc_dncend2()

- 601 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.122 Output NC program for operation (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_dnc2

[Syntax]
include <fwindow.h>
short cnc_dnc2( long *length, char *data );

[Arguments]
length [in/out] Specify a pointer to a long variable in which the number of the
characters of an NC program to be output is set.
When control is returned from this function, the number of characters
actually output is set.
Data [in] Specify the starting address of an area in which an NC program to be
output is set.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_RESET(-2) The CNC is reset.
After a DNC operation starts, the CNC requests the stop of a remote
program operation.
EW_FUNC( 1) The cnc_dncstart2 function has not been executed.
EW_LENGTH( 2) The specified data length is invalid.
A negative value is specified as the number of output characters.
EW_PARAM( 9) Parameter error.
EW_BUFFER(10) The buffer is full.
Because the buffer does not have enough space, output operation fails.
Retry.

- 602 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Outputs an NC program for remote program operation (DNC operation) on the CNC side.

This function outputs as many characters as the number specified in length. If the buffer
for data transfer to the CNC does not have enough space for the specified number of
characters, data for the available buffer space is output, and the number of actually
output characters is set in length.

When the CNC stops the DNC operation, EW_RESET is returned. When this function returns
EW_RESET, specify DNC_CANCEL as the output result in the CNC_dncend2 function to end
NC program output.

The output NC program format is shown below:

EOB command 1 EOB command 2 EOB ..... command n EOB Mxx EOB
Command 1 to n ASCII characters
EOB LF(0x0A)
Mxx M code for ending DNC operation (such as M02 and M30)

(Note) Execution of M198 is not permitted.

- 603 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.123 Stop output of NC program for operation (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_dncend2

[Syntax]
#include <fwindow.h>
short cnc_dncend2( short result );

[Arguments]
result [in] DNC_NORMAL : Successful.
DNC_CANCEL : Canceled by operation stop request from the CNC.
DNC_OPENERR : A file could not be opened.
DNC_NOFILE : A file is not present.
DNC_READERR : A file could not be read.

When one of the above values is specified, EW_DATA is issued.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) The cnc_dncstart2 function has not been executed.
EW_DATA( 5) The value specified as the output result is invalid.
EW_PARAM( 9) Parameter error.
Set parameters as follows:

[Description]
Notifies the CNC of the end of the output of a CNC program for a DNC operation.

When notifying the CNC, specify the result of NC program output processing performed
by an application program to indicate whether the processing ended normally or ended
with an error.

When EW_RESET is returned during NC program output (during execution of the cnc_dnc2
function), specify DNC_CANCEL as the output result in this function, and execute this
function.

(Note) Execution of M198 is not permitted.

- 604 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.124 Read abnormal load torque data. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_loadtorq

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_loadtorq( short motor, short axis, short length,
struct odbload *buf ) ;

struct odbload {
short datano ; /* Motor type. */
short type ; /* Axis number. */
short data[N] ; /* Abnormal load torque data. */
} ; /* N is the maximum number of controlled axes. */

[Arguments]
motor Motor type.
0 : Servo motor
1 : Spindle motor
axis Axis number. (= (1 to the maximum number of controlled axes) or "-1")
-1 : Specifies all axes (ALL_AXES).
1 to m : Specifies one axis (m: current number of controlled
axes).
length Data block length. (= 4 + 2 × (number of axes to be read))
buf Buffer in which abnormal load torque data is stored.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) The specified data block length is invalid.
The buf size (length) is invalid.
EW_ATTRIB( 4) The specified axis number is invalid.
The specified data is neither "-1" nor a number ranging from "1" to
the maximum number of controlled axes.

- 605 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads abnormal load torque data (estimated load torque) of servo motors or spindle motors.
Data is stored in buf in signed binary form.

motor specifies the type of a target motor for reading.

motor Motor type


0 Servo motor
1 Spindle motor

As an axis number (axis), a value from "1" to the maximum number of controlled axes (read
for one axis) or "-1" (read for all axes at a time) is specified. When all axes are
specified for spindle motors, data for two axes is read.

In buf.data, a digitized value of load torque data is stored in binary form. When reading
for one axis is specified, load torque data for a specified axis is stored in buf.data[0].

length specifies the data block length (buf size).

buf 0┌─────┐ ─
│datano │ ↑
2├─────┤ │
│type │ │
4├─────┤ │
│data[0] │ │
6├─────┤ length
~ ~ │
4+2×(N-1) ├─────┐ │
│data[N-1] │ │
├─────┤ │
│data[N] │ ↓
4+2×N └─────┘ ─

N denotes the number of axes for which data is to be read.

- 606 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(1) For servo motors


In buf.data, a digitized value of a load current ("0" to "+/-6554") is stored
in binary form. From this value, the load current value can be obtained by using
the following formula:

Load current = buf.data × N / 6554 [Apeak]

where, N denotes the following:

Value of parameter No.


N value
2165
Smaller than 20 Value of parameter No. 2165
Value of parameter No. 2165/10 × 10
20 or greater
(The figure of the unit's place is omitted.)

(2) For spindle motors


A value from "-32767" to "+32767" is stored. From this value, the percentage
to the maximum torque can be obtained by using the following formula:

Percentage to the maximum torque = buf.data/32767 × 100 [%]

[Example]
The following program displays the load torque data of the first spindle motor on the
screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>

void example( void )


{
struct odbload buf ;
short torque ;
cnc_loadtorq( 1, 1, 4+2*1, &buf ) ;
torque = abs( ( (long)buf.data[0] * 100 + 8192 ) / 16384 ) ;
printf( "Current spindle torque = %d [%]\n", torque ) ;
}

- 607 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.125 Read CNC hardware configuration information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdsyshard

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdsyshard( short hard_num, short *read_num,
struct odbsysh *syshard) ;

struct odbsysh {
unsigned long id1 ; /* ID-1(ID) */
unsigned long id2 ; /* ID-2 (additional information). */
short group_id ; /* Group name ID. */
short hard_id ; /* Hardware name ID. */
short hard_num ; /* Serial number assigned to information. */
short slot_no ; /* Slot number. */
short id1_format ; /* ID-1 display format. */
short id2_format ; /* ID-2 display format. */
} ;

[Arguments]
hard_num For the first read operation, specify hard_num = 1.
Data is acquired in the order of information serial numbers. The second and
subsequent read operations are performed repeatedly with hard_num set to
(hard_num acquired last + "1").
read_num Specify a pointer to the number of hardware information items to be read.
Before the function is called, the number of hardware items to be read must
be specified.
After the function is called, the number of items actually read is set. A
value from 1 to 25 can be specified. If no data can be read, read_num = "0"
is returned.
syshard Pointer to a structure to which CNC hardware configuration information is
returned.
As many arrays as the number specified in (*read_num) are required.
id1 The ID of hardware is stored.
id2 Additional hardware information is stored.
group_id Group name ID of hardware.
A numeric value indicating the type of the group of each hardware item is
stored.
The group name IDs of major hardware items are as follows:
(When new data is added, an ID is added.)
0100H MAIN BOARD
0200H OPTION BOARD
0400H BUS EXTN
0500H (UNKNOWN)

- 608 -
B-64303EN-3/01 PROGRAMMING 3.Function References

0600H DISPLAY
0700H OTHERS
0f00H CERTIFY ID
hard_id Hardware name ID
A numeric value indicating the type of hardware is stored.
Major hardware name IDs are listed below.
(When new data is added, an ID is added.)
0100H MAIN BOARD
0101H CPU CARD
0102H SERVO CARD
0103H PMC MODULE
0110H FROM/SRAM
0200H FAST ETHER
0210H FL-NET
0220H PROFI MASTER
0230H PROFI SLAVE
0240H C LANGUAGE
0250H HSSB 2CH
0260H HSSB 1CH
0270H TPU
0280H ADD SPDL
0290H ADD AXIS
02A0H DEVNT MASTER
0400H BUS EXTN
0500H (QFS)
0510H (WRC)
0520H (ETC)
0530H (LIME)
0540H (NBG)
0550H (LSC)
0560H (PHI)
0570H (NEW)
0601H LCD BOARD
0602H DISP ID
0603H GUI CARD
0604H GUI BOARD
0605H GUI ID
0701H MDI ID
0702H BASIC UNIT ID
0f00H CERTIFY ID-1
0f01H CERTIFY ID-2
0f02H CERTIFY ID-3
hard_num A serial number of hardware information is stored.
slot_no A slot number is stored.
id1_format ID-1 display format.

- 609 -
3.Function References PROGRAMMING B-64303EN-3/01

id2_format ID-2 display format.


The display formats of ID-1 and ID-2 used on the system configuration screen
are stored.
0 : Displays nothing.
1 : Displays hexadecimal numbers in 2-digit binary
representation.
2 : Displays hexadecimal numbers in 4-digit binary
representation.
3 : Displays hexadecimal numbers in 6-digtit binary
representation.
4 : Displays 2-digit hexadecimal numbers.
5 : Displays 4-digit hexadecimal numbers as shown in (Example
1) below:
(Example 1) 1234 → 12/34
A slash (/) is inserted so that four characters are
divided into two-character pairs.
6 : Displays 8-digit hexadecimal numbers.
7 : Displays 8-digit hexadecimal numbers by changing character
display positions as shown in (Example 2) below:
(Example 2) 01234567 → 56723 40 1
A space is inserted after the fifth character and the
seventh character.
(Note) When a value begins with "0", "0" is also
displayed.
(Example) When type_id1 = "3"
0002H → 0010

When the following sample data is obtained, information is displayed as shown in the display
example:
/**** Sample data ***********************************************************
* group_id/hard_id/ id1 /id1_format/ id2 /id2_format/slot_no/hard_num *
* *
* 0100H 0100H 00010003 7 0 0 1 *
* 0100H 0101H 00060004 7 800C1104 6 0 2 *
* 0100H 0110H 0000C103 5 0 0 3 *
* *
* 0200H 0200H 10010007 7 0 1 4 *
* *
* 0200H 0220H 10040007 7 0 2 5 *
* *
* 0600H 0602H 00000005 2 0 0 6 *
****************************************************************************/

- 610 -
B-64303EN-3/01 PROGRAMMING 3.Function References

/* Display example ***************************


* 1.HARDWARE CONFIGURATION *
* NAME ID-1 ID-2 SLOT *
* +-------------+----------+--------+----+ *
* MAIN BOARD *
* MAIN BOARD 00301 00 0 *
* CPU CARD 00406 00 0 800C1104 *
* FROM/SRAM C1/03 *
* *
* OPTION BOARD *
* FAST ETHER 00701 10 0 1 *
* PROFI(M) 00704 10 0 2 *
* *
* DISPLAY *
* DISP ID 0101 *
*********************************************/
[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_DATA( 5) Error in the value of hard_num or read_num.

[Description]
Reads CNC hardware configuration information. Each information item is stored in a member
of a structure. Up to 25 hardware configuration information items can be read at a time.
When all information cannot be read at one time, specify hard_num, and read information
repeatedly. There is no path-dependent data.

- 611 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.126 Read CNC system information (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_sysinfo_ex

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_sysinfo_ex( struct odbsysex *sys );

struct odbsysex {
short max_axis; /* Maximum number of controlled axes. */
short max_spdl; /* Maximum number of spindles. */
short max_path; /* Maximum number of paths. */
short max_mchn; /* Maximum number of machine groups. */
short ctrl_axis; /* Number of controlled axes. */
short ctrl_srvo; /* Number of controlled servo axes. */
short ctrl_spdl; /* Number of controlled spindles. */
short ctrl_path; /* Number of controlled paths. */
short ctrl_mchn; /* Number of controlled machines. */
short reserved[3];

struct {
short system; /* System type. */
short group; /* System group type. */
short attrib; /* Path attribute. */
short ctrl_axis; /* Number of controlled axes in a path. */
short ctrl_srvo; /* Number of controlled servo axes in a path. */
short ctrl_spdl; /* Number of controlled spindles in a path. */
short mchn_no; /* Machine group number. */
short reserved;
} path[MAX_PATH];
} ;

MAX_PATH : 2

[Arguments]
sys [out] Pointer to the struct odbsysex structure to which CNC system information
is returned.
max_axis Maximum number of axes controllable in the entire CNC system.
max_spdl Maximum number of spindles controllable in the entire CNC system.
max_path Maximum number of paths controllable in the entire CNC system.
max_mchn Maximum number of machine groups controllable in the entire CNC system.
ctrl_axis Current number of controlled axes in the entire CNC system.
ctrl_srvo Current number of servo axes in the entire CNC system.
* The same value as the number of controlled axes is acquired.
ctrl_spdl Current number of spindles in the entire CNC system.

- 612 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ctrl_path Current number of paths.


ctrl_mchn Current number of machine groups.
path Information specific to each path is stored in an array. As many arrays as
max_path are used.
system System type.
0x0000 : None
0x204D : (= "M") Machining center
0x2054 : (= "T") Lathe
group System group type.
0 : None
1 : Machining center group
2 : Lathe group
attrib Path attribute
0 : CNC
ctrl_axis Number of controlled axes in a path.
ctrl_srvo Number of servo axes in a path.
* The same value as the number of controlled axes is acquired.
ctrl_spdl Number of spindles in a path.
mchn_no Machine group number.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Reads CNC-specific system information such as information indicating whether the CNC
system is a machining center system or lathe system, path information, and the number
of controlled axes.

Use this function to confirm compatibility between the CNC's system software and the
PMC's software or to obtain the number of axes before reading coordinate data such as
absolute coordinates or machine coordinates on the CNC side.

- 613 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.127 Read machine position of controlled axis (3). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_machine3

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_machine3( short axis, short length, short type,
struct iodbaxis *machine);

struct iodbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[N] ; /* Machine position of controlled axis. */
} ; /* N : Maximum number of controlled axes. */

[Arguments]
axis Specify a target axis number for reading.
ALL_AXES : Specifies all axes. (ALL_AXES: "-1")
1 to m : Specifies one axis. (m: Current number of controlled axes)
length Specify the data block length (size of the iodbaxis structure).

1 axis specified All axes specified


iodbaxis 0┌───┐ ─ 0┌───┐ ─
│dummy │ ↑ │dummy │ ↑
2├───┤ │ 2├───┤ │
│type │ length │type │ length
4├───┴───┐│ 4├───┴───┐│
│ data[0] │↓ │ data[0] ││
8└───────┘─ 8├───────┤│
~ ~│
4+4×(n-1) ├───────┤│
│ data[n-1] │↓
4+4×n └───────┘─
n = Maximum number of controlled axes
(Data for controlled axes is valid.)

- 614 -
B-64303EN-3/01 PROGRAMMING 3.Function References

type Specify the type of machine coordinates to be read.

Servo or acceleration/deceleration
Value Coordinates to be read
delay
0 Machine-based machine coordinates Considered
Machine coordinates depending on
1 Not considered
bit 0 (MCN) of parameter No. 3104
2 Machine-based machine coordinates Not considered

machine Pointer to the iodbaxis structure to which the machine position on each
controlled axis is returned.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The size (length) of the iodbaxis structure is invalid.
EW_ATTRIB( 4) Data attribute error.
The specified axis number (axis) is invalid.
The machine coordinate type (type) is invalid.

[Description]
Reads the machine position on an axis specified in axis.
type specifies the type of machine position to be read.

The machine position is stored in data[0] of the iodbaxis structure.

When ALL_AXES is specified in axis, the positions on all axes can be read at a time.
In this case, the machine position on each axis is stored in the data array in the iodbaxis
structure.

The decimal point position of the machine position can be acquired by using the
cnc_getfigure function.

This function is related to the following parameters:


- Bit 0 (INM) of parameter No. 1001 (when type="0" or "2")
- Bit 2 (INI) of parameter No. 0000 (when type="1")
- Bit 0 (MCN) of parameter No. 3104 (when type="1")
- Bit 7 (EMP) of parameter No. 11313 (when type="0")
- Bit 5 (MPH) of parameter No. 11300 (when type="2")
For details of parameters, refer to "Parameter Manual" (B-64310EN) of the CNC.

- 615 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.128 Read jogging speed or dry run speed. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdjogdrun

[Declaration]
#include <data.h>
#include <fwindow.h>
short cnc_rdjogdrun( short axis, struct odbjogdrun *jogdrun );

struct odbjogdrun {
struct speedelm jogdrun ; /* Jogging speed or dry run speed. */
} ;

struct speedelm {
long data ; /* Speed. */
short dec ; /* Decimal point position of speed. */
short unit ; /* Unit of speed. */
short reserve ; /* Not used. */
char name ; /* Name. */
char suff ; /* Suffix of name. */
} ;

[Arguments]
axis Specify "1" at any time.
Jogdrun Pointer to the speedelm structure to which the speed is returned.
Acquired information is stored.
Each member variable of the speedelem structure holds the following
value:
data Speed
dec Decimal point position of speed
unit Unit of speed
0 : mm/min
1 : inch/min
name Name (ASCII)
Jogging speed: "J"
Dry run speed: "D"
suff Suffix of the name (ASCII). Always set to "F"

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

- 616 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Obtains the jogging feedrate or dry run speed displayed on the CNC's position display
screen.

The jogging feedrate and dry run speed can be made visible or invisible by setting bit
7 (JSP) of parameter No. 3108. For details of the parameter, refer to "Parameter Manual"
(B-64310EN) of the CNC.
This function can acquire the jogging feedrate or dry run speed regardless of parameter
setting.

Acquired information is stored in jogdrun.


Which value, the jogging feedrate or dry run speed, is to be read is determined
automatically according to the mode set in the CNC, and can be confirmed by checking
the name value of the odbjogdrun structure.

- 617 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.129 Read P-code macro variables (double-precision floating point). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpmacror2

[Syntax]
#include <fwindow.h>
short cnc_rdpmacror2( unsigned long stnum, unsigned long *num,
unsigned short type, double *mcval ) ;

[Arguments]
stnum [ in ] Specify a starting P-code macro variable number with which reading
starts.
num [ in ] Specify the number of P-code macro variables to be read.
After the function is called, the number of variables actually read
is set.
type [ in ] Specify the type of the target macro for reading.
0 : Conversational
1 : Auxiliary
2 : Execution
* For P-code macro variable numbers "10000" to "89999", this value
is ignored.
mcval [ out ] Array for storing read P-code macro variables.
For empty data, 0xFFFFFFFFFFFFFFFF is set.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Data number error. The specified P-code macro variable number (stnum)
is invalid.
EW_NOOPT( 6) A required function is not provided.
The macro executor function is required.

[Description]
Reads as many P-code macro variables as the number specified in num, starting with the
P-code macro variable (variable for the macro executor) specified in stnum.

This function differs from cnc_rdpmacror in the following points:

- An argument for specifying a macro type, which is required when P-code macro
variables are read, is added.
- Values to be read were represented with an integer type variable value and
the number of decimal positions in a structure. With this function, these
values are represented in double form.

- 618 -
B-64303EN-3/01 PROGRAMMING 3.Function References

- The block size specified at the time of reading is changed to the number of
P-code macro variables to be read.

For details of P-code macro variables, refer to "Macro Compiler/Macro Executor


Programming Manual" (B-64303EN-2).

- 619 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.130 Write P-code macro variables (double-precision floating point). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrpmacror2

[Syntax]
#include <fwindow.h>
short cnc_wrpmacror2( unsigned long stnum, unsigned long *num,
unsigned short type, double *pmacror );

[Arguments]
stnum [ in ] Specify a P-code macro variable number with which writing
starts.
num [ in ] Specify the number of P-code macro variables to which data is to be
written.
After the function is called, the number of variables actually written
is set.
type [ in ] Specify one of the following as the target macro type for writing:
0 : Conversational
1 : Auxiliary
2 : Execution
* For P-code macro variable numbers "10000" to "89999", this
value is ignored.
pmacror [ in ] Array of values to be written to P-code macro variables.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NUMBER( 3) Data number error.
The specified P-code macro variable number (stnum) is invalid.
EW_NOOPT( 6) A required function is not provided.
The macro executor function is required.

[Description]
Writes as many P-code macro variables as the number specified in num, starting with the
P-code macro variable number (variable for the macro executor) specified in stnum.

This function differs from cnc_wrpmacror in the following points:

- An argument for specifying a macro type, which is required when P-code macro variables
are written, is added.
- Values to be written were represented with an integer type variable value and the number
of decimal positions. With this function, these values are represented in double form.

- 620 -
B-64303EN-3/01 PROGRAMMING 3.Function References

- The block size specified for writing is changed to the number of P-code macro variables
to be written.

For details of P-code macro variables, refer to "Macro Compiler/Macro Executor


Programming Manual" (B-64303EN-2).

- 621 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.131 Read all alarm messages at once. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdalmmsg

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdalmmsg( short type, short *num, struct odbalmmsg *almmsg);

struct odbalmmsg {
long alm_no ; /* Alarm number. */
short type ; /* Alarm type. */
short axis ; /* Axis number. */
short dummy ; /* Reserved. */
short msg_len ; /* Number of message characters. */
char alm_msg[32]; /* Alarm message. */
};

alm_no An alarm number is set.


Type The type of an alarm is set.
This value is the same as that specified in the type argument.
Axis An axis number is set. (1 to the maximum number of controlled axes)
For alarms that are not related to any axis, "0" is set.
msg_len The number of message characters (in binary) is set. ("1" to "32")
alm_msg An alarm message character string (ASCII) is set.

[Arguments]

type [ in ] Specify an alarm type.


0 : Parameter writing switch on (SW)
1 : Parameter input that requires power-off (PW)
2 : I/O error (IO)
3 : PS for foreground (PS)
4 : Overtravel/external data input error (OT)
5 : Overheat (OH)
6 : Servo alarm (SV)
7 : Data I/O error (SR)
8 : Macro alarm (MC)
9 : Spindle alarm (SP)
10 : OT alarm other than PS alarms (DS)
11 : Alarm related to malfunction prevention function (IE)
12 : PS for background (BG)
13 : Excessive synchronization error (SN)
14 : Reserved
15 : External alarm message (EX)
16 : External alarm message (EX2)

- 622 -
B-64303EN-3/01 PROGRAMMING 3.Function References

17 : External alarm message (EX3)


18 : External alarm message (EX4)
19 : PMC error (PC)
-1 : All types
num [ in/out ] Specify a pointer to the number of alarms to be read.
Before calling the function, specify the number of alarms to be read.
After the function is called, the number of alarms actually read is
set.
almmsg [ out ] Pointer to an array of a structure to which an alarm message is returned.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) The specified data length is invalid.
The number of alarms (*num) is "0" or less.
EW_ATTRIB( 4) Data attribute error.
The specified alarm type (type) is invalid.

[Description]
Reads alarm messages issued in the CNC. All alarm messages can be read at once.

Unlike the cnc_rdalminfo function, this function inserts axis names in alarm messages
that are related to axes.

- 623 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.132 Read alarm message (extended message string). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdalmmsg2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdalmmsg2( short type, short *num,
struct odbalmmsg2 *almmsg) ;

struct odbalmmsg2 {
long alm_no ; /* Alarm number. */
short type ; /* Alarm type. */
short axis ; /* Axis number. */
short dummy ; /* Reserved. */
short msg_len ; /* Number of message characters. */
char alm_msg[64]; /* Alarm message. */
};

alm_no An alarm number is set.


type The type of an alarm is set.
This value is the same as that specified in the type argument.
axis An axis number is set. (1 to the maximum number of controlled axes)
For alarms that are not related to any axis, "0" is set.
msg_len The number of message characters (in binary) is set. ("1" to "64")
alm_msg An alarm message character string (ASCII) is set.

[Arguments]
type Specify an alarm type.
0 : Parameter writing switch on (SW)
1 : Parameter input that requires power-off (PW)
2 : I/O error (IO)
3 : PS for foreground (PS)
4 : Overtravel/external data input error (OT)
5 : Overheat (OH)
6 : Servo alarm (SV)
7 : Data I/O error (SR)
8 : Macro alarm (MC)
9 : Spindle alarm (SP)
10 : OT alarm other than PS alarms (DS)
11 : Alarm related to malfunction prevention function (IE)
12 : PS for background (BG)
13 : Excessive synchronization error (SN)
14 : Reserved
15 : External alarm message (EX)
16 : External alarm message (EX2)

- 624 -
B-64303EN-3/01 PROGRAMMING 3.Function References

17 :
External alarm message (EX3)
18 :
External alarm message (EX4)
19 :
PMC error (PC)
20 :
Not used
:
31 : Not used
num Specify a pointer to the number of alarms to be read.
Before calling the function, specify the number of alarms to be read. After
the function is called, the number of alarms actually read is set.
Almmsg Pointer to an array of a structure to which an alarm message is returned.
As many arrays as the number specified in (*num) are required.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) The specified data length is invalid.
The number of alarms (*num) is "0" or less.
EW_ATTRIB( 4) Data attribute error.
The specified alarm type (type) is invalid.

[Description]
Reads alarm messages issued in the CNC.

All alarm messages can be read at once.


While the cnc_rdalmmsg function can obtain up to 32 alarm message characters,
cnc_rdalmmsg2 can obtain up to 64 characters.
Unlike the cnc_rdalminfo function, this function inserts axis names in alarm messages
that are related to axes.

- 625 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.133 Read program directory (4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdprogdir4

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdprogdir4( short type, long top_number, short *num_prog,
struct prgdir4 *buf);

struct prgdir4 {
long number;
long length;
long page;
char comment[52];
struct{
short year;
short month;
short day;
short hour;
short minute;
short dummy;
} mdate;
struct{
short year;
short month;
short day;
short hour;
short minute;
short dummy;
} cdate;
};

[Arguments]
type [in] Specify the format of a list of programs to be read.
0 : Program numbers only
1 : Program numbers and comments
2 : Program numbers, comments, dates, and sizes
top_number [in] Specify a starting program with which acquisition of information is
to be started, as the position of the program in the order of
registered NC programs ("1" or greater).
Programs are obtained sequentially from the smallest program number.
num_prog [in/out] Pointer to the number of programs to be read.
After the function is called, the number of programs actually read
is set.

- 626 -
B-64303EN-3/01 PROGRAMMING 3.Function References

buf [out] Pointer to the struct prgdir4 structure to which a program directory
is returned.
struct prgdir4 has the same format as the struct prgdir3 structure.
number Program number.
A program number is returned.
length Program size (the number of characters).
The program size in characters is returned.
This argument is valid when the type argument is set to "2".
Page Not used.
comment Comment.
A comment recorded immediately after the program number is stored.
A comment body consists of up to 48 characters (up to 50 characters
when the parentheses before and after the comment are included).
When a comment consisting of more than 48 characters is recorded,
the 49th and subsequent characters are not output.
When a program has no comment, only parentheses ("()") are output.
The character string ends with a NULL character.
This argument is valid when the type argument is set to "1" or "2".
mdate Date of update.
The date when the program was updated.
This argument is valid when the type argument is set to "2".
The structure consists of the following:
year : 4-digit year
month : Month
day : Day
hour : Hour
minute : Minute
cdate Not used.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 2) Error in the data block length.
The number of programs to be read (num_prog) is invalid.
EW_NUMBER( 3) Data number error.
The starting program number (top_number) is invalid.
EW_ATTRIB( 4) Data attribute error.
The output format (type) is invalid.

- 627 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the program numbers of all machining programs registered in the CNC.

As many program numbers as specified in num_prog, starting with the program number
specified in num_prog, and their comments, dates (dates of creation and dates of update),
and sizes are read.

In any case, if no program is registered, or if there is no program in a specified range,


num_prog is set to "0".

[Example]
The following program reads the registration status of all NC programs and displays a
list of program numbers on the screen:

#define BUFSIZE 100

void example()
{
struct prgdir4 prg[BUFSIZE];
short i, num;
short top = 0;

do {
num = BUFSIZE;
ret = cnc_rdprogdir4( h, 0, &top, &num, prg );
if ( ret == EW_NUMBER ) {
break;
}
if ( ret ) {
printf( "ERROR: %d\n", ret );
break;
}
for ( i = 0 ; i < num ; i++ ) {
printf( "O%d\n", prg[i].number );
}
top = prg[num-1].number + 1;
} while ( num >= BUFSIZE );
}

- 628 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.134 Stop history data sampling. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_stopophis

[Syntax]
#include <fwindow.h>
short cnc_stopophis( void );

[Arguments]
------

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_REJECT(13) CNC processing is rejected.

[Description]
Instructs the CNC to stop sampling operation history data, alarm history data, and
external operator's message history data.

- 629 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.135 Resume history data sampling. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_startophis

[Syntax]
#include <fwindow.h>
short cnc_startophis( void );

[Arguments]
------

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Instructs the CNC to resume sampling operation history data, alarm history data, and
external operator's message history data.

- 630 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.136 Read the number of operation history data items. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdophisno

[Syntax]
#include <fwindow.h>
short cnc_rdophisno( unsigned short * hisno );

[Arguments]
hisno Specify the address of a variable for storing the number of operation
history data items.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) Function is not executed.
History data sampling is not stopped (by using the cnc_stopophis
function).

[Description]
Reads the number of operation history data items.

When reading operation history data by using the cnc_rdophistry3 function, use the
cnc_rdophisno3 function instead of this function.

Before this function can be used, history data sampling must be stopped (cnc_stopophis
function).

(Example)
When the following history data is displayed on the operation history screen of
the NC, using this function sets the number of operation history data items to "3".

History No. Operation history


1 2008/09/29 ┐ Power-on time
12:34:56 ┘
2 SW0100 ┐
2008/09/29 │ Alarm
13:00:00 ┘
3 [SOFT 1] ─ MDI key operation

- 631 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.137 Read the number of operation history data items (3). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdophisno3

[Syntax]
#include <fwindow.h>
short cnc_rdophisno3( unsigned short * hisno );

[Arguments]
hisno Specify the address of a variable for storing the number of operation
history data items.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) Function is not executed.
History data sampling is not stopped (cnc_stopophis function).

[Description]
Reads the number of operation history data items.

This function is a special function used when operation history data is to be read using
the cnc_rdophistry3 function.

Before this function can be used, history data sampling must be stopped (cnc_stopophis
function).

- Difference from the cnc_rdophisno function


Only records of the record types (MDI keys, signals, alarms, and dates and times)
handled by the cnc_rdophistry3 function are counted.
When the following history data is displayed on the operation history screen
of the CNC, using this function sets the number of operation history data items
to "3".

History No. Operation history


1 2008/09/29 ┐ Power-on time
12:34:56 ┘
2 SW0100 ┐
2008/09/29 │ Alarm
13:00:00 ┘
3 [SOFT 1] ─ MDI key operation

- 632 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.138 Read operation history data (4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdophistry4

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdophistry4( unsigned short s_no, unsigned short *e_no,
unsigned short *length, void *his);
struct odbophis4 {
short rec_len; /* Valid record length. */
short rec_type; /* Record type. */
union {
struct {
char key_code; /* Key code. */
char pw_flag; /* Power-on flag. */
short pth_no; /* Path number. */
short ex_flag; /* External MDI key flag. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
} rec_mdi; /* MDI key operation. */
struct {
short sig_name; /* Signal name. */
short sig_no; /* Signal number. */
char sig_old; /* Bit pattern before change. */
char sig_new; /* Bit pattern after change. */
short pmc_no; /* PMC number. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
short dummy; /* Not used. */
} rec_sgn; /* Signal. */
struct {
short alm_grp; /* Alarm type. */
short alm_no; /* Alarm number. */
short axis_no; /* Absolute axis number or absolute */
/* spindle number. */
short year; /* Year. */
short month; /* Month. */
short day; /* Day. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */

- 633 -
3.Function References PROGRAMMING B-64303EN-3/01

short pth_no; /* Path number. */


} rec_alm; /* Alarm. */
struct {
short evnt_type;/* Event type. */
short year; /* Year. */
short month; /* Month. */
short day; /* Day. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
short dummy; /* Not used. */
} rec_date; /* Date and time. */
struct {
short alm_grp; /* Alarm type. */
short alm_no; /* Alarm number. */
short axis_no; /* Absolute axis number or absolute */
/* spindle number. */
short year; /* Year. */
short month; /* Month. */
short day; /* Day. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
short pth_no; /* Path number. */
short dammy; /* Not used. */
short dsp_flg; /* Flag for message display. */
short axis_num; /* Total number of axes. */
long g_modal[10];/* G code modal value. */
char g_dp[10]; /* #7: When 1 is set, the value is */
/* specified in a specified block. */
/* #6 to #0: Number of decimal */
/* positions.*/
long a_modal[10];/* B, D, E, F, H, M, N, O, S, or T */
/* code modal value. */
char a_dp[10]; /* #7: When 1 is set, the value is */
/* specified in a specified block. */
/* #6 to #0: Number of decimal */
/* positions.*/
long abs_pos[32];/* Absolute coordinate value when */
/* the alarm is issued. */
char abs_dp[32]; /* Number of decimal positions of */
/* the coordinate value when the alarm */
/* is issued.*/
long mcn_pos[32];/* Machine coordinate value when */
/* the alarm is issued. */
char mcn_dp[32]; /* Number of decimal positions of */
/* the coordinate value when the alarm */
/* is issued. */
} rec_ial; /* Alarm with additional information */
/* (MC alarm/EXT alarm).*/

- 634 -
B-64303EN-3/01 PROGRAMMING 3.Function References

struct {
short alm_grp; /* Alarm type. */
short alm_no; /* Alarm number. */
short axis_no; /* Absolute axis number or absolute */
/* spindle number. */
short year; /* Year. */
short month; /* Month. */
short day; /* Day. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
short pth_no; /* Path number. */
short dammy; /* Not used. */
short dsp_flg; /* Flag for message display. */
short axis_num; /* Total number of axes. */
char alm_msg[64];/* Alarm message. */
long g_modal[10];/* G code modal value. */
char g_dp[10]; /* #7: When 1 is set, the value is */
/* specified in a specified block. */
/* #6 to #0: Number of decimal */
/* positions.*/
long a_modal[10];/* B,D,E,F,H,M,N,O,S, or T */
/* code modal value. */
char a_dp[10]; /* #7: When 1 is set, the value is */
/* specified in a specified block. */
/* #6 to #0: Number of decimal */
/* positions.*/
long abs_pos[32];/* Absolute coordinate value when */
/* the alarm is issued. */
char abs_dp[32]; /* Number of decimal positions of */
/* the coordinate value when the alarm */
/* is issued.*/
long mcn_pos[32];/* Machine coordinate value when */
/* the alarm is issued. */
char mcn_dp[32]; /* Number of decimal positions of */
/* the coordinate value when the alarm */
/* is issued. */
} rec_mal; /* Alarm with a message with additional :/
/* information. */
struct {
short dsp_flg; /* Flag for message display. */
short om_no; /* Message number. */
short year; /* Year. */
short month; /* Month. */
short day; /* Day. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */

- 635 -
3.Function References PROGRAMMING B-64303EN-3/01

char ope_msg[256];/* Message. */


} rec_opm; /* External operator's */
/* message. */
struct {
short ofs_grp; /* Tool offset data type. */
short ofs_no; /* Tool offset number. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
short pth_no; /* Path number. */
long ofs_old; /* Tool offset data before change. */
long ofs_new; /* Tool offset data after change. */
short old_dp; /* Number of decimal positions of */
/* tool offset data before change. */
short new_dp; /* Number of decimal positions of */
/* tool offset data after change. */
} rec_ofs; /* Change of tool offset. */
struct {
short prm_grp; /* Parameter data type. */
short prm_num; /* Number (varying depending on the */
/* parameter data type. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
short prm_len; /* Parameter data length. */
long prm_no; /* Parameter number. */
long prm_old; /* Parameter data before change. */
long prm_new; /* Parameter data after change. */
short old_dp; /* Number of decimal positions of */
/* parameter data before change. */
short new_dp; /* Number of decimal positions of */
/* parameter data after change. */
} rec_prm; /* Parameter change. */
struct {
short ofs_grp; /* Work offset data type. */
short ofs_no; /* Work offset number. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
short pth_no; /* Path number. */
short axis_no; /* Relative axis number in a path. */
short dummy; /* Not used. */
long ofs_old; /* Work offset data before change. */
long ofs_new; /* Work offset data after change. */
short old_dp; /* Number of decimal positions of */
/* work offset data before change. */

- 636 -
B-64303EN-3/01 PROGRAMMING 3.Function References

short new_dp; /* Number of decimal positions of */


/* work offset data after change. */
} rec_wof; /* Change of work offset. */
struct {
short mac_no; /* Custom macro common variable number. */
short hour; /* Hour. */
short minute; /* Minute. */
short second; /* Second. */
long mac_old; /* Common variable data before change. */
long mac_new; /* Common variable data after change. */
short old_dp; /* Number of decimal positions of common */
/* data before change. */
short new_dp; /* Number of decimal positions of common */
/* data after change. */
} rec_mac; /* Change of custom macro common */
/* variable. */
} u;
};

[Arguments]
s_no Specify an operation history data number with which reading is started.
(Specify "1" or a greater value.)
e_no Specify a pointer to an operation history data number with which reading
is ended.
(Specify "1" or a greater value.)
The function returns the last operation history data number that was
actually read.
length Specify a pointer to the data block length required for storing
operation history data in a specified range.
The structure for storing each operation history data item is shown
below. The size of a structure is indicated by rec_len. As many
structures as specified are placed in the order of operation history
record numbers. The length to be specified is the sum of the rec_len
values of these structures.

The function returns the size of data actually read, so a little bit longer size may
be specified.

- 637 -
3.Function References PROGRAMMING B-64303EN-3/01

MDI key operation


struct odbophis4 0┌───────────┐ ─
│ rec_len = 16 │ ↑
2├───────────┤ │
│ rec_type │ │
4├─────┬─────┘ │
│ key_code │ │
5├─────┤ │
│ pw_flag │ │
6├─────┴─────┐ │
│ pth_no │rec_len
8├───────────┤ │
│ ex_flag │ │
10├───────────┤ │
│ hour │ │
12├───────────┤ │
│ minute │ │
14├───────────┤ │
│ second │ ↓
16└───────────┘ ─

Signal
struct odbophis4 0┌───────────┐ ─
│ rec_len = 20 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ sig_name │ │
6├───────────┤ │
│ sig_no │ │
8├─────┬─────┘ │
│ sig_old │ │
9├─────┤ rec_len
│ sig_new │ │
10├─────┴─────┐ │
│ pmc_no │ │
12├───────────┤ │
│ hour │ │
14├───────────┤ │
│ minute │ │
16├───────────┤ │
│ second │ │
18├───────────┤ │
│ dummy │ ↓
20└───────────┘ ─

- 638 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Alarm
struct odbophis4 0┌───────────┐ ─
│ rec_len = 24 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ alm_grp │ │
6├───────────┤ │
│ alm_no │ │
8├───────────┤ │
│ axis_no │ │
10├───────────┤ │
│ year │ │
12├───────────┤rec_len
│ month │ │
14├───────────┤ │
│ day │ │
16├───────────┤ │
│ hour │ │
18├───────────┤ │
│ minute │ │
20├───────────┤ │
│ second │ │
22├───────────┤ │
│ pth_no │ ↓
24└───────────┘ ─
Date and time
struct odbophis4 0┌───────────┐ ─
│ rec_len = 20 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ evnt_type │ │
6├───────────┤ │
│ year │ │
8├───────────┤ │
│ month │rec_len
10├───────────┤ │
│ day │ │
12├───────────┤ │
│ hour │ │
14├───────────┤ │
│ minute │ │
16├───────────┤ │
│ second │ │
18├───────────┤ │
│ dummy │ ↓
20└───────────┘ ─

- 639 -
3.Function References PROGRAMMING B-64303EN-3/01

Alarm with additional information


struct odbophis4 0┌───────────┐ ─
│ rec_len =450 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ alm_grp │ │
6├───────────┤ │
│ alm_no │ │
8├───────────┤ │
│ axis_no │ │
10├───────────┤ │
│ year │ │
12├───────────┤ │
│ month │ │
14├───────────┤ │
│ day │ │
16├───────────┤ │
│ hour │ │
18├───────────┤ │
│ minute │ │
20├───────────┤ │
│ second │ │
22├───────────┤ │
│ pth_no │ │
24├───────────┤ │
│ dammy │ │
26├───────────┤ │
│ dsp_flg │ │
28├───────────┤ │
│ axis_num │ │
30├───────────┤ │
│ │ │
│ g_modal[0] │ │
│ │ │
34├───────────┤ │
~ ~ │
66├───────────┤ │
│ │ │
│ g_modal[9] │ │
│ │rec_len
70├─────┬─────┘ │
│ g_dp[0] │ │
71├─────┤ │
~ ~ │

- 640 -
B-64303EN-3/01 PROGRAMMING 3.Function References

~ ~ │
79├─────┤ │
│ g_dp[9] │ │
80├─────┴─────┐ │
│ │ │
│ a_modal[0] │ │
│ │ │
84├───────────┤ │
~ ~ │
116├───────────┤ │
│ │ │
│ a_modal[9] │ │
│ │ │
120├─────┬─────┘ │
│ a_dp[0] │ │
121├─────┤ │
~ ~ │
129├─────┤ │
│ a_dp[9] │ │
130├─────┴─────┐ │
│ │ │
│ abs_pos[0] │ │
│ │ │
134├───────────┤ │
~ ~ │
254├───────────┤ │
│ │ │
│ abs_pos[31] │ │
│ │ │
258├─────┬─────┘ │
│abs_dp[0] │ │
259├─────┤ │
~ ~ │
289├─────┤ │
│abs_dp[31]│ │
290├─────┴─────┐ │
│ │ │
│ mcn_pos[0] │ │
│ │ │
294├───────────┤ │
~ ~ │

- 641 -
3.Function References PROGRAMMING B-64303EN-3/01

~ ~ │
414├───────────┤ │
│ │ │
│ mcn_pos[31] │ │
│ │ │
418├──────┬────┘ │
│mcn_dp[0] │ │
419├──────┤ │
~ ~ │
449├──────┤ │
│mcn_dp[31] │ ↓
450└──────┘ ─
Alarm with a message with additional information
struct odbophis4 0┌───────────┐ ─
│ rec_len =514 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ alm_grp │ │
6├───────────┤ │
│ alm_no │ │
8├───────────┤ │
│ axis_no │ │
10├───────────┤ │
│ year │ │
12├───────────┤ │
│ month │ │
14├───────────┤ │
│ day │ │
16├───────────┤ │
│ hour │ │
18├───────────┤ │
│ minute │ │
20├───────────┤ │
│ second │ │
22├───────────┤ │
│ pth_no │ │
24├───────────┤ │
│ dammy │ │
26├───────────┤ │
│ dsp_flg │ │
28├───────────┤ │
│ axis_num │ │
30├──────┬────┘ │
│alm_msg[0] │ │
31├──────┤ │
~ ~ │

- 642 -
B-64303EN-3/01 PROGRAMMING 3.Function References

~ ~ │
93├──────┤ │
│alm_msg[63] │ │
94├──────┴────┐ │
│ │ │
│ g_modal[0] │ │
│ │ │
98├───────────┤ │
~ ~ │
130├───────────┤ │
│ │ │
│ g_modal[9] │ │
│ │rec_len
134├─────┬─────┘ │
│ g_dp[0] │ │
135├─────┤ │
~ ~ │
143├─────┤ │
│ g_dp[9] │ │
144├─────┴─────┐ │
│ │ │
│ a_modal[0] │ │
│ │ │
148├───────────┤ │
~ ~ │
180├───────────┤ │
│ │ │
│ a_modal[9] │ │
│ │ │
184├─────┬─────┘ │
│ a_dp[0] │ │
185├─────┤ │
~ ~ │
193├─────┤ │
│ a_dp[9] │ │
194├─────┴─────┐ │
│ │ │
│ abs_pos[0] │ │
│ │ │
198├───────────┤ │
~ ~ │

- 643 -
3.Function References PROGRAMMING B-64303EN-3/01

~ ~ │
318├───────────┤ │
│ │ │
│ abs_pos[31] │ │
│ │ │
322├─────┬─────┘ │
│abs_dp[0] │ │
323├─────┤ │
~ ~ │
353├─────┤ │
│abs_dp[31]│ │
354├─────┴─────┐ │
│ │ │
│ mcn_pos[0] │ │
│ │ │
358├───────────┤ │
~ ~ │
478├───────────┤ │
│ │ │
│ mcn_pos[31] │ │
│ │ │
482├──────┬────┘ │
│mcn_dp[0] │ │
483├──────┤ │
~ ~ │
513├──────┤ │
│mcn_dp[31] │ ↓
514└──────┘ ─

- 644 -
B-64303EN-3/01 PROGRAMMING 3.Function References

External operator's message


struct odbophis4 0┌───────────┐ ─
│ rec_len = 276 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ dsp_flg │ │
6├───────────┤ │
│ om_no │ │
8├───────────┤ │
│ year │ │
10├───────────┤ │
│ month │ │
12├───────────┤ │
│ day │ │
14├───────────┤ │
│ hour │rec_len
16├───────────┤ │
│ minute │ │
18├───────────┤ │
│ second │ │
20├──────┬────┘ │
│ ope_msg[0] │ │
21├──────┤ │
~ ~ │
275├──────┤ │
│ope_msg[255]│ ↓
276└──────┘ ─

- 645 -
3.Function References PROGRAMMING B-64303EN-3/01

Change of a tool offset


struct odbophis4 0┌───────────┐ ─
│ rec_len = 28 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ ofs_grp │ │
6├───────────┤ │
│ ofs_no │ │
8├───────────┤ │
│ hour │ │
10├───────────┤ │
│ minute │ │
12├───────────┤rec_len
│ second │ │
14├───────────┤ │
│ pth_no │ │
16├───────────┤ │
│ │ │
│ ofs_old │ │
│ │ │
20├───────────┤ │
│ │ │
│ ofs_new │ │
│ │ │
24├───────────┤ │
│ old_dp │ │
26├───────────┤ │
│ new_dp │ ↓
28└───────────┘ ─

- 646 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Change of a parameter
struct odbophis4 0┌───────────┐ ─
│ rec_len = 32 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ prm_grp │ │
6├───────────┤ │
│ prm_num │ │
8├───────────┤ │
│ hour │ │
10├───────────┤ │
│ minute │ │
12├───────────┤rec_len
│ second │ │
14├───────────┤ │
│ prm_len │ │
16├───────────┤ │
│ │ │
│ prm_no │ │
│ │ │
20├───────────┤ │
│ │ │
│ prm_old │ │
│ │ │
24├───────────┤ │
│ │ │
│ prm_new │ │
│ │ │
28├───────────┤ │
│ old_dp │ │
30├───────────┤ │
│ new_dp │ ↓
32└───────────┘ ─

- 647 -
3.Function References PROGRAMMING B-64303EN-3/01

Change of a work offset


struct odbophis4 0┌───────────┐ ─
│ rec_len = 32 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ ofs_grp │ │
6├───────────┤ │
│ ofs_no │ │
8├───────────┤ │
│ hour │ │
10├───────────┤ │
│ minute │ │
12├───────────┤rec_len
│ second │ │
14├───────────┤ │
│ pth_no │ │
16├───────────┤ │
│ axis_no │ │
18├───────────┤ │
│ dammy │ │
20├───────────┤ │
│ │ │
│ ofs_old │ │
│ │ │
24├───────────┤ │
│ │ │
│ ofs_new │ │
│ │ │
28├───────────┤ │
│ old_dp │ │
30├───────────┤ │
│ new_dp │ ↓
32└───────────┘ ─

- 648 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Change of a custom macro common variable


struct odbophis4 0┌───────────┐ ─
│ rec_len = 24 │ ↑
2├───────────┤ │
│ rec_type │ │
4├───────────┤ │
│ mac_no │ │
6├───────────┤ │
│ hour │ │
8├───────────┤ │
│ minute │ │
10├───────────┤ │
│ second │ │
12├───────────┤rec_len
│ │ │
│ mac_old │ │
│ │ │
16├───────────┤ │
│ │ │
│ mac_new │ │
│ │ │
20├───────────┤ │
│ old_dp │ │
22├───────────┤ │
│ new_dp │ ↓
24└───────────┘ ─

his Pointer to an area to which operation history data is returned.

Structures are used for reference to individual operation history data


items.
rec_len The length of a structure is set.
rec_type The type of a record is set.
0 : MDI key operation
1 : Signal
2 : Alarm
3 : Date and time
4 : Change of a custom macro common variable
5 : Change of a parameter
6 : External operator's message
7 : Change of a tool offset
8 : Change of a work offset
9 : Alarm with additional information
10 : Alarm with a message with additional information

- 649 -
3.Function References PROGRAMMING B-64303EN-3/01

key_code A key code is set.

0x 1x 2x 3x 4x 5x 6x 7x
x0 SP 0 @ P
x1 1 A Q
x2 2 B R
x3 # 3 C S
x4 4 D T
x5 5 E U
x6 & 6 F V
x7 7 G W
x8 CAN ( 8 H X
x9 ) 9 I Y
xA EOB * J Z
xB + K [
xC , L
xD INPUT - M ]
xE . N
xF / ? O

8x 9x Ax Bx Cx Dx Ex Fx
x0 RESET F0
x1 F1
x2 F2
x3 F3
x4 INSERT F4
x5 DELETE F5
x6 ALTER F6
x7 F7
x8 Curs→ POS F8
x9 Curs← PROG F9
xA Curs↓ HELP OFS/SET
xB Curs↑ SYSTEM
xC MESSAGE
Xd GRAPH
xE Page↓ CUSTOM1 FR
xF Page↑ CUSTOM2 FL
・ How to use this table: To know the key code of 'A' for example, "4x" is combined
with "x1" to form "41" (in hexadecimal).

pw_flag Power-on flag.


1 : Power-on
0 : Others
ex_flag External MDI key flag.
1 : External MDI key
0 : Ordinary MDI key

- 650 -
B-64303EN-3/01 PROGRAMMING 3.Function References

sig_name Signal name.


1 : "X"
2 : "G"
3 : "Y"
4 : "F"
sig_no Signal number.
X : "0" to "127"
G : "0" to "767"
Y : "0" to "127"
F : "0" to "767"
sig_old Bit pattern before change.
sig_new Bit pattern after change.
alm_grp The type of an alarm is set.
0 : Parameter writing switch on (SW)
1 : Parameter input that requires power-off (PW)
2 : I/O error (IO)
3 : PS for foreground (PS)
4 : Overtravel/external data input error (OT)
5 : Overheat (OH)
6 : Servo alarm (SV)
7 : Data I/O error (SR)
8 : Macro alarm (MC)
9 : Spindle alarm (SP)
10 : OT alarm other than PS alarms (DS)
11 : Alarm related to malfunction prevention function (IE)
12 : PS for background (BG)
13 : Excessive synchronization error (SN)
14 : Reserved
15 : External alarm message (EX)
16 : External alarm message (EX2)
17 : External alarm message (EX3)
18 : External alarm message (EX4)
19 : PMC error (PC)
20 : Not used
:
31 : Not used
alm_no An alarm number is set.
axis_no When the type of a record is an alarm, an alarm with additional
information, or an alarm with a message with additional information,
an absolute axis number ("1" to the maximum number of controlled axes)
or an absolute spindle number ("1" to the number of spindles) is set.
(For an alarm that is not related to axes or spindles, "0" is set.)
When the type of a record is set to change of a workpiece offset,
a relative axis in a path ("0" or a greater value) is set.

- 651 -
3.Function References PROGRAMMING B-64303EN-3/01

year Year ("1995" to "2094").


month Month ("1" to "12").
day Day ("1" to "31").
hour Hour ("0" to "23").
minute Minute ("0" to "59").
second Second ("0" to "59").
evnt_typeEvent type.
0 : Power-off
1 : Power-on
2 : Change of date
3 : Time stamp
4 : Data erasure
pth_no Path number ("1" to "10").
In case of an alarm, a PMC number ("0" to "2") is set if alm_grp =
"15" to "18".
pmc_no PMC number ("1" to "3").
axis_num Total number of axes ("0" to "31").
g_modal G code modal value present when an alarm was issued.
(If no G code modal value is present, "-1" is set.)
A G code group is specified in parameter No. 12990 to 12999.
g_modal[0], g_dp[0] = Parameter (No.12990)
: :
g_modal[9], g_dp[9] = Parameter (No.12999)
g_dp #7 : When "1" is set, the value is specified in a specified block.
(When the value is not present, "-1" is set.)
#6 to #0 : Number of decimal positions
7 6 5 4 3 2 1 0
┌─┬─┬─┬─┬─┬─┬─┬─┐
| Number of decimal positions |
└─┴─┴─┴─┴─┴─┴─┴─┘
#7 : 0 : Not specified in a specified block.
1 : Specified in a specified block.

a_modal Auxiliary function (parameter No. 3460), or D, E, F, H, M, N, O, S,


or T code modal value when an alarm was issued. (When no value is
present, "-1" is set.)

- 652 -
B-64303EN-3/01 PROGRAMMING 3.Function References

a_dp #7 : When 1 is set, the value is specified in a specified block.


(When the value is not present, "-1" is set.)
#6 to #0 : Number of decimal positions

7 6 5 4 3 2 1 0
┌─┬─┬─┬─┬─┬─┬─┬─┐
| Number of decimal positions |
└─┴─┴─┴─┴─┴─┴─┴─┘
#7 : 0 : Not specified in a specified block.
1 : Specified in a specified block.
a_modal[0],a_dp[0]=Auxiliary function code
a_modal[1],a_dp[1]=D code
a_modal[2],a_dp[2]=E code
a_modal[3],a_dp[3]=F code
a_modal[4],a_dp[2]=H code
a_modal[5],a_dp[3]=M code
a_modal[6],a_dp[2]=N code
a_modal[7],a_dp[3]=O code
a_modal[8],a_dp[2]=S code
a_modal[9],a_dp[3]=T code
* When 'O' (program name) is specified, the first five
characters are set.
(Example) O123 TEST_PROGRAM
a_modal ┌──┐ ┌──┐
│'O' │ │'T' │
├──┤ ├──┤
│'1' │ │'E' │
├──┤ ├──┤
│'2' │ │'S' │
├──┤ ├──┤
│'3' │ │'T' │
a_dp ├──┤ ├──┤
│ 0 │ │'_' │
└──┘ └──┘
abs_pos Absolute coordinate value when an alarm was issued.
abs_dp Number of decimal positions of an absolute coordinate value when an
alarm was issued.
mcn_pos Machine coordinate value when an alarm was issued.
cn_dp Number of decimal positions of a machine coordinate value when an
alarm was issued.
* An undefined value is set in areas beyond the number of axes.
alm_msg Alarm message.
dsp_flg Flag for message display.
1 : For a macro alarm, MCxxxx is indicated.
For an external alarm or external operator's message,
EXxxxx is indicated.
0 : Messages are displayed without modification.
om_no Message number.
ope_msg Message (a NULL character (\0) is set at the end.)

- 653 -
3.Function References PROGRAMMING B-64303EN-3/01

ofs_grp Offset data type.


- Tool offset data:
(The type of a tool offset is set.)
0 : Tool offset (Type A memory: M series)
1 : Geometry offset (type B memory: M series)
2 : Wear offset (type B memory: M series)
3 : Tool length compensation (geometry) (type C memory: M
series)
4 : Tool length compensation (wear) (type C memory: M series)
5 : Tool radius compensation (geometry) (type C memory: M
series)
6 : Tool radius compensation (wear) (type C memory: M series)
7 : X-axis tool offset (type A memory: T series)
8 : Z-axis tool offset (type A memory: T series)
9 : X-axis tool offset (geometry) (type B memory: T series)
10 : X-axis tool offset (wear) (type B memory: T series)
11 : Z-axis tool offset (geometry) (type B memory: T series)
12 : Z-axis tool offset (wear) (type B memory: T series)
13 : Tool-nose radius offset (type A memory: T/M series)
14 : Tool-nose radius offset (geometry) (type B memory: T/M
series)
15 : Tool-nose radius offset (wear) (type B memory: T/M series)
16 : Y-axis tool offset (type A memory: T series)
17 : Y-axis tool offset (geometry) (type B memory: T series)
18 : Y-axis tool offset (wear) (type B memory: T series)
19 : Tool tip direction (common: T/M series (for M series, when
bit 5 (TIP) of parameter No. 5009 is set to "1")
- Work offset data:
(The type of a work offset is set.)
0 : Work offset (EXT, G54 to G59)
1 : Extended work offset (G54.1P1 to G54.1P300)
2 : Work shift amount (T series only)
ofs_no Offset number.
- For tool offset data, a tool offset number (1 to 9999) is set.
- For work offset data, a work offset number is set as follows:
ofs_grp="0" : "0"=EXT, "1"=G54, "2"=G55, "3"=G56,
"4"=G57, "5"=G58, "6"=G59
="1" : "1" to "300"
="2" : Invalid

- 654 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ofs_old Tool or work offset data before change.


ofs_new Tool or work offset data after change.
old_dp Number of decimal positions of data before change(*1).
new_dp Number of decimal positions of data after change(*1).
(*1) Applicable to common variables. Data includes tool and work
offset data, parameters, and custom macro common
variables.
(Note) See the description of custom macro common variables.
mac_old Custom macro common variable data before change.
mac_new Custom macro common variable data after change.

(Note) A custom macro common variable is represented in the following


data format:
M×(10^(-E))

mac_old,mac_new : Variable value (=M)


old_dp,new_dp : Number of decimal positions (=E)
("-128" (0x80) to "127" (0x7f))
(Example)
- When a variable value is "12.345", the following data is read:
mcr_val = "1234500000"
dec_val = "8"
→ 1234500000×(10^(-8)) = 12.345
- When a variable value is "123456789012345", the following data is
read:
mcr_val = "1234567890"
dec_val = "-5"
→ 1234567890×(1^5) = 123456789000000
* Special cases
- Empty data:
mac_old, mac_new = "0"
old_dp, new_dp = "-1"(0xff)
- Overflow:
mac_old, mac_new = "-1",
old_dp, new_dp = "-1" (0xff)
prm_grp Parameter data type.
(The type of parameter data is set.)
1: Axis type
2: Spindle type
3: Path type
4: Machine group type
0: Others
prm_num The set value varies depending on the parameter data type, and this
argument is valid only when prm_grp = "1" to "4":
If prm_grp="1", an absolute axis number ("1" to "8" maximum)
is set.
If prm_grp="2", an absolute spindle number ("1" to "3" maximum)
is set.
If prm_grp="3", a path number ("1" to "2") is set.

- 655 -
3.Function References PROGRAMMING B-64303EN-3/01

If prm_grp="4", a machine group number ("1") is set.


prm_len Parameter data length.
0: Bit type, 1: INT8, 2: INT16, 3: INT32, 4: REAL64
prm_no Parameter number ("0" to "99999").
prm_old Parameter number before change.
prm_new Parameter number after change.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) Function is not executed.
History data sampling is not stopped (by using the cnc_stopophis
function).
EW_LENGTH( 2) Error in the data block length.
The size (length) of the operation history data storage area is invalid.
EW_NUMBER( 3) Data number error.
The starting data number (s_no) or ending data number (e_no) is invalid.

[Description]
Reads operation history data.

When reading operation history data, use this function or the CNC_rdophistry3 function
instead of the cnc_rdophistry function.
The cnc_rdophistry3 function differs from the cnc_rdophistry4 function in data type.
For details, see the descriptions of these functions.

The structure of operation history data to be read varies depending on the type of the
operation history data.

The CNC automatically records operation history data, alarm history data, and external
operator's message history data.
Before these types of data can be accessed, sampling performed by the CNC must be stopped
temporarily. Therefore, before using this function, stop history data sampling
(cnc_stopophis function).

As soon as the read operation is completed, resume history data sampling (cnc_startophis
function) to minimize the period during which history data sampling is stopped.

Record numbers such as the starting and ending record numbers are assigned to individual
records of operation history data to be read. These record numbers stay valid during
the time from the stop of history data sampling until history data sampling is resumed.

This function is related to the following parameters:


- Bit 3 (EAH) of parameter No. 3112
- Bits 5 and 6 (HKE and HDE) of parameter No. 3195
- Bits 0 to 3 (HTO, HWO, HPM, and HMV) of parameter No. 3196

- 656 -
B-64303EN-3/01 PROGRAMMING 3.Function References

- Bits 6 and 7 (HOM and HAL) of parameter No. 3196


- Bit 1 (MCA) of parameter No. 6008
- Bit 0 (EXA) of parameter No. 6301
- Bit 1 (EXM) of parameter No. 6301
- Parameter Nos. 12990 to 12999
For details of parameters, refer to "Parameter Manual" (B-64310EN) of the CNC.

- 657 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.139 Clear history data. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_clearophis

[Syntax]
#include <fwindow.h>
short cnc_clearophis( short slct );

[Arguments]
slct Specify the type of history data to be cleared.
0 : Operation history data and external operator history data
1 : Alarm history data

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_ATTRIB( 4) Data attribute error.
The specified history data type (slct) is invalid.
EW_PARAM( 9) CNC parameter error.
Set bit 7 (EKE) of parameter No. 3195 to "1".

[Description]
Data is cleared according to the slct argument as follows:
0 : Operation history data and external operator history data
1 : Alarm history data

- 658 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.140 Read signal to be included in operation history (3). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdhissgnl3

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdhissgnl3( struct iodbsig3 * sig );

struct iodbsig3 {
short datano; /* Not used. */
short type; /* Not used. */
struct {
short ent_no; /* Entry number.*/
short pmc_no; /* PMC number. */
short sig_no; /* Signal number. */
char sig_name; /* Signal name. */
char mask_pat; /* Signal mask pattern. */
} data[60];
} ;

[Arguments]
sig Pointer to a structure to which a signal to be included in operation
history is returned.
ent_no Entry number ("1" to "60").
pmc_no PMC number ("1" to "3").
sig_no Number of a registered signal.
X : "0" to "127"
G : "0" to "767"
Y : "0" to "127"
F : "0" to "767"
sig_name Name of a registered signal.
0 : Not registered
1 : "X"
2 : "G"
3 : "Y"
4 : "F"
mask_pat Signal mask pattern.

[Return]
Main return value is as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

- 659 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads a signal to be included in the operation history.

When reading signals to be included in the operation history, use this function instead
of the cnc_rdhissgnl function.

This function is related to the following parameter:


- Bit 6 (HDE) of parameter No. 3195
For details of parameters, refer to "Parameter Manual" (B-64310EN) of the CNC.

- 660 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.141 Set signal to be included in operation history (3). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrhissgnl3

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrhissgnl3( struct iodbsig3 * sig);

struct iodbsig3 {
short datano; /* Not used. */
short type; /* Number of signals. */
struct {
short ent_no; /* Registration entry number. */
short pmc_no; /* PMC number. */
short sig_no; /* Signal number. */
char sig_name; /* Signal name. */
char mask_pat; /* Signal mask pattern. */
} data[60];
} ;

[Arguments]
sig Pointer to the structure for setting signals to be included in the
operation history.
ent_no Registration entry number ("1" to "60").
pmc_no PMC number ("1" to "3").
sig_no Number of a signal to be registered.
X: "0" to "127"
G: "0" to "767"
Y: "0" to "127"
F: "0" to "767"
sig_name Name of the signal to be registered.
0: Not registered.
1: "X"
2: "G"
3: "Y"
4: "F"
mask_pat Signal mask pattern.

- 661 -
3.Function References PROGRAMMING B-64303EN-3/01

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_ATTRIB(4) Data attribute error.
The specified number of signals to be registered (type) is invalid.
EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function. One of the following detail status codes is
set in member err_no in structure odberr:
1: Registration number (ent_no) error
2: Signal number (sig_no) error
This code is also set when the same signal name or number
is specified more than once.
3: Signal name (sig_name) error
4: PMC number (pmc_no) error
A nonexistent PMC number is specified.

EW_PARAM(9) CNC parameter error.


Set bit 6 (HDE) of parameter No. 3195 to "0".

[Description]
Sets signals to be included in the operation history.

To set signals to be included in the operation history, use this function, not the
cnc_wrhissgnl function.

- 662 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.142 Read the number of alarm history data items (3). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdalmhisno3

[Syntax]
#include <fwindow.h>
short cnc_rdalmhisno3( unsigned short * hisno );

[Arguments]
hisno Specify the address of the variable for which to store the number of
alarm history data items.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_FUNC(1) Function is not executed.
History data sampling is not stopped (the cnc_stopophis function is not
executed).

[Description]
Reads the number of alarm history data items.

This is a dedicated function for reading alarm history data using the cnc_rdalmhistry4
function.

Before using this function, stop history data sampling (execute the cnc_stopophis
function).

- 663 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.143 Read alarm history data (5). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdalmhistry5

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdalmhistry5( unsigned short s_no,unsigned short e_no,
unsigned short length, struct odbahis5 *his);

struct odbahis5 {
unsigned short s_no; /* Start record number. */
unsigned short e_no; /* End record number. */
struct {
short alm_grp; /* Kind of alarm. */
short alm_no; /* Alarm number. */
short axis_no; /* Absolute axis number or absolute */
/* spindle number (1 to the maximum */
/* controlled axis number). */
short year; /* Year. */
short month; /* Month. */
short day; /* Day. */
short hour; /* Hours. */
short minute; /* Minutes. */
short second; /* Seconds. */
short len_msg; /* Number of characters in an alarm message */
/* (0-63). */
short pth_no; /* Path number. */
short dammy; /* Not used. */
short dsp_flg; /* Message display flag. */
short axis_num; /* Total number of axes. */
char alm_msg[64]; /* Alarm message. */
long g_modal[10]; /* Modal G code */
char g_dp[10]; /* When #7 is set to 1, the code is */
/* specified with the specified block. */
/* #6 to #0: Number of digits after the */
/* decimal point. */
long a_modal[10]; /* Modal B, D, E, F, H, M, N, O, S, or T */
/* code */
char a_dp[10]; /* When #7 is set to 1, the code is */
/* specified with the specified block. */
/* #6 to #0: Number of digits after the */
/* decimal point. */
long abs_pos[32]; /* Absolute coordinates when the alarm */
/* is issued. */

- 664 -
B-64303EN-3/01 PROGRAMMING 3.Function References

char abs_dp[32]; /* Number of digits after the decimal point */


/* of the absolute coordinates when the */
/* alarm is issued. */
long mcn_pos[32]; /* Machine coordinates when the alarm is */
/* issued. */
char mcn_dp[32]; /* Number of digits after the decimal point */
/* of the machine coordinates when the */
/* alarm is issued. */
} alm_his[N]; /* N: Number of alarm history data items */
/* to be read. */
} ;

[Arguments]
s_no Specifies the start record number. (Specify "1" or greater.)
e_no Specifies the end record number. (Specify "1" or greater.)
length Specifies the data block length (structure size).

struct odbahis5 0┌────┐ ─


│ s_no │ ↑
2├────┤ │
│ e_no │ │
4├────┴────┐ │
│ alm_his[0] │length
516├─────────┤ │
~ ~ │
4+512×(n-1) ├─────────┤ │
│ alm_his[n] │ ↓
4+512×n └─────────┘ ─

alm_his 0┌─────────────┐
│ alm_grp │
2├─────────────┤
│ alm_no │
4├─────────────┤
│ axis_no │
6├─────────────┤
│ year │
8├─────────────┤
│ month │
10├─────────────┤
│ day │
12├─────────────┤
│ hour │
14├─────────────┤
│ minute │
~ ~

- 665 -
3.Function References PROGRAMMING B-64303EN-3/01

~ ~
16├─────────────┤
│ second │
18├─────────────┤
│ len_msg │
20├─────────────┤
│ pth_no │
22├─────────────┤
│ dammy │
24├─────────────┤
│ dsp_flg │
26├─────────────┤
│ axis_num │
28├──────┬──────┘
│alm_msg[0] │
29├──────┤
~ ~
91├──────┤
│alm_msg[63] │
92├──────┴──────┐
│ │
│ g_modal[0] │
│ │
96├─────────────┤
~ ~
128├─────────────┤
│ │
│ g_modal[9] │
│ │
132├─────┬───────┘
│ g_dp[0] │
133├─────┤
~ ~
141├─────┤
│ g_dp[9] │
142├─────┴───────┐
│ │
│ a_modal[0] │
│ │
146├─────────────┤
~ ~

- 666 -
B-64303EN-3/01 PROGRAMMING 3.Function References

~ ~
178├─────────────┤
│ │
│ a_modal[9] │
│ │
182├─────┬───────┘
│ a_dp[0] │
183├─────┤
~ ~
191├─────┤
│ a_dp[9] │
192├─────┴───────┐
│ │
│ abs_pos[0] │
│ │
196├─────────────┤
~ ~
316├─────────────┤
│ │
│ abs_pos[31] │
│ │
320├─────┬───────┘
│abs_dp[0] │
321├─────┤
~ ~
351├─────┤
│abs_dp[31]│
352├─────┴───────┐
│ │
│ mcn_pos[0] │
│ │
356├─────────────┤
~ ~
476├─────────────┤
│ │
│ mcn_pos[31] │
│ │
480├──────┬──────┘
│mcn_dp[0] │
481├──────┤
~ ~
511├──────┤
│mcn_dp[31] │
512└──────┘

- 667 -
3.Function References PROGRAMMING B-64303EN-3/01

his Pointer to the structure to which to return alarm history data.


alm_grp A type of alarm is set.
0: The parameter write switch is on. (SW)
1: A parameter that requires turning off the power was input. (PW)
2: I/O error (IO)
3: Foreground P/S (PS)
4: Overtravel/external data input error (OT)
5: Overheat (OH)
6: Servo alarm (SV)
7: Data input/output error (SR)
8: Macro alarm (MC)
9: Spindle alarm (SP)
10: OT alarm that will not lead to a PS alarm (DS)
11: Alarm related to malfunction prevention (IE)
12: Background P/S (BG)
13: Synchronization error too high (SN)
14: Reserved
15: External alarm message (EX)
16: External alarm message (EX2)
17: External alarm message (EX3)
18: External alarm message (EX4)
19: PMC error (PC)
20: Not used
:
31: Not used
alm_no An alarm number is set.

axis_no An absolute axis number ("1" to the maximum controlled axis number)
or absolute spindle number ("1" to the number of spindles) is set.
("0" is set for an alarm which is not relevant to an axis or spindle.)

year Year ("1995" to "2094").


month Month ("1" to "12").
day Day ("1" to "31").
hour Hours ("0" to "23").
minute Minutes ("0" to "59").
second Seconds ("0" to "59").

len_msg Number of characters in the alarm message ("0" to "65").


alm_msg Alarm message.

pth_no Path number ("1" to "10").

dsp_flg Message display flag.


1: Displays MCxxxx for a macro alarm or EXxxxx for an external alarm
or external operator’s message.
0: Displays the message as is.

axis_num Total number of axes ("0" to "7").

- 668 -
B-64303EN-3/01 PROGRAMMING 3.Function References

g_modal Modal G code when the alarm is issued.


("-1" when there is no modal G code.)
Specify the G code group with parameter Nos. 12990 to 12999.
g_modal[0],g_dp[0]= Parameter (No. 12990)
: :
g_modal[9],g_dp[9]= Parameter (No. 12999)
g_dp #7: When "1" is indicated, the G code is specified with the specified
block.
("-1" when there is no modal G code.)
#6 to #0: Number of digits after the decimal point.

7 6 5 4 3 2 1 0
┌─┬─┬─┬─┬─┬─┬─┬─┐
| | Number of digits after the decimal point |
└─┴─┴─┴─┴─┴─┴─┴─┘

#7: 0: The G code is not specified with the specified block.


1: The G code is specified with the specified block.

a_modal 2nd auxiliary function (parameter No. 3460), or modal D, E, F, H, M,


N, O, S, or T code when the alarm is issued ("-1" when there is no
2nd auxiliary function, or modal D, E, F, H, M, N, O, S, or T code).
a_dp #7: When "1" is indicated, the 2nd auxiliary function, or modal D,
E, F, H, M, N, O, S, or T code is specified with the specified
block.
("-1" when there is no 2nd auxiliary function, or modal D, E, F,
H, M, N, O, S, or T code.)
#6 to #0: Number of digits after the decimal point.

7 6 5 4 3 2 1 0
┌─┬─┬─┬─┬─┬─┬─┬─┐
| | Number of digits after the decimal point |
└─┴─┴─┴─┴─┴─┴─┴─┘

#7: 0: The 2nd auxiliary function, or modal D, E, F, H, M, N, O, S,


or T code is not specified with the specified block.
1: The 2nd auxiliary function, or modal D, E, F, H, M, N, O, S,
or T code is specified with the specified block.
a_modal[0],a_dp[0]= 2nd auxiliary function code
a_modal[1],a_dp[1]= D code
a_modal[2],a_dp[2]= E code
a_modal[3],a_dp[3]= F code
a_modal[4],a_dp[2]= H code
a_modal[5],a_dp[3]= M code
a_modal[6],a_dp[2]= N code
a_modal[7],a_dp[3]= O code
a_modal[8],a_dp[2]= S code
a_modal[9],a_dp[3]= T code

- 669 -
3.Function References PROGRAMMING B-64303EN-3/01

* When "0" (program name) is indicated, the first 5 characters are stored,
however.

(Example) O123 TEST_PROGRAM


a_modal ┌──┐ ┌──┐
│'O' │ │'T' │
├──┤ ├──┤
│'1' │ │'E' │
├──┤ ├──┤
│'2' │ │'S' │
├──┤ ├──┤
│'3' │ │'T' │
a_dp ├──┤ ├──┤
│ 0 │ │'_' │
└──┘ └──┘

abs_pos Absolute coordinates when the alarm is issued.


abs_dp Number of digits after the decimal point of the absolute coordinates
when the alarm is issued.
mcn_pos Machine coordinates when the alarm is issued.
mcn_dp Number of digits after the decimal point of the machine coordinates
when the alarm is issued.
* Undefined value for an item other than the number of axes.
alm_msg Alarm message.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_FUNC(1) Function is not executed.
History data sampling is not stopped (the cnc_stopophis function is not
executed).
EW_LENGTH(2) Error in the data block length.
The structure size (length) is invalid. The length value meets the
following condition:
(e_no-s_no+1) × sizeof(data[0]) + 4 > length
EW_NUMBER(3) Data number error.
The start record number (s_no) or end record number (e_no) is invalid.

- 670 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads alarm history data.

To read alarm history data, use this function, or cnc_rdalmhistry4 function, not the
cnc_rdalmhistry function.
For the differences among these functions, see the description of each of these functions.

The unit of one alarm history data item is called a record.

Operation history data, alarm history data, and external operator’s message history data
are automatically recorded by the CNC.
To access these data items, data sampling by the CNC must be stopped temporarily. To
stop data sampling, before using this function, execute "stop history data sampling"
(cnc_stopophis function).

To minimize the history data sampling stop time, execute "resume history data sampling"
(cnc_startophis function) immediately after history data has been read.

The start/end record number is the number assigned to each alarm history data record
to be read. These record numbers are effective after "stop history data sampling" is
executed until "resume history data sampling" is executed.

The following parameters are related to this function:


- Bit 3 (EAH) of parameter No. 3112.
- Bit 7 (HAL) of parameter No. 3196.
- Bit 1 (MCA) of parameter No. 6008.
- Bit 1 (EXM) of parameter No. 6301.
- Parameters Nos. 12990 to 12999.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 671 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.144 Read the number of external operator’s message history data items. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdomhisno

[Syntax]
#include <fwindow.h>
short cnc_rdomhisno( unsigned short * hisno );

[Arguments]
hisno Specifies the address of the variable for which to store the number of
external operator’s message history data items.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_FUNC(1) Function is not executed.
History data sampling is not stopped (the cnc_stopophis function is not
executed).
EW_PARAM(9) CNC parameter error.
Set bit 6 (HOM) of parameter No. 3196 to "0" and bit 2 (OMH) of parameter
No. 3112 to "1".

[Description]
Reads the number of external operator’s message alarm data items.

Before using this function, stop history data sampling (execute the cnc_stopophis
function).

The following parameters are related to this function:


- Bit 2 (OMH) of parameter No. 3112 = "1" (must be set when this function is used).
- Bit 6 (HOM) of parameter No. 3196 = "0" (must be set when this function is used).
- Bit 3 (EAH) of parameter No. 3112.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 672 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.145 Read external operator’s message history data (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdomhistry2

[Syntax]
#include <fwindow.h>
short cnc_rdomhistry2( unsigned short s_no,unsigned short e_no,
unsigned short length, struct odbmhis2 *his);
struct odbmhis2 {
unsigned short s_no; /* Start record number. */
unsigned short e_no; /* End record number. */
struct {
short dsp_flg; /* Message display flag. */
short om_no; /* Message number. */
short year; /* Year. */
short month; /* Month. */
short day; /* Day. */
short hour; /* Hours. */
short minute; /* Minutes. */
short second; /* Seconds. */
char ope_msg[256];/* Message (ends with null (\0)). */
} opm_his[N]; /* N: Number of external operator’s message */
/* history data items to be read. */
} ;

[Arguments]
s_no Specifies the start record number. (Specify "1" or greater.)
e_no Specifies the end record number. (Specify "1" or greater.)
length Specifies the data block length (structure size).

struct odbmhis2 0┌────┐ ─


│ s_no │ ↑
2├────┤ │
│ e_no │ │
4├────┴────┐ │
│ opm_his[0] │length
278├─────────┤ │
~ ~ │
4+274×(n-1) ├─────────┤ │
│ opm_his[n] │ ↓
4+274×n └─────────┘ ─

- 673 -
3.Function References PROGRAMMING B-64303EN-3/01

opm_his 0┌─────────────┐
│ dsp_flg │
2├─────────────┤
│ om_no │
4├─────────────┤
│ year │
6├─────────────┤
│ month │
8├─────────────┤
│ day │
10├─────────────┤
│ hour │
12├─────────────┤
│ minute │
16├─────────────┤
│ second │
18├──────┬──────┘
│ ope_msg[0] │
19├──────┤
~ ~
273├──────┤
│ope_msg[255]│
274└──────┘

his Pointer to the structure to which to return external operator’s


message history data.

dsp_flg Message display flag.


1: Displays EXxxxx.
0: Displays the message as is.

om_no Message number.

year Year ("1995" to "2094").


month Month ("1" to "12").
day Day ("1" to "31").
hour Hours ("0" to "23").
minute Minutes ("0" to "59").
second Seconds ("0" to "59").

ope_msg Message (ends with NULL character (\0)).

- 674 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_FUNC(1) Function is not executed.
History data sampling is not stopped (the cnc_stopophis function is not
executed).
EW_LENGTH(2) Error in the data block length.
The structure size (length) is invalid. The length value meets the
following condition:
(e_no-s_no+1) × sizeof(data[0]) + 4 > length
EW_NUMBER(3) Data number error.
The start record number (s_no) or end record number (e_no) is invalid.
EW_PARAM(9) CNC parameter error.
Set bit 2 (OMH) of parameter No. 3112 to "1".

[Description]
Reads external operator’s message history data.

The unit of one external operator’s message history data item is called a record.

Operation history data, alarm history data, and external operator’s message history data
are automatically recorded by the CNC.
To access these data items, data sampling by the CNC must be stopped temporarily. To
stop data sampling, before using this function, execute "stop history data sampling"
(cnc_stopophis function).

To minimize the history data sampling stop time, execute "resume history data sampling"
(cnc_startophis function) immediately after history data has been read.

The start/end record number is the number assigned to each external operator’s message
history data record to be read. These record numbers are effective after "stop history
data sampling" is executed until "resume history data sampling" is executed.

The following parameters are related to this function:


- Bit 2 (OMH) of parameter No. 3112 = "1" --- Must be set.
- Bit 6 (HOM) of parameter No. 3196 = "0" --- Must be set.
- Bit 3 (EAH) of parameter No. 3112.
- Bit 1 (EXM) of parameter No. 6301.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 675 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.146 Read tool life management data (tool group number). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdgrpid

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdgrpid( short number, struct odbtlife1 *grpid);

struct odbtlife1 {
short dummy ; /* Not used. */
short type ; /* Tool number. */
long data ; /* Tool group number. */
} ;

[Arguments]
number Specifies a tool number.
grpid Pointer to structure odbtlife1 to which to return the tool group number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_ATTRIB(4) Data attribute error.
The specified tool number (number) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the number of the tool group in which the specified tool is registered.

When the tool number is found in multiple tool groups, the smallest group number is stored.
This function is available only when you use an up to 4-digit tool number.
If you use a tool number longer than 4 digits, you must use the cnc_rdgrpid2 function.
The number of the tool group in which the specified tool number is registered is stored
in grpid.data with binary format. When "0" is specified for number, the number of the
tool group being currently used is stored. When no tool group number has been specified
since power-on, however, "0" is stored.
Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.

- 676 -
B-64303EN-3/01 PROGRAMMING 3.Function References

The following parameters are related to this function:


- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 677 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.147 Read tool life management data (number of tool groups). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdngrp

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdngrp( struct odbtlife2 *ngrp);

struct odbtlife2 {
short dummy[2] ; /* Not used. */
long data ; /* Number of tool groups. */
} ;

[Arguments]
ngrp Pointer to structure odbtlife2 to which to return the number of tool
groups.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the total number of tool groups in which tools are registered.

The number of tool groups is stored in ngrp.data with binary format.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.

The following parameters are related to this function:


- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 678 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.148 Read tool life management data (number of tools). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdntool

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdntool( short number, struct odbtlife3 *ntool);

struct odbtlife3 {
short datano ; /* Tool group number. */
short dummy ; /* Not used. */
long data ; /* Number of tools. */
} ;

[Arguments]
number Specifies a tool group number.
ntool Pointer to structure odbtlife3 to which to return the number of tools.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (number) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the number of tools registered in the specified tool group.

The number of tools registered in the specified tool group is stored in ntool.data with
binary format. When "0" is specified for number, the number of tools in the tool group
being currently used is stored. When no tool group number has been specified since
power-on, however, "0" is stored.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.

The following parameters are related to this function:


- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.

- 679 -
3.Function References PROGRAMMING B-64303EN-3/01

For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 680 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.149 Read tool life management data (tool life). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdlife

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdlife( short number,struct odbtlife3 *life);

struct odbtlife3 {
short datano ; /* Tool group number. */
short dummy ; /* Not used. */
long data ; /* Tool life value. */
} ;

[Arguments]
number Specifies a tool group number with binary format.
life Pointer to structure odbtlife3 to which to return the tool life value.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (number) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the tool life value of the specified tool group.

The unit of tool life is [minutes] or [times].


Which unit is used depends on the setting of bit 2 (LTM) of parameter No. 6800 on the
CNC. For the M series, the tool life counter type (time or count specification) can be
set for each tool group number with the G10 command.

The tool life value of the specified tool group is stored in life.data with binary format.
When "0" is specified for number, the tool life value of the tool group being currently
used is stored. When no tool group number has been specified since power-on, however,
"0" is stored.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.

- 681 -
3.Function References PROGRAMMING B-64303EN-3/01

The following parameters are related to this function:


- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 682 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.150 Read tool life management data (tool life counter). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdcount

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdcount( short number, struct odbtlife3 *count);

struct odbtlife3 {
short datano ; /* Tool group number. */
short dummy ; /* Not used. */
long data ; /* Tool life counter value. */
} ;

[Arguments]
number Specifies a tool group number with binary format.
count Pointer to structure odbtlife3 to which to return the tool life counter
value.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (number) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the tool life counter value of the specified tool group.

The unit of the tool life counter value is [minutes] or [times].


Which unit is used depends on the setting of bit 2 (LTM) of parameter No. 6800 on the
CNC. For the M series, the tool life counter type (time or count specification) can be
set for each tool group number with the G10 command.

The tool life counter value of the specified tool group is stored in count.data with
binary format. When "0" is specified for number, the tool life counter value of the tool
group being currently used is stored. When no tool group number has been specified since
power-on, however, "0" is stored.

- 683 -
3.Function References PROGRAMMING B-64303EN-3/01

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.

The following parameters are related to this function:


- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 684 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.151 Read tool life management data (tool length compensation number 1). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rd1length

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rd1length( short grp_num, short tool_num,
struct odbtlife4 *tl_len1);

struct odbtlife4 {
short datano ; /* Tool group number. */
short type ; /* Tool number. */
long data ; /* Tool length compensation number (always 0 for */
/* the lathe system (T series)). */
} ;

[Arguments]
grp_num Specifies a tool group number with binary format.
tool_num Specifies a tool number with binary format.
tl_len1 Pointer to structure odbtlife4 to which to return the tool length
compensation number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool number (tool_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

- 685 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the tool length compensation number for the specified tool group and tool numbers.

This function is effective only for the machining system. For the lathe system (T series),
"0" is always read.
This function is available only when you use an up to 4-digit tool number.
If you use a tool number longer than 4 digits, you must use the cnc_rd1tlifedat2 function.
The tool length compensation number of the specified tool is stored in tl_len1.data with
binary format. When "0" is specified for grp_num or tool_num, the tool group or tool
being currently used is referenced, respectively. When no tool group number has been
specified since power-on, however, "0" is stored.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 686 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.152 Read tool life management data (tool length compensation number 2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rd2length

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rd2length( short grp_num, short tuse_num,
struct odbtlife4 *tl_len2 );

struct odbtlife4 {
short datano ; /* Tool group number. */
short type ; /* Tool ordinal number. */
long data ; /* Tool length compensation number (always 0 for */
/* the lathe system (T series)). */
} ;

[Arguments]
grp_num Specifies a tool group number with binary format.
tuse_num Specifies a tool ordinal number with binary format.
tl_len2 Pointer to structure odbtlife4 to which to return the tool length
compensation number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (tuse_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

- 687 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the tool length compensation number for the specified tool group and tool ordinal
numbers.

This function is effective only for the machining system. For the lathe system (T series),
"0" is always read.
The tool length compensation number of the specified tool is stored in tl_len2.data with
binary format.
When "0" is specified for grp_num, the tool group being currently used is referenced.
When no tool group number has been specified since power-on, however, "0" is stored.
When "0" is specified for tuse_num, the tool being currently used is referenced for the
number of a tool group already used or the first tool is referenced for the number of
a tool group which has not yet been used.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 688 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.153 Read tool life management data (tool radius compensation number 1). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rd1radius

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rd1radius( short grp_num, short tool_num,
struct odbtlife4 *radius1);
struct odbtlife4 {
short datano ; /* Tool group number. */
short type ; /* Tool number. */
long data ; /* Tool radius compensation number (always a value */
/* of 0 is read for the lathe system (T series)). */
} ;

[Arguments]
grp_num Specifies a tool group number with binary format.
tool_num Specifies a tool number with binary format.
radius1 Pointer to structure odbtlife4 to which to return the tool radius
compensation number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool number (tool_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the tool radius compensation number for the specified tool group and tool numbers.

This function is effective only for the machining system. For the lathe system (T series),
"0" is always read.
This function is available only when you use an up to 4-digit tool number.
If you use a tool number longer than 4 digits, you must use the cnc_rd1tlifedat2 function.
The tool radius compensation number of the specified tool is stored in radius1.data with
binary format. When "0" is specified for grp_num or tool_num, the tool group or tool
being currently used is referenced, respectively. When no tool group number has been
specified since power-on, however, "0" is stored.

- 689 -
3.Function References PROGRAMMING B-64303EN-3/01

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 690 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.154 Read tool life management data (tool radius compensation number 2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rd2radius

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rd2radius( short grp_num, short tuse_num,
struct odbtlife4 *radius2);
struct odbtlife4 {
short datano ; /* Tool group number. */
short type ; /* Tool ordinal number. */
long data ; /* Tool radius compensation number (always a value */
/* of 0 is read for the lathe system (T series)). */
} ;

[Arguments]
grp_num Specifies a tool group number with binary format.
tuse_num Specifies a tool ordinal number with binary format.
radius2 Pointer to structure odbtlife4 to which to return the tool radius
compensation number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (tuse_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

- 691 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads the tool radius compensation number for the specified tool group and tool ordinal
numbers.

This function is effective only for the machining system. For the lathe system (T series),
"0" is always read.
The tool radius compensation number of the specified tool is stored in radius2.data with
binary format.
When "0" is specified for grp_num, the tool group being currently used is referenced.
When no tool group number has been specified since power-on, however, "0" is stored.
When "0" is specified for tuse_num, the tool being currently used is referenced for the
number of a tool group already used or the first tool is referenced for the number of
a tool group which has not yet been used.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 692 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.155 Read tool life management data (tool information 1). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_t1info

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_t1info( short grp_num, short tool_num,
struct odbtlife4 *tinfo1);
struct odbtlife4 {
short datano ; /* Tool group number. */
short type ; /* Tool number. */
long data ; /* Tool information. */
} ;

[Arguments]
grp_num Specifies a tool group number with binary format.
tool_num Specifies a tool number with binary format.
tinfo1 Pointer to structure odbtlife4 to which to return tool information.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool number (tool_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

- 693 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads tool information of the specified tool group and tool numbers.

This function is available only when you use an up to 4-digit tool number.
If you use a tool number longer than 4 digits, you must use the cnc_rd1tlifedat2 function.

Tool information of the specified tool is stored in tinfo1.data with binary format.

tinfo1.data Tool information


0 (See below.)
1 The tool is registered.
2 The life of the tool ends.
3 The tool is skipped.

When "0" is specified for grp_num or tool_num, the tool group or tool being currently
used is referenced, respectively. When no tool group number has been specified since
power-on, however, "0" is stored.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 694 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.156 Read tool life management data (tool information 2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_t2info

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_t2info( short grp_num, short tuse_num,
struct odbtlife4 *tinfo2);

struct odbtlife4 {
short datano ; /* Tool group number. */
short type ; /* Tool ordinal number. */
long data ; /* Tool information. */
} ;

[Arguments]
grp_num Specifies a tool group number with binary format.
tuse_num Specifies a tool ordinal number with binary format.
tinfo2 Pointer to structure odbtlife4 to which to return tool information.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (tuse_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

- 695 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Reads tool information of the specified tool group and tool ordinal numbers.

Tool information of the specified tool is stored in tinfo2.data with binary format.

tinfo1.data Tool information


0 (See below.)
1 The tool is registered.
2 The life of the tool ends.
3 The tool is skipped

When "0" is specified for grp_num, the tool group being currently used is referenced.
When no tool group number has been specified since power-on, however, "0" is stored.

When "0" is specified for tuse_num, the tool being currently used is referenced for the
number of a tool group already used or the first tool is referenced for the number of
a tool group which has not yet been used.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 696 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.157 Read tool life management data (tool number). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_toolnum

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_toolnum( short grp_num, short tuse_num,
struct odbtlife4 *toolnum);

struct odbtlife4 {
short datano ; /* Tool group number. */
short type ; /* Tool ordinal number. */
long data ; /* Tool number. */
} ;

[Arguments]
grp_num Specifies a tool group number with binary format.
tuse_num Specifies a tool ordinal number with binary format.
toolnum Pointer to structure odbtlife4 to which to return the tool number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (tuse_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the tool number corresponding to the specified tool group and tool ordinal numbers.

The tool number of the relevant tool is stored in toolnum.data with binary format.
When "0" is specified for grp_num, the tool group being currently used is referenced.
When no tool group number has been specified since power-on, however, "0" is stored.
When "0" is specified for tuse_num, the tool being currently used is referenced for the
number of a tool group already used or the first tool is referenced for the number of
a tool group which has not yet been used.

- 697 -
3.Function References PROGRAMMING B-64303EN-3/01

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 698 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.158 Read tool life management data (number of tools, tool life, life counter) (range specified).
<Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtoolrng

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtoolrng( short s_number, short e_number, short length,
struct iodbtr *toolnum);

struct iodbtr {
short datano_s ; /* Read start group number. */
short dummy ; /* Not used. */
short datano_e ; /* Read end group number. */
struct {
long ntool ; /* Number of tools. */
long life ; /* Tool life value. */
long count ; /* Tool life counter value. */
} data[N] ;
} ; /* N: Number of groups of which data is to be read. */

[Arguments]
s_number Specifies the read start tool group number with binary format.
e_number Specifies the read end tool group number with binary format.
length Specifies the data block length (size of structure iodbtr).

iodbtr 0┌────┐ ─
│datano_s│ ↑
2├────┤ │
│dummy │ │
4├────┤ │
│datano_e│ │
6├────┤ │
│ │ length
8├────┴────┐ │
│ data[0] │ │
20├─────────┤ │
~ ~ │
8+12×(N-1) ├─────────┤ │
│ data[N-1] │ ↓
8+12×N └─────────┘ ─

- 699 -
3.Function References PROGRAMMING B-64303EN-3/01

data 0┌─────┐
│ ntool │
4├─────┤
│ life │
8├─────┤
│ count │
12└─────┘

N is the number of groups of which data is to be read.

toolnum Pointer to structure iodbtr to which to return the number of tools, tool
life value, and tool life counter value of each tool group number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
The size (length) of structure iodbtr is invalid.
EW_NUMBER(3) Data number error.
The tool group number (s_number or e_number) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the number of tools, tool life value, and tool life counter value of each tool
group within the specified range.

The units of the tool life value and tool life counter value are [minutes] or [times].
Which unit is used depends on the setting of bit 2 (LTM) of parameter No. 6800 on the
CNC.

The number of tools, tool life value, and tool life counter value of each tool group
within the specified range are stored in toolnum.data[i].ntool, toolnum.data[i].life,
and toolnum.data[i].count with binary format, respectively.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 700 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.159 Read all tool life management data in group at once. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtoolgrp

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtoolgrp( short grp_num, short length,
struct odbtg *toolgrp);

struct odbtg {
short grp_num ; /* Tool group number. */
short dummy[2] ; /* Not used. */
long ntool ; /* Number of tools. */
long life ; /* Tool life. */
long count ; /* Tool life counter value. */
struct {
long tuse_num ; /* Tool ordinal number. */
long tool_num ; /* Tool number. */
long length_num ; /* Tool length compensation number. */
long radius_num ; /* Tool radius compensation number. */
long tinfo ; /* Tool information. */
} data[N] ;
} ; /* N: Number of tools registered. */

[Arguments]
grp_num Specifies a tool group number with binary format.
When "0" is specified, the tool group being currently used is
referenced.
length Specifies the data block length (size of structure odbtg).

odbtg 0┌────┐ ─
│grp_num │ ↑
2├────┤ │
│dummy[0]│ │
4├────┤ │
│dummy[1]│ │
6├────┤ │
│ │ │
8├────┴────┐ │
│ ntool │ │
12├─────────┤length
~ life ~ │

- 701 -
3.Function References PROGRAMMING B-64303EN-3/01

16├─────────┤ │
│ count │ │
20├─────────┤ │
│ data[0] │ │
40├─────────┤ │
~ ~ │
20+20×(N-1) ├─────────┤ │
│ data[N-1] │ ↓
20+20×N └─────────┘ ─

data 0┌─────┐ N is the number of tools registered.


│tuse_num │
4├─────┤
│tool_num │
8├─────┤
│length_num│
12├─────┤
│radius_num│
16├─────┤
│ tinfo │
20└─────┘

toolgrp Pointer to structure odbtg to which to return various tool information.


The following information items are stored in toolgrp with binary
format:
ntool Number of tools.
life Tool life value.
count Tool life counter value.
data[i].tuse_num Tool ordinal number.
data[i].tool_num Tool number.
data[i].length_num Tool length compensation number (always "0"
for the lathe system (T series)).
data[i].radius_num Tool radius compensation number (always of "0"
for the lathe system (T series)).
data[i].tinfo Tool information.

- 702 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
The size (length) of structure odbtg is invalid.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads various tool information of the specified tool group at a time.

The units of the tool life value and tool life counter value are [minutes] or [times].
Which unit is used depends on the setting of bit 2 (LTM) of parameter No. 6800 on the
CNC.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 703 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.160 Write tool life management data (life counter) (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrcountr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrcountr( short length, struct idbwrc *wrcount);

struct idbwrc {
short datano_s ; /* Write start group number. */
short dummy ; /* Not used. */
short datano_e ; /* Write end group number. */
struct {
long dummy[2] ; /* Not used. */
long count ; /* Tool life counter value. */
} data[N] ;
} ; /* N: Number of groups of which the tool */
/* life counter value is to be written. */

[Arguments]
length Specifies the data block length (size of structure idbwrc).

idbwrc 0┌────┐ ─
│datano_s│ ↑
2├────┤ │
│ dummy │ │
4├────┤ │
│datano_e│ │
6├────┤ │
│ │ │
8├────┴────┐ │
│ │ │
│ data[0] │length
│ │ │
20├─────────┤ │
~ ~ │
8+12×(N-1) ├─────────┤ │
│ │ │
│ data[N-1] │ │
│ │ ↓
8+12×N └─────────┘ ─

- 704 -
B-64303EN-3/01 PROGRAMMING 3.Function References

data 0┌─────┐
│ dummy[0] │
4├─────┤
│ dummy[1] │
8├─────┤
│ count │
12└─────┘

N is the number of groups of which the tool life counter value is to be written.

wrcoun Pointer to structure idbwrc in which to set the tool life counter value.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
The size (length) of structure idbwrc is invalid.
EW_NUMBER(3) Data number error.
The tool group number (datano_s or datano_e) is invalid.
EW_DATA(5) The tool life counter value is out of the limit.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Rewrites the tool life counter value of each tool group within the specified range.

The unit of the tool life counter value is [minutes] or [times].


Which unit is used depends on the setting of bit 2 (LTM) of parameter No. 6800 on the
CNC.

The maximum life counter value is as follows:


For the count specification: 99999999 times
For the time specification: 60000 minutes

The write start group number is stored in wrcount.datano_s with binary format.
The write end group number is stored in wrcount.datano_e with binary format.
The tool life counter value is stored wrcount.data[i].count with binary format.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 705 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.161 Register tool life management data (tool group). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrtoolgrp

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrtoolgrp( long toolno, struct idbitd *buf);

struct idbitd {
short datano; /* Tool group number. */
short type; /* Tool life counter type. */
long data; /* Tool life value. */
} ;

[Arguments]
toolno Specifies a tool number.
buf Pointer to structure idbitd in which to set tool data.
datano Specifies a tool group number.
type Specifies a tool life counter type.
data Specifies a tool life value.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool number (toolno) is invalid.
EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
3: Tool life counter type (type) error.
4: Tool life value (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
The number of the tool group containing invalid data is set in member
err_dtno in structure odberr.

- 706 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_OVRFLOW(8) The maximum number of tools that can be registered is exceeded.
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being
currently used or the next tool group to be used.

[Description]
- When the specified tool group number is not registered:
Registers a new tool group with the specified number and sets the tool number,
tool life value, and tool counter type.
- When the specified tool group number has already been registered:
Adds the specified tool number to the end of the specified tool group.
Does not change the tool life value or tool counter type.

The unit of the tool life value is [minutes] or [times].


Life count interval: Life count interval:
1 second 0.1 seconds
Unit of the tool life value
for the time specification 1 minute 0.1 minutes

The unit of the tool life value can be determined by getting the "tool life counter type"
(executing cnc_rdcnttype).
When the tool life counter type is set to the time specification, bit 1 (FGL) of parameter
No. 6805 can be used to set 1 or 0.1 minutes for the unit of the tool life value.

The maximum tool life value is as follows:


For the count specification: 65535 times
For the time specification: 4300 minutes

The life counter is set to "0".


Tool data can be registered only.
The H and D codes are set to "0", and the code indicating that "the life of the tool
does not end" is set for tool information.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 707 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.182 Write tool life management data (tool life). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrlife

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrlife( struct idbitd *buf);

struct idbitd {
short datano; /* Tool group number. */
short type; /* Not used. */
long data; /* Tool life value. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set the tool life value.
datano Specifies a tool group number.
data Specifies a tool life value.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_DATA(5) Tool life value (data) error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
1: Tool life value (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)
The number of the tool group containing invalid data is set in member
err_dtno in structure odberr.

- 708 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being
currently used or the next tool group to be used.

[Description]
Writes a tool life value for the specified tool group.

The unit of the tool life value is [minutes] or [times].

Life count interval: Life count interval:


1 second 0.1 seconds
Unit of the tool life value
for the time specification 1 minute 0.1 minutes

The unit of the tool life value can be determined by getting the "tool life counter type"
(executing cnc_rdcnttype).

When the tool life counter type is set to the time specification, bit 1 (FGL) of parameter
No. 6805 can be used to set 1 or 0.1 minutes for the unit of the tool life value.

The maximum tool life value is as follows:

For the count specification: 65535 times


For the time specification: 4300 minutes

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 709 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.163 Write tool life management data (life counter). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrcount

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrcount( struct idbitd *buf);

struct idbitd {
short datano; /* Tool group number. */
short type; /* Not used. */
long data; /* Tool life counter value. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set the tool life counter value.
datano Specifies a tool group number.
data Specifies a tool life counter value.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_DATA(5) Tool life counter value (data) error.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

- 710 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Rewrites the tool life counter value of the specified tool group.

The unit of the tool life value is [minutes] or [times].

Life count interval: Life count interval:


1 second 0.1 seconds
Unit of the tool life value
for the time specification 1 minute 0.1 minutes

The unit of the tool life value can be determined by getting the "tool life counter type"
(executing cnc_rdcnttype).

When the tool life counter type is set to the time specification, bit 1 (FGL) of parameter
No. 6805 can be used to set 1 or 0.1 minutes for the unit of the tool life value.

The maximum tool life counter value is as follows:


For the count specification: 65535 times
For the time specification: 4300 minutes

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 711 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.164 Write tool life management data (life counter type). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrcnttype

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrcnttype( struct idbitd *buf);

struct idbitd {
short datano; /* Tool group number. */
short type; /* Not used. */
long data; /* Tool life counter type. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set the tool life counter type.
datano Specifies a tool group number.
data Specifies a tool life counter type.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_DATA(5) Tool life counter type (data) error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
3: Tool life counter type (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)
The number of the tool group containing invalid data is set in member
err_dtno in structure odberr.

- 712 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being
currently used or the next tool group to be used.

[Description]
Rewrites the tool life counter type of the specified tool group.

The value of the tool life counter type is either of the following:
0: Count
1: Time

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 713 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.165 Write tool life management data (tool length compensation number 1). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wr1length

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wr1length( struct idbitd *buf);

struct idbitd2 {
short datano; /* Tool group number. */
long type; /* Tool number. */
long data; /* Tool length compensation number. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set the tool length compensation
number.
datano Specifies a tool group number.
type Specifies a tool number.
data Specifies a tool length compensation number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool number (type) is invalid.
EW_DATA(5) Tool life counter type (data) error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
2: Tool length compensation number (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)

- 714 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being
currently used or the next tool group to be used.

[Description]
Sets a tool length compensation number for the specified tool group and tool numbers.

This function is enabled only for the M series. If this function is executed in the
T series, EW_OK(0) is returned as the return value without data being written. @@2@@
Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 715 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.166 Write tool life management data (tool length compensation number 2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wr2length

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wr2length(struct idbitd *buf);

struct idbitd {
short datano; /* Tool group number. */
short type; /* Tool ordinal number. */
long data; /* Tool length compensation number. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set tool data.
datano Specifies a tool group number.
type Specifies a tool ordinal number.
data Specifies a tool length compensation number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (type) is invalid.
EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
2: Tool length compensation number (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)

- 716 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being
currently used or the next tool group to be used.

[Description]
Sets a tool length compensation number for the specified tool group and tool ordinal
numbers.

This function is enabled only for the M series. If this function is executed in the
T series, EW_OK(0) is returned as the return value without data being written.
Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 717 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.167 Write tool life management data (tool radius compensation number 1). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wr1radius

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wr1radius( struct idbitd2 *buf);

struct idbitd2 {
short datano; /* Tool group number. */
long type; /* Tool number. */
long data; /* Tool radius compensation number. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set tool data.
datano Specifies a tool group number.
type Specifies a tool number.
data Specifies a tool radius compensation number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool number (type) is invalid.
EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
3: Tool radius compensation number (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)

- 718 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being
currently used or the next tool group to be used.

[Description]
Sets a tool radius compensation number for the specified tool group and tool numbers.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 719 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.168 Write tool life management data (tool radius compensation number 2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wr2radius

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wr2radius( struct idbitd *buf);

struct idbitd {
short datano; /* Tool group number. */
short type; /* Tool ordinal number. */
long data; /* Tool radius compensation number. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set tool data.
datano Specifies a tool group number.
type Specifies a tool ordinal number.
data Specifies a tool radius compensation number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (type) is invalid.
EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
3: Tool radius compensation number (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)

- 720 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being
currently used or the next tool group to be used.

[Description]
Sets a tool radius compensation number for the specified tool group and tool ordinal
numbers.

This function is enabled only for the M series. If this function is executed in the
T series, EW_OK(0) is returned as the return value without data being written.
Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 721 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.169 Write tool life management data (tool information 1). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrt1info

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrt1info( struct idbitd2 *buf );

struct idbitd2 {
short datano; /* Tool group number. */
long type; /* Tool number. */
long data; /* Tool information. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set tool data.
datano Specifies a tool group number.
type Specifies a tool number.
data Specifies tool information:
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool number (type) is invalid.
EW_DATA(5) Data error.
The specified tool information (data) is invalid.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
4: Tool information (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)

- 722 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
No data can be written because processing is being executed for the group,
the group is being selected, or data of the group is being buffered.

[Description]
Sets tool information for the specified tool group and tool numbers.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 723 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.170 Write tool life management data (tool information 2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrt2info

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrt2info( struct idbitd *buf );

struct idbitd {
short datano; /* Tool group number. */
short type; /* Tool ordinal number. */
long data; /* Tool information. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set tool data.
datano Specifies a tool group number.
type Specifies a tool ordinal number.
data Specifies tool information:
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (type) is invalid.
EW_DATA(5) Data error.
The specified tool information (data) is invalid.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
4: Tool information (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)

- 724 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
No data can be written because processing is being executed for the group,
the group is being selected, or data of the group is being buffered.

[Description]
Sets tool information for the specified tool group and tool ordinal numbers.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 725 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.171 Write tool life management data (tool number). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrtoolnum

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrtoolnum( struct idbitd *buf );

struct idbitd {
short datano; /* Tool group number. */
short type; /* Tool ordinal number. */
long data; /* Tool number. */
} ;

[Arguments]
buf Pointer to structure idbitd in which to set tool data.
datano Specifies a tool group number.
type Specifies a tool ordinal number.
data Specifies a tool number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (type) is invalid.
EW_DATA(5) Data error.
The specified tool information (data) is invalid.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
0: Error other than EW_DATA.
1: Tool number (data) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be
changed.)

- 726 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_OVRFLOW(8) The maximum number of tools that can be registered is exceeded.
EW_REJECT(13) CNC processing is rejected.
No data can be written because processing is being executed for the group,
the group is being selected, or data of the group is being buffered.

[Description]
Changes the tool number for the specified tool group and tool ordinal numbers.

When the current maximum ordinal number + 1 is specified as the tool ordinal number,
a new tool is added.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 727 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.172 Read tool life management data (tool life counter type). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdcnttype

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdcnttype( short number, struct odbtlife3 *ntool);

struct odbtlife3 {
short datano ; /* Tool group number. */
short dummy ; /* Not used. */
long data ; /* Tool life counter type. */
} ;

[Arguments]
number Specifies a tool group number.
ntool Pointer to structure odbtlife3 to which to return the tool life counter
type.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (number) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the tool life counter type registered for the specified tool group.
(0: Count 1: Time)
The tool life counter type registered for the specified tool group is stored in ntool.data
with binary format. When "0" is specified for number, the tool life counter type
registered for the tool group being currently used is stored. When no tool group number
has been specified since power-on, however, "0" is stored.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.

- 728 -
B-64303EN-3/01 PROGRAMMING 3.Function References

The following parameters are related to this function:


- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 729 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.173 Read tool life management data (number of tool group being used or to be used). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdusegrpid

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdusegrpid( struct odbusegr *usegrpid );

struct odbusegr {
short datano; /* Not used. */
short type; /* Not used. */
long next; /* Number of the next tool group to be used. */
long use; /* Number of the tool group being used. */
long slct; /* Number of the tool group being selected. */
} ;

[Arguments]

usegrpid Pointer to structure odbusegr to which to return the target tool group
numbers.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the number of the next tool group to be used, number of the tool group being used,
and number of the tool group being selected.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 730 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.174 Read tool life management data (maximum number of tool groups that can be registered).
<Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdmaxgrp

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmaxgrp( struct odblfno *maxgrp );

struct odblfno {
short datano; /* Not used. */
short type; /* Not used. */
short data; /* Maximum number of tool groups that can be */
/* registered. */
} ;

[Arguments]
maxgrp Pointer to structure odblfno to which to return the maximum number of
tool groups that can be registered.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the maximum number of tool groups that can be registered.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 731 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.175 Read tool life management data (maximum number of tools that can be registered in group).
<Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdmaxtool

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmaxtool( struct odblfno *maxtool );

struct odblfno {
short datano; /* Not used. */
short type; /* Not used. */
short data; /* Maximum number of tools that can be registered */
/* in a group.*/
} ;

[Arguments]
maxtool Pointer to structure odblfno to which to return the maximum number of
tools that can be registered in a group.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the maximum number of tools that can be registered in a group.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 732 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.176 Read tool life management data (ordinal number of tool to be used in group). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdusetlno

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdusetlno( short s_grp, short e_grp, short length,
struct odbtluse *usetlno);

struct odbtluse {
short s_grp; /* Read start tool group number. */
short dummy; /* Not used. */
short e_grp; /* Read end tool group number. */
long data[N]; /* Ordinal number of a tool to be used in each */
/* group. */
}; /* N: Number of groups of which the tool */
/* ordinal number is to be read. */

[Arguments]
s_grp Specifies the read start tool group number with binary format.
e_grp Specifies the read end tool group number with binary format.
length Specifies the data block length (size of structure odbtluse).

odbtluse 0┌────┐ ─
│ s_grp │ ↑
2├────┤ │
│ dummy │ │
4├────┤ │
│ e_grp │ │
6├────┤ │
│ │ │
8├────┴────┐length
│ data[0] │ │
12├─────────┤ │
~ ~ │
8+4×(N-1) ├─────────┤ │
│ data[N] │ ↓
8+4×N └─────────┘ ─

N is the number of groups of which the tool ordinal number is to be read.

- 733 -
3.Function References PROGRAMMING B-64303EN-3/01

Usetlno Pointer to structure odbtluse to which to return the ordinal number of


a tool to be used.
The following information items are stored in Usetlno with binary
format:
s_grp Read start tool group number.
e_grp Read end tool group number.
data[i] Ordinal number of a tool to be used in each group.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
The size (length) of structure odbtluse is invalid.
EW_NUMBER(3) Data number error.
The tool group number (s_grp or e_grp) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the ordinal number of a tool to be used in each group.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 734 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.177 Read tool life management data (tool data 1). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rd1tlifedata

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rd1tlifedata( short grp_no, short tool_no,
struct iodbtd *tld1);

struct iodbtd {
short datano; /* Tool group number. */
short type; /* Not used. */
long tool_num; /* Tool number. */
long h_code; /* Tool length compensation number. */
long d_code; /* Tool radius compensation number. */
long tool_inf; /* Tool information. */
} ;

[Arguments]
grp_no Specifies a tool group number.
tool_no Specifies a tool number.
tld1 Pointer to structure iodbtd to which to return various tool information.
The following information items are stored in tld1 with binary format:
datano Specifies a tool group number.
type Specifies a current tool number.
tool_num Specifies a new tool number.
h_code Specifies a tool length compensation number. (Always "0" for
the lathe system (T series).)
d_code Specifies a tool radius compensation number. (Always "0" for
the lathe system (T series).)
tool_inf Specifies tool information:
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_no) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool number (tool_no) is invalid.

- 735 -
3.Function References PROGRAMMING B-64303EN-3/01

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads various tool information.

The following information items can be obtained:


- Tool length compensation number ("0" is always read for the lathe system (T series)).
- Tool radius compensation number ("0" is always read for the lathe system (T series)).
- Tool information.
0: (See below.)
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

When "0" is specified for grp_no or tool_no, the tool group or tool being currently used
is referenced, respectively. When no tool group number has been specified since power-on,
however, "0" is stored.

This function is available only when you use an up to 4-digit tool number.
If you use a tool number longer than 4 digits, you must use the cnc_rd1tlifedat2.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 736 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.178 Read tool life management data (tool data 1) (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rd1tlifedat2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rd1tlifedat2( short grp_num, long tool_num,
struct iodbtd2 *tld1);

struct iodbtd2 {
short datano; /* Tool group number. */
short dummy; /* Not used. */
long type; /* Not used. */
long tool_num; /* Tool number. */
long h_code; /* Tool length compensation number. */
long d_code; /* Tool radius compensation number. */
long tool_inf; /* Tool information. */
} ;

[Arguments]
grp_num Specifies a tool group number.
tool_num Specifies a tool number.
tld1 Pointer to structure iodbtd2 to which to return various tool
information.
The following information items are stored in tld1 with binary format:
datano Specifies a tool group number.
type Specifies a current tool number.
tool_num Specifies a new tool number.
h_code Specifies a tool length compensation number. (Always "0"
for the lathe system (T series).)
d_code Specifies a tool radius compensation number. (Always "0"
for the lathe system (T series).)
tool_inf Specifies tool information:
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.

- 737 -
3.Function References PROGRAMMING B-64303EN-3/01

EW_ATTRIB(4) Data attribute error.


The specified tool number (tool_num) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads various tool information.

The following information items can be obtained:


- Tool length compensation number ("0" is always read for the lathe system (T series)).
- Tool radius compensation number ("0" is always read for the lathe system (T series)).
- Tool information.
0: (See below.)
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

When "0" is specified for grp_no or tool_no, the tool group or tool being currently used
is referenced, respectively. When no tool group number has been specified since power-on,
however, "0" is stored.

Normally, use this function to get tool data.


The cnc_rd1tlifedata function is available only when you use an up to 4-digit tool number.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 738 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.179 Read tool life management data (tool data 2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rd2tlifedata

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rd2tlifedata( short grp_no, short use_no,
struct iodbtd * tld2);

struct iodbtd {
short datano; /* Tool group number. */
short type; /* Tool ordinal number. */
long tool_num; /* Tool number. */
long h_code; /* Tool length compensation number. */
long d_code; /* Tool radius compensation number. */
long tool_inf; /* Tool information. */
} ;

[Arguments]
grp_no Specifies a tool group number.
use_no Specifies a tool ordinal number.
tld2 Pointer to structure iodbtd to which to return various tool information.
The following information items are stored in tld2 with binary format:
datano Specifies a tool group number.
type Specifies a current tool number.
tool_num Specifies a new tool number.
h_code Specifies a tool length compensation number. (Always "0"
for the lathe system (T series).)
d_code Specifies a tool radius compensation number. (Always "0"
for the lathe system (T series).)
tool_inf Specifies tool information:
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_no) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (use_no) is invalid.

- 739 -
3.Function References PROGRAMMING B-64303EN-3/01

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads various tool information.

The following information items can be obtained:


- Tool length compensation number ("0" is always read for the lathe system (T series)).
- Tool radius compensation number ("0" is always read for the lathe system (T series)).
- Tool information.
0: (See below.)
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

When "0" is specified for grp_no, the tool group being currently used is referenced.
When no tool group number has been specified since power-on, however, "0" is stored.

When "0" is specified for use_no, the tool being currently used is referenced for the
number of a tool group already used or the first tool is referenced for the number of
a tool group which has not yet been used.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 740 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.180 Write tool life management data (tool data 1). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wr1tlifedata

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wr1tlifedata( struct iodbtd *tld1);

struct iodbtd {
short datano; /* Tool group number. */
short type; /* Current tool number. */
long tool_num; /* New tool number. */
long h_code; /* Tool length compensation number. */
long d_code; /* Tool radius compensation number. */
long tool_inf; /* Tool information. */
} ;

[Arguments]
tld1 Pointer to structure iodbtd for updating various tool information.
The following information items are stored in tld1 with binary format:
datano Specifies a tool group number.
type Specifies a current tool number.
tool_num Specifies a new tool number.
h_code Specifies a tool length compensation number. (Always "0"
for the lathe system (T series).)
d_code Specifies a tool radius compensation number. (Always "0"
for the lathe system (T series).)
tool_inf Specifies tool information:
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_no) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified current tool number (type) is invalid.

- 741 -
3.Function References PROGRAMMING B-64303EN-3/01

EW_DATA(5) Data error.


To get more detailed information on this return value, execute the
cnc_getdtailerr function. One of the following detail status codes is
set in member err_no in structure odberr:
0: Error other than EW_DATA.
1: New tool number (tool_num) error.
2: Tool length compensation number (h_code) error.
3: Tool radius compensation number (d_code) error.
4: Tool information (tool_inf) error.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being currently
used or the next tool group to be used.

[Description]
Writes various tool information.

The following information items can be updated:


- Tool number.
- Tool length compensation number.
- Tool radius compensation number.
- Tool information.
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

1. As preprocessing, set TLIFE_OPTION as the option and "1" as the value for the
cnc_setlibopt function and call the function.
2. Call cnc_wr1tlifedata.
3. As postprocessing, set TLIFE_OPTION as the option and "0" as the value for the
cnc_setlibopt function and call the function.

When all of the following conditions are satisfied at a normal call, error EW_REJECT(13)
is returned:
- During automatic operation (OP = "1").
- The tool group with the target number is being used or to be used next.
- Bit 1 (TCO) of parameter No. 6802 = "0".

- 742 -
B-64303EN-3/01 PROGRAMMING 3.Function References

When all of the following conditions are satisfied at a normal call, the tool status
cannot be changed to the cleared state:
- During automatic operation (OP = "1").
- The tool group with the target number is being used or to be used next.
- The tool with the target number is being used.
- Bit 1 (TCO) of parameter No. 6802 = "1".
- Bit 2 (E17) of parameter No. 6802 = "1".

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 743 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.181 Write tool life management data (tool data 1) (2). (2) <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wr1tlifedat2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wr1tlifedat2( struct iodbtd2 *tld1);

struct iodbtd2 {
short datano; /* Tool group number. */
short dummy; /* Not used. */
long type; /* Current tool number. */
long tool_num; /* New tool number. */
long h_code; /* Tool length compensation number. */
long d_code; /* Tool radius compensation number. */
long tool_inf; /* Tool information. */
} ;

[Arguments]
tld1 Pointer to structure iodbtd2 for updating various tool information.
The following information items are stored in tld1 with binary format:
datano Specifies a tool group number.
type Specifies a current tool number.
tool_num Specifies a new tool number.
h_code Specifies a tool length compensation number. (Always
"0" for the lathe system (T series).)
d_code Specifies a tool radius compensation number. (Always
"0" for the lathe system (T series).)
tool_inf Specifies tool information:
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified current tool number (type) is invalid.

- 744 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_DATA(5) Data error.


To get more detailed information on this return value, execute the
cnc_getdtailerr function. One of the following detail status codes is
set in member err_no in structure odberr:
0: Error other than EW_DATA.
1: New tool number (tool_num) error.
2: Tool length compensation number (h_code) error.
3: Tool radius compensation number (d_code) error.
4: Tool information (tool_inf) error.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being currently
used or the next tool group to be used.

[Description]
Writes various tool information.

The following information items can be updated:


- Tool number.
- Tool length compensation number.
- Tool radius compensation number.
- Tool information.
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

1. As preprocessing, set TLIFE_OPTION as the option and "1" as the value for the
cnc_setlibopt function and call the function.
2. Call cnc_wr1tlifedat2.
3. As postprocessing, set TLIFE_OPTION as the option and "0" as the value for the
cnc_setlibopt function and call the function.

When all of the following conditions are satisfied at a normal call, error EW_REJECT(13)
is returned:
- During automatic operation (OP = "1").
- The tool group with the target number is being used or to be used next.
- Bit 1 (TCO) of parameter No. 6802 = "0".

- 745 -
3.Function References PROGRAMMING B-64303EN-3/01

When all of the following conditions are satisfied at a normal call, the tool status
cannot be changed to the cleared state:
- During automatic operation (OP="1").
- The tool group with the target number is being used or to be used next.
- The tool with the target number is being used.
- Bit 1 (TCO) of parameter No. 6802 = "1".
- Bit 2 (E17) of parameter No. 6802 = "1".

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 746 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.182 Write tool life management data (tool data 2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wr2tlifedata

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wr2tlifedata( struct iodbtd *tld2 );

struct iodbtd {
short datano; /* Tool group number. */
short type; /* Tool ordinal number. */
long tool_num; /* Tool number. */
long h_code; /* Tool length compensation number. */
long d_code; /* Tool radius compensation number. */
long tool_inf; /* Tool information. */
};

[Arguments]
tld2 Pointer to structure iodbtd for updating various tool information.
The following information items are stored in tld2 with binary format:
datano Specifies a tool group number.
type Specifies a current tool number.
tool_num Specifies a new tool number.
h_code Specifies a tool length compensation number. (Always
"0" for the lathe system (T series).)
d_code Specifies a tool radius compensation number. (Always
"0" for the lathe system (T series).)
tool_inf Specifies tool information:
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (type) is invalid.

- 747 -
3.Function References PROGRAMMING B-64303EN-3/01

EW_DATA(5) Data error.


To get more detailed information on this return value, execute the
cnc_getdtailerr function. One of the following detail status codes is
set in member err_no in structure odberr:
0: Error other than EW_DATA.
1: New tool number (tool_num) error.
2: Tool length compensation number (h_code) error.
3: Tool radius compensation number (d_code) error.
4: Tool information (tool_inf) error.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
For a normal call:
An attempt was made to rewrite data of the tool group being currently
used or the next tool group to be used.

[Description]
Writes various tool information.

The following information items can be updated:


- Tool number.
- Tool length compensation number.
- Tool radius compensation number.
- Tool information.
1: The tool is registered.
2: The life of the tool ends.
3: The tool is skipped.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the CNC.

- 748 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.183 Read tool life management data (tool group information). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdgrpinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdgrpinfo( short s_grp, short e_grp, short length,
struct iodbtgi *grpinfo);

struct iodbtgi {
short s_grp; /* Read start group number. */
short dummy; /* Not used. */
short e_grp; /* Read end group number. */
struct {
long n_tool; /* Number of tools. */
long count_value; /* Tool life value. */
long counter; /* Tool life counter value. */
long count_type; /* Tool life counter type. */
} data[N];
} ; /* N: Number of groups of which information is to be read. */
[Arguments]
s_grp Specifies the read start tool group number with binary format.
e_grp Specifies the read end tool group number with binary format.
length Specifies the data block length (size of structure iodbtgi).

iodbtgi 0┌────┐ ─
│ s_grp │ ↑
2├────┤ │
│ dummy │ │
4├────┤ │
│ e_grp │ │
6├────┤ │
│ │ │
8├────┴────┐length
│ data[0] │ │
24├─────────┤ │
~ ~ │
8+16×(N-1) ├─────────┤ │
│ data[N-1] │ ↓
8+16×N └─────────┘ ─

N is the number of groups of which information is to be read.

- 749 -
3.Function References PROGRAMMING B-64303EN-3/01

data 0┌──────┐
│ n_tool │
4├──────┤
│count_value │
8├──────┤
│ counter │
12├──────┤
│ count_type │
16└──────┘

grpinfo Pointer to structure iodbtgi to which to return tool group information.


The following information items are stored in grpinfo with binary
format:
s_grp Read start tool group number.
e_grp Read end tool group number.
n_tool Number of tools.
count_value Tool life value.
counter Tool life counter value.
count_type Tool life counter type.
0: Count
1: Time

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
The size (length) of structure iodbtgi is invalid.
EW_NUMBER(3) Data number error.
The tool group number (s_grp or e_grp) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads tool group information. The following information items can be obtained:
- Number of tools.
- Tool life value.
- Tool life counter value.
- Tool life counter type (0: Count, 1: Time).
The unit of the tool life value is [minutes] or [times].
Which unit is used depends on the setting of bit 2 (LTM) of parameter No. 6800 on the
CNC. For the M series, the tool life counter type (time or count specification) can be
set for each tool group number with the G10 command.

- 750 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system. The following parameters
are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 751 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.184 Read tool life management data (tool group information 4). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdgrpinfo4

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdgrpinfo4( short grp_no, short direction,
short num_to_read, short *num_read,struct iodbtgi4 *grpinfo4);

struct iodbtgi4 {
short grp_no; /* Tool group number. */
long n_tool; /* Number of tools. */
long count_value; /* Tool life value. */
long counter; /* Tool life counter value. */
long count_type; /* Tool life counter type. */
long opt_grpno; /* Arbitrary group number. */
long life_rest; /* Remaining life setting. */
} ;

[Arguments]
grp_no Specifies the read start tool group number with binary format.
If a number outside the tool group number range is specified, an error
is returned.
When the specified number is within the tool group number range, this
function starts reading tool information of the existing tool group with
the number nearest the specified number.
Direction Specifies the read search direction.
Reads tool information based on the tool group number specified for the
read start tool group number (grp_no):
0: In ascending order (in the direction in which the tool group number
increases).
1: In descending order (in the direction in which the tool group number
decreases).
num_to_read Specifies the number of items to be read.
If a value smaller than or equal to "0" is specified, an error is
returned.
num_read Specifies the pointer to a short variable for which to store the number
of items read actually.
After a search is performed for the read start tool group number in the
read search direction, if no group for which a tool is specified is found,
a value of 0 is returned.
grpinfo4 Pointer to structure iodbtgi4 to which to return tool group information.
The following information items are stored in grpinfo4 with binary
format:
grp_no Tool group number.

- 752 -
B-64303EN-3/01 PROGRAMMING 3.Function References

n_tool Number of tools.


count_value Tool life value.
counter Tool life counter value.
count_type Tool life counter type.
opt_grpno Arbitrary group number.
life_rest Remaining life setting.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
A number smaller than or equal to 0 is specified for the number of items
to be read (num_to_read).
EW_NUMBER(3) Data number error.
The tool group number (grp_no) is invalid.
EW_ATTRIB(4) Data attribute error.
The search direction (direction) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads tool group information 4. The following information items can be obtained:
- Number of tools.
- Tool life value.
- Tool life counter value.
- Tool life counter type (0: Count, 1: Time).
- Arbitrary group number.
- Remaining life setting.

The unit of the tool life value is [times] or [minutes] depending on the setting of bit
2 (LTM) of parameter No. 6800 on the CNC.

For the M series, the tool life counter type (time or count specification) can be set
for each tool group number with the G10 command.
"0" is returned for the arbitrary group number and remaining life setting.

(Note) At least as many arrays as the number of items to be read that is specified for
num_to_read must be prepared.
If the prepared number of arrays is smaller than the number specified for
num_to_read, the operation of this function is not guaranteed.

- 753 -
3.Function References PROGRAMMING B-64303EN-3/01

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
- Bit 5 (TGN) of parameter No. 6802.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 754 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.185 Write tool life management data (tool group information). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrgrpinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_wrgrpinfo( short length, struct iodbtgi *grpinfo);

struct iodbtgi {
short s_grp; /* Write start group number. */
short dummy; /* Not used. */
short e_grp; /* Write end group number. */
struct {
long n_tool; /* Not used. */
long count_value; /* Tool life value. */
long counter; /* Tool life counter value. */
long count_type; /* Tool life counter type. */
} data[N];
}; /* N: Number of groups of which information */
/* is to be written. */

[Arguments]
length Specifies the data block length (size of structure iodbtgi).

iodbtgi 0┌────┐ ─
│ s_grp │ ↑
2├────┤ │
│ dummy │ │
4├────┤ │
│ e_grp │ │
6├────┤ │
│ │ │
8├────┴────┐length
│ data[0] │ │
24├─────────┤ │
~ ~ │
8+16×(N-1) ├─────────┤ │
│ data[N-1] │ ↓
8+16×N └─────────┘ ─

- 755 -
3.Function References PROGRAMMING B-64303EN-3/01

data 0┌──────┐
│ n_tool │
4├──────┤
│count_value │
8├──────┤
│ counter │
12├──────┤
│ count_type │
16└──────┘
N is the number of groups of which information is to be written.

Grpinfo Pointer to structure iodbtgi in which to set various tool information.


The following information items are stored in iodbtgi with binary
format:
s_grp Specifies the write start group number.
e_grp Specifies the write end group number.
count_value Specifies a tool life value.
counter Specifies a tool life counter value.
count_type Specifies a tool life counter type.
0: Count
1: Time

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
The size (length) of structure iodbtgi is invalid.
EW_NUMBER(3) Data number error.
The tool group number (s_grp or e_grp) is invalid.
EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function. One of the following detail status codes is
set in member err_no in structure odberr:
0: Error other than EW_DATA.
1: Tool life value (count_value) error.
2: Tool life counter value (counter) error.
3: Tool life counter type (count_type) error.
5: During automatic operation.
6: Next group to be used or group being used.
(No items other than the life counter value can be changed.)
The number of the tool group containing invalid data is set in member
err_dtno in structure odberr.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

- 756 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EW_REJECT(13) CNC processing is rejected.


For a normal call:
An attempt was made to rewrite data of the tool group being currently
used or the next tool group to be used.

[Description]
Writes tool group information.

The following information items can be updated:


- Tool life value.
- Tool life counter value.
- Tool life counter type.
0: Count
1: Time

The maximum life value and life counter value are as follows:
For the count specification: 99999999 times
For the time specification: 60000 minutes

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 757 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.186 Delete tool life management data (tool group information). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_deltlifegrp

[Syntax]
#include <fwindow.h>
short cnc_deltlifegrp( short number );

[Arguments]
number Specifies a tool group number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (number) is invalid.
EW_DATA(5) Data error.
The specified tool number (data) is invalid.
To get more detailed information on this return value, execute the
cnc_getdtailerr function. One of the following detail status codes is
set in member err_no in structure odberr:
0: Error other than EW_DATA.
5: During automatic operation.
6: Next group to be used or group being used.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
No data can be written because processing is being executed for the group,
the group is being selected, or data of the group is being buffered.

[Description]
Deletes a tool group.

Information belonging to the specified group is all cleared.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 758 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.187 Add tool life management data (tool data). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_instlifedt

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_instlifedt( struct idbitd * inst );

struct idbitd {
short datano; /* Tool group number. */
short type; /* Tool ordinal number. */
long data; /* Tool number. */
};

[Arguments]
inst Pointer to structure idbitd in which to set tool data.
The following information items are stored in idbitd with binary
format:
datano Specifies a tool group number.
type Specifies a tool ordinal number.
data Specifies a tool number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (datano) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (type) is invalid.
EW_DATA(5) Data error.
The specified tool number (data) is invalid.
To get more detailed information on this return value, execute the
cnc_getdtailerr function. One of the following detail status codes is
set in member err_no in structure odberr:
0: Error other than EW_DATA.
1: Tool number (data) error.
5: During automatic operation.
6: Next group to be used or group being used.

- 759 -
3.Function References PROGRAMMING B-64303EN-3/01

EW_NOOPT(6) A required function is not provided.


Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_OVRFLOW(8) The maximum number of tools that can be registered is exceeded.
EW_REJECT(13) CNC processing is rejected.
No data can be written because processing is being executed for the group,
the group is being selected, or data of the group is being buffered.

[Description]
Adds tool data.

The code indicating that "the life of the tool does not end" is set for tool information.
Added data is inserted following the specified tool ordinal number.

When a tool is added to a tool group which is not registered, the tool group itself is
also registered.
In this case, the life value, life counter value, H code, and D code are set to "0".
The life counter type depends on the parameter setting.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 760 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.188 Delete tool life management data (tool data). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_deltlifedt

[Syntax]
#include <fwindow.h>
short cnc_deltlifedt( short grp_num, short ent_num );

[Arguments]
grp_num Specifies a group number.
ent_num Specifies a tool ordinal number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grp_num) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (ent_num) is invalid.
EW_DATA(5) Data error.
The specified tool number (data) is invalid.
To get more detailed information on this return value, execute the
cnc_getdtailerr function. One of the following detail status codes is
set in member err_no in structure odberr:
0: Error other than EW_DATA.
5: During automatic operation.
6: Next group to be used or group being used.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
No data can be written because processing is being executed for the group,
the group is being selected, or data of the group is being buffered.

- 761 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Deletes tool data.

After tool data is deleted, the space is filled up in the file (see the figure below).

┌────┐ ┌────┐
Tool ordinal│Tool │ Tool ordinal│Tool │
number │number │ number │number │
├────┤ Delete tool data with ├────┤
1 │ 010 │ tool ordinal number 2. 1 │ 010 │
├────┤ ├────┤
2 │ 020 │ ────────> 2 │ 030 │
├────┤ ├────┤
3 │ 030 │ 3 │ 040 │
├────┤ ├────┤
・ ~ ~ ・ ~ ~

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 762 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.189 Clear tool life management data (life counter, tool information) (range specified).
<Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_clrcntinfo

[Syntax]
#include <fwindow.h>
short cnc_clrcntinfo( short grpno_s, short grpno_e );

[Arguments]
grpno_s Specifies the write start group number.
grpno_e Specifies the write end group number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) Data number error.
The tool group number (grpno_s or grpno_e) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).
EW_REJECT(13) CNC processing is rejected.
No data can be written because processing is being executed for the group,
the group is being selected, or data of the group is being buffered.
To get more detailed information on this return value, execute the
cnc_getdtailerr function. The number of the tool group containing
invalid data is set in member err_dtno in structure odberr.

[Description]
Clears the life counter and tool information.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 763 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.190 Read tool life management data (maximum number of groups that can be registered/maximum
number of tools that can be registered in group/maximum tool life value). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtlinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtlinfo( struct odbtlinfo *tlinfo ) ;

struct odbtlinfo {
long max_group; /* Maximum number of groups that can be */
/* registered. */
long max_tool; /* Maximum number of tools that can be registered. */
long max_minute; /* Maximum tool life value (time) */
long max_cycle; /* Maximum tool life value (count) */
} ;

[Arguments]
tlinfo Pointer to structure odbtlinfo in which to store the number of tool
groups, maximum number of groups that can be registered, maximum number
of tools that can be registered in a group, and maximum tool life value.
The following information items are stored in odbtlinfo with binary
format:
max_group Maximum number of groups that can be registered.
max_tool Maximum number of tools that can be registered.
max_minute Maximum tool life value (time).
max_cycle Maximum tool life value (count).

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the maximum number of groups that can be registered, maximum number of tools that
can be registered in a group, and maximum tool life value.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:

- 764 -
B-64303EN-3/01 PROGRAMMING 3.Function References

- Bit 0 (GS1) of parameter No. 6800.


- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
- Bit 2 (LTM) of parameter No. 6800.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 765 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.191 Read tool life management data (tool group information). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtlgrp

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtlgrp( short grp_no,short *num, struct iodbtlgrp *tlgrp);

struct iodbtlgrp {
long ntool; /* Number of tools. */
long nfree; /* Number of tools that can be used. */
long life; /* Tool life value. */
long count; /* Tool life counter value. */
long use_tool; /* Ordinal number of the tool being selected. */
long opt_grpno; /* Arbitrary group number. */
long life_rest; /* Remaining life setting. */
short rest_sig; /* Advance notice signal status. */
short count_type ; /* Counter type. */
} ;

[Arguments]
grp_no Specifies the read start tool group number with binary format.
num Specifies the pointer to the variable for the number of groups to be
read.
The number of groups actually installed is stored in this variable.
tlgrp Pointer to arrays of structure iodbtlgrp in which to store tool group
information.
The following information items are stored in iodbtlgrp with binary
format:
ntool Number of tools.
nfree Number of tool that can be used.
life Tool life value.
use_tool Ordinal number of the tool being selected.
opt_grpno Arbitrary group number.
"-1" is returned.
life_rest Remaining life setting.
"-1" is returned.
rest_sig Advance notice signal status.
"0" is returned.
count_type Counter type.
0: The type is count.
1: The type is time.

- 766 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
The number of groups (*num) is invalid.
EW_NUMBER(3) Data number error.
The specified tool group number (grp_no) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads tool group information. The following information items can be obtained:
- Number of tools.
- Number of tools that can be used.
- Tool life value.
- Tool life counter value.
- Ordinal number of the tool being selected.
- Arbitrary group number.
- Remaining life setting.
- Advance notice signal status.
- Tool life counter type (0: Count 1: Time).

The unit of the tool life value is [times] or [minutes] depending on the setting of bit
2 (LTM) of parameter No. 6800 on the CNC.

For the M series, the tool life counter type (time or count specification) can be set
for each tool group number with the G10 command.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
- Bit 5 (TGN) of parameter No. 6802.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 767 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.192 Read tool life management data (tool information). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdtltool

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdtltool( long grp_no, long use_no, short *num,
struct iodbtltool *tltool);

struct iodbtltool {
long tool_num; /* Tool number. */
long h_code; /* Tool length compensation number. */
long d_code; /* Tool radius compensation number. */
long tool_inf; /* Tool information. */
} ;

[Arguments]
grp_no Specifies a tool group number.
use_no Specifies the read start tool ordinal number.
num Specifies the pointer to the variable for the number of tool data items
to be read.
The number of tool data items actually installed is stored in this
variable.
tltool Pointer to arrays of structure iodbtltool in which to store tool
information.
The following information items are stored in iodbtltool with binary
format:
ool_num Number of tools.
h_code Number of tools that can be used.
d_code Tool life value.
tool_inf Tool information.

- 768 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) Error in the data block length.
The number of tool information items (*num) is invalid.
EW_NUMBER(3) Data number error.
The specified tool group number (grp_no) is invalid.
EW_ATTRIB(4) Data attribute error.
The specified tool ordinal number (use_no) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads various tool information. The following information items can be obtained:
- Tool number.
- Tool length compensation number ("0" is always read for the lathe system (T
series)).
- Tool radius compensation number ("0" is always read for the lathe system (T
series)).
- Tool information.
0: No tool data.
1: The life does not end.
2: The life of the tool ends.
3: Skipped tool.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 769 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.193 Read tool life management data (tool group number) (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdgrpid2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdgrpid2( long number, struct odbtlife5 *grpid);

struct odbtlife5 {
long dummy ; /* Not used. */
long type ; /* Tool number. */
long data ; /* Tool group number. */
} ;

[Arguments]
number Specifies a tool number.
grpid Pointer to structure odbtlife5 to which to return the tool group number.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_ATTRIB(4) Data attribute error.
The specified tool number (number) is invalid.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

- 770 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the number of the tool group in which the specified tool is registered.

When the tool number is found in multiple tool groups, the smallest group number is stored.

Normally, use this function to get the tool group number.


The cnc_rdgrpid function is available only when you use an up to 4-digit tool number.

The number of the tool group in which the specified tool number is registered is stored
in grpid data with binary format. When "0" is specified for number, the number of the
tool group being currently used is stored. When no tool group number has been specified
since power-on, however, "0" is stored.

Up to 128 sets (for M and T series) or 256 sets (for T series (2-path control)) are
available for tool life management through the entire system.
The following parameters are related to this function:
- Bit 0 (GS1) of parameter No. 6800.
- Bit 1 (GS2) of parameter No. 6800.
- Parameter No. 6813.
For information about the parameters, refer to "Parameter Manual" (B-64310EN) of the
CNC.

- 771 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.194 Read tool life management data (count override). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdcntover

[Syntax]
#include <fwindow.h>
short cnc_rdcntover( short * cntover )

[Arguments]
cntover Pointer to the variable to which to return the count override value.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NOOPT(6) A required function is not provided.
Enable the tool life management function (bit 0 (TLF) of parameter No.
8132 =1).

[Description]
Reads the count override value.

- 772 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.195 Get CNC error details. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_getdtailerr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_getdtailerr( struct odberr *err ) ;

struct odberr{
short err_no ; /* Detail status. */
short err_dtno ; /* Error data number. */
} ;

[Arguments]
err Area in which to store error details.

[Return]
EW_OK(0) Successful.

[Description]
Gets detailed information of an error which occurred when a function was executed.

Error details are stored in buf.err_no and buf.err_dtno.

- 773 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.196 Write MDI program. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrmdiprog

[Syntax]
#include <fwindow.h>
short cnc_wrmdiprog( short length, char *data ) ;

[Arguments]
length Specifies the number of characters in the MDI program to be written.
data Specifies the start address of the MDI program data to be written.
Up to 500 characters including the end NULL character are allowed for
an MDI program data string.
Specify NULL at the end of MDI program data.

[Return]
Return values are listed below. For information about other return values, see Subsection
3.4.2, "Return values of data window functions" above in II, "PROGRAMMING".

EW_OK(0) Successful.
EW_LENGTH(2) The number of characters in the MDI program (length) is invalid.
EW_DATA(5) A character which is unavailable for NC programs is detected.
EW_MODE(12) The function is executed in an unavailable CNC mode.
Set the CNC mode to MDI.
EW_REJECT(13) MDI operation is being executed or the CNC is in the emergency stop
status.

[Description]
Writes an MDI program to the CNC.
This function must be used in the MDI mode.
The written data format is shown below.

MDI program data format)


MDI program data registered to the CNC is an ASCII code string in the following
format:

LF Block1 LF Block2 LF ... LF %

- 774 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Example) To write the following MDI program to the CNC:

< MDI program >


M03 S2000 ;
G28 U0 W0 ;
T0101 ;
G00 X35.0 Z-10.0 ;

< Sample program >


#include <string.h>
#include <fwindow.h>

void sample( void ){


short ret ;
short len ;

char data[ ] =
"\nM03S2000\nG28U0W0\nT0101\nG00X35.0Z-10.0\n%" ;
len = (short)strlen( data ) ;
ret = cnc_wrmdiprog( len, data ) ;
return ;
}

- 775 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.197 Read execution pointer for MDI operation. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdmdipntr

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdmdipntr( struct odbmdip *buf ) ;

struct odbmdip{
long mdiprog ; /* Number of the program being executed. */
long mdipntr ; /* Execution block pointer. */
long crntprog ; /* Buffered program number. */
long crntpntr ; /* Buffered block pointer. */
} ;

[Arguments]
buf Pointer to structure odbmdip to which to return execution pointer
information.

[Return]
Return values are listed below. For information about other return values, see Subsection
3.4.2, "Return values of data window functions" above in II, "PROGRAMMING".

EW_OK(0) Successful.
EW_MODE(12) The function is executed in an unavailable CNC mode.
Set the CNC mode to MDI.

[Description]
Reads the execution pointer for MDI operation.
This function must be used in the MDI mode.
The following data items can be obtained:

Number of the program being executed.


For MDI operation, this value is basically 0.
When the program being executed is a subprogram, the subprogram number is indicated.
Execution block pointer.
Pointer to the block being currently executed.
Buffered program number.
Number of the program which is buffered.
For MDI operation, this value is basically 0. When a subprogram is buffered, the
subprogram number is indicated.
Buffered block pointer.
Pointer to the last block of the program that is buffered.

- 776 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.198 Write execution pointer for MDI operation. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrmdipntr

[Syntax]
#include <fwindow.h>
short cnc_wrmdipntr( long crntpntr ) ;

[Arguments]
crntpntr Specifies the execution start block pointer with an absolute pointer
value (block number indicated when the number of the first block of
the program is 0).

[Return]
Return values are listed below. For information about other return values, see Subsection
3.4.2, "Return values of data window functions" above in II, "PROGRAMMING".

EW_OK(0) Successful.
EW_DATA(5) The specified execution start block pointer (crntpntr) is invalid.
EW_MODE(12) The function is executed in an unavailable CNC mode.
Set the CNC mode to MDI.
EW_REJECT(13) MDI operation is being executed or the CNC is in the emergency stop
status.

[Description]
Specifies the execution pointer for MDI operation. (The pointer cannot be directly
manipulated while a program is being executed.)
Before executing this function, register an MDI program using the cnc_wrmdiprog
function.
This function must be used in the MDI mode.

- 777 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.199 Read CNC status information (2). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_statinfo2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_statinfo( struct odbst2 *buf ) ;

struct odbst2 {
short hdck ; /* Manual handle retrace status. */
short tmmode ; /* Not used. */
short aut ; /* Auto/manual operation mode selection. */
short run ; /* Automatic operation status. */
short motion ; /* Axis movement/dwell status. */
short mstb ; /* M/S/T/B function status. */
short emergency ; /* Emergency stop status. */
short alarm ; /* Alarm status. */
short edit ; /* Program editing status. */
short warning ; /* Warning message status. */
short o3dchk ; /* Not used. */
short ext_opt ; /* Not used. */
short restart ; /* Restart check status after program editing. */
} ;

* For a 2-path system, all status values are indicated for each path.

[Arguments]
buf Status information storage area

[Return]
Main return value is as follows. For information about other return values, see Subsection
3.4.2, "Return values of data window functions" above in Part II, "PROGRAMMING".

EW_OK(0) Successful.

- 778 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads CNC status information.
The following status information items can be read:

hdck Manual handle retrace status.


0: Manual handle retrace disable state.
1: M.H.RTR. (Manual handle retrace.)
2: NO RVRS. (Movement in the backward direction prohibited.)
3: NO CHAG. (Reverse prohibited.)

aut Auto/manual operation mode selection.


0: MDI 1: MEMory
2: **** 3: EDIT
4: HaNDle 5: JOG
6: Teach in JOG 7: Teach in HaNDle
8: INC・feed 9: REFerence
10: ReMoTe

run Automatic operation status.


0: ****(reset) 1: STOP
2: HOLD 3: STaRT

motion Axis movement/dwell status.


0: *** 1: MoTioN
2: DWeLl

mstb M/S/T/B function status.


0: *** (others) 1: FIN

emergency Emergency stop status.


0: (Emergency stop canceled.) 1: EMerGency
2: ReSET

alarm Alarm status.


0: *** (others) 1: ALarM
2: BATtery low

edit Other status.


- M series
0: **** (no editing)
1: EDIT (during editing)
2: SeaRCH (during a search)
3: OUTPUT (during data output)
4: INPUT (during data input)
5: COMPARE (during comparison)
6: Label SKip (label skip state)
7: ReSTaRt (during program restart)

- 779 -
3.Function References PROGRAMMING B-64303EN-3/01

13: HANDLE (during a handle interrupt)


16: AICC (during AI contour control operation)
17: MEmory-CHecK (during tape memory check)

- T series
0: **** (no editing)
1: EDIT (during editing)
2: SeaRCH (during a search)
3: OUTPUT (during data output)
4: INPUT (during data input)
5: COMPARE (during comparison)
6: Label SKip (label skip state)
8: Work ShiFT (in the workpiece shift write mode)
9: ReSTaRt (during program restart)
17: MEmory-CHecK (during tape memory check)

warning Warning message status.


0: (No warning)
1: WaRNing (start in the middle of a program)

restart Check performed at the restart of automatic operation after program editing.
0: One of the following states:
- The program is not edited.
- Bit 7 (RSC) of parameter No. 10330 is set to disable the function which displays
a confirmation message at the restart of automatic operation.
- NC not supported.
1: The program is edited.

- 780 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.200 Read parameter data information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdparainfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_rdparainfo( short s_number, unsigned short read_no,
struct odbparaif *paraif ) ;

struct odbparaif {
unsigned short info_no ; /* Number of parameter data information items. */
short prev_no ; /* Previous parameter data number. */
short next_no ; /* Next parameter data number. */
struct {
short prm_no ; /* Parameter data number. */
short prm_type ; /* Parameter data attribute. */
} info[N] ; /* N: Number of parameter data information items to be */
/* read. */
} ;

[Arguments]
s_number [in] Specifies the start parameter data number.
read_no [in] Specifies the number of parameter data information items to be
read.
paraif [out] Information storage area to which to return parameter data
information.
Pointer to setif to which to return parameter data information.
info_no Number of parameter data information items.
Number of actually read parameter data information items.
prev_no Previous parameter data number.
Valid number preceding the first read parameter data
information.
next_no Next parameter data number.
Valid number following the last read parameter data
information.
info[N].prm_no Parameter data number.
Actually existing parameter data number.

- 781 -
3.Function References PROGRAMMING B-64303EN-3/01

info[N].prm_type Parameter data attribute.


The following attribute values are set:
#0, #1: Type attribute.
0: Bit
1: Byte
2: Word
3: 2-word or real
#2: Axis attribute.
0: Non axis
1: Axis
#3: Sign
0: Signed
1: Unsigned
#4: Setting input
0: Disabled
1: Enabled
#5: Write protection
0: Enabled
1: Disabled
#6: Whether the power must be turned off, then on again after
writing
0: Not required
1: Required
#7: Read protection
0: Enabled
1: Disabled
#8: Spindle parameter
0: Other than spindle parameter
1: Spindle parameter
#9 to #11: (Reserved.)
#12: When the type attribute is 3
0: Other than real
1: Real
#13 to #15: (Reserved.)

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_NUMBER(3) The specified start parameter data number (s_number) is invalid.

[Description]
Reads CNC parameter data information specified with s_number and read_no.

In principle, CNC parameter data is not stored contiguously, and attributes such as the
type and size differ depending on the individual number. Use this function to display
parameter data.

- 782 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.201 Read program on a line-by-line basis. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_rdpdf_line

[Syntax]
#include <fwindow.h>
short cnc_rdpdf_line( char *prog_name, unsigned long line_no,
char *prog_data, unsigned long *line_len,
unsigned long *data_len ) ;

[Arguments]
prog_name Specifies a program path with drive-name+path-name+file-name.
When prog_name data is NULL, the name of the last accessed program is
assumed to be specified.
If you want to specify an MDI program, specify "MDI".
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is "//DATA_SV/".
Specify the following paths for the program folder of the CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/"
Path 2:"//CNC_MEM/USER/PATH2/"
line_no Specifies the read start line number.
For the first line in the program, specify 0.
If a number greater than the number of registered lines is specified,
an error (EW_DATA) is returned.
prog_data Specifies the start address of the buffer in which to store read program
data.
line_len Specifies the number of lines to be read in the program.
The function returns the number of actually read lines.
data_len Specifies the number of characters to be read in the program.
The function returns the number of actually read characters.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_BUSY(-1) Busy.
- During the execution of a search.
EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
1: Program path (prog_name) error.
2: Read start line number (line_no) error.

- 783 -
3.Function References PROGRAMMING B-64303EN-3/01

3: Error in the number of lines to be read (*line_len).


EW_PROT(7) Write protection.
- CNC parameters (Nos. 8000s and Nos. 9000s protection and encryption)
are write-protected according to the setting.
EW_MODE(12) CNC mode error.
EW_REJECT(13) CNC processing is rejected.
- In emergency stop status.

[Description]
Reads the specified program on a line-by-line basis.

This function attempts to read as many lines in the program as specified for (*line_len)
(it returns the number of actually read lines). If the number of characters that is
specified for (*data_len) is reached (the function returns the number of actually read
characters), the function stops reading the program. When the end (EOB (‘\n’)) of the
last line read is not read, the line is not counted as the read line, however.

Example) If you want to read lines 1 to 3 of the following program, you must specify
at least 33 for the number of characters to be read. If a value of 30 is specified
for the number of characters to be read, a value of 2 is set for the number of read
lines (*line_len) because line 3 cannot be read to its end. Thirty characters are
set in the buffer, however.

O1234 ;
N001 G01 X0. F100 ;
N002 X20. ;
N003 X50. ;
N004 X80. ;
N005 M30 ;
%

The following table shows the relationships between each CNC mode and target program
(MDI program, program being selected, or program not selected):

MDI mode Other modes


MDI program ○ ×
Program being selected ○ ○
Program not selected ○ ○
○: Can be executed. / ×: Cannot be executed (EW_MODE is returned).

Even when the OP signal is set to 1, this function can be executed if the STL signal
is set to 0 (in the status such as feed hold stopped or single block stopped).

When this function is executed for an MDI program or program being selected, the execution
pointer moves to the beginning of the line specified for line_no in the following cases:
- When an MDI program is specified in the MDI mode
- When the program being selected is specified in the EDIT mode
- When the program being selected is specified in the TJOG/THND mode with a playback
function

- 784 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.202 Write program on a line-by-line basis. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_wrpdf_line

[Syntax]
#include <fwindow.h>
short cnc_wrpdf_line( char *prog_name, unsigned long line_no,
char *prog_data, unsigned long data_len);

[Arguments]
prog_name Specifies a program path with drive-name+path-name+file-name.
When prog_name data is NULL, the name of the last accessed program is
assumed to be specified.
If you want to specify an MDI program, specify "MDI".
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths for the program folder of the CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/"
Path 2:"//CNC_MEM/USER/PATH2/"
line_no Specifies the number of a line to be written.
Line 0 is the first line (line containing a program name and program
number) of a program.
prog_data Specifies the pointer to the buffer in which the program string to be
written is stored.
Note the following points and specify a string in ASCII code:
- Codes other than those significant for the NC are ignored.
- Lowercase alphabetic characters are ignored.
- '%' (EOR) is ignored.
Even when the specified string contains multiple EOB characters ('\n'),
the registered line with the specified line number is replaced with the
specified string.
That is, one line can be replaced with multiple lines.
data_len Specifies the number of characters to be written.
Before data is written, the unused space in the NC is checked. If the
size of the space is smaller than that for the number of characters to
be written + 100 characters, data is not written and an error
(EW_OVRFLOW) is returned.
Up to 200 characters can be written at a time.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_BUSY(-1) Busy.

- 785 -
3.Function References PROGRAMMING B-64303EN-3/01

- During the execution of a search.


EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
1: Program path (prog_name) error.
2: Write start line number (line_no) error.
3: Error in the number of characters to be written (data_len).
4: An attempt was made to change the O number at the beginning.
5: The first character of the string is invalid.
6: An error occurred during deletion of the write start line.
7: An error occurred during writing.
EW_PROT(7) Write protection.
- CNC parameters (Nos. 8000s and Nos. 9000s protection and encryption)
are write-protected according to the setting.
EW_OVRFLOW(8) Memory overflow.
- The unused space on the NC is insufficient. Allocate the required
space.
EW_MODE(12) CNC mode error.
EW_REJECT(13) CNC processing is rejected.
- During MDI or background editing.

[Description]
Writes the specified program on a line-by-line basis.

The file name on the first line cannot be changed. If an attempt is made to rewrite the
file name, an error (EW_DATA) is returned.
The following table shows the relationships between each CNC mode and target program
(MDI program, program being selected, or program not selected):

EDIT mode MDI mode Other modes


MDI program × ○ ×
Program being selected ○ × ×
Program not selected ○ ○ ○
○: Can be executed. / ×: Cannot be executed (EW_MODE is returned).

When a playback function is enabled, TJOG/THND mode is assumed to be the same as the
"EDIT mode".

Even when the OP signal is set to 1, this function can be executed if the STL signal
is set to 0 (in the status such as feed hold stopped or single block stopped).

When this function is executed for an MDI program or program being selected, the execution
pointer moves to the beginning of the line specified for line_no in the following cases:
- When an MDI program is specified in the MDI mode
- When the program being selected is specified in the EDIT mode
- When the program being selected is specified in the TJOG/THND mode with a playback
function

- 786 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.203 Delete program on a line-by-line basis. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_delline

[Syntax]
#include <fwindow.h>
short cnc_pdf_delline( char *prog_name, unsigned long line_no,
unsigned long line_len);

[Arguments]
prog_name Specifies a program path with drive-name+path-name+file-name.
When prog_name data is NULL, the name of the last accessed program is
assumed to be specified.
If you want to specify an MDI program, specify "MDI".
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths for the program folder of the CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/"
Path 2:"//CNC_MEM/USER/PATH2/"
line_no Specify the deletion start line number.
For the first line of the program, specify 0.
If the specified number exceeds the number of registered lines, an error
(EW_DATA) is returned.
line_len Specify the number of lines in the program that are to be deleted.
If the specified number exceeds the number of registered lines, the
lines from that with the specified line number to the last line but one
are deleted. The last line (%) is not deleted.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_BUSY(-1) Busy.
- During the execution of a search.
EW_DATA(5) Data error.
To get more detailed information on this return value, execute the
cnc_getdtailerr function.
One of the following detail status codes is set in member err_no in
structure odberr:
1: Program path (prog_name) error.
2: Deletion start line number (line_no) error.
3: Error in the number of lines to be deleted (line_len).
EW_PROT(7) Write protection.
- CNC parameters (Nos. 8000s and Nos. 9000s protection and encryption)
are write-protected according to the setting.

- 787 -
3.Function References PROGRAMMING B-64303EN-3/01

EW_MODE(12) CNC mode error.


EW_REJECT(13) CNC processing is rejected.
- In the emergency stop status

[Description]
Deletes the specified program on a line-by-line basis.

When the number of the line containing the file name ("Oxxxx" or "<xxxx>") is specified
for the deletion start line number, data following the file name to the end of line ('\n')
is deleted, but the file name is not deleted.

Example)
Deletes the following program on a line-by-line basis:
O1234(TEST PROGRAM) ;
G01 X0. F100 ;
X20. ;
M30 ;
%

When three lines starting from line 0 in the program are deleted, the result is:
O1234 M30 ;
%

The following table shows the relationships between each CNC mode and target program
(MDI program, program being selected, or program not selected):

EDIT mode MDI mode Other modes


MDI program × ○ ×
Program being selected ○ × ×
Program not selected ○ ○ ○
○: Can be executed. / ×: Cannot be executed (EW_MODE is returned).

When a playback function is enabled, TJOG/THND mode is assumed to be the same as the
"EDIT mode".

Even when the OP signal is set to 1, this function can be executed if the STL signal
is set to 0 (in the status such as feed hold stopped or single block stopped).

When this function is executed for an MDI program or program being selected, the execution
pointer moves to the beginning of the line specified for line_no in the following cases:
- When an MDI program is specified in the MDI mode
- When the program being selected is specified in the EDIT mode
- When the program being selected is specified in the TJOG/THND mode with a playback
function

- 788 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.204 Get program execution pointer. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_rdactpt

[Syntax]
#include <fwindow.h>
short cnc_pdf_wractpt( char *prog_name, long *blk_no ) ;

[Arguments]
prog_name Specifies the pointer to the area in which to store the program being
executed.
When an MDI program is executed, "MDI" is set. The buffer must be able
to contain at least 244 characters.
blk_no Specifies the pointer to the area in which to store the block number
indicated when the number of the first block of the program is 0.

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_MODE(12) CNC mode error.
- The function is executed in a mode other than the MDI, MEM, EDIT,
TJOG, or THND mode.
EW_REJECT(13) Pointer get processing is rejected.
- Currently, the target program does not exist.
- The CNC is performing DNC or M198 operation.
- The STL signal is on.
- In the emergency stop status.

[Description]
Gets the current program name and block number in the MDI or MEM mode and EDIT, TJOG,
or THND mode and stores them in prog_name.

There are the following restrictions on executing this function:


- During DNC or M198 operation, EW_REJECT is returned.
- When the STL signal is on, EW_REJECT is returned.
- When the program is buffered, the number of the block following the buffered block
is obtained.

- 789 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.205 Set program execution pointer. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
cnc_pdf_wractpt

[Syntax]
#include <fwindow.h>
short cnc_pdf_wractpt( char *prog_name, short type, long *blk_no );

[Arguments]
prog_name Specifies a program for which to set the execution pointer with
drive-name+path-name+file-name.
For an MDI program, specify "MDI".
The drive name of the memory card is “//MEMCARD/”.
The drive name of the data server is “//DATA_SV/”.
Specify the following paths for the program folder of the CNC memory.
Path 1:"//CNC_MEM/USER/PATH1/"
Path 2:"//CNC_MEM/USER/PATH2/"
type Execution pointer type.
0: Absolute pointer
(The number of the first block of the program is 0.)
1: Relative pointer
(Relative value to the current execution pointer)
blk_no Specifies the pointer to the long variable for which to store the block
number to be set.
When type = 0
- Specify a block number indicated when the number of the first block
of the program is 0.
When type = 1
- Specify the relative value to the current execution pointer as the
block number.
- When a value of 0 is specified for the block number, the execution
pointer is not changed, and the next pointer to be executed is set
in blk_no with an absolute pointer.

The following shows values to be specified as absolute and relative pointers.


Absolute Relative
Selected NC command program
pointer pointer
O1234; 0 -3
G00 X0. Z0.; 1 -2
G01 X10. Z5. F100.; 2 -1
X20. Z15.; 3 0
X35.; 4 1
Z20.: 5 2
M30; 6 3
% 7 4
* For relative pointers in the above table, assume that the current
execution pointer is on block "X20. Z15.;".
- 790 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
Main return values are as follows. For information about other return values, see
Subsection 3.4.2, "Return values of data window functions" above in Part II,
"PROGRAMMING".

EW_OK(0) Successful.
EW_ATTRIB(4) Data attribute error.
- An invalid value is specified for type.
EW_DATA(5) Data error.
- The specified program name is invalid or does not exist.
- The specified block number is invalid or does not exist.
EW_MODE(12) CNC mode error.
- In the EDIT mode, NULL is specified for prog_name.
EW_REJECT(13) CNC processing is rejected.
- During operation.
- No MDI program exists.
- No program is selected.
- An alarm is issued.
- In the emergency stop status.

[Description]
Sets the next pointer (block) to be executed for a program for MDI or memory operation.

When a block has been buffered, the buffered block is executed before the pointer (block)
set with this function is executed.

- 791 -
3.Function References PROGRAMMING B-64303EN-3/01

2. PMC window library

------------------------------------------------------------------------------------------
2.1 Read arbitrary PMC data (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_rdpmcrng

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_rdpmcrng( short adr_type, short data_type, short s_number,
short e_number, short length, struct iodbpmc *buf ) ;

struct iodbpmc {
short type_a ; /* Kind of PMC address. */
short type_d ; /* Type of PMC data. */
short datano_s ; /* Start PMC address. */
short datano_e ; /* End PMC address. */
union {
char cdata[N] ; /* PMC data (Byte) */
short idata[N] ; /* (Word) */
long ldata[N] ; /* (2-Word) */
} u ; /* N is number of data to be read. */
} ;

[Arguments]
adr_type Kind of PMC address.
data_type Type of PMC data.
s_number Start PMC address.
e_number End PMC address.
length Data block length
( =8+(byte size of data)*(number of data to be read)).
buf Buffer in which the PMC data are stored.

[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect PMC address "s_number" or "e_number".
EW_ATTRIB( 4) Incorrect kind of PMC address "adr_type" or type of PMC data
"data_type".

- 792 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the PMC data at the specified PMC address or in the specified address range.
This function is used to read or write data between an application program in C Language
Executor and PMC ladder software.

Argument adr_type specifies the identification code corresponding to the type of a PMC
address to be read.

Identification
PMC address type
code
0, ‘G‘ G ( PMC → CNC )
1, ‘F‘ F ( CNC → PMC )
2, ‘Y‘ Y ( PMC → Machine )
3, ‘X‘ X ( Machine → PMC )
4, ‘A‘ A ( Message request )
5, ‘R‘ R ( Internal relay/system relay )
6, ‘T‘ T ( Variable timer )
7, ‘K‘ K ( Keep relay )
8, ‘C‘ C ( Counter )
9, ‘D‘ D ( Data table )
12, ‘E‘ E ( Expansion relay )

For the PMC data referenceable area of each PMC address type, see Table 3.4.2.1, "PMC
data referenceable areas" shown later.

Argument data_type specifies a PMC data type. This data type must be the same as that
on the PMC side.
0: byte type
1: word type
2: long type

Argument s_number specifies the PMC address number at which read operation is started.

Argument e_number specifies the PMC address number at which read operation is ended.

Argument length specifies a data block length.


When data_type is "0" (byte type): length = 8 + N
When data_type is "1" (word type): length = 8 + N × 2
When data_type is "2" (long type): length = 8 + N × 4

* N indicates the number of data items to be


read.

- 793 -
3.Function References PROGRAMMING B-64303EN-3/01

Example of arguments specification


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(1) Reading "D0100" (Word type data).
adr_type "9"
data_type "1"
s_number "100"
e_number "101"
length 8+2×1 (=10)
buf.u.idata[0] Content of "D0100" will be stored.

(2) Reading "R0200" through "R0209" (Byte type data).


adr_type "5"
data_type "0"
s_umber "200"
e_number "209"
length 8+1×10 (=18)
buf.u.cdata[0] Contents of "R0200",..,"R0209" will be stored.
,..,buf.u.cdata[9]

Table 3.4.2.1 PMC data referenceable areas


0i-D / 0i Mate-D
Signal type Symbol 0i-D PMC
PMC/L
Input signal from machine to PMC X X0 to X127 X0 to X127
X200 to X327 X200 to X327(NOTE 1)
X400 to X527 (NOTE 1) X1000 to X1127 (NOTE 1)
X600 to X727 (NOTE 1)
X1000 to X1127(NOTE 1)
Output signal from PMC to machine Y Y0 to Y127 Y0 to Y127
Y200 to Y327 Y200 to Y327(NOTE 1)
Y400 to Y527 (NOTE 1) Y1000 to Y1127 (NOTE 1)
Y600 to Y727 (NOTE 1)
Y1000 to Y1127 (NOTE 1)
Input signal from CNC to PMC F F0 to F767 F0 to F767
F1000 to F1767 F1000 to F1767(NOTE 2)
F2000 to F2767 (NOTE 2)
F3000 to F3767 (NOTE 2)
F4000 to F4767 (NOTE 2)
F5000 to F5767 (NOTE 2)
F6000 to F6767 (NOTE 2)
F7000 to F7767 (NOTE 2)
F8000 to F8767 (NOTE 2)
F9000 to F9767 (NOTE 2)

- 794 -
B-64303EN-3/01 PROGRAMMING 3.Function References

0i-D / 0i Mate-D
Signal type Symbol 0i-D PMC
PMC/L
Output signal from PMC to CNC G G0 to G767 G0 to G767
G1000 to G1767 G1000 to G1767(NOTE 2)
G2000 to G2767 (NOTE 2)
G3000 to G3767 (NOTE 2)
G4000 to G4767 (NOTE 2)
G5000 to G5767 (NOTE 2)
G6000 to G6767 (NOTE 2)
G7000 to G7767 (NOTE 2)
G8000 to G8767 (NOTE 2)
G9000 to G9767 (NOTE 2)
Internal relay R R0 to R7999 R0 to R1499
System relay R R9000 to R9499 R9000 to R9499
Expansion relay E E0 to E9999 E0 to E9999

Message display A
- Display request A0 to A249 A0 to A249
- Display status A9000 to A9249 A9000 to A9249

Timer T
- Variable timer T0 to T499 T0 to T79
- For variable timer precision (NOTE 3) T9000 to T9499 T9000 to T9079
Counter C
- Variable counter C0 to C399 C0 to C79
- Constant counter C5000 to C5199 C5000 to C5039
Keep relay K
- User area K0 to K99 K0 to K19
- System area K900 to K999 K900 to K999
Data table D D0 to D9999 D0 to D2999
Label L L1 to L9999 L1 to L9999
Sub program P P1 to P5000 P1 to P512

- 795 -
3.Function References PROGRAMMING B-64303EN-3/01

NOTE
1 Reserved area for the PMC management software. No I/O can be allocated to this
area. A user program cannot use this area.
2 Reserved area for the PMC management software. A user program cannot use
this area.
3 Area used to set the timer precision of the variable timer
- Do not change the set time or precision setting during operation of the timer. (It
is allowed to continue writing the same value.)
- The precision setting must fall within the following specified range.
- If the above rules are not observed, normal timer operation is not guaranteed.
- The areas other than T9000-T9999(0i-D PMC) or T9000-T9079(PMC/L, DCS
PMC) are reserved by FANUC.
The correspondence between the precision settings and the values that can be
written to T9000 is shown below.
0: Default (8/48 msec)
1: 1 msec
2: 10 msec
3: 100 msec
4: 1 sec
5: 1 min

- 796 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program reads and displays the feed rate override value
(G0012).

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

void example( void )


{
unsigned short fov ;
struct iodbpmc buf ;
pmc_rdpmcrng( 'G', 0, 12, 12, 8+1*1, &buf ) ;
fov = (unsigned char)~buf.u.cdata[0] ;
printf( "Current feedrate override is %u[%].\n", fov ) ;
}

- 797 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.2 Write arbitrary PMC data (range specified). <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_wrpmcrng

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_wrpmcrng( short length, struct iodbpmc *buf ) ;

struct iodbpmc {
short type_a ; /* Kind of PMC address. */
short type_d ; /* Type of PMC data. */
short datano_s ; /* Start PMC address. */
short datano_e ; /* End PMC address. */
union {
char cdata[N] ; /* PMC data (Byte) */
short idata[N] ; /* (Word) */
long ldata[N] ; /* (2-Word) */
} u ; /* N is number of data to be written. */
} ;

[Arguments]
length Specifies the data block length.
When type_d is "0" (byte type): length = 8 + N
When type_d is "1" (word type): length = 8 + N × 2
When type_d is "2" (long type): length = 8 + N × 4
* N is the number of data items to be rewritten.
buf PMC data storage area
type_a Specifies the identification code corresponding to the type of a PMC
address to be read.
type_d Specifies the type of PMC data.

buf.type_d Type of PMC data Byte size


0 byte type 1
1 word type 2
2 2-word type 4

datano_s Specifies the PMC address number at which write operation is started.
datano_e Specifies the PMC address number at which write operation is ended.
For the specifiable address types, start address, and end address, see
"PMC data referenceable areas" in "Read arbitrary PMC data (range
specified) (pmc_rdpmcrng)".

- 798 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Return]
EW_OK( 0) Successful.
EW_LENGTH( 2) Incorrect data block length "length".
EW_NUMBER( 3) Incorrect PMC address "buf.datano_s" or "buf.datano_e".
EW_ATTRIB( 4) Incorrect kind of PMC address "buf.type_a" or type of
PMC data "buf.type_d".

[Description]
Writes the PMC data at the specified PMC address or in the specified address range.

This function is used to read or write data between an application program in C Language
Executor and PMC ladder software.

Example of specifying arguments


~~~~~~~~~~~~
(1) Writing "250" in D0100 (Word type data)
buf.type_a "9" or "D"
buf.type_d "1"
buf.datano_s "100"
buf.datano_e "101"
length 8+2×1 (=10)
buf.u.idata[0] "250"

(2) Writing "0" in R0200 to R0209 (Byte type data)


buf.type_a "5" or "R"
buf.type_d "0"
buf.datano_s "200"
buf.datano_e "209"
length 8+1×10 (=18)
buf.u.cdata[0] All "0"
~buf.u.cdata[9]

- 799 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program sets the specified bit of a specified internal relay (R) to "1".

#include <data.h>
#include <fwindow.h>
#include <stdio.h>

/* number is index number of R. */


/* bit is target bit index to be set. */
short example( short number, short bit )
{
short ret ;
struct iodbpmc buf ;
ret = pmc_rdpmcrng( 'R', 0, number, number, 8+1*1, &buf ) ;
if ( !ret ) {
buf.u.cdata[0] |= ( 1 << bit ) ;
ret = pmc_wrpmcrng( 8+1*1, &buf ) ;
}
return ( ret ) ;
}

- 800 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.3 Read PMC message. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_rdpcmsg

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_rdpcmsg( unsigned short adr_no, unsigned short adr_bit,
struct pmcmsg *buf ) ;

struct pmcmsg {
unsigned short msg_len ; /* Length of message. */
unsigned char pmc_msg[256] ; /* PMC message string. */
} ;

[Arguments]
adr_no PMC address A. ( =0 - 24 )
adr_bit Bit of PMC address A. ( =0 - 7 )
buf Buffer in which PMC message is stored.

[Return]
EW_OK( 0) Successful.
EW_NUMBER( 3) Incorrect PMC address A.
EW_ATTRIB( 4) Incorrect bit of PMC address A.
EW_DATA( 5) No message for specified address.

[Description]
Reads the specified PMC message data.

This function reads the corrsponding message to the specified PMC address A and bit
number.

Specify the number of address A in "adr_no" with binary format.


Specify the bit number 0 - 7 in "adr_bit" with binary format.

The PMC message is stored in "buf.pmc_msg". The PMC message is the ASCII string as same
as one which is displayed in the CNC's alarm message screen. The 2-byte character such
as Japanese Kanji character is stored by Shift-JIS code. A 'NULL' character ('\x00')
is added at the end of the string. The length of the string stored in "buf.pcm_msg"
is stored in "buf.msg_len" with binary format.

- 801 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads all PMC message character strings and displays them on the
screen.

#include <data.h>
#include <fwindow.h>
#include <stdio.h>
#include <stdlib.h>

void example( void )


{
short ret ;
unsigned short idx, bit ;
struct pmcmsg *buf ;
buf = (struct pmcmsg *)malloc( sizeof( struct pmcmsg ) ) ;
for ( idx = 0 ; idx <= 24 ; idx++ ) {
for ( bit = 0 ; bit <= 7 ; bit++ ) {
ret = pmc_rdpcmsg( idx, bit, buf ) ;
if ( !ret ) printf( "A%02u.%u \"%s\"\n",
idx, bit, buf->pmc_msg ) ;
}
}
free( buf ) ;
}

- 802 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.4 Get the unit type of PMC currently being operated. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_get_current_pmc_unit

[Syntax]
#include <fwindow.h>
short pmc_get_current_pmc_unit ( long * unittype );

[Arguments]
unittype Specifies a pointer to the place in which the current PMC unit type is
stored.

Value Unit type


PMCUNIT_PMC1 (1) 1st PMC

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_FUNC( 1) No PMC is present.

[Description]
Gets the unit type of the PMC currently being operated.

- 803 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.5 Get the number of PMC paths. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_get_number_of_pmc

[Syntax]
#include <fwindow.h>
short pmc_get_number_of_pmc ( long * number );

[Arguments]
number Specifies a pointer to the place in which the number of PMC paths is
stored.

[Return]
The main return value is shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Gets the number of existing PMC paths (units).

- 804 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.6 Get PMC unit types. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_get_pmc_unit_types

[Syntax]
#include <fwindow.h>
short pmc_get_pmc_unit_types ( long unittypes[], long * count );

[Arguments]
unittypes Specifies a pointer to the place in which the PMC unit type is stored.
The number of PMC paths can be acquired by the pmc_get_number_of_pmc
function.

The individual PMCs correspond to the following values.

Value Unit type


0 No PMC
PMCUNIT_PMC1 (1) 1st PMC

If this array is referenced with a PMC path number specified as an index,


the unit type of the PMC can be acquired.
Count During a call, the number of elements of a unit type array, which was
passed to the first argument unittypes, is passed.
During a return, the number of elements (number of paths) in which
information is actually contained is stored.

[Return]
The main return value is shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.

[Description]
Acquires information as to which unit types of PMCs compose a multi-PMC system.

- 805 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.7 Select PMC unit to be operated. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_select_pmc_unit

[Syntax]
#include <fwindow.h>
short pmc_select_pmc_unit ( long unittype ) ;

[Arguments]
unittype Specifies the unit type of a PMC to be selected.

Value Unit type


PMCUNIT_PMC1 (1) 1st PMC

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_NOPMC( 1) The specified PMC is not present.

[Description]
Selects the unit type of a PMC to be operated.

- 806 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.8 Get PMC memory address information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_getpmcptr

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_getpmcptr(short adr_type, short number, short size,
struct odbpmcptr * p_pmcptr);

struct odbpmcptr {
unsigned long attr; /* Attribute */
unsigned long ptr; /* Pointer */
} ;

[Arguments]
adr_type [in] PMC memory type
G:0, F:1, Y:2, X:3, A:4, R:5, T:6,
K:7, C:8, D:9, M:10, N:11, E:12
* For details, see the pmc_rdpmcrng function.
number [in] PMC memory offset
size [in] Access size
Specify one of the following access sizes.
1: 1 byte, 2: 2 bytes, 4: 4 bytes
The memory access function, which is described later, returns an error
if memory access is performed using the size greater than this
setting.
*p_pmcptr [out] Address information of PMC memory
The members of the structure are described below.
Attr PMC memory attribute
#31: Valid bit
(0: Pointer invalid, 1: Pointer valid)
#30: Write enable bit
(0: Write disabled, 1: Write enabled)
#0 to #15: Access size
ptr Pointer to PMC memory (physical address)

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH(2) Argument size is illegal.
EW_NUMBER(3) Argument number is illegal.
EW_ATTRIB(4) Argument adr_type is illegal.
EW_DATA(5) Argument p_pmcptr is NULL.

- 807 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Returns the address information of PMC memory.

If the acquired address information is set in the first argument of a memory access
function (pmc_rdpmcchar function, pmc_rdpmcshort function, pmc_rdpmclong function,
pmc_wrpmcchar function, pmc_wrpmcshort function, or pmc_wrpmclong function, which is
described later), it is possible to access PMC memory at high speed.

If the function aborts because, for example, the specified adr_type, number, or size
is illegal, invalid address information is returned. To determine whether the acquired
address information is valid, use the pmc_isvalidpmcptr function described later.
If the PMC memory access function is executed with invalid address information specified,
the memory access function does nothing.

If the PMC memory write function is executed with address information of the write inhibit
PMC memory (X or F address) specified, the write operation is not performed.

The PMC memory access function performs memory access of the PMC path selected during
acquisition of address information, not the PMC path selected during execution of the
memory access function.
Do not change address information structure odbpmcptr acquired by the pmc_getpmcptr
function using an application program. If the PMC memory access function is called with
changed address information, normal operation is not guaranteed.

Whether the pointer is valid is determined as shown below.


Enabled: (p_pmcptr.attr#31 != 0 && p_pmcptr.ptr != 0)
Disabled: (p_pmcptr.attr#31 == 0 || p_pmcptr.ptr == 0)

Whether writing is enabled is determined as shown below.


Write enabled: p_pmcptr.attr#30 == 1
Write disabled: p_pmcptr.attr#30 == 0

- 808 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.9 Validate PMC memory address information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_isvalidpmcptr

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_getpmcptr(const struct odbpmcptr * p_pmcptr);

struct odbpmcptr {
unsigned long attr; /* Attribute */
unsigned long ptr; /* Pointer */
} ;

[Arguments]
p_pmcptr [in] Pointer to address information of PMC memory
The members of the structure are described below.
Attr PMC memory attribute
#31: Enable bit
(0: Pointer invalid, 1: Pointer valid)
#30: Write enable bit
(0: Write disabled, 1: Write enabled)
#0 to #15: Access size
ptr Pointer to PMC memory (physical address)

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) The specified address information is valid.


EW_DATA(5) The specified address information is invalid.

[Description]
Checks whether the address information acquired by the pmc_getpmcptr function is valid.

Whether the pointer is valid is determined as shown below.


Enabled: (p_pmcptr.attr#31 != 0 && p_pmcptr.ptr != 0)
Disabled: (p_pmcptr.attr#31 == 0 || p_pmcptr.ptr == 0)

Whether writing is enabled is determined as shown below.


Write enabled: p_pmcptr.attr#30 == 1
Write disabled: p_pmcptr.attr#30 == 0

- 809 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.10 Read 1-byte signed data from PMC memory. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_rdpmcchar

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_rdpmcchar(const struct odbpmcptr * p_pmcptr, char * p_data);

struct odbpmcptr {
unsigned long attr; /* Attribute */
unsigned long ptr; /* Pointer */
} ;

[Arguments]
p_pmcptr [in] Pointer to address information of PMC memory
Set the pointer to the address information acquired by the pmc_getpmcptr
function.
The members of the structure are described below.
attr PMC memory attribute
#31: Enable bit
(0: Pointer invalid, 1: Pointer valid)
#30: Write enable bit
(0: Write disabled, 1: Write enabled)
#0 to #15: Access size
ptr Pointer to PMC memory (physical address)
*p_data [out] Returns the read data.
If the function abnormally ends, a value of 0 is returned.

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH(2) The access size is illegal.
EW_DATA(5) Argument p_pmcptr is NULL, address information is invalid, or argument
p_data is NULL.

- 810 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads PMC memory using the PMC memory address information acquired by the pmc_getpmcptr
function.

Whether the pointer is valid is determined as shown below.


Enabled: (p_pmcptr.attr#31 != 0 && p_pmcptr.ptr != 0)
Disabled: (p_pmcptr.attr#31 == 0 || p_pmcptr.ptr == 0)

Whether writing is enabled is determined as shown below.


Write enabled: p_pmcptr.attr#30 == 1
Write disabled: p_pmcptr.attr#30 == 0

- 811 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.11 Read 2-byte signed data from PMC memory. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_rdpmcshort

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_rdpmcshort(const struct odbpmcptr * p_pmcptr,
short * p_data);

struct odbpmcptr {
unsigned long attr; /* Attribute */
unsigned long ptr; /* Pointer */
} ;

[Arguments]
p_pmcptr [in] Pointer to address information of PMC memory
Set the pointer to the address information acquired by the pmc_getpmcptr
function.
The members of the structure are described below.
attr PMC memory attribute
#31: Enable bit
(0: Pointer invalid, 1: Pointer valid)
#30: Write enable bit
(0: Write disabled, 1: Write enabled)
#0 to #15: Access size
ptr Pointer to PMC memory (physical address)
*p_data [out] Returns the read data.
If the function abnormally ends, a value of 0 is returned.

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH(2) The access size is illegal.
EW_DATA(5) Argument p_pmcptr is NULL, address information is invalid, or argument
p_data is NULL.

- 812 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads PMC memory using the PMC memory address information acquired by the pmc_getpmcptr
function.

Whether the pointer is valid is determined as shown below.


Enabled: (p_pmcptr.attr#31 != 0 && p_pmcptr.ptr != 0)
Disabled: (p_pmcptr.attr#31 == 0 || p_pmcptr.ptr == 0)

Whether writing is enabled is determined as shown below.


Write enabled: p_pmcptr.attr#30 == 1
Write disabled: p_pmcptr.attr#30 == 0

- 813 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.12 Read 4-byte signed data from PMC memory. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_rdpmclong

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_rdpmclong(const struct odbpmcptr * p_pmcptr, long * p_data);

struct odbpmcptr {
unsigned long attr; /* Attribute */
unsigned long ptr; /* Pointer */
} ;

[Arguments]
p_pmcptr [in] Pointer to address information of PMC memory
Set the pointer to the address information acquired by the pmc_getpmcptr
function.
The members of the structure are described below.
Attr PMC memory attribute
#31: Enable bit
(0: Pointer invalid, 1: Pointer valid)
#30: Write enable bit
(0: Write disabled, 1: Write enabled)
#0 to #15: Access size
ptr Pointer to PMC memory (physical address)
*p_data [out] Returns the read data.
If the function abnormally ends, a value of 0 is returned.

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH(2) The access size is illegal.
EW_DATA(5) Argument p_pmcptr is NULL, address information is invalid, or argument
p_data is NULL.

- 814 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads PMC memory using the PMC memory address information acquired by the pmc_getpmcptr
function.

Whether the pointer is valid is determined as shown below.


Enabled: (p_pmcptr.attr#31 != 0 && p_pmcptr.ptr != 0)
Disabled: (p_pmcptr.attr#31 == 0 || p_pmcptr.ptr == 0)

Whether writing is enabled is determined as shown below.


Write enabled: p_pmcptr.attr#30 == 1
Write disabled: p_pmcptr.attr#30 == 0

- 815 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.13 Write 1-byte signed data to PMC memory. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_wrpmcchar

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_wrpmcchar(const struct odbpmcptr * p_pmcptr, char data);

struct odbpmcptr {
unsigned long attr; /* Attribute */
unsigned long ptr; /* Pointer */
} ;

[Arguments]
p_pmcptr [in] Pointer to address information of PMC memory
Set the pointer to the address information acquired by the pmc_getpmcptr
function.
The members of the structure are described below.
attr PMC memory attribute
#31: Enable bit
(0: Pointer invalid, 1: Pointer valid)
#30: Write enable bit
(0: Write disabled, 1: Write enabled)
#0 to #15: Access size
ptr Pointer to PMC memory (physical address)
data [in] Data to be written

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH(2) The access size is illegal.
EW_DATA(5) Argument p_pmcptr is NULL, address information is invalid, or argument
p_data is NULL.
EW_PROT(7) Write prohibition address

- 816 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Writes data to PMC memory using the PMC memory address information acquired by the
pmc_getpmcptr function.

If the function abnormally ends, writing to the memory is not performed.

Whether the pointer is valid is determined as shown below.


Enabled: (p_pmcptr.attr#31 != 0 && p_pmcptr.ptr != 0)
Disabled: (p_pmcptr.attr#31 == 0 || p_pmcptr.ptr == 0)

Whether writing is enabled is determined as shown below.


Write enabled: p_pmcptr.attr#30 == 1
Write disabled: p_pmcptr.attr#30 == 0

- 817 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.14 Write 2-byte signed data to PMC memory. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_wrpmcshort

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_wrpmcshort(const struct odbpmcptr * pmcptr, short data);

struct odbpmcptr {
unsigned long attr; /* Attribute */
unsigned long ptr; /* Pointer */
} ;

[Arguments]
p_pmcptr [in] Pointer to address information of PMC memory
Set the pointer to the address information acquired by the pmc_getpmcptr
function.
The members of the structure are described below.
Attr PMC memory attribute
#31: Enable bit
(0: Pointer invalid, 1: Pointer valid)
#30: Write enable bit
(0: Write disabled, 1: Write enabled)
#0 to #15: Access size
ptr Pointer to PMC memory (physical address)
data [in] Data to be written

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH(2) The access size is illegal.
EW_DATA(5) Argument p_pmcptr is NULL, address information is invalid, or argument
p_data is NULL.
EW_PROT(7) Write prohibition address

- 818 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Writes data to PMC memory using the PMC memory address information acquired by the
pmc_getpmcptr function.

If the function abnormally ends, writing to the memory is not performed.

Whether the pointer is valid is determined as shown below.


Enabled: (p_pmcptr.attr#31 != 0 && p_pmcptr.ptr != 0)
Disabled: (p_pmcptr.attr#31 == 0 || p_pmcptr.ptr == 0)

Whether writing is enabled is determined as shown below.


Write enabled: p_pmcptr.attr#30 == 1
Write disabled: p_pmcptr.attr#30 == 0

- 819 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.14 Write 4-byte signed data to PMC memory. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_wrpmclong

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_wrpmclong(const struct odbpmcptr * p_pmcptr, long data);

struct odbpmcptr {
unsigned long attr; /* Attribute */
unsigned long ptr; /* Pointer */
} ;

[Arguments]
p_pmcptr [in] Pointer to address information of PMC memory
Set the pointer to the address information acquired by the pmc_getpmcptr
function.
The members of the structure are described below.
Attr PMC memory attribute
#31: Enable bit
(0: Pointer invalid, 1: Pointer valid)
#30: Write enable bit
(0: Write disabled, 1: Write enabled)
#0 to #15: Access size
ptr Pointer to PMC memory (physical address)
data [in] Data to be written

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH(2) The access size is illegal.
EW_DATA(5) Argument p_pmcptr is NULL, address information is invalid, or argument
p_data is NULL.
EW_PROT(7) Write prohibition address

- 820 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Writes data to PMC memory using the PMC memory address information acquired by the
pmc_getpmcptr function.

If the function abnormally ends, writing to the memory is not performed.

Whether the pointer is valid is determined as shown below.


Enabled: (p_pmcptr.attr#31 != 0 && p_pmcptr.ptr != 0)
Disabled: (p_pmcptr.attr#31 == 0 || p_pmcptr.ptr == 0)

Whether writing is enabled is determined as shown below.


Write enabled: p_pmcptr.attr#30 == 1
Write disabled: p_pmcptr.attr#30 == 0

- 821 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.16 Get PMC address information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
pmc_rdpmcinfo

[Syntax]
#include <data.h>
#include <fwindow.h>
short pmc_rdpmcinfo(short adr_type, struct odbpmcinf * pmcif);

struct odbpmcinf {
short datano; /* PMC data information count */
struct odbpmcinf {
char pmc_adr; /* PMC address type */
char adr_attr; /* PMC address attribute */
short top_num; /* PMC address start number */
short last_num; /* PMC address end number */
} info[64];
}

[Arguments]
adr_type [in] Type of a PMC address
G:0, F:1, Y:2, X:3, A:4, R:5, T:6,
K:7, C:8, D:9, E:12, all types: -1
* For details, see the pmc_rdpmcrng function.

* pmcif [out] Pointer to the structure that returns data information

[Return]
The main return values are shown below. For information about other return values, see
Subsection 3.4.2, "Return values of data window fanctions" above in Part II,
"PROGRAMMING".

EW_OK( 0) Successful.
EW_LENGTH( 1) Address type error. (The adr_type value is illegal.)

- 822 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Reads the PMC address attribute for each type and PMC address information of the valid
range.
The following information can be acquired.
- PMC data information count (1 to 64)
* The same PMC address may be divided into multiple sections.
- Character indicating a PMC address type (ASCII code)
- PMC address attributes
#7 … 0: Write prohibition enabled
1: Write prohibition disabled
#0 to #6 … Not used
- PMC address start number
- PMC address end number

The following information is stored in odbpmcinf in the binary format.


odbpmcinf.datano PMC data information count
odbpmcinf.info.pmc_adr PMC address type
odbpmcinf.info.adr_attr PMC address attribute
odbpmcinf.info.top_num PMC address start number
odbpmcinf.info.last_num PMC address end number

- 823 -
3.Function References PROGRAMMING B-64303EN-3/01

3.5 MDI operation library

3.5.1 Library outline

1. Outline

The application program can control the MDI-KEY using the MDI operation library.

2. MDI key matrix

(1) Structure of matrix

MDI key matrix is a table where the relationship of the MDI key bit matrix which is defined
by the hardware specification and the key attributes and the key code is defined. This is
referenced to convert the MDI key bit matrix data read from MDI panel into key code for the
application program.

The MDI Key matrix consists of the key function table which defines key attributes and the
key code table which defines key codes. There are both matrix for the user application program
and one for CNC software.
The relationship of the MDI key bit matrix and the MDI key matrix is as follows.

MDI key bit matrix Function flag table Key code table
0th bit 0th byte 0th word
1st bit 1st byte 1st word
0th byte
: : :
7th bit 7th byte 7th word
: : : :
n-th byte m-th bit (n*8+m)-th byte (n*8+m)-th word

Each words of the key code table include both "Main code" and "Sub code".

Upper byte Main code Code generated by pushing individually.


Lower byte Sub code Code generated by pushing next to the SHIFT key.

It is impossible to push the SHIFT key and any ordinary keys simultaneously.
To input sub code, operate as following sequence.

Push the SHIFT key, and then release it.


Push any ordinary key.

- 824 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(2) Structure of function flag

The function flag is one byte flag which defines attributes of key for every key.
This flag defines following items bit by bit.

Bit Symbol definition


Enabling/disabling key repeat.(effective when FUNC=0000)
7 F 0 : Disable key repeat.
1 : Enable key repeat.
Destination of key code. (effective when FUNC=0000)
00 : Screen selected side. (default setting)
6–5 OUT 01 : Always C application.
10 : Always CNC software.
11 : Both c application and CNC software.(for only "RESET" key)
Enabling/disabling SHIFT key.(effective when FUNC=0000)
4 S 0 : Enable SHIFT key.
1 : Disable SHIFT key.
Kind of key.
0000 : Ordinary key.
3-0 FUNC 1011 : SHIFT key.
1111 : Invalid key.
Others: Not used. (These are handled as same as ordinary keys.)

(3) Uppercase/Lowercase

There is no special key to select uppercase/lowercase of alphabetic character on MDI panel


of CNC. Usually, all alphabetic characters are input as uppercase characters. Lowercase
characters can be input by the following operation.

Operation Input mode


SHIFT + Cursor[↑] Uppercase (default)
SHIFT + Cursor[↓] Lowercase

Call "aux_mdi_contrl" function to enable this operation.

aux_mdi_control( MDI_CASE_ON ) Enable changing uppercase/lowercase.


aux_mdi_control( MDI_CASE_OFF ) Disable changing uppercase/lowercase.

The initial status is "disabled changing uppercase/lowercase".

This function is made ineffective by altering MDI key matrix of "Cursor[↑]" or "Cursor[↓]".
Only uppercase characters are always input to the CNC software regardless of this operation.
Also "Key input by application program" described in next section isn't influenced by this
operation.

- 825 -
3.Function References PROGRAMMING B-64303EN-3/01

3. Key input by application program

(1) Functions

The application program can send an arbitrary character or string to the key input buffer of
the MDI-KEY by calling following functions.

aux_mdi_putc() Output one character.


aux_mdi_write() Output a string.

These character and string are received regardless of any operation to the screen or MDI panel.

(2) Arguments

The application program sends a pair of the function flag and the key code to be output to
the above functions. The format of the function flag is same as the MDI key matrix. Any arbitrary
value is allowed to be specified for key code. Also any key code which isn't registered in the
standard key matrix. (It is possible to send a key code as a message from any auxiliary task
to the main task.)

(3) Relation to the MDI panel

The key input from the application program is handled more preferentially than one from the
MDI panel. Therefore, when any key is input from both the application and the MDI panel
simultaneously, the former is given to the software. Usually, inhibit the key input from the
MDI panel during inputting key from the application program using following functions.

aux_mdi_control( MDI_LOK_PNL ) Disable key input from the MDI panel.


aux_mdi_control( MDI_ULK_PNL ) Enable key input from the MDI panel.

Only RESET key is accepted during being inhibited key input from the MDI panel.

- 826 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.5.2 Lists of Functions

ITEM NAME FUNCTION


1 aux_mdi_getmatrix Get MDI key matrix.
2 aux_mdi_putmatrix Put MDI key matrix.
3 aux_mdi_rstmatrix Reset MDI key matrix.
4 aux_mdi_altmatrix Alter MDI key matrix.
5 aux_mdi_putc Put one character to key input buffer.
6 aux_mdi_write Write block data to key input buffer.
7 aux_mdi_control Test or control key input buffer.
8 aux_mdi_repeat Set key repeating interval time.
9 aux_mdi_getstat Read inputting status of MDI key.
10 aux_mdi_clrbuf Clear input buffer of MDI key.

[CAUTION] Use "aux_mdi_getmatrix" and "aux_mdi_putmatrix" functions in case that you must
needs them anyway.
These functions are very flexible, but very dangerous if you mistake those usage.

- 827 -
3.Function References PROGRAMMING B-64303EN-3/01

3.5.3 Function Reference

------------------------------------------------------------------------------------------
1. Get MDI key matrix. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_getmatrix

[Syntax]
#include <bios.h>
int aux_mdi_getmatrix( void *matrix_ptr, int matrix_len,
int module_id ) ;

[Arguments]
matrix_ptr Buffer in which key matrix is stored.
matrix_len Byte size of key matrix buffer.
module_id Class of matrix.

[Return]
0 Successful.
-1 Incorrect byte size of key matrix buffer "matrix_len". Or incorrect class of
matrix "module_id".

[Description]
Reads the current key matrix (function flag table and key code table) of MDI key, and
stores them in the specified buffer.

This function is used to read the original key matrix for altering the part of the key
matrix.

Specify pointer to the matrix buffer area in "matrix_ptr".


Specify byte size of key matrix area buffer.
Specify one of following matrix class.

module_id Matrix class


MAIN_MDI_MATRIX Matrix of CNC software
MMC_MDI_MATRIX Matrix of application program

Get the required table size of the key matrix before calling this function, and allocate
buffer area for reading.

- 828 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2. Put MDI key matrix. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_putmatrix

[Syntax]
#include <bios.h>
int aux_mdi_putmatrix( void *matrix_ptr, int matrix_len,
int module_id ) ;

[Arguments]
matrix_ptr Buffer in which key matrix is stored.
matrix_len Byte size of key matrix buffer.
module_id Class of matrix.

[Return]
0 Successful.
-1 Incorrect byte size of key matrix buffer "matrix_len". Or
incorrect class of matrix "module_id".

[Description]
Registers the specified key matrix as the new matrix.

This function is used to restore the modified key matrix.

Specify pointer to the matrix buffer area in "matrix_ptr".


Specify byte size of key matrix area buffer.
Specify one of following matrix class.

module_id Matrix class


MAIN_MDI_MATRIX Matrix of CNC software
MMC_MDI_MATRIX Matrix of application program

This function is very dangerous. If there are any mistakes in the specified key matrix,
the key inputting process may not work correctly.
Take care to use this function.

All keys can be customized by this function. But you should not customize the important
key for CNC operation such as RESET key.

- 829 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
3. Reset MDI key matrix. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_rstmatrix

[Syntax]
#include <bios.h>
int aux_mdi_rstmatrix( int module_id ) ;

[Arguments]
module_id Class of matrix.

[Return]
0 Successful.
Negative Incorrect class of matrix "module_id".

[Description]
Restore the MDI key matrix to the initial (power-on) setting.

This function is used to restore te MDI key matrix which is modified by


"aux_mdi_putmatrix" function to the initial setting.

Specify one of following matrix class.

module_id Matrix class


MAIN_MDI_MATRIX Matrix of CNC software
MMC_MDI_MATRIX Matrix of application program

- 830 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
4. Alter MDI key matrix. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_altmatrix

[Syntax]
#include <bios.h>
int aux_mdi_altmatrix( int module_id, int category, int update ) ;

[Arguments]
module_id Class of matrix.
category Kind of key to be altered.
update New specification.

[Return]
0 Successful (No alteration was applied.).
Positive Successful ("Positive" is number of applied alteration.).
-1 Incorrect class of matrix "module_id".
-2 Incorrect kind of key to be altered "category".
-3 Incorrect new specification "update".
-4 Incorrect "MDI_SHIFT_xx" specification.
-5 Incorrect "MDI_TO_xx" specification.
-6 Incorrect "MDI_REPEAT_xx" specification.
-7 Attempted to alter the RESET key.

[Description]
Alters character code or character attribute which is assigned to the specified MDI key.

This function is used to alter character code assigned to the key or to enable automatic
key repeating of the cursor key or the page key, etc.

Specify one of following matrix class. The specified matrix will be altered.

module_id Matrix class


MAIN_MDI_MATRIX Matrix of CNC software
MMC_MDI_MATRIX Matrix of application program

(1) Altering character code.

Replaces the specified code in the current matrix with the new code.When there are
multiple specified codes in the matrix, all codes are replaced. This alteration can't
be executed with alteration of character attribute simultaneously.

- 831 -
3.Function References PROGRAMMING B-64303EN-3/01

Specify "MDI_ALT_CODE" (altering character code) in "category".

Specify updating specification of key in "update".

upper byte of "update" <- current code


lower byte of "update" <- new code

The specified key is set as "invalid key" by specifying "NULL(0x00)" as new code.

It is impossible to alter the RESET key.

(2) Altering character attribute.

Alters the attribute of the specified key in the current matrix.


This alteration can't be executed with replacement of character code simultaneously.

Specify kind of key to be altered in "category".


All keys are classified into the following category by the "main character code".

category Kind of key Character code


MDI_ALT_ALPA Alphanumeric key 0x20 to 0x7F
MDI_ALT_CURS Cursor key 0x88 to 0x8B
MDI_ALT_PAGE Page key 0x8E, 0x8F
MDI_ALT_DELE DELETE key 0x08, 0x95
MDI_ALT_INPT INPUT key 0x0D, 0x94
MDI_ALT_REST RESET key 0x90
MDI_ALT_HELP HELP key 0x9A
MDI_ALT_FUNC Function key 0xE8 to 0xEF
MDI_ALT_SOFT Soft key 0xF0 to 0xFF

The multiple classes can be specified simultaneously in "category".

Specify the following control attribute in "update".


The non-specified attributes is kept as it is.

(1) Enable/disable shift function.


MDI_SHIFT_OK Enable shift function.
MDI_SHIFT_NO Disable shift function.

- 832 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(2) Enable/disable automatic key repeating.


MDI_REPEAT_OK Enable automatic key repeating.
MDI_REPEAT_NO Disable automatic key repeating.

(Note) The repeat attributes of the following key codes are valid regardless
of the MDI key matrix value, so it is impossible to switch the automatic
repeat function between enabled and disabled.

Key code Key to be operated


0x87 SHIFT + CAN
0x88 Curs→
0x98 Curs←
0x8A Curs↓
0x8B Curs↑
0x8E Page↓
0x8F Page↑

(3) Specify software which can read MDI key.


MDI_TO_ETHER Either CNC software or application program
according to the current displayed screen.
MDI_TO_MMC Application program.
MDI_TO_MAIN CNC software.
MDI_TO_BOTH Both CNC software and application program.

(Note) It is impossible to set the RESET key being inhibited to be read by CNC software.

- 833 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
5. Put one character to key input buffer. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_putc

[Syntax]
#include <bios.h>
int aux_mdi_putc( int c ) ;

[Arguments]
c Output data.

[Return]
1 Successful.
0 Key input buffer is full.

[Description]
Output the specified 1-byte character to the key input buffer.

Specify a function flag in the upper byte of "c" and a character code in the lower byte.
For example, specify as follows to output 'A'.
upper byte <- 0x20 (function flag)
lower byte <- 0x41 (character code)

This function outputs data to the key input buffer. Check buffer emptiness by calling
"aux_mdi_control" function to confirm completion of outputting data from the buffer.

- 834 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
6. Write block data to key input buffer. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_write

[Syntax]
#include <bios.h>
int aux_mdi_write( void *buffer, int size ) ;

[Arguments]
buffer Buffer in which the output data are stored.
size Byte size of output data.

[Return]
Positive Successful. (Byte size of actually output data.)
This value will be smaller than the specified size in case that
there are not enough room for specified size in the key input buffer.
0 Key input buffer is full.

[Description]
Output data for specified byte size from the specified buffer to the key input buffer.

Store the output data in output order in "buffer".


The format of each output data is same as "aux_mdi_putc" function.
Specify one character by 2 bytes. (upper byte: function flag, lower byte: character code)

This function outputs data to the key input buffer. Check buffer emptiness by calling
"aux_mdi_control" function to confirm completion of outputting data from the buffer.

- 835 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
7. Test or control key input buffer. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_control

[Syntax]
#include <bios.h>
int aux_mdi_control( int control ) ;

[Arguments]
control Control code.

[Return]
(1) In case of successful.
MDI_CHK_BUF Returns number of data in the buffer.
MDI_GET_MTXLEN Returns byte size of MDI key matrix.
MDI_CASE_ON Returns the previous status.
MDI_CASE_OFF Returns the previous status.
MDI_CHK_FKEY Returns the key code of pushed function key.
Others Returns "0".

(2) In case of error.


Returns "-1" for all instructions.

[Description]
Test the key input buffer, or execute specified operation to the key input buffer.

Specify one of the following control code in "control".

control Operation
MDI_CHK_BUF Returns number of data in the application key input buffer.
MDI_CLR_BUF Clears the application key input buffer.
MDI_LOK_PNL Locks MDI key input except RESET key.
MDI_ULK_PNL Unlocks MDI key input.
MDI_GET_MTXLEN Return byte size of the MDI key matrix table.
MDI_CASE_ON Enables uppercase/lowercase character input from the MDI panel.
MDI_CASE_OFF Disables uppercase/lowercase character input from the MDI panel.
If the screen switching was disabled while any user screen was
MDI_CHK_FKEY displaying for some reason and any function key was pushed during
disabling screen switching, returns key code of that function key.

- 836 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
8. Set key repeating interval time. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_repeat

[Syntax]
#include <bios.h>
int aux_mdi_repeat( int delay, int repeat ) ;

[Arguments]
delay Delay time of automatic repeating.
repeat Interval time of automatic repeating.

[Return]
0 Successful.
-1 Incorrect delay time "delay".
-2 Incorrect interval time "repeat".

[Description]
Set the delay time and the interval time of automatic key repeating.

Specify one of the following delay times in "delay".

delay Delay time


MDI_KEY_DELAY1 256 [msec]
MDI_KEY_DELAY2 512 [msec] (default setting)
MDI_KEY_DELAY3 768 [msec]
MDI_KEY_DELAY4 1024 [msec]

Specify the interval time 32 through 1024 [msec] in "repeat" with binary format. The
unit of the interval time is "millisecond". Only multiple of "32[msec]" are allowed to
set. The default setting value of the interval time is "MDI_KEY_REPEAT"
(32[msec]).

- 837 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
9. Read inputting status of MDI key. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_getstat

[Syntax]
#include <bios.h>
unsigned int aux_mdi_getstat( void ) ;

[Arguments]
------

[Return]
Returns inputting status of MDI key.

[Description]
Gets the inputting status of MDI key.

Each bits of returned value mean following information.

bit0 SHIFT state. (MDI_ST_SHIFT)


0: Not SHIFT state.
1: SHIFT state.
bit1 - bit7 Undefined.
bit8 - bit15 Number of characters read in the MDI key input buffer.

"SHIFT state" means the following state.

Once push [SHIFT] key, and then release it.


↓ <- This period is "SHIFT state".
Push any other key.
(Sub code is read in this case.)

That is, once pushing [SHIFT] key makes "SHIFT state" ON, then, pushing any other key
makes "SHIFT state" released. Pushing [SHIFT]key again during "SHIFT state" makes
"SHIFT released.
It is impossible to input Sub code by pushing any key and [SHIFT] key simultaneously.

Bit8 through bit15 of return value indicate a number of characters input from the MDI
panel and not read yet by the application program.

This function gets the status of key input buffer while the C Language Executor's user
screen is being displayed. It can't get the status of the key input buffer of the CNC
software.

- 838 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program reads a line of alpha-numeric characters from the MDI panel.
Inputting operation is completed by inputting [INPUT] key. It displays one of '_' (in
normal state) and '^' as cursor.

#include <bios.h>
#include <ctype.h>
#include <stdio.h>
#define BUFSIZE 80
unsigned char buf[BUFSIZE] ;

void example( void )


{
unsigned int idx = 0, stat = 0 ;
unsigned char ch ;
printf( "\033[>5h_" ) ;
for (;;) {
if ( kbhit() ) {
ch = getch() ;
if ( ch == MDIKEY_INPUT ) {
buf[idx] = 0x00 ;
return ;
}
else if ( ( ch == MDIKEY_CAN ) && idx ) {
buf[--idx] = 0x00 ;
printf( "\010 \010\010_" ) ;
stat = 0 ;
}
else if ( isalnum( ch ) && ( idx < BUFSIZE - 1 ) ) {
buf[idx++] = ch ;
printf( "\010%c_", ch ) ;
stat = 0 ;
}
}
else {
if ( aux_mdi_getstat() & MDI_ST_SHIFT ){
if ( !( stat & MDI_ST_SHIFT ) ) {
printf( "\010^" ) ;
stat = MDI_ST_SHIFT ;
}
}
else if ( stat & MDI_ST_SHIFT ) {
printf( "\010_" ) ;
stat = 0 ;
}
}
}
}

- 839 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
10. Clear input buffer of MDI key. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
aux_mdi_clrbuf

[Syntax]
#include <bios.h>
void aux_mdi_clrbuf( void ) ;

[Arguments]
------

[Return]
------

[Description]
Clears input buffer of MDI key.

This function clears all characters which are input from MDI panel and not read by the
application program yet, and makes "SHIFT state" at the same time.

This function makes no effects to the key input buffer of the CNC software.

- 840 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.5.4 Key code table

The following are the key code table of various keyboard which are supported by C Language
Executor. Lines and columns of "Key bit matrix", "Key function flag table" and "Key code table"
are correspond each other in every keyboard.

For example, to get key code and function flag for C application of "X" key in the machining
system's full key, search as follows.

(1) Search "X" key in "Key bit matrix". (7th line, 4th column)
(2) See the 7th line and 4th column of "Key function flag table" and "Key code table"
for C application.
(3) You get 0x10 for key function flag and "58 55" for key code.
This means that a code 0x58 will be generated by pushing "X" key individually, and
0x55 by pushing SHIFT + "X".

To change this function flag and key code, do as follows.

(1) Get the matrix by "aux_mdi_getmatrix" function.


(2) Change the function flag in 0x3D from the top of the matrix and the key code in
0xC8 and 0xC9.
(3) Restore the matrix by "aux_mdi_putmatrix" function.

In the MDI key matrix, F0 to F9, FL, and FR are horizontal soft keys.
8.4-inch color LCD

[FL] [F5] [F6] [F7] [F8] [F9] [FR] 7 (5+2) horizontal soft keys

- 841 -
3.Function References PROGRAMMING B-64303EN-3/01

10.4-inch color LCD

[FL] [F0] [F1] [F2] [F3] [F4] [F5] [F6] [F7] [F8] [F9] [FR] 12 (10+2) horizontal soft keys

- 842 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.5.5 Reading extension MDI keys

Setting bit 2 (EKY) of parameter(No.8650) in the NC to 1 causes the key BIOS of the C Language
Executor to scan the extension MDI keys. If a user application assigns key codes to the extension
of the key matrix, the assigned keys can be read.(If no key code is specified, it is impossible
to read the extension keys.)

1. 0i-D standard ONG MDI (T series)

MDI Key bit matrix

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7
0

8 9 - ・ / EOB CAN
1

ALTER INSERT DELETE INPUT HELP SHIFT → ←


2

POS PROG OFS/SET SYSTEM MESSAGE GRAPH CUSTOM


3

↓ ↑ PAGE PAGE I K R F
4
DOWN UP [ ] & SP

RESET
5 SKH12 SKH11 SKH10 SKH9

6 SKH8 SKH7 SKH6 SKH5 SKH4 SKH3 SKH2 SKH1

O N G P X Z C Y
7
( ) E Q A B D ?

U W H V M S T L
8
, J @ _ # = * +

- 843 -
3.Function References PROGRAMMING B-64303EN-3/01

Key function flag table for CNC


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 10 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 10 09
20 10 10 10 10 10 10 10 10
28 10 10 10 10 0F 0F 0F 40
30 10 10 10 10 10 10 10 10
38 10 10 10 10 10 10 10 10
40 10 10 10 10 10 10 10 10
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for CNC


+0 +2 +4 +6 +8 +A +C +E
60 30 00 31 82 32 83 33 8C 34 8D 35 A9 36 00 37 00
70 38 AA 39 AB 2D 2D 2E 2E 00 00 2F 2F 0A 0A 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 EE E1 EF E1
A0 8A FB 8B FD 8E 9D 8F 9E 49 5B 4B 5D 52 26 46 20
B0 FF FF F0 B0 F1 B1 F2 B2 00 00 00 00 00 00 90 90
C0 F3 B3 F4 B4 F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 28 4E 29 47 45 50 51 58 41 5A 42 43 44 59 3F
E0 55 2C 57 4A 48 40 56 5F 4D 23 53 3D 54 2A 4C 2B
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 844 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Key function flag table for C application


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 10 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 10 09
20 10 10 10 10 10 10 10 10
28 10 10 10 10 0F 0F 0F 60
30 10 10 10 10 10 10 10 10
38 10 10 10 10 10 10 10 10
40 10 10 10 10 10 10 10 10
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for C application


+0 +2 +4 +6 +8 +A +C +E
60 30 00 31 82 32 83 33 8C 34 8D 35 A9 36 00 37 00
70 38 AA 39 AB 2D 2D 2E 2E 00 00 2F 2F 0A 0A 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 EE E1 EF E1
A0 8A FB 8B FD 8E 9D 8F 9E 49 5B 4B 5D 52 26 46 20
B0 FF FF F0 B0 F1 B1 F2 B2 00 00 00 00 00 00 90 90
C0 F3 B3 F4 B4 F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 28 4E 29 47 45 50 51 58 41 5A 42 43 44 59 3F
E0 55 2C 57 4A 48 40 56 5F 4D 23 53 3D 54 2A 4C 2B
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 845 -
3.Function References PROGRAMMING B-64303EN-3/01

2. 0i-D standard ONG MDI (M series)

MDI Key bit matrix

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7
0

8 9 - ・ / EOB CAN
1

ALTER INSERT DELETE INPUT HELP SHIFT → ←


2

POS PROG OFS/SET SYSTEM MESSAGE GRAPH CUSTOM


3

↓ ↑ PAGE PAGE F D H B
4
DOWN UP [ ] & SP

RESET
5 SKH12 SKH11 SKH10 SKH9

6 SKH8 SKH7 SKH6 SKH5 SKH4 SKH3 SKH2 SKH1

O N G P X Y Z Q
7
( ) E C U V W ?

I J K R M S T L
8
, A @ _ # = * +

- 846 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Key function flag table for CNC


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 10 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 10 09
20 10 10 10 10 10 10 10 10
28 10 10 10 10 0F 0F 0F 40
30 10 10 10 10 10 10 10 10
38 10 10 10 10 10 10 10 10
40 10 10 10 10 10 10 10 10
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for CNC


+0 +2 +4 +6 +8 +A +C +E
60 30 00 31 82 32 83 33 8C 34 8D 35 A9 36 00 37 00
70 38 AA 39 AB 2D 2D 2E 2E 00 00 2F 2F 0A 0A 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 EE E1 EF E1
A0 8A FB 8B FD 8E 9D 8F 9E 46 5B 44 5D 48 26 42 20
B0 FF FF F0 B0 F1 B1 F2 B2 00 00 00 00 00 00 90 90
C0 F3 B3 F4 B4 F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 28 4E 29 47 45 50 43 58 55 59 56 5A 57 51 3F
E0 49 2C 4A 41 4B 40 52 5F 4D 23 53 3D 54 2A 4C 2B
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 847 -
3.Function References PROGRAMMING B-64303EN-3/01

Key function flag table for C application


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 10 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 10 09
20 10 10 10 10 10 10 10 10
28 10 10 10 10 0F 0F 0F 60
30 10 10 10 10 10 10 10 10
38 10 10 10 10 10 10 10 10
40 10 10 10 10 10 10 10 10
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for C application


+0 +2 +4 +6 +8 +A +C +E
60 30 00 31 82 32 83 33 8C 34 8D 35 A9 36 00 37 00
70 38 AA 39 AB 2D 2D 2E 2E 00 00 2F 2F 0A 0A 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 EE E1 EF E1
A0 8A FB 8B FD 8E 9D 8F 9E 46 5B 44 5D 48 26 42 20
B0 FF FF F0 B0 F1 B1 F2 B2 00 00 00 00 00 00 90 90
C0 F3 B3 F4 B4 F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 28 4E 29 47 45 50 43 58 55 59 56 5A 57 51 3F
E0 49 2C 4A 41 4B 40 52 5F 4D 23 53 3D 54 2A 4C 2B
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 848 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3. Small vertical key (T series)

MDI Key bit matrix

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7
0
* , # = [ ] SP A

8 9 - ・ EOB CAN
1
B D + / E

ALTER INSERT DELETE INPUT HELP SHIFT → ←


2

POS PROG OFS/SET SYSTEM MESSAGE CSTM/


3
GRPH

↓ ↑ PAGE PAGE
4
DOWN UP

RESET
5

6 SFL SF1 SF2 SF3 SF4 SF5 SFR

O N G X Z F
7
P Q R C Y L

U W M S T
8
H V I K J

- 849 -
3.Function References PROGRAMMING B-64303EN-3/01

Key function flag table for CNC


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 0F 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 0F 0F
20 10 10 10 10 0F 0F 0F 0F
28 0F 0F 0F 0F 0F 0F 0F 40
30 0F 10 10 10 10 10 10 10
38 10 10 10 0F 10 10 10 0F
40 10 10 0F 0F 10 10 10 0F
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for CNC


+0 +2 +4 +6 +8 +A +C +E
60 30 2A 31 2C 32 23 33 3D 34 5B 35 5D 36 20 37 41
70 38 42 39 44 2D 2B 2E 2F 00 00 00 00 0A 45 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 00 00 00 00
A0 8A FB 8B FD 8E 9D 8F 9E 00 00 00 00 00 00 00 00
B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 90
C0 00 00 FF FF F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 50 4E 51 47 52 00 00 58 43 5A 59 46 4C 00 00
E0 55 48 57 56 00 00 00 00 4D 49 53 4B 54 4A 00 00
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 850 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Key function flag table for C application


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 0F 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 0F 0F
20 10 10 10 10 0F 0F 0F 0F
28 0F 0F 0F 0F 0F 0F 0F 60
30 0F 10 10 10 10 10 10 10
38 10 10 10 0F 10 10 10 0F
40 10 10 0F 0F 10 10 10 0F
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for C application


+0 +2 +4 +6 +8 +A +C +E
60 30 2A 31 2C 32 23 33 3D 34 5B 35 5D 36 20 37 41
70 38 42 39 44 2D 2B 2E 2F 00 00 00 00 0A 45 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 00 00 00 00
A0 8A FB 8B FD 8E 9D 8F 9E 00 00 00 00 00 00 00 00
B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 90
C0 00 00 FF FF F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 50 4E 51 47 52 00 00 58 43 5A 59 46 4C 00 00
E0 55 48 57 56 00 00 00 00 4D 49 53 4B 54 4A 00 00
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 851 -
3.Function References PROGRAMMING B-64303EN-3/01

4. Small vertical key (M series)

MDI Key bit matrix

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7
0
* , # = [ ] SP A

8 9 - ・ EOB CAN
1
B C + / E

ALTER INSERT DELETE INPUT HELP SHIFT → ←


2

POS PROG OFS/SET SYSTEM MESSAGE CSTM/


3
GRPH

↓ ↑ PAGE PAGE
4
DOWN UP

RESET
5

6 SFL SF1 SF2 SF3 SF4 SF5 SFR

O N G X Y Z
7
P Q R U V W

F H M S T
8
L D I J K

- 852 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Key function flag table for CNC


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 0F 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 0F 0F
20 10 10 10 10 0F 0F 0F 0F
28 0F 0F 0F 0F 0F 0F 0F 40
30 0F 10 10 10 10 10 10 10
38 10 10 10 0F 10 10 10 0F
40 10 10 0F 0F 10 10 10 0F
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for CNC


+0 +2 +4 +6 +8 +A +C +E
60 30 2A 31 2C 32 23 33 3D 34 5B 35 5D 36 20 37 41
70 38 42 39 43 2D 2B 2E 2F 00 00 00 00 0A 45 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 00 00 00 00
A0 8A FB 8B FD 8E 9D 8F 9E 00 00 00 00 00 00 00 00
B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 90
C0 00 00 FF FF F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 50 4E 51 47 52 00 00 58 55 59 56 5A 57 00 00
E0 46 4C 48 44 00 00 00 00 4D 49 53 4A 54 4B 00 00
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 853 -
3.Function References PROGRAMMING B-64303EN-3/01

Key function flag table for C application


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 0F 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 0F 0F
20 10 10 10 10 0F 0F 0F 0F
28 0F 0F 0F 0F 0F 0F 0F 60
30 0F 10 10 10 10 10 10 10
38 10 10 10 0F 10 10 10 0F
40 10 10 0F 0F 10 10 10 0F
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for C application


+0 +2 +4 +6 +8 +A +C +E
60 30 2A 31 2C 32 23 33 3D 34 5B 35 5D 36 20 37 41
70 38 42 39 43 2D 2B 2E 2F 00 00 00 00 0A 45 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 00 00 00 00
A0 8A FB 8B FD 8E 9D 8F 9E 00 00 00 00 00 00 00 00
B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 90
C0 00 00 FF FF F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 50 4E 51 47 52 00 00 58 55 59 56 5A 57 00 00
E0 46 4C 48 44 00 00 00 00 4D 49 53 4A 54 4B 00 00
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 854 -
B-64303EN-3/01 PROGRAMMING 3.Function References

5. Small horizontal key (T series)

MDI Key bit matrix

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7
0
* , # = [ ] SP A

8 9 - ・ EOB CAN
1
B D + / E

ALTER INSERT DELETE INPUT HELP SHIFT → ←


2

POS PROG OFS/SET SYSTEM MESSAGE CSTM/


3
GRPH

↓ ↑ PAGE PAGE
4
DOWN UP

RESET
5 SKH12 SKH11 SKH10 SKH9

6 SKH8 SKH7 SKH6 SKH5 SKH4 SKH3 SKH2 SKH1

O N G X Z F
7
P Q R C Y L

U W M S T
8
H V I K J

- 855 -
3.Function References PROGRAMMING B-64303EN-3/01

Key function flag table for CNC


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 0F 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 0F 0F
20 10 10 10 10 0F 0F 0F 0F
28 0F 0F 0F 0F 0F 0F 0F 40
30 0F 10 10 10 10 10 10 10
38 10 10 10 0F 10 10 10 0F
40 10 10 0F 0F 10 10 10 0F
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for CNC


+0 +2 +4 +6 +8 +A +C +E
60 30 2A 31 2C 32 23 33 3D 34 5B 35 5D 36 20 37 41
70 38 42 39 44 2D 2B 2E 2F 00 00 00 00 0A 45 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 00 00 00 00
A0 8A FB 8B FD 8E 9D 8F 9E 00 00 00 00 00 00 00 00
B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 90
C0 00 00 FF FF F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 50 4E 51 47 52 00 00 58 43 5A 59 46 4C 00 00
E0 55 48 57 56 00 00 00 00 4D 49 53 4B 54 4A 00 00
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 856 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Key function flag table for C application


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 0F 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 0F 0F
20 10 10 10 10 0F 0F 0F 0F
28 0F 0F 0F 0F 0F 0F 0F 60
30 0F 10 10 10 10 10 10 10
38 10 10 10 0F 10 10 10 0F
40 10 10 0F 0F 10 10 10 0F
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for C application


+0 +2 +4 +6 +8 +A +C +E
60 30 2A 31 2C 32 23 33 3D 34 5B 35 5D 36 20 37 41
70 38 42 39 44 2D 2B 2E 2F 00 00 00 00 0A 45 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 00 00 00 00
A0 8A FB 8B FD 8E 9D 8F 9E 00 00 00 00 00 00 00 00
B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 90
C0 00 00 FF FF F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 50 4E 51 47 52 00 00 58 43 5A 59 46 4C 00 00
E0 55 48 57 56 00 00 00 00 4D 49 53 4B 54 4A 00 00
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 857 -
3.Function References PROGRAMMING B-64303EN-3/01

6. Small horizontal key (M series)

MDI Key bit matrix

0 1 2 3 4 5 6 7

0 1 2 3 4 5 6 7
0
* , # = [ ] SP A

8 9 - ・ EOB CAN
1
B C + / E

ALTER INSERT DELETE INPUT HELP SHIFT → ←


2

POS PROG OFS/SET SYSTEM MESSAGE CSTM/


3
GRPH

↓ ↑ PAGE PAGE
4
DOWN UP

RESET
5 SKH12 SKH11 SKH10 SKH9

6 SKH8 SKH7 SKH6 SKH5 SKH4 SKH3 SKH2 SKH1

O N G X Y Z
7
P Q R U V W

F H M S T
8
L D I J K

- 858 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Key function flag table for CNC


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 0F 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 0F 0F
20 10 10 10 10 0F 0F 0F 0F
28 0F 0F 0F 0F 0F 0F 0F 40
30 0F 10 10 10 10 10 10 10
38 10 10 10 0F 10 10 10 0F
40 10 10 0F 0F 10 10 10 0F
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for CNC


+0 +2 +4 +6 +8 +A +C +E
60 30 2A 31 2C 32 23 33 3D 34 5B 35 5D 36 20 37 41
70 38 42 39 43 2D 2B 2E 2F 00 00 00 00 0A 45 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 00 00 00 00
A0 8A FB 8B FD 8E 9D 8F 9E 00 00 00 00 00 00 00 00
B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 90
C0 00 00 FF FF F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 50 4E 51 47 52 00 00 58 55 59 56 5A 57 00 00
E0 46 4C 48 44 00 00 00 00 4D 49 53 4A 54 4B 00 00
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 859 -
3.Function References PROGRAMMING B-64303EN-3/01

Key function flag table for C application


+0 +1 +2 +3 +4 +5 +6 +7
00 10 10 10 10 10 10 10 10
08 10 10 10 10 0F 0F 10 10
10 0D 10 10 10 10 0B 10 10
18 10 10 10 10 10 10 0F 0F
20 10 10 10 10 0F 0F 0F 0F
28 0F 0F 0F 0F 0F 0F 0F 60
30 0F 10 10 10 10 10 10 10
38 10 10 10 0F 10 10 10 0F
40 10 10 0F 0F 10 10 10 0F
48 0F 0F 0F 0F 0F 0F 0F 0F
50 0F 0F 0F 0F 0F 0F 0F 0F
58 0F 0F 0F 0F 0F 0F 0F 0F

Key code table for C application


+0 +2 +4 +6 +8 +A +C +E
60 30 2A 31 2C 32 23 33 3D 34 5B 35 5D 36 20 37 41
70 38 42 39 43 2D 2B 2E 2F 00 00 00 00 0A 45 08 87
80 96 99 94 94 95 95 0D 0D 9A 9F 84 85 88 AC 89 AD
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 00 00 00 00
A0 8A FB 8B FD 8E 9D 8F 9E 00 00 00 00 00 00 00 00
B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 90
C0 00 00 FF FF F5 B5 F6 B6 F7 B7 F8 B8 F9 B9 FE FE
D0 4F 50 4E 51 47 52 00 00 58 55 59 56 5A 57 00 00
E0 46 4C 48 44 00 00 00 00 4D 49 53 4A 54 4B 00 00
F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

- 860 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.6 CRT operation library

3.6.1 Supported display device

C Language Executor supports the following display devices.

(1) VGA Display

(A) For the 10.4-inch color LCD

Character 80-column × 25-line/half-size (40-column × 25-line/full-size)


× 16-color.
80-column × 30-line/half-size (40-column × 30-line/full-size)
× 16-color.
Dot matrix (H×V): 8×16 dots(half-size).

Display device 10.4-inch color LCD,


10.4-inch color LCD(with touch-panel)

Twelve horizontal softkeys are provided at the bottom of the screen.


(Touch-panel works like softkeys on "LCD with touch-panel" device.)

80-column

25-line (or 30-line)

[FL] [F0] [F1] [F2] [F3] [F4] [F5] [F6] [F7] [F8] [F9] [FR]<- 12 (10+2) horizontal soft keys

- 861 -
3.Function References PROGRAMMING B-64303EN-3/01

(C) For the 8.4-inch color LCD

Characters 40 columns × 16 lines/half-size (20 columns × 16 lines/full-size)


× 16 colors
40 columns × 19 lines/half-size (20 columns x 19 lines/full-size)
× 16 colors
Dot matrix (H × V): 16 × 25 dots (half-size)

Display device 8.4-inch color LCD

All display devices have 7 horizontal soft keys along the bottom of the screen.

40 columns

16 lines (or 19 lines)

[FL] [ F5 ] [ F6 ] [ F7 ] [ F8 ] [ F9 ] [FR]<- 7 (5 + 2) horizontal soft keys

- 862 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.6.2 Lists of Functions

1. CRT operation functions

1. CRT operation library

ITEM NAME FUNCTION


1.1 crt_getcurscrn Get current screen index.
1.2 crt_setuserscrn Register user screen index.
1.3 crt_isnewscrn Test screen switching status.
1.4 crt_gettype Get CRT information.
1.5 crt_setmode Set CRT screen mode.
1.6 crt_cncscrn Switch to CNC screen.
1.7 crt_fchar Output character by FANUC character code.
1.8 crt_setuserskey Customize softkey on CNC screen.
1.9 crt_setswt Set switching method between CNC's screen and user's.
1.10 crt_setscrlarea Set scroll area.
1.11 crt_opengr Open graphic display.
1.12 crt_closegr Close graphic display.
1.13 crt_graphic Enable or disable graphic display.
1.14 crt_readfkey Read the status of function keys.
1.15 crt_2ndcursor Display the secondary cursor.
1.16 crt_settextattr Set attribute of characters on VRAM.
1.17 crt_gettextattr Get attribute of character on VRAM.
1.18 crt_setpalette Set color palette of VGA characters.
1.19 crt_setallpalette Set all color palette of VGA characters.
1.20 crt_getcncpalette Get color palette of CNC screen.
1.21 crt_fstr Output character string by FANUC character code.
1.22 crt_gettextimg Get text data from VRAM.
1.23 crt_puttextimg Put text data into VRAM.
1.24 crt_setgraphpage Select graphic page to use.
1.25 crt_set6chmode Select drawing method of 6x sized character.

- 863 -
3.Function References PROGRAMMING B-64303EN-3/01

2. Multiple window display library

ITEM NAME FUNCTION


2.1 win_open Open window.
2.2 win_close Close window.
2.3 win_select Select window.
2.4 win_activate Activate window.
2.5 win_move Move window.
2.6 win_size Alter window size.
2.7 win_full Let active window be full screen size.
2.8 win_window Let active window be window size.
2.9 win_info Get window information.
2.10 win_col Set color of window frame and title string.
2.11 win_hide Hide window.
2.12 win_show Show window.
2.13 win_setttl Set window title string.
2.14 win_setfrm Set window frame line character.
2.15 win_getstat Get window display status.
2.16 win_redraw Redraw windows.

3. User definition character library

ITEM NAME FUNCTION


3.1 crt_reguserchar Register user character.
3.2 crt_mapuch Map user character.
3.3 crt_getcgpttn Get CG pattern.

4. VGA window display library

ITEM NAME FUNCTION


4.1 vwin_open Open VGA window.
4.2 vwin_close Close VGA window.
4.3 vwin_select Select VGA window.
4.4 vwin_show Show VGA window.
4.5 vwin_hide Hide VGA window.
4.6 vwin_info Get VGA window information.

- 864 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.6.3 Function Reference

1. CRT operation library

------------------------------------------------------------------------------------------
1.1 Get current screen index. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
crt_getcurscrn

[Syntax]
#include <crt.h>
int crt_getcurscrn( void ) ;

[Arguments]
------

[Return]
Returns the index number of the currently displayed screen.

[Description]
Gets the index number of the currently displayed screen.

The format of the screen index number is as follows.

Upper byte Lower byte


---------------+---------------
Small Large
classification classification

Refer the following screen index number list for index numbers of each screens. All
available index values are defined in crt.h as "CRT_xxx_xxx".

- 865 -
3.Function References PROGRAMMING B-64303EN-3/01

Screen index number of Series 0i-D

Index
Symbol Screen
number
POSITION
CRT_POS_ABS 0x0100 ABS
CRT_POS_REL 0x0200 REL
CRT_POS_ALL 0x0300 ALL
CRT_POS_HNDL 0x0400 HNDL
CRT_POS_MONI 0x0600 MONITOR
CRT_POS_CEXE 0x3200 C Language Executor
CRT_POS_CEXE2 0x3300 C Language Executor 2
CRT_POS_CEXE3 0x3400 C Language Executor 3
CRT_POS_CEXE4 0x3500 C Language Executor 4
CRT_POS_CEXE5 0x3600 C Language Executor 5
CRT_POS_CNC 0x3f00 Previous CNC screen
PROGRAM
CRT_PRG_PRG 0x0101 PROG
CRT_PRG_LIB 0x0201 FOLDER (EDIT/TJOG)
CRT_PRG_NEXT 0x0301 NEXT (MDI/MEM/JOG)
CRT_PRG_PCHK 0x0401 CHECK (MEM)
CRT_PRG_REST 0x0801 RSTR (MDI/MEM/JOG/TJOG)
CRT_PRG_LIB2 0x1101 FOLDER (OTHER)
CRT_PRG_MDI 0x1201 MDI (MDI)
CRT_PRG_CUR 0x1301 CURRENT(MDI/MEM/JOG)
CRT_PRG_GRAPHIC 0x2e01 C.A.P (EDIT)
CRT_PRG_TMAC_MG0I 0x2f01 Conversational Macro MANUAL GUIDE 0i (EDIT)
CRT_PRG_CEXE 0x3201 C Language Executor
CRT_PRG_CEXE2 0x3301 C Language Executor 2
CRT_PRG_CEXE3 0x3401 C Language Executor 3
CRT_PRG_CEXE4 0x3501 C Language Executor 4
CRT_PRG_CEXE5 0x3601 C Language Executor 5
CRT_PRG_CNC 0x3f01 Previous CNC screen
OFFSET
CRT_OFS_OFS 0x0102 OFFSET
CRT_OFS_SETP 0x0202 SETTING
CRT_OFS_WORK 0x0302 WORK
CRT_OFS_MCR 0x0602 MACRO
CRT_OFS_PTNMENU 0x0702 PATTERN MENU
CRT_OFS_OPR 0x0802 OPR
CRT_OFS_TOOLMNG 0x0902 TOOL MANAGER
CRT_OFS_YOFS 0x0b02 OFST.2
CRT_OFS_WSFT 0x0c02 W.SHFT
CRT_OFS_TLFM 0x0e02 TOOL.F
CRT_OFS_PRELEV 0x1102 PR-LEV
CRT_OFS_CHUCK 0x1502 CHUCK TAIL
CRT_OFS_LANG 0x1602 LANG.
CRT_OFS_PROTECT 0x1702 PROTECT
CRT_OFS_SAFEGUARD 0x1802 GUARD
CRT_OFS_CEXE 0x3202 C Language Executor
CRT_OFS_CEXE2 0x3302 C Language Executor 2
CRT_OFS_CEXE3 0x3402 C Language Executor 3
CRT_OFS_CEXE4 0x3502 C Language Executor 4
CRT_OFS_CEXE5 0x3602 C Language Executor 5

- 866 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Index
Symbol Screen
number
CRT_OFS_CNC 0x3f02 Previous CNC screen
CRT_OFS_WEAR_S 0x0112 OFFSET-WEAR(SUB)
CRT_OFS_GEOM_S 0x0212 OFFSET-GEOM(SUB)
CRT_OFS_WEAR_S2 0x0312 OFFSET-WEAR2(SUB)
CRT_OFS_GEOM_S2 0x0412 OFFSET-GEOM2(SUB)
SYSTEM
CRT_SYS_PRM 0x0103 PARAM
CRT_SYS_DGN 0x0203 DGNOS
CRT_SYS_SYS 0x0403 SYSTEM
CRT_SYS_MEM 0x0603 MEMORY
CRT_SYS_PIT 0x0703 PITCH
CRT_SYS_SVPR 0x0803 SV-PRM
CRT_SYS_SPPR 0x0903 SP.SET
CRT_SYS_MAINTENANCE 0x0b03 PMC MAINTE
CRT_SYS_LADDER 0x0c03 PMC LADDER
CRT_SYS_PMCCONFIG 0x0d03 PMC CONFIG
CRT_SYS_MTUNE 0x1003 M-TUN
CRT_SYS_ALIO 0x1103 ALL IO
CRT_SYS_OHIS 0x1303 OPEHIS
CRT_SYS_COLOR 0x1503 COLOR
CRT_SYS_MAINT 0x1603 MAINTE
CRT_SYS_MINFO 0x1703 M-INFO
CRT_SYS_WANL 0x1803 W.DGNS
CRT_SYS_TOUCH 0x1a03 TOUCH
CRT_SYS_FSSB 0x1b03 FSSB
CRT_SYS_PARAMTUNE 0x1c03 PRMTUN
CRT_SYS_PMM 0x1d03 PMM
CRT_SYS_EMB_ETH 0x1f03 EMBED PORT
CRT_SYS_PCM_ETH 0x2003 PCMCIA LAN
CRT_SYS_BOARD_ETH 0x2103 ETHER BOARD
CRT_SYS_MAS_PROFI 0x2203 PROFI MASTER
CRT_SYS_REMOTEDGN 0x2403 RMTDGN
CRT_SYS_MCOD 0x2503 M CODE
CRT_SYS_SLV_PROFI 0x2903 PROFI SLAVE
CRT_SYS_DCSDGN 0x2e03 DUAL CHECK
CRT_SYS_IDINF 0x4103 CNC ID INFORMATION
CRT_SYS_PRMCHKSUM 0x4303 PRM CHK SUM
CRT_SYS_CEXE 0x3203 C Language Executor
CRT_SYS_CEXE2 0x3303 C Language Executor 2
CRT_SYS_CEXE3 0x3403 C Language Executor 3
CRT_SYS_CEXE4 0x3503 C Language Executor 4
CRT_SYS_CEXE5 0x3603 C Language Executor 5
CRT_SYS_CNC 0x3f03 Previous CNC screen
MESSAGE
CRT_MSG_ALM 0x0104 ALARM
CRT_MSG_EMSG 0x0204 MSG
CRT_MSG_AHIS 0x0304 HISTRY
CRT_MSG_MHIS 0x0404 MSGHIS
CRT_MSG_EMB_ETHLOG 0x0604 EMBED LOG
CRT_MSG_PCM_ETHLOG 0x0704 PCMCIA LOG
CRT_MSG_BOARD_ETHLOG 0x0804 BOARD LOG
CRT_MSG_SYSAHIS 0x0a04 SYS ALM HISTRY
CRT_MSG_CEXE 0x3204 C Language Executor

- 867 -
3.Function References PROGRAMMING B-64303EN-3/01

Index
Symbol Screen
number
CRT_MSG_CEXE2 0x3304 C Language Executor 2
CRT_MSG_CEXE3 0x3404 C Language Executor 3
CRT_MSG_CEXE4 0x3504 C Language Executor 4
CRT_MSG_CEXE5 0x3604 C Language Executor 5
CRT_MSG_CNC 0x3f04 Previous CNC screen
GRAPHIC
CRT_GRH_PRM 0x0105 (M/T) PARAMETER
CRT_GRH_GRP 0x0205 (M) GRAPH
CRT_GRH_TGRP 0x0305 (T) GRAPH
CRT_GRH_SCALE 0x0405 (M/T) SCALE
CRT_GRH_DYNPRM 0x0605 (M) DYNAMIC GRAPH PARAMETER
CRT_GRH_DYNGRP 0x0705 (M) DYNAMIC GRAPH
CRT_GRH_DYNPOS 0x0905 (M) DYNAMIC GRAPH TOOL POS
CRT_GRH_ANIMEPRM1 0x0b05 (M) DYNAMIC GRAPH ANIME PARAMETER 1
CRT_GRH_ANIME 0x0d05 (M) DYNAMIC GRAPH ANIME
CRT_GRH_ANIMEPRM2 0x1005 (M) DYNAMIC GRAPH ANIME PARAMETER 2
CRT_GRH_ANIME3PLN 0x1105 (M) DYNAMIC GRAPH ANIME 3 PLANES
CRT_GRH_DYNTPRM 0x1505 (T) DYNAMIC GRAPH PARAMETER
CRT_GRH_DYNTGRP 0x1705 (T) DYNAMIC GRAPH
CRT_GRH_DYNTSCALE 0x1805 (T) DYNAMIC GRAPH SCALE
CRT_GRH_CEXE 0x3205 C Language Executor
CRT_GRH_CEXE2 0x3305 C Language Executor 2
CRT_GRH_CEXE3 0x3405 C Language Executor 3
CRT_GRH_CEXE4 0x3505 C Language Executor 4
CRT_GRH_CEXE5 0x3605 C Language Executor 5
CRT_GRH_CNC 0x3f05 Previous CNC screen
CUSTOM
CRT_CUS_TMAC1 0x0106 Conversational Macro 1
CRT_CUS_TMAC2 0x0206 Conversational Macro 2
CRT_CUS_TMAC3 0x0306 Conversational Macro 3
CRT_CUS_CEXE 0x3206 C Language Executor
CRT_CUS_CEXE2 0x3306 C Language Executor 2
CRT_CUS_CEXE3 0x3406 C Language Executor 3
CRT_CUS_CEXE4 0x3506 C Language Executor 4
CRT_CUS_CEXE5 0x3606 C Language Executor 5
CRT_CUS_CNC 0x3f06 Previous CNC screen
CUSTOM2
CRT_CS2_CEXE 0x3207 C Language Executor
CRT_CS2_CEXE2 0x3307 C Language Executor 2
CRT_CS2_CEXE3 0x3407 C Language Executor 3
CRT_CS2_CEXE4 0x3507 C Language Executor 4
CRT_CS2_CEXE5 0x3607 C Language Executor 5
CRT_CS2_CNC 0x3f07 Previous CNC screen

- 868 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program displays the index number of the current screen.

#include <crt.h>
#include <stdio.h>

void example( void )


{
int scrn ;
scrn = crt_getcurscrn() ;
printf( "Current screen index is %02X-%02X\n",
scrn & 0xFF, scrn >> 8 ) ;
}

- 869 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.2 Register user screen index. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_setuserscrn

[Syntax]
#include <crt.h>
int crt_setuserscrn( int num, int *scrntbl ) ;

[Arguments]
num Number of screen index to be registered.
scrntbl Pointer to the user screen index table.

[Return]
Returns zero if successful.
If any error, returns -1 and sets the following error code in the global variable "errno".

EUCRT Number of the screen index "num" is 0 or above 200.

[Description]
Registers the screen index numbers of the CNC screens which is replaced by the user
application program.

The index numbers of the user screens are registered in CNC by calling of this function.
Then, the user application will be called by selection of registered screens.

Store the screen index numbers in "scrntbl" with the following format.
The storing order is arbitrary.

Upper byte Lower byte


Small classification Large classification

Refer the screen index number list of "Get current screen index(crt_getcurscrn)" for
index numbers of each screens. All available index values are defined in crt.h as
"CRT_xxx_xxx".

At the start time of the application program, no user screen is registered. In this
condition, screen switching from the user screen to the CNC's is not allowed because
it is impossible to return to the user screen from the CNC screen again if no user screen
is registered.
So, this function must be called in the beginning of the main task of the user application
program.

- 870 -
B-64303EN-3/01 PROGRAMMING 3.Function References

This function doesn't check integrity of the screen index numbers to be registered.

Re-registration of the user screen index numbers by calling of this function again is
allowable. In this case, this function must be called under condition that any screen
switching is disabled by "crt_setswt" function.

For Series 0i-D, "C Language Executor screen" is added to each large classification of
CNC screens. (C Language Executor screen) C Language Executor screen is exclusive screen
for C Language Executor. The CNC software doesn't use this screen.
By registering this "C Language Executor screen" as user screen using this function,
the new user screen is added without replacing any existing CNC screens.

[Example]
The following program registers all position screens([ABS]/[REL]/[ALL]) as user's
screen.

#include <crt.h>

void example( void )


{
int crt_table[] = { CRT_POS_ABS, /* POSITION/ABSOLUTE */
CRT_POS_REL, /* POSITION/RELATIVE */
CRT_POS_ALL /* POSITION/ALL */
} ;
crt_setuserscrn( scrn_tbl_size(crt_table), crt_table ) ;
}

- 871 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.3 Test screen switching status. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
crt_isnewscrn

[Syntax]
#include <crt.h>
int crt_isnewscrn( void ) ;

[Arguments]
------

[Return]
Returns non-zero value if any screen switching has been done after the last calling this
function. If not, returns zero.

[Description]
Test whether any screen switching has been done or not.

This function is used to check the new entrance to the user screen by screen switching
such as
(any user screen) -> (CNC screen) -> (the same user screen).

In this case, it is impossible to get screen switching status by only calling


"crt_getcurscrn" function.

[Example]
The following program displays whether any screen switching has been done or not.

#include <crt.h>
#include <stdio.h>

void example( void )


{
if ( crt_isnewscrn() )
printf( "Any" ) ;
else
printf( "No" ) ;
printf( " screen switching has been done.\n" ) ;
}

- 872 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.4 Get CRT information. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
crt_gettype

[Syntax]
#include <crt.h>
unsigned int crt_gettype( void ) ;

[Arguments]
------

[Return]
Returns CRT information.

- 873 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Gets the equipped LCD specification and the current display mode.
This function is used to get whether LCD is 8.4 inch or 10.4 inch, etc.

The following informations are returned on each bits of the return value.

bit0 0: 8.4-inch LCD.


1: 10.4-inch LCD. (CRT_TYPE_14)
bit1 0: 40-column × 16-line.
1: 80-column × 25-line. (CRT_TYPE_80X25)
bit2 0: Graphic function is unavailable.
1: Graphic function is available. (CRT_TYPE_GRAPH)
(This bit is always set as "1".)
bit3 0: Graphic function is not in use.
1: Graphic function is in use. (CRT_TYPE_GAUTH)
bit4 0: 8.4/10.4-inch LCD.
1: Undefined.
(This bit is always set as "0".)
bit5 0: CRTC Display.
1: VGA Display. (CRT_TYPE_VGA)
(This bit is always set as "1".)
bit6 0: 80-column × 25-line.
1: 80-column × 30-line. (CRT_TYPE_V30)
(This bit is always set as "1".)
bit7 0: 16-color mode
1: 256-color mode (CRT_TYPE_VGAMD)
bit8 0: 40-column × 16-line.
1: 40-column × 19-line. (CRT_TYPE_V19)
bit9 0: 8.4-inch LCD.
1: Undefined.
(This bit is always set as "0".)
bit10 0: Normal display
1: Extended and reduced display (CRT_TYPE_V9MD2)
bit11 0: VGA Display
1: Character Card Display
bit12-15 Undefined.

- 874 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program displays information of the current display equipment.

#include <crt.h>
#include <stdio.h>

void example( void )


{
unsigned int crt ;
crt = crt_gettype() ;
printf( "Current screen mode is %s on %sinchCRT with%s "
"Graphic device.\n",
(crt&CRT_TYPE_80X25)?"80x25":"40x16",
(crt&CRT_TYPE_14)?"14":"9",
(crt&CRT_TYPE_GRAPH)?"":"out" ) ;
}

- 875 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.5 Set CRT screen mode. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
crt_setmode

[Syntax]
#include <crt.h>
int crt_setmode( unsigned int mode ) ;

[Arguments]
mode CRT screen mode.

[Return]
Returns zero if successful.
If any error, returns non-zero value.

[Description]

Sets the number of characters to be displayed and the color/monochrome mode.

When this function has been executed successfully, screen display is switched to the
specified mode and the screen is initialized.
When the 8.4-inch display unit is used and 256 colors are specified by the
_setvideomode function, however, if this function is executed, an error (-1) is returned
because the number of characters to be displayed cannot be set or changed.

Argument mode is set to one (or a combination) of the following values.

mode Description
CRT_MODE_80X25 80-column × 25-line mode
Monochrome mode (without intensity modulation) (Specified with
CRT_MODE_MONO
CRT_MODE_80X25)
VGA display, 40-column × 16-line (with no line of space left from the top)
CRT_MODE_V16_0
mode
CRT_MODE_V16_1 VGA display, 40-column × 16-line (with a line of space left from the top) mode
VGA display, 40-column × 16-line (with two lines of space left from the top)
CRT_MODE_V16_2
mode
VGA display, 40-column × 16-line (with three lines of space left from the top)
CRT_MODE_V16_3
mode
CRT_MODE_V19 VGA display, 40-column × 19-line mode (Valid only for the 8.4-inch LCD.)
VGA display, 80-column × 25-line (with no line of space left from the top)
CRT_MODE_V25_0
mode
CRT_MODE_V25_1 VGA display, 80-column × 25-line (with a line of space left from the top) mode
VGA display, 80-column × 25-line (with two lines of space left from the top)
CRT_MODE_V25_2
mode

- 876 -
B-64303EN-3/01 PROGRAMMING 3.Function References

mode Description
VGA display, 80-column × 25-line (with three lines of space left from the top)
CRT_MODE_V25_3
mode
VGA display, 80-column × 25-line (with four lines of space left from the top)
CRT_MODE_V25_4
mode
VGA display, 80-column × 25-line (with five lines of space left from the top)
CRT_MODE_V25_5
mode
CRT_MODE_V30 VGA display, 80-column × 30-line mode
CRT_MODE_MODE2 Performs reduced display using 10.4-inch LCD font on the 8.4-inch LCD.
CRT_MODE_CFLAG Specifies the display operation flag.
Enables the replacement of the JIS ruled line/98 ruled line with the FANUC
CFLAG_KEISEN
ruled line.
Sets the display language to simplified Chinese characters. For details, see
CFLAG_GBCODE Section 5.11, "Display of Simplified Chinese messages" in Part II,
"PROGRAMMING", later.
Sets the display language to Russian. For details, see Section 5.12
CFLAG_CYRILLIC
"Display/acquisition of Russian messages" in Part II, "PROGRAMMING", later.
Sets the display language to Turkish. For details, see Section 5.12
CFLAG_TURKISH
"Display/acquisition of Turkish messages" in Part II, "PROGRAMMING", later.

※Note 1 Valid only for the 8.4-inch LCD.

The expression "with n lines of space left from the top" in a VGA display indicates the
position of 25 lines (or 16 lines) of the display area relative to the entire screen
(30 lines or 19 lines).

n lines of

Display start line space

30 lines
25 lines
(19 lines) Display area
(16 lines)

- 877 -
3.Function References PROGRAMMING B-64303EN-3/01

Possible combinations are shown below.


− 8.4-inch color LCD
mode Description
CRT_MODE_V16_0 40 × 16 (with no space left from the top), color
CRT_MODE_V16_0 + CRT_MODE_MONO 40 × 16 (with no space left from the top), monochrome
CRT_MODE_V16_1 40 × 16 (with one line of space left from the top), color
CRT_MODE_V16_1 + CRT_MODE_MONO 40 × 16 (with one line of space left from the top), monochrome
CRT_MODE_V16_2 40 × 16 (with two lines of space left from the top), color
CRT_MODE_V16_2 + CRT_MODE_MONO 40 × 16 (with two lines of space left from the top), monochrome
CRT_MODE_V16_3 40 × 16 (with three lines of space left from the top), color
CRT_MODE_V16_3 + CRT_MODE_MONO 40 × 16 (with three lines of space left from the top),
monochrome
CRT_MODE_V19 40 × 19, color
CRT_MODE_V19 + CRT_MODE_MONO 40 × 19, monochrome
CRT_MODE_V25_0 + CRT_MODE_MONO 80 × 25 (with no space left from the top), color
CRT_MODE_V25_0 + CRT_MODE_MODE2 + 80 × 25 (with no space left from the top), monochrome
CRT_MODE_MONO
CRT_MODE_V25_1 + CRT_MODE_MONO 80 × 25 (with one line of space left from the top), color
CRT_MODE_V25_1 + CRT_MODE_MODE2 + 80 × 25 (with one line of space left from the top), monochrome
CRT_MODE_MONO
CRT_MODE_V25_2 + CRT_MODE_MONO 80 × 25 (with two lines of space left from the top), color
CRT_MODE_V25_2 + CRT_MODE_MODE2 + 80 × 25 (with two lines of space left from the top), monochrome
CRT_MODE_MONO
CRT_MODE_V25_3 + CRT_MODE_MONO 80 × 25 (with three lines of space left from the top), color
CRT_MODE_V25_3 + CRT_MODE_MODE2 + 80 × 25 (with three lines of space left from the top),
CRT_MODE_MONO monochrome
CRT_MODE_V25_4 + CRT_MODE_MONO 80 × 25 (with four lines of space left from the top), color
CRT_MODE_V25_4 + CRT_MODE_MODE2 + 80 × 25 (with four lines of space left from the top), monochrome
CRT_MODE_MONO
CRT_MODE_V25_5 + CRT_MODE_MONO 80 × 25 (with five lines of space left from the top), color
CRT_MODE_V25_5 + CRT_MODE_MODE2 + 80 × 25 (with five lines of space left from the top), monochrome
CRT_MODE_MONO
CRT_MODE_V30 + CRT_MODE_MONO 80 × 30, color
CRT_MODE_V30 + CRT_MODE_MODE2 + 80 × 30, monochrome
CRT_MODE_MONO

- 878 -
B-64303EN-3/01 PROGRAMMING 3.Function References

− 10.4-inch color LCD/12.1-inch color LCD


mode Description
CRT_MODE_V25_0 80 × 25 (with no space left from the top), color
CRT_MODE_V25_0 + CRT_MODE_MONO 80 × 25 (with no space left from the top), monochrome
CRT_MODE_V25_1 80 × 25 (with one line of space left from the top), color
CRT_MODE_V25_1 + CRT_MODE_MONO 80 × 25 (with one line of space left from the top), monochrome
CRT_MODE_V25_2 80 × 25 (with two lines of space left from the top), color
CRT_MODE_V25_2 + CRT_MODE_MONO 80 × 25 (with two lines of space left from the top), monochrome
80 × 25 (with three lines of space left from the top), color
CRT_MODE_V25_3
(Default)
80 × 25 (with three lines of space left from the top),
CRT_MODE_V25_3 + CRT_MODE_MONO
monochrome
CRT_MODE_V25_4 80 × 25 (with four lines of space left from the top), color
CRT_MODE_V25_4 + CRT_MODE_MONO 80 × 25 (with four lines of space left from the top), monochrome
CRT_MODE_V25_5 80 × 25 (with five lines of space left from the top), color
CRT_MODE_V25_5 + CRT_MODE_MONO 80 × 25 (with five lines of space left from the top), monochrome
CRT_MODE_V30 80 × 30, color
CRT_MODE_V30 + CRT_MODE_MODE2 +
80 × 30, monochrome
CRT_MODE_MONO

− For all cases


mode Description
Enables the replacement of the JIS ruled line/98 ruled line with
CRT_MODE_CFLAG + CFLAG_KEISEN
the FANUC ruled line.
CRT_MODE_CFLAG + CFLAG_GBCODE Sets the display language to Simplified Chinese characters.
CRT_MODE_CFLAG + CFLAG_CYRILLIC Sets the display language to Russian.
CRT_MODE_CFLAG + CFLAG_TURKISH Sets the display language to Turkish.

In the monochrome mode, color specification by escape sequences is disabled.


White is always used as the display color (the maximum brightness is used for a monochrome
display device).

When this function is executed, the console driver is initialized. Since the settings
related to the CRT are cleared, make settings again as needed. If this function is
executed during graphic display, the graphic display is also initialized.
This is equivalent to the _setvideomode function with "Text mode" specified.

- 879 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.6 Switch to CNC screen. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
crt_cncscrn

[Syntax]
#include <crt.h>
int crt_cncscrn( int index ) ;

[Arguments]
index Index number of the CNC screen to be switched to.

[Return]
Returns zero if successful. If not, returns one of following values and sets the same
value in the global variable "errno".

ER_CNC_DATA (=5) Incorrect screen index number "index".


ER_CNC_OPTION (=6) There are no additional options/board required
for the specified screen.
ER_CNC_BUSY (=-1) CNC window is busy.

[Description]
Changes into the CNC screen which is specified by the application program. Also execution
of program is switched from the application task to the CNC task. This is the same
operation as switching to CNC
screen by pressing of the function keys on MDI panel.

The CRT display will be switched into the specified CNC screen by the successful calling
of this function.
At the same time, the control of software will be switches to the CNC side, and then,
the application program is put into sleep state.

When the screen will be changed from the CNC side into the user's screen again, the
application program will restart from the next instruction to this function call.

Specify the screen index numbers in "index" with the following format.

Upper byte Lower byte


Small classification Large classification

Refer the screen index number list of "Get current screen index(crt_getcurscrn)" for
index numbers of each screens. All available index values are defined in crt.h as
"CRT_xxx_xxx".
It is possible to switch to any user's screen by specifying the index number of the user
screen.
[Example]
The following program changes into "PROGRAM CHECK" screen if the current mode is "MEM".

- 880 -
B-64303EN-3/01 PROGRAMMING 3.Function References

#include <crt.h>
#include <data.h>
#include <fwindow.h>

void example( void )


{
struct odbst stat ;
cnc_statinfo( &stat ) ;
if ( stat.aut == 1 )
crt_cncscrn( CRT_PRG_PCHK ) ;
}

- 881 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.7 Output character by FANUC character code. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_fchar

[Syntax]
#include <crt.h>
int crt_fchar( unsigned int code ) ;

[Arguments]
code FANUC character code ( 0x0000 through 0x1fff ),
or FANUC character code | 0x8000 (0x8000 through 0x9fff).

[Return]
Returns always zero.

[Description]
Outputs a character that is included in FANUC character set and is specified by FANUC
character code on the current cursor position.

A character which is specified by FANUC character code is displayed on the current cursor
position. In case that (FANUC code | 0x8000) is specified, the function works as follows.

In case of "ESC (A" mode (JIS Kanji set mode) is specified.


Character codes 0x0000 through 0xFFFF can be accepted.
This function must display the specified half-size character.
In case of other than "ESC (A" mode is specified.
Two characters are displayed continuously, the first one is(specified code),
and the next one is (specified code + 1).

This function works like putchar() function except character code format.
That is, displaying a half-size character on the current cursor position with the
specified character attribute, and then forwarding a cursor for one character.

- 882 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program displays the specified integer value using bold numeric characters.

#include <crt.h>
#include <stdio.h>
#include <string.h>

void example( unsigned int val )


{
int idx ;
char buf[6] ;
sprintf( buf, "%u", val ) ;
for ( idx = 0 ; idx < strlen( buf ) ; idx++ )
crt_fchar( 0x1D20 + buf[idx] - '0' ) ;
}

- 883 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.8 Customize softkey on CNC screen. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_setuserskey

[Syntax]
#include <crt.h>
int crt_setuserskey( unsigned int index, unsigned int num,
struct user_softkey *skey ) ;

struct user_softkey {
unsigned int index ; /* Softkey index number. */
int op ; /* Operation code. */
unsigned int submode ; /* Small classification of */
/* user's screen. */
unsigned int *string ; /* Display string. */
} ;

[Arguments]
index Softkey table index number to be customized.
num Number of customizing item.
skey Customizing data table.

[Return]
Returns zero if successful. If any error, returns -1 and sets the following error code
in the global variable "errno".

EUSKEY Incorrect softkey table index number "index" or softkey index number
"skey.index".

[Description]
Alters the softkey displayed on the CNC screen as follows, adds new items, by which any
user screens are selected, moves the existent items, by which the CNC screens are selected,
deletes the existent items.

Specify the softkey table index number to be customized in "index".


There are the softkey tables for each large classifications of the CNC screen (and more,
for each modes in the PROGRAM screen).
All available table index values are defined in crt.h as "SKEY_xxxx".

Store multiple customizing data in "skey".


The customizing data includes the following items.

index Softkey index number to be customized.


op Operation code.
submode Small classification of the user's screen.
string User specified display string.

- 884 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Softkey index number is the sequential number for each softkey tables.
For example, the following sequential numbers are assigned to the softkeys on the POSITION
screen.

Key Softkey index number


[ ABS ] 1
[ REL ] 2
[ ALL ] 3
[ HNDL ] 4

Available operations are "Deletion", "User specified" and "Moving".

Operation code Action


Deletion
SKEY_OP_DEL makes the specified softkey ineffective. Blank is displayed
for the softkey.
User specified
makes the specified softkey effective forcibly. The user
SKEY_OP_USER specified string is displayed on the screen. The user
specified (small classification) screen will be selected by
pushing the specified softkey.
Moving
Other values moves the softkey which is specified by the operation
code to the specified position.

Specify the small classification number of the screen which is selected by the specified
softkey in "submode" when the operation code is "SKEY_OP_USER".
"submode" is not referenced when the operation code is "SKEY_OP_DEL" or moving softkey.

Specify display string of the softkey in "string" by FANUC code when the operation code
is "SKEY_OP_USER". The maximum string length is 12 characters (6 characters x 2-line).

Register the small classification number of the screen which is specified in "submode"
as the user's screen using "crt_setuserscrn" function when "SKEY_OP_USER" is specified.

Call this function before calling "crt_setuserscrn" function.

- 885 -
3.Function References PROGRAMMING B-64303EN-3/01

CNC original softkey table


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following table shows the display items of the Series 0i-D original soft keys.
Softkeys shown in the left side are defined for screen selection in each screens (and
each modes). The numbers in the lower half are the subsection number (submode) of the
screen selected by each key and the soft key number (index).

Display item
submode (hexadecimal) index (decimal)

(Caution) These contents are subject to change without prior notice.

POSITION
ABSOLUTE RELATIVE ALL HANDLE
0x01 1 0x02 2 0x03 3 0x04 4
MONITOR
0x06 6
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 11 0x33 12 0x34 13 0x35 14 0x36 15

PROGRAM
MDI mode
PROGRAM CURRENT
0x01 1 0x13 3
RESTART
0x08 6
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 11 0x33 12 0x34 13 0x35 14 0x36 15
MEM/RMT mode
PROGRAM CURRENT
0x01 1 0x13 3
RESTART
0x08 6
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 11 0x33 12 0x34 13 0x35 14 0x36 15

- 886 -
B-64303EN-3/01 PROGRAMMING 3.Function References

EDIT mode
PROGRAM
0x01 1
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 11 0x33 12 0x34 13 0x35 14 0x36 15
HND/REF/JOG mode
PROGRAM CURRENT
0x01 1 0x13 3
RESTART
0x08 6
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 11 0x33 12 0x34 13 0x35 14 0x36 15
THND/TJOG mode
PROGRAM
0x01 1
RESTART
0x08 6
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 11 0x33 12 0x34 13 0x35 14 0x36 15

- 887 -
3.Function References PROGRAMMING B-64303EN-3/01

OFFSET/SETTING
OFFSET SETTING WORK
0x01 1 0x02 2 0x03 3
MACRO MENU OPERATE PANEL TOOL LIFE
0x06 6 0x07 7 0x08 8 0x09 9
Y OFFSET WORK SHIFT TOOL FORM BARIER
0x0b 11 0x0c 12 0x0d 13 0x15 14
PRECI LEVEL TL GEOM SIZE
0x11 17 0x0e 19
LANGUAGE PROTECT GUARD
0x16 22 0x17 23 0x18 24
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 26 0x33 27 0x34 28 0x35 29 0x36 30

- 888 -
B-64303EN-3/01 PROGRAMMING 3.Function References

SYSTEM
PATAMETER DIAGNOSIS SYSTEM
0x01 1 0x02 2 0x04 4
PITCH ERROR SERVO PARAM SPINDL SETING
0x07 7 0x08 8 0x09 9
WAVE DIAG ALL IO MCODE GROUP OPERAT HISTRY
0x18 11 0x11 12 0x25 13 0x13 14
PMC MAINTE PMC LADDER PMC CONFIG PMM
0x0b 16 0x0c 17 0x0d 18 0x1d 19
COLOR MAINTE MAINTE INFO
0x15 21 0x16 22 0x17 23
TOUCH PANEL FSSB PRMTUN
0x1a 26 0x1b 27 0x1c 28
EMBED PORT PCMCIA LAN ETHER BOARD
0x1f 31 0x20 32 0x21 33

REMOTE DIAG MCHN TUNING DUAL CHECK


0x24 41 0x10 42 0x2e 43
ID-INF MEMORY PARAM CHKSUM
0x41 46 0x06 48 0x43 49
PROFI MASTER PROFI SLAVE
0x22 51 0x29 52
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 56 0x33 57 0x34 58 0x35 59 0x36 60

- 889 -
3.Function References PROGRAMMING B-64303EN-3/01

MESSAGE
ALARM MESSAGE HISTRY
0x01 1 0x02 2 0x03 3
MESSAGE
HISTRY SYSALMHIS
0x04 7 0x0a 8
EMBED LOG PCMCIA LOG BOARD LOG
0x06 11 0x07 12 0x08 13
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 16 0x33 17 0x34 18 0x35 19 0x36 20

GRAPH
PARAMETER GRAPH GRAPH ZOOM
0x01 1 0x02 2 0x03 3 0x04 4
PARAMETER EXEC POS
0x06 6 0x07 7 0x09 9
PARAMETER EXEC
0x0b 11 0x0d 13
PARAMETER 3-PLN
0x10 16 0x11 17
PARAMETER GRAPH ZOOM
0x15 21 0x17 23 0x18 24
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 26 0x33 27 0x34 28 0x35 29 0x36 30

- 890 -
B-64303EN-3/01 PROGRAMMING 3.Function References

CUSTOM
TMAC1 TMAC2 TMAC3
0x01 1 0x02 2 0x03 3
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 6 0x33 7 0x34 8 0x35 9 0x36 10

CUSTOM2
CEXE CEXE2 CEXE3 CEXE4 CEXE5
0x32 1 0x33 2 0x34 3 0x35 4 0x36 5

- 891 -
3.Function References PROGRAMMING B-64303EN-3/01

How to define display string of the softkey


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The display string of the softkey must be defined by FANUC code when softkey item is
customized using this function. For FANUC character codes, see Appendix C, "Character
Code List".

(1) Define array of "int" type(or "unsigned int" type). The total number of elements is 12( 6
characters × 2-line). The exceeded elements are ignored.

(2) Store one code for a character in each "int"-type element.


For double-sized character (such as Japanese Kanji character),store the codes for the
left-side and the right-side of the character continuously.

(Example 1) Define a string " USER ".

unsigned int skey_user[] = {


0x0020,0x0055,0x0053,0x0045,0x0052,0x0020 /* " USER " */
} ;

(Example 2) Define a string "TOOL# seting"

unsigned int skey_kougu[] = {


0x0054,0x004F,0x004F,0x004C,0x0023,0x0020, /* "TOOL# " */
0x0073,0x0065,0x0074,0x0069,0x006e,0x0067 /* "seting" */
} ;

[Example]
This is procedure to customize the softkey of POSITION screen as follows.

Original [ ALL ][ REL ][ ABS ][ MCN ]


After customizing [ USER ][ ALL ][ ABS ][ ]

1. Define a string " USER " by FANUC character code.

unsigned int skey_str[] = {


0x0020,0x0055,0x0053,0x0045,0x0052,0x0020, /* " USER " */
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020 /* " " */
} ;

- 892 -
B-64303EN-3/01 PROGRAMMING 3.Function References

2. Define customizing data.

struct user_softkey skey_table[] = {


/* Delete [ MCN ] key. */
{ 4, SKEY_OP_DEL, 0, NULL },
/* Move [ ALL ] to [ REL ]'s position. */
{ 2, 1, 0, NULL },
/* Define new user key at [ ALL ]'s position, the small
classification is 3. Register the small classification 3 screen
in POS function as user's screen using "crt_setuserscrn"
function. */
{ 1, SKEY_OP_USER, 3, skey_str }
} ;

3. Call "crt_setuserskey" function.

crt_setuserskey( SKEY_POSITION, skey_tbl_size(skey_table),


skey_table ) ;

After customizing, the small classification 3 user's screen is displayed by pushing


[ USER ] key, the ordinary all position screen by [ ALL ] key, and the absolute position
screen by [ ABS ] key.

The above procedures are described in the following program.

#include <crt.h>

void example( void ) {


unsigned int skey_str[] = {
0x0020,0x0055,0x0053,0x0045,0x0052,0x0020, /* " USER " */
0x0020,0x0020,0x0020,0x0020,0x0020,0x0020 /* " " */
} ;
struct user_softkey skey_table[] = {
{ 4, SKEY_OP_DEL, 0, NULL },
{ 2, 1, 0, NULL },
{ 1, SKEY_OP_USER, 3, skey_str }
} ;
crt_setuserskey( SKEY_POSITION, skey_tbl_size(skey_table),
skey_table ) ;
}

- 893 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.9 Set switching method between CNC's screen and user's. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
crt_setswt

[Syntax]
#include <crt.h>
unsigned int crt_setswt( unsigned int mode ) ;

[Arguments]
mode Screen switching mode.

[Return]
Returns the old setting value.

[Description]
Set switching method such as, disable/enable to switch to the CNC screen from the user's,
disable/enable to output video signal at switching to the user screen from the CNC's.

Specify the following setting value in each bits of "mode".


It is possible to specify the multiple bits simultaneously.

bit0 0: Enables switching to the CNC screen from the user's.


(default)
1: Disable switching to the CNC screen from the user's. (CRT_SWT_DIS)
bit1 0: Video beam is ON at switching to the user screen from
the CNC's (default)
1: Video beam is OFF at switching to the user screen
from the CNC's. (CRT_SWT_VOFF)
bit2 0: Disable switching screen during graphic drawing.
(default)
1: Enable switching screen during graphic drawing. (CRT_SWT_GREN)
bit3 When any CNC alarm occurred in the CNC screen, the
screen is switched to the CNC's alarm screen
automatically or not
0: according to the ordinary CNC setting. (Parameter
No.3111#7)
1: according to the user screen's setting. (Parameter
No.8650#1) (CRT_SWT_ACNC)
bit4 The function keys on MDI panel are
0: read by the CNC software. (default)
1: not read by the CNC software. (The CNC software can't
switch the screen.) (CRT_SWT_MFKY)
bit5 The automatic graphic beam ON when the screen is
switched from the CNC to the user's is
0: not executed.
1: executed. (only when the graphic beam is enabled on
the previous user's screen.) (CRT_SWT_GRON)

- 894 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Setting by this function goes on being effective until this function will be called newly.

"CRT_SWT_DIS" disables switching to the CNC screen by MDI key operation, so take care
of usage of this function.
Under condition that "CRT_SWT_DIS" is set, also screen switching by "crt_cncscrn"
function is disabled.

Under condition that "CRT_SWT_VOFF" is set, nothing is displayed on the screen after
screen switching from the CNC screen to the user's until the application program enables
video beam output. Output escape sequence "ESC [>9l" to console, or clear whole screen
by "ESC [2J" to enable beam output.("ESC [2J" enables video beam output.]

Under condition that "CRT_SWT_MFKY" is set, the screen switching by the function keys
is disabled. When this bit is set, the user application must read the status of the
function keys using "crt_readfkey" function and switch the screen. This setting is
effective on the CNC's screen.

During the CNC screen is being displayed, execute reading the function keys and switching
the screen in the auxiliary task.

When the application program manages the screen switching with setting this bit ON, set
parameter No.8650#1 CNA as "1" and manages also screen switching at CNC alarm rising
by the application program.

[Example]
The following program disables screen switching, executes foo() function and restores
the original status again.

#include <crt.h>

void example( void )


{
unsigned int save_mode ;
save_mode = crt_setswt( CRT_SWT_DIS ) ;
foo() ;
crt_setswt( save_mode ) ;
}

- 895 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.10 Set scroll area. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_setscrlarea

[Syntax]
#include <crt.h>
int crt_setscrlarea( unsigned int start, unsigned int height ) ;

[Arguments]
start Start line of the scroll area (1 - max line).
height Height of the scroll area (1 - max line).

"max line" is 30 . (in case of line extended)

[Return]
Returns zero if successful.
If any error (for example, the scroll area is out of the screen, etc.),returns "1".

[Description]
Set the scroll area for automatic scrolling by line-feeding.

Only specified scroll area is scrolled by line-feeding by this function. This function
doesn't clear the screen, and doesn't change the current cursor position.

The whole screen is scroll area on the start-up time.

The scroll area which is specified by this function is effective to both automatic
scrolling by line-feeding and scroll-up/scroll-down by escape-sequence ("ESC [nL", "ESC
[nM").

[Example]
The following program sets the scroll area in 2 through 24th line.
(The top line and the bottom line are not scrolled.)

#include <crt.h>

void example( void )


{
crt_setscrlarea( 2, 24 ) ;
}

- 896 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.11 Open graphic display. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_opengr

[Syntax]
#include <crt.h>
int crt_opengr( void ) ;

[Arguments]
------

[Return]
Returns "0" or "1" if successful.
If any error (Graphic board is not equipped, or the graphic function option is not set.),
returns "-1".
The difference between return code "0" and "1" is as follows.

0 The authorization to use graphic display has not been


given to another application after the last calling
of crt_closegr() function. So, initialization of
graphic screen is not required because the state of
graphic display on the last calling of crt_closegr()
is being kept.
1 The authorization to use graphic display has been
given to another application after the last calling of
crt_closegr() function. So, initialization of graphic
screen is required because the state of graphic
display on the last calling of crt_closegr() is not
being kept.

[Description]
Acquire authorization to use graphic display and become ready for the graphic display.

After successful completion of this function, the authorization of graphic display is


given to the C Language Executor application program and the application program become
capable of drawing on the graphic screen.

After the execution of this function, screen switching is disabled until crt_closegr()
function is executed.
Calling crt_setswt(CRT_SWT_GREN) prior to crt_opengr() enables screen switching while
graphics display is open.

- 897 -
3.Function References PROGRAMMING B-64303EN-3/01

When screen is switched from the user screen to the CNC screen while displaying
application graphics, graphic display to the display unit is disabled (BEAM OFF). However,
the graphics drawn by the user application program is retained as is, provided no graphic
screen is displayed by CNC. When screen is switched back to the user screen, the function
crt_opengr() returns the value '0' if graphics is retained.
But , to re-display the graphics on the CRT, beam should be made on by the function
crt_graphic(). If the "CRT_SWT_GRON" bit is set by the crt_setswt() function, "BEEM
ON" is automatically done when returned from the CNC screen to the user screen.

[Example]
Following program draws a line defined by two specified end points.

#include <crt.h>
#include <graph.h>

void example( int x1, int y1, int x2, int y2 )


{
int ret ;
ret = crt_opengr() ;
if ( ret == -1 ) return ;
if ( ret ) _setvideomode( 81 ) ;
_moveto( x1, y1 ) ;
_lineto( x2, y2 ) ;
crt_closegr() ;
}

- 898 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.12 Close graphic display. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_closegr

[Syntax]
#include <crt.h>
void crt_closegr( void ) ;

[Arguments]
------

[Return]
------

[Description]
Stop using graphic display and become ready to release authorization for graphic display.

By calling this function, access to the graphic display function from the user application
program is disabled, and no user graphics display can be done until the crt_opengr()
function is called again. This function, at the same time, enables screen switching,
and the screen switching which has been suspended during open graphic display mode is
executed after the execution of this function.

This function does not always release authorization for graphic display at it's execution.
If there are no other application programs requiring authorization for graphic display
when this function is called, this function only prepares for releasing the authorization
of graphic display.

[Example]
Refer to the example of "Open graphic display (crt_opengr)".

- 899 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.13 Enable or disable graphic display. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
crt_graphic

[Syntax]
#include <crt.h>
int crt_graphic( int mode ) ;

[Arguments]
mode Specify graphic output ON or OFF.

[Return]
Returns zero if successful and returns non zero if any error (graphic
function is not ready for use).

[Description]
Specify whether to display graphics on the CRT or not (GRAPHIC BEAM ON or OFF).

One of the following should be specified for the "mode".

CRT_ON_BEAM Enable graphic display on the CRT.


CRT_OFF_BEAM Disable graphic display on the CRT.

This function controls whether the graphics drawn by the user application program is
displayed on the display unit or not , and has no effect on the display of characters,
while BEAM ON/OFF command by using the escape sequences, "ESC [>9l"/"ESC [>9h", affects
both graphics and characters.

Graphics can be drawn even while the display of the graphics to the display unit is
disabled.

The default state of the "GRAPHIC BEAM" right after the graphic screen is initialized
(i.e. when returned from the "_setvideomode" function) is "ON".

Screen switching from the user screen to the CNC screen automatically turns the "GRAPHIC
BEAM" off. After switching the screen to the user's again, turn the "GRAPHIC BEAM" on
by this function to get graphic display on the display unit.

- 900 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
Following program tests the current screen, and turns the "GRAPHIC BEAM" on if it is
POSITION display screen. Turns the "GRAPHIC BEAM" off if else.

#include <crt.h>

void example( void )


{
int scrn ;
scrn = crt_getcurscrn() ;
if ( ( scrn & 0xFF ) == ( CRT_POS_ABS & 0xFF ) )
crt_graphic( CRT_ON_BEAM ) ;
else
crt_graphic( CRT_OFF_BEAM ) ;
}

- 901 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.14 Read the status of function keys. <Main,Alarm>
------------------------------------------------------------------------------------------

[Name]
crt_readfkey

[Syntax]
#include <crt.h>
int crt_readfkey( void ) ;

[Arguments]
------

[Return]
Returns zero if no function keys are depressed or CRT_SWT_MFKY bit of the "crt_setswt"
function is set to "0". When CRT_SWT_MFKY bit is set to "1", keycode for the
function key being depressed is returned.
Keycodes are shown below.

KEY SYMBOL CODE


POS MDIKEY_POS 0xE8
PROG MDIKEY_PROG 0xE9
OFS/SET MDIKEY_OFFSET 0xEA
SYSTEM MDIKEY_SYSTEM 0xEB
MESSAGE MDIKEY_MESSAGE 0xEC
GRAPH MDIKEY_GRAPH 0xED
CUSTOM1 MDIKEY_CUSTOM 0xEE
CUSTOM2 MDIKEY_CUSTOM2 0xEF

[Description]
This function reads the status of the function keys on the MDI panel, and is used by
the user application program to switch screens according to the status of the function
keys.

If function key is depressed, corresponding keycode is read and returned.

When reading the status of the function keys, set "CRT_SWT_MFKY" bit of the crt_setswt()
function to "1". This disables the ordinary screen switching caused by the function keys.
User application program reads the status of the function keys by means of this function
and switch the screens by using crt_cncscrn() function.

- 902 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
Following is a sample program which, when a function key is pressed, switches the screen
to the corresponding CNC screen.(Execute as auxiliary task)

#include <crt.h>
#include <oscall.h>

void main( void ) {


unsigned int idx, fkey, newscrn, curscrn, savescrn[8] ;

for ( idx = 0 ; idx < 8 ; idx++)


savescrn[idx] = idx ; /* initialize savescrn[8] */

for (;;) {
os_wait_tim( 5 ) ; /* run every 40msec */
curscrn = crt_getcurscrn() ; /* get current screen index */
/* number */
savescrn[curscrn % 0x100] = curscrn ;
/* save index including small classification */
/* if function key is pressed */
if ( fkey = crt_readfkey() ) {
/* restore previous small classification number */
newscrn = savescrn[fkey - MDIKEY_POS] ;
if ( newscrn != curscrn ) {
crt_cncscrn( newscrn ) ;
crt_setswt( CRT_SWT_MFKY ) ;
}
}
}
}

- 903 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.15 Display the secondary cursor. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_2ndcursor

[Syntax]
#include <crt.h>
int crt_2ndcursor( unsigned int attrib, unsigned int start,
unsigned int end, unsigned int position,
unsigned int width ) ;

[Arguments]
attrib cursor attribute
start cursor start raster
end cursor end raster
position cursor position
width cursor width

[Return]
Returns zero if successful and returns "-1" if any error( invalid argument).

[Description]
The crt_2ndcursor() sets cursor display ON/OFF or other attributes for the 2nd cursor.
The 2nd cursor is a cursor which can freely be controlled by the user application program
independent of the usual character cursor.

The 2nd cursor is set to OFF(non display) state, after the screen is initialized by
crt_swtmode() function or "ESC [2J". Other than these two methods, crt_2ndcursor() is
the only means to control ON/OFF of the 2nd cursor.

Specify following values for each arguments in binary form.

attrib Specify one of the following.


CUR2_ON non-blink
CUR2_OFF no cursor display
CUR2_FBLINK fast blink
CUR2_SBLINK slow blink
start Specify cursor start raster.
end Specify cursor end raster.
Cursor start raster and cursor end raster specifies
the top and bottom raster position of the cursor
respectively. This defines the shape of the cursor, box or underline.

- 904 -
B-64303EN-3/01 PROGRAMMING 3.Function References

position Specify cursor position. To display cursor on the Mth


column of the Nth line, specify as
(N-1)×(columns per line)+(M-1). (Both line number and
column number starts from "1" which corresponds to the
top line and the left-most column. Columns are the
number of single column character.)
width Specify width of the cursor in the unit of single
column character width. Allowable maximum width is the
number of columns per line. (80) Cursor cannot be
displayed across the lines.

Allowable parameter range of each argument

Specifiable
argument
range
start 0 to 15
end
0 to 15
(must satisfy end>=start)
position 0 to 2399
width 1 to 80

[Example]
Following program modifies the specified lines to be underlined.

#include <crt.h>

void example( unsigned int line )


{
if ( crt_gettype() & CRT_TYPE_80X25 )
crt_2ndcursor( CUR2_ON, 15, 15, (line-1)*80, 80 ) ;
else
crt_2ndcursor( CUR2_ON, 24, 24, (line-1)*40, 40 ) ;
}

- 905 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.16 Set attribute of characters on VRAM. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_settextattr

[Syntax]
#include <crt.h>
int crt_settextattr( unsigned int y1, unsigned int x1,
unsigned int y2, unsigned int x2,
unsigned int attr, unsigned int op ) ;

[Arguments]
y1 Line number of the upper-left position of the
attribute setting region.
x1 Column number of the upper-left position of the
attribute setting region.
y2 Line number of the lower-right position of the
attribute setting region.
x2 Column number of the lower-right position of the
attribute setting region.
attr Set attribute value.
op Logical operation specification.

[Return]
Returns zero if successful. If any error (incorrect coordinate spec or incorrect logical
operation spec), returns non-zero value.

- 906 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Description]
Sets the specified attributes to the characters displayed on the screen.
This function doesn't change the already displayed character1 code but changes only its
attributes.

Specify line and column number of the upper-left and the lower-right position in "y1",
"x1" and "y2", "x2". (The upper-left position of the screen is (1st-column, 1st-line).)

(1, 1) Whole screen

(y1, x1)

(y2, x2)

Attribute setting region

(ymax, xmax)

ymax=30, xmax=80

This function changes the attributes of all characters included in the rectangle region
specified by y1,x1,y2,x2.

Specify the bit pattern of newly set attributes in "attr" as follows.

15 8 7 0

0 0 0 Ib Bb Gb Rb I B G R r b 0 0 0

B: Blue r: Reverse
G: Green b: Blink
R: Red
I: Low intensity
Bb: Background Blue
Gb: Background Green
Rb: Background Red
Ib: Background Low intensity

- 907 -
3.Function References PROGRAMMING B-64303EN-3/01

The available setting values are as follows.

Normal Reverse Blink Reverse+Blink


Black 0x0000 0x0010 0x0008 0x0018
Red 0x0020 0x0030 0x0028 0x0038
Green 0x0040 0x0050 0x0048 0x0058
Yellow 0x0060 0x0070 0x0068 0x0078
Blue 0x0080 0x0090 0x0088 0x0098
Magenta 0x00a0 0x00b0 0x00a8 0x00b8
Cyan 0x00c0 0x00d0 0x00c8 0x00d8
White 0x00e0 0x00f0 0x00e8 0x00f8

Actually, 4-bits of "IRGB" and "IbRbGbBb" indicate the palette index number of character
and background.

Specify the logical operation method of attribute setting in "op".

op Operation Set attributes


3 Set attr
2 Set negative ~attr
0 Or Char_attr | attr
1 And Char_attr & attr
4 Xor Char_attr ^ attr

[Example]
The following program makes the top line of the screen "REVERSE" for a moment.

#include <crt.h>

void example( void )


{
crt_settextattr( 1, 1, 1, 80, 0x0010, 0 ) ;
crt_settextattr( 1, 1, 1, 80, ~0x0010, 1 ) ;
}

- 908 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.17 Get attribute of character on VRAM. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_gettextattr

[Syntax]
#include <crt.h>
unsigned int crt_gettextattr( unsigned int y, unsigned int x ) ;

[Arguments]
y Line position of the character to be got the attribute.
x Column position of the character to be got the attribute.

[Return]
Returns the attribute of the character at the specified position.
If incorrect position specification, returns -1.

[Description]
Gets the attribute of the character at the specified position.

Specify line and column position of the character to be got the attribute in "y" and
"x". (The top-left position of the screen is (1st-column, 1st-line).)

The read attribute is returned as the return code of this function.


The attribute bits are same as the specification of "crt_settextattr" function. Refer
the description of "crt_settextattr" function.

[Example]
The following program reads the attribute of the character at (3rd-line, 30th-column)
of the screen.

#include <stdio.h>
#include <crt.h>

void example( void )


{
unsigned int attr ;

attr = crt_gettextattr( 3, 30 ) ;
printf( "attribute is 0x%04X\n", attr ) ;
}

- 909 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.18 Set color palette of VGA characters. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_setpalette

[Syntax]
#include <crt.h>
#include <graph.h>
int crt_setpalette( unsigned int index, unsigned long color ) ;

[Arguments]
index Index of color palette. (0..15,_PAL_COMP,_PAL_RVS)
color Color value.

[Return]
Returns zero if successful. If any error (incorrect color palette index or not a VGA
display device), returns non-zero value.

[Description]
Sets the color value to the color palette for character.

Specify the color palette index number (0..15) in "index" and the color value in "color".
The format of the color value specified in "color" is same as the color value used in
a graphic function "_remappalette". (The symbols of the color value defined in the header
file "graph.h" such as _98GREEN are available for "color"'s specification.)

32 0

0 0 0 0 0 0 0 0 0 0 B B B B B B 00GGGGGG 0 0 R R R R R R

R Red data (Lower byte)


G Green data (2nd byte)
B Blue data (3rd byte)

Each data mean the intensity of each color in range 0x00 - 0x3F.
The larger value means more intensity color.

The color values of each palettes are initialized at the application start-up as follows.
(System initial values)

- 910 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ESC sequence specification


value
Palette index Color value Displayed color
Character Character
color color
0 0x00000000 Black 30 40
1 0x0000003F Red 31 41
2 0x00003F00 Green 32 42
3 0x00003F3F Yellow 33 43
4 0x003F0000 Blue 34 44
5 0x003F003F Magenta 35 45
6 0x003F3F00 Cyan 36 46
7 0x003F3F3F White 37 47
8 0x00181818 Gray 1;30 3;40
9 0x000C0C1C Dark Red 1;31 3;41
10 0x000C1C0C Dark Green 1;32 3;42
11 0x000C1C1C Dark Yellow 1;33 3;43
12 0x001C0C0C Dark Blue 1;34 3;44
13 0x001C0C1C Dark Magenta 1;35 3;45
14 0x001C1C0C Dark Cyan 1;36 3;46
15 0x00282828 Dark White 1;37 3;47

While "Without brightness conversion" (CRT_MODE_MONO) is specified by "crt_setmode"


function, the palette index 0 is initialized as 0x00000000 and all of the other palettes
as 0x003F3F3F.
In the above table, for example, output "ESC [43;1;31m" to print dark red characters
on the yellow background.

Once "low intensity (dark)" mode is set by "ESC [1m" or "ESC [3m", all of the following
color specifications are assumed to be low intensity. For example,

printf( "\033[1;31mDARK RED\n" ) ; // Dark Red.


printf( "\033[34mDARK BLUE\n" ) ; // Blue.
printf( "\033[22;34mBLUE\n" ) ; // Cancel low intensity,
// Blue.

this displays

DARK RED <-- Dark Red.


DARK BLUE <-- Dark Blue.
BLUE <-- Blue.

To display normal intensity color after once low intensity mode was specified, cancel
low intensity mode positively. (similarly about background color.)

For LCD device, the lower 2 bits of each color are masked. That is,0x00,0x04,0x08,..,0x3C
are valid setting value for each color.
Even if the application program specifies "1" at the lower 2 bits, the VGA firmware masks
them.(In this case, max.4,096 colors are representable.)

- 911 -
3.Function References PROGRAMMING B-64303EN-3/01

The color values set by the C application program are effective to only the C user screen.
The other screens such as the CNC's screen are not affected by this setting. Similarly,
the color setting in the other screens are not effective to the C user screen. The color
palettes used for graphics are different from the palettes for characters, they are not
affected by this function's setting.
Use "remappalette" or "_remapallpalette" function to set the color palettes for graphics.

It is possible to set the priority of the palette of characters and graphics by specifying
"_PAL_COMP" in "index". In this case, specify the palette priority in "color".

color Palette priority


CRT_PAL_COMP Composite (default)
CRT_PAL_CHAR Character over graphics
CRT_PAL_GRPH Graphics over character

"Composite" means that the intensity of each color of character and one of graphic pixel
are mixed. (logical OR). For example, in case that

Character color R/G/B = 0x30/0x00/0x20


Graphic color R/G/B = 0x00/0x20/0x38
Composite color R/G/B = 0x30/0x20/0x38

is output on the screen.


The displayed colors on the screen are for each setting as follows.

Character palette Graphics


index palette index Dot color
0 0 Composite color
Not 0 0 Composite color
Composite
0 Not 0 Composite color
Not 0 Not 0 Composite color
0 0 Graphic color
Character over Not 0 0 Character color
Graphics 0 Not 0 Graphic color
Not 0 Not 0 Character color
0 0 Character color
Graphics over Not 0 0 Character color
Character 0 Not 0 Graphic color
Not 0 Not 0 Graphic color

This table indicates that the palette index 0 is the special part for overlapping the
character and the graphics. Allocate "Black" to the palette 0 as same as initial value
so far as there are no exceptional reasons.

- 912 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.19 Set all color palette of VGA characters. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_setallpalette

[Syntax]
#include <crt.h>
#include <graph.h>
int crt_setallpalette( unsigned long *colors ) ;

[Arguments]
colors Pointer to the color value array.

[Return]
Returns zero if successful. If any error (not a VGA display device),
returns non-zero value.

[Description]
Sets the color values to the all color palette for character.

Store 16 color values in "color". The format of the color value is same as data used
in "crt_setpalette" function.
This function stores 16 color values to the all 16 color palettes, and set the palette
priority as "Composite".

This function doesn't affect the color palettes of the other screen and the color palettes
of graphics.

All palettes are set as the system initial values by specifying NULL in "color". The
system initial values are listed in the description of "crt_setpalette" function.

- 913 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.20 Get color palette of CNC screen. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_getcncpalette

[Syntax]
#include <crt.h>
int crt_getcncpalette( unsigned long *cnccol ) ;

[Arguments]
cnccol Color palette table of CNC screen. (32 elements)

[Return]
Returns zero if successful. If any error (one of following cases),
returns non-zero value.
- Not VGA display device.

[Description]
Gets the color palette setting values of the CNC screen.

This function is used to display the user's screen with the same color as the CNC's screen
or to get the colors of the base CNC screen by the window task.

The color palette values of the CNC screen are stored in "cnccol" as follows

cnccol[0] - cnccol[15] Color palette No.0 through 15


for character.

cnccol[16] - cnccol[31] Color palette No.0 through 15


for graphics.

The format of color value is same as "crt_setpalette" function.


The color value got by this function is used in "crt_setallpalette" and
"_remapallpalette" function as it is, like this;

crt_setallpalette( &cnccol[0] ) ;
_remapallpalette( &cnccol[16] ) ;

Take care of palette index handling when VGA window screen is overlapped on any CNC screen
by the window task.

- 914 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program sets all color palettes as same as the CNC's screen.

#include <crt.h>
#include <graph.h>

void example( void )


{
unsigned long cnccol[32] ;

if ( !crt_getcncpalette( cnccol ) ) {
crt_setallpalette( &cnccol[0] ) ;
_remapallpalette( &cnccol[16] ) ;
}
}

- 915 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.21 Output character string by FANUC character code. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_fstr

[Syntax]
#include <crt.h>
int crt_fstr( unsigned int *code, unsigned int len ) ;

[Arguments]
code Array of FANUC character code ( 0x0000 - 0xffff ).
len Length of the character string.

[Return]
Returns always zero.

[Description]
Outputs a character string that is included in FANUC character set and is specified by
FANUC character code on the current cursor position.

Store "len" of FANUC code (16-bit) for each half-size character in an array "code".
Store the character string length in "len".

The behavior of this function is equivalent to the following program.


(This function is faster to display.)

unsigned int i ;
for ( i = 0 ; i < len ; i++ )
crt_fchar( code[i] ) ;

[Example]
The following program displays an icon of a tester on the current cursor position.

#include <crt.h>

void example( void )


{
static unsigned int tester[] =
{ 0x1E64, 0x1E65, 0x1E66, 0x1E67 } ;

crt_fstr( tester, sizeof( tester )/sizeof( unsigned int ) ) ;


}

- 916 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
1.22 Get text data from VRAM. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_gettextimg

[Syntax]
#include <crt.h>
int crt_gettextimg( unsigned int y1, unsigned int len x1,
unsigned int y2, unsigned int len x2,
unsigned long *buf ) ;

[Arguments]
y1 Left, upper position of the area from where characters are got.
x1 Left, lower position of the area from where characters are got.
y2 Right, lower position of the area from where characters are got.
x2 Right, upper position of the area from where characters are got.
buf Area that characters data are stored.

[Return]
Returns zero when terminated normally, not zero when error, i.e. specified coordinates
is not correct, is occurred.

- 917 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Gets character codes, displayed on the screen, with their attribute.

This function is used with the function "crt_puttextimg" to backup or restore the text
image on the screen.

y1,x1 is top, left, y2,x2 is bottom, right position of the area from where characters
are got as follows.(The top of left side shows raw-1, and column-1.)

(1, 1) Full screen

(y1, x1)

(y2, x2)

Area for getting character

(ymax, xmax)

ymax=30, xmax=80
All character codes and their attributes, included the rectangular area that is enclosed
by (y1,x1)-(y2,x2),can be got.

(The characters which are enclosed in above area)*4 bytes area must be reserved as "BUF".
The data form, stored in "BUF", is as follows.

Upper word Lower word

Attribute Character code

The character code is FANUC character code, and the type of the attribute is explained
the same as that of "crt_settextattr".
The position on the memory is corresponding to the position on the screen as follows.

Position on the memory Position on the screen


buf + 0 y1 , x1 (Top, left)
buf + 1 y1 , x1 + 1
: :
buf + (x2 – x1) y1 , x2
buf + (x2 – x1) + 1 y1 + 1 , x1
: :
buf + (x2 – x1 + 1)×(y2 – y1 + 1) – 1 y2 , x2 (Bottom, right)

- 918 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program backs up and restores the displayed characters of upper 3 rows
on the 10.4 inch LCD screen.

#include <crt.h>
#include <stdlib.h>

void example( void )


{
unsigned long *buf ;

/* allocate (3-line)*(80-column)*(4-byte) buffer */


buf = (unsigned long *)malloc( 3*80*4 ) ;
/* get text image */
crt_gettextimg( 1, 1, 3, 80, buf ) ;
...... (another process)
/* restore text image */
crt_puttextimg( 1, 1, 3, 80, buf, 0 ) ;
/* free buffer */
free( buf ) ;
}

- 919 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.23 Put text data into VRAM. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_puttextimg

[Syntax]
#include <crt.h>
int crt_puttextimg( unsigned int y1, unsigned int len x1,
unsigned int y2, unsigned int len x2,
unsigned long *buf, unsigned int op ) ;

[Arguments]
y1 Left,upper position of the area where characters are put.
x1 Left,lower position of the area where characters are put.
y2 Right, lower position of the area where characters are put.
x2 Right, upper position of the area where characters are put.
buf Area that characters data are stored.
op The way to put characters or attributes into VRAM.

[Return]
Returns zero when terminated normally, not zero when error, i.e.
specified coordinates is not correct, is occurred.

[Description]
Puts character codes on the screen, with their attribute.

This function is used with the function "crt_gettextimg" to back up or restore the text
image on the screen.

y1,x1 is top, left, y2,x2 is bottom, right position of the area into where characters
are put.(The top of left side shows raw-1, and column-1.)
This position specification is same as "crt_gettextimg" function.

Character codes and their attributes are read out from "buf" where is regarded that the
data, got by "crt_gettextimg" function, exist. The data, got by "crt_gettextimg" function,
is put on the screen usually but it is also possible to put originally prepared data
if they have the same type as the data, got by "crt_gettextimg" function. It is possible
to put the data, got by "crt_gettextimg" function, into the different area from where
they are got, if the size of the rectangular area is the same.

- 920 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Put data is selected from character codes or attributes or both of them by "op" as follows.

op Put Data
0 Character codes and attributes
1 Character codes
2 Attributes

When either characters or attributes are put on the screen, the attributes or character
codes originally present in the rectangular area on the screen are kept as is.

[Example]
The following program makes the characters and attributes that are displayed on the
specified area to move to right by 3 digits.

#include <crt.h>
#include <stdio.h>
#include <stdlib.h>

void example( unsigned int y1, unsigned int x1,


unsigned int y2, unsigned int x2 )
{
unsigned long *buf ;
unsigned int i ;

buf = (unsigned long *)malloc( (y2-y1+1)*(x2-x1+1)*4 ) ;


crt_gettextimg( y1, x1, y2, x2, buf ) ;
crt_puttextimg( y1, x1+3, y2, x2+3, buf, 0 ) ;
free( buf ) ;
/* erase disused characters */
for ( i = y1 ; i <= y2 ; i++ )
printf( "\033[%u;%uH ", i, x1 ) ;
}

- 921 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.24 Select graphic page to use. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_setgraphpage

[Syntax]
#include <crt.h>
int crt_setgraphpage( int page ) ;

[Arguments]
page Graphic page number to use. (0, 1 or -1)

[Return]
Returns zero if successful.
If any error (i.e. invalid page number was specified),returns non-zero value.

[Description]
Select graphic page to use for graphic drawing.

The graphic system of Series 0i-D has two pages for graphic drawing.
"_setactivepage" and "_setvisualpage" functions select graphic page for drawing and
displaying.
"_setvideomode" function initializes both two pages.

This function selects the page that is initialized by "_setvideomode" function. Specify
one of 0, 1 and -1 in "page".
Each value means as follows.

page _behavior of "_setvideomode" function


0 initializes only page #0, sets display/draw page=#0
1 initializes only page #1, sets display/draw page=#1
-1 initializes both page #0 and #1 (default),sets display/draw page=#0

When "_setvideomode" function initializes one of page #0 and #1, the contents of the
other page are kept.

This function affects only behavior of "_setvideomode" function which is called after
calling of this function. Even if any value is specified by this function, you can
specify an arbitrary page number in "_setactivepage" and "_setvisualpage" function.

By calling this function with "page=1", both drawing and displaying pages are set as
#1 after calling "_setvideomode" function. With "page=0" or "page=-1", both drawing and
displaying page are #0.

- 922 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program draws graphics using only graphic page #1.

#include <crt.h>
#include <graph.h>

void example( void )


{
if ( crt_opengr() == 1 ) {
crt_setgraphpage( 1 ) ;
_setvideomode( _VRES16COLOR ) ;
}

<< Calling graphic function >>

crt_closegr() ;
}

- 923 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
1.25 Select drawing method of 6x sized character. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_set6chmode

[Syntax]
#include <crt.h>
int crt_set6chmode( int mode ) ;

[Arguments]
mode Drawing method of 6x sized character.
0: High speed mode
1: Complete mode

[Return]
0 Successful.
1 Invalid value (other than 0 and 1) is specified.
2 Ineffective in the current display mode.

[Description]
Selects drawing method of 6x sized character.

This function selects the drawing method of 6x sized character that is displayed over
"CNC screen display function" application program on PC side of Series 0i-D.
Specify one of the followings.

mode = 0 High speed mode (default).


This is effective for displaying the frequently updated
information such as the current position of NC using 6x sized
character. The character is updated without flicker.
mode = 1 Complete mode.
Each elements of 6x sized character are individually drawn.

Normally "High speed mode" of the default setting is used.


Use "Complete mode" in case of following.

* The text window displayed by "win_***" functions overlaps 6x sized characters drawn
over the base screen.
In this case, any elements of 6x sized character which adjoins the window border may
not be drawn correctly. To avoid this, select "Complete mode" by this function.

This setting is not effective for NC side screen.


6x sized character is always drawn by "Complete mode" on NC side screen.

- 924 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Setting by this function is effective to all 6x sized character drawing until terminating
the current "CNC screen display function" session.

Setting by this function is effective to drawing method of 6x sized character on the


text screen by "printf" function etc., not effective to 6x sized character drawing by
graphic functions.

[Remarks]
This function is available only with the CNC screen display function at the PC side on
the Series 0i-D system.

- 925 -
3.Function References PROGRAMMING B-64303EN-3/01

2. Multiple window display library

------------------------------------------------------------------------------------------
2.1 Open window. <Main>
------------------------------------------------------------------------------------------

[Name]
win_open

[Syntax]
#include <crt.h>
whandle win_open( winfo *spec, char *title, int flag ) ;

typedef int whandle ; /* window handle */


typedef struct _winfo {
unsigned int posl ; /* window line position */
unsigned int posc ; /* window column position */
unsigned int sizev ; /* window vertical size */
unsigned int sizeh ; /* window horizontal size */
} winfo ;

[Arguments]
spec window geometry(position& size) structure
title window title string
flag window attribute

[Return]
Returns window handle if successful.
When failed, returns "-1" and sets following error code to the global variable "errno".

EW_SPEC Invalid window position or size is specified.


EW_MAX Attempted to open a window beyond the limit of maximum number of
windows(MAX-WIN).

[Description]
Creates new window on the screen.

A window of the specified size is created and placed on the screen at the specified
position.

- 926 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Values set for each member of the structure "spec" are as follows.

posl line number of the upper left corner of the window


( >=2) (top line of the screen being "1")
posc column number of the upper left corner of the window
( >=2) (left-most column of the screen being "1")
sizev number of lines of the window ( >=1)
sizeh number of columns of the window( >=1)
(=number of single byte characters per window)

Full screen ←Line 1

□ window

(posl, posc)
sizev

sizeh


Window frame

←Line N

↑ ↑
Column 1 Column M

N=30, M=80

Specify window title string by the argument "title". The length of the window title string
should be less than 32 single byte characters.
(single byte alpha-numeric and Katakana characters, symbols and double byte
alpha-numeric, Hirakana, Kanji characters and symbols can be used.)

- 927 -
3.Function References PROGRAMMING B-64303EN-3/01

Specify one of the following window attributes by the argument "flag".


("0" is equivalent to WIN_F_FULL.)

WIN_F_FULL Full screen window


WIN_F_FRM0 Frame line style: Normal (Thin line)
WIN_F_FRM1 Frame line style: Bold
WIN_F_FRM2 Frame line style: White space (When using this mode, specify
reverse attribute for frame color by win_col() function.)
WIN_F_FRM3 Frame line style: User defined line (define line style by
win_setfrm() function)
WIN_F_NOFRM Frame-less window: Window size of the frame-less window can be
expanded to full screen size, without specifying WIN_F_FUL
attribute.

A new window is placed over existing windows and both screen output and key input are
bound to this window (active window).

When new window is opened, cursor is placed on the upper-left corner (home position)
of the window and cursor display attribute is set to non-display state.

While more than one windows are open, access to the screen areas other than window areas
is disabled. Generally, full screen should be cleared before opening the first window,
or the first window should be full-screen window. When opening windows over the usual
screen display, display the base usual screen in the full-screen window.
Calling this function at the start of the application program as shown in the following
example will do this.

winfo mainwin ;
whandle win_main ;
mainwin.posl = 2 ;
mainwin.posc = 2 ;
mainwin.sizev = 23 ;
mainwin.sizeh = 78 ;
win_main = win_open( &mainwin, "Main Window", WIN_F_FULL ) ;

- 928 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.2 Close window. <Main>
------------------------------------------------------------------------------------------

[Name]
win_close

[Syntax]
#include <crt.h>
int win_close( void ) ;

[Arguments]
------

[Return]
Returns zero if successful.
When failed, returns "-1" and sets following error code to the global variable "errno".

EW_CLOS E no open window

[Description]
Close active window.

When the last window is closed, screen display returns to the default screen state where
no windows are open. Otherwise, the window underneath the closed window become active
and whole screen is redrawn.

- 929 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.3 Select window. <Main>
------------------------------------------------------------------------------------------

[Name]
win_select

[Syntax]
#include <crt.h>
int win_select( whandle handle ) ;

[Arguments]
handle window handle of the window to be selected

[Return]
Returns zero if successful.
When failed, returns "-1" and sets following error code to the global variable "errno".

EW_NOTOPEN specified window not exist

[Description]
Select one of the open windows on the screen for display window.

After this function is called and a window is selected, all succeeding screen output
is drawn on the selected window.

This function does not change the overlapping order of the window.

When window is selected by this function, former cursor position of that window is
restored.

- 930 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.4 Activate window. <Main>
------------------------------------------------------------------------------------------

[Name]
win_activate

[Syntax]
#include <crt.h>
int win_activate( whandle handle ) ;

[Arguments]
handle window handle for the window to be activated

[Return]
Returns zero if successful.
When failed, returns "-1" and sets following error code to the global variable "errno".

EW_NOTOPEN specified window not exist

[Description]
Select one of the open windows on the screen for keyboard input.

After this function is called, succeeding input from MDI keyboard is valid only while
the window is selected for display by win_select().

The window selected by this function is also selected as display window.

This function changes the overlapping order of the windows so that the selected window
comes on top of other windows.

Whole screen is redrawn by this function call.

- 931 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.5 Move window. <Main>
------------------------------------------------------------------------------------------

[Name]
win_move

[Syntax]
#include <crt.h>
int win_move( int dy, int dx ) ;

[Arguments]
dy vertical displacement
dx horizontal displacement

[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".

EW_DISP invalid displacement specified

[Description]
Move active window .

Whole screen is redrawn after the window is moved. Overlapping order does not change.

Displacement value which would cause whole or a part of the window to be off the screen
cannot be specified.

- 932 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.6 Alter window size. <Main>
------------------------------------------------------------------------------------------

[Name]
win_size

[Syntax]
#include <crt.h>
int win_size( int dy, int dx ) ;

[Arguments]
dy vertical expansion/reduction value
dx horizontal expansion/reduction value

[Return]
Returns zero if successful.
When failed, returns "-1" and sets following error code to the global variable "errno".

EW_DISP invalid size value specified

[Description]
Change active window size.

Window size expansion or reduction takes place so that the bottom or the right side border
is moved by the specified value relative to the upper-left corner of the window.

The size expansion value which would cause a part of the window to be off the screen
cannot be specified. Also the size reduction value which would shrink the window less
than the size of 1 line/1 column cannot be specified.

After the window size is expanded or reduced, whole screen is redrawn.

Win_size() does not change overlapping order of the windows.

- 933 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.7 Let active window be full screen size. <Main>
------------------------------------------------------------------------------------------

[Name]
win_full

[Syntax]
#include <crt.h>
int win_full( void ) ;

[Arguments]
------

[Return]
Returns zero if successful.
When failed, returns "-1" and sets following error code to the global variable "errno".

EW_CHANGE specified window is already in full screen window mode

[Description]
Let the size of the active window be full screen size.

Full screen window is placed underneath all other open windows.

- 934 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.8 Let active window be window size. <Main>
------------------------------------------------------------------------------------------

[Name]
win_window

[Syntax]
#include <crt.h>
int win_window( void ) ;

[Arguments]
------

[Return]
Returns zero if successful.
When failed, returns "-1" and sets following error code to the global variable "errno".

EW_CHANGE specified window is not a full screen window

[Description]
Active full screen window is shrunk to be a normal window.

Size and position of the shrunk window is that of original window before being expanded
to be full size window.

Win_windows() redraws whole screen.

- 935 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.9 Get window information. <Main>
------------------------------------------------------------------------------------------

[Name]
win_info

[Syntax]
#include <crt.h>
int win_info( whandle handle, winfo *spec ) ;

[Arguments]
handle window handle of the target window
spec pointer to the window geometry(size&position) structure

[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".

EW_NOTOPEN specified window not exist

[Description]
Get the position and size of the specified window. Position and size is set to the
corresponding member of the structure "spec".

- 936 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.10 Set color of window frame and title string. <Main>
------------------------------------------------------------------------------------------

[Name]
win_col

[Syntax]
#include <crt.h>
void win_col( int colf, int colt, int colh,
int colfa, int colta, int colha ) ;

[Arguments]
colf window frame color
colt window title color
colh window handle color
colfa active window frame color
colta active window title color
colfa active window handle color

[Return]
------

- 937 -
3.Function References PROGRAMMING B-64303EN-3/01

[Description]
Set color for window frame and window title string.

Specify colors and attribute for each argument as follows.

15 8 7 0

0 0 0 Ib Bb Gb Rb I B G R r b 0 0 0

B: Blue r: Reverse video


G: Green b: Blink
R: Red
I: Low intensity
Bb: Background Blue
Gb: Background Green
Rb: Background Red
Ib: Background Low intensity

Valid color value is as follows.

normal reverse blink reverse+blink


Black 0x0000 0x0010 0x0008 0x0018
Red 0x0020 0x0030 0x0028 0x0038
Green 0x0040 0x0050 0x0048 0x0058
Yellow 0x0060 0x0070 0x0068 0x0078
Blue 0x0080 0x0090 0x0088 0x0098
Magenta 0x00a0 0x00b0 0x00a8 0x00b8
Cyan 0x00c0 0x00d0 0x00c8 0x00d8
White 0x00e0 0x00f0 0x00e8 0x00f8

Actually, 4-bits of "IRGB" and "IbRbGbBb" indicate the palette index number of character
and background.

If "0x000" is specified for the window handle, it will not be displayed.

Colors and attributes set by this function are applied to the window frames, titles or
window handles which are displayed after this function call. Colors or attributes of
those already displayed when this function is called is not affected. To change them,
redraw the window by calling functions to move, change size or hide/show the window.

This function affects all windows.

- 938 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.11 Hide window. <Main>
------------------------------------------------------------------------------------------

[Name]
win_hide

[Syntax]
#include <crt.h>
int win_hide( whandle handle ) ;

[Arguments]
handle window handle for the window to be hidden

[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".

EW_NOTOPEN specified window not exist

[Description]
Win_hide() hides specified window.

Hidden window continues to be invisible until it is shown again by win_show() function.

Overlapping order of other windows is not changed.


Even while a window is hidden, data can be written in the window by selecting the window
by win_select().

Calling this function redraws whole screen.

- 939 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.12 Show window. <Main>
------------------------------------------------------------------------------------------

[Name]
win_show

[Syntax]
#include <crt.h>
int win_show( whandle handle ) ;

[Arguments]
handle window handle of the window to be hidden

[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".

EW_NOTOPEN specified window not exist

[Description]
Windows hidden by win_hide() function become visible by this function.

Overlapping order of the windows is not changed.

Calling this function redraws whole screen.

- 940 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.13 Set window title string. <Main>
------------------------------------------------------------------------------------------

[Name]
win_setttl

[Syntax]
#include <crt.h>
int win_setttl( whandle handle, char *title ) ;

[Arguments]
handle window handle of the window whose title string is to
be changed
title window title string

[Return]
Returns zero if successful. When failed, returns "-1" and sets
following error code to the global variable "errno".

EW_NOTOPEN specified window not exist

[Description]
Change title string for a window.

The length of the window title string should be less than 32 single byte characters.
(single byte alpha-numeric and Katakana characters, symbols and double byte
alpha-numeric, Hiragana, Kanji characters and symbols can be used.)

Calling this function redraws whole screen.

- 941 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2.14 Set window frame line character. <Main>
------------------------------------------------------------------------------------------

[Name]
win_setfrm

[Syntax]
#include <crt.h>
void win_setfrm( unsigned int *frame ) ;

[Arguments]
frame character code array which defines window frame line style

[Return]
------

[Description]
Set user defined line style for window frame.

Set the FANUC character code for each window frame line to the argument "frame" in the
following order(horiz.-0, horiz.-1,vert.-2, vert.-3, upper-left corner-4......).

[4]-----[0]-----[6]
| |
| |
[2] [3]
| |
| |
[5]-----[1]-----[7]

For example, following character cord array is to be specified to set usual frame line.

unsigned char waku[] = {


0x01ED,0x01ED,0x01EE,0x01EE,
0x01EC,0x01EA,0x01E6,0x01E8
} ;

Window frame lines set by this function are applied to the windows which are opened with
WIN_F_FRM3 attribute after this function call.
Frame lines of those windows already opened with WIN_F_FRM3 attribute are changed to
the specified style when they are redrawn.

The line style set by this function is applied to all windows with WIN_F_FRM3 attribute.

- 942 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.15 Get window display status. <Main>
------------------------------------------------------------------------------------------

[Name]
win_getstat

[Syntax]
#include <crt.h>
void win_getstat( struct winstat *stat ) ;

struct winstat {
whandle selected ; /* Window handle of the
currently selected window*/
whandle active ; /* Window handle of the
currently active window. */
unsigned int numwin ; /* Number of opened window. */
unsigned int winstack[MAX_WIN] ; /* Stacking order of
opened windows. */
} ;

[Arguments]
stat Windows status information.

[Return]
------

[Description]
Gets the current window display status.

The window handle the currently selected window and the currently active window are stored
in each "stat.selected" and "stat.active".
The number of the currently opened windows is stored in "stat.numwin".
The number in "stat.numwin" includes the windows hidden by "win_hide" function. The
stacking order of the all opened windows is stored in "stat.winstack". The handles of
all of the opened windows are stored like this, the window handle of the top window is
stored in "winstack[0]", the next in "winstack[1]".

- 943 -
3.Function References PROGRAMMING B-64303EN-3/01

For example, three windows are opened now as below.


This function returns the following result.

[1]

[2] Selected

[3]
Active

stat.selected = 1
stat.active = 3
stat.numwin = 3
stat.winstack[0] = 3
stat.winstack[1] = 1
stat.winstack[2] = 2
(stat.winstack[3] and later are undefined.)

When "stat.numwin" = 0, that is, no window is opened, the contents of "selected", "active"
and "winstack" are undefined.

[Example]
The following program tests if the currently active window is selected or not, then,
if not, selects it.

#include <crt.h>

void example( void )


{
struct winstat stat ;

win_getstat( &stat ) ;
if ( ( numwin != 0 ) && ( stat.selected != stat.active ) )
win_select( stat.active ) ;
}

- 944 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2.16 Redraw windows. <Main>
------------------------------------------------------------------------------------------

[Name]
win_redraw

[Syntax]
#include <crt.h>
void win_redraw( void ) ;

[Arguments]
------

[Return]
------

[Description]
Redraws all opening windows.

This function just redraw the opening and displayed window keeping the current window
status (open/close, displayed/hidden, overlapping order of windows).

This function does nothing when no window is opened.

When the screen has been switched from/to NC side and PC side on "CNC screen display
function", use function to redraw windows.

- 945 -
3.Function References PROGRAMMING B-64303EN-3/01

3. User defined character library

3-1. scope

User defined character is a character which is defined by machine tool builders. (usually
referred to as extended character) C Language Executor allows the user application program to
define and use extended characters. Up to 256 single byte characters can be defined and registered.
Arbitrary character code in single byte character set dedicated for user defined characters or
in standard JIS Kanji character set can be assigned to the registered extended character.

3-2. Character dot pattern

(1) 10.4-inch color LCD and other equivalent display units (display units which usually use
half-size 80-column x 25-line display)

a) Dot pattern size

single byte character 2-byte character

8 dots 16 dots
| | | |
- -

16 dots 16 dots

- -
2-byte character is composed of two consecutive single byte character patterns.

- 946 -
B-64303EN-3/01 PROGRAMMING 3.Function References

b) Binary notation

Horizontally aligned 8 bits(dots) are represented by one byte data.

Single byte character 2-byte character


bit order→#7 #0 #7 #0 #7 #0
byte 1 byte 1 byte 17

byte 16 byte 16 byte 32

c) Example

- Single byte character 'A'

pattern □□□□□□□□
□□□□□□□□
□□□□□□□□
□□■■■□□□
□■□□□■□□
■□□□□□■□
■□□□□□■□
■□□□□□■□
■■■■■■■□
■□□□□□■□
■□□□□□■□
■□□□□□■□
□□□□□□□□
□□□□□□□□
□□□□□□□□
□□□□□□□□

Binary 0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,
notation 0xFE,0x82,0x82,0x82,0x00,0x00,0x00,0x00

- 947 -
3.Function References PROGRAMMING B-64303EN-3/01

- 2-byte character ("漢" of Japanese KANJI character)

pattern □□□□□□□□□□□□□□□□
□□□□□□□■□□□■□□□□
□■■□□■■■■■■■■■□□
□□□■□□□■□□□■□□□□
□□□□□□■■■■■■■□□□
□■■□□□■□□■□□■□□□
□□□■□□■■■■■■■□□□
□□□□□□□□□■□□□□□□
□□□■□□■■■■■■■□□□
□□□■□□□□□■□□□□□□
□□□■□■■■■■■■■■□□
□□■□□□□□■□■□□□□□
□□■□□□□■□□□■□□□□
□■■□□■■□□□□□■■□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□

Binary 0x00,0x01,0x67,0x11,0x03,0x62,0x13,0x00,
notation 0x13,0x10,0x17,0x20,0x21,0x66,0x00,0x00,
0x00,0x10,0xFC,0x10,0xF8,0x48,0xF8,0x40,
0xF8,0x40,0xFC,0xA0,0x10,0x0C,0x00,0x00

(2) 8.4-inch color LCD, and other equivalent display units (display units which usually use
half-size 40-column x 16-line display)

a) Dot pattern size

- Half-size character - Full-size character


16 dots 32 dots
| | | |
- -

25 dots 25 dots

- -
A full-size character consists of two consecutive half-size patterns.

b) Representation by numerical data

Horizontally-aligned 8 bits are represented by one-byte data.

- 948 -
B-64303EN-3/01 PROGRAMMING 3.Function References

- Half-size character - Full-size character

Bit order → #7 #0 #7 #0 #7 #0 #7 #0 #7 #0 #7 #0

1 26 1 26 51 76

25 50 25 50 75 100

- 949 -
3.Function References PROGRAMMING B-64303EN-3/01

c) Example

- Half-size character 'A'

Pattern □□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□
□□□□□□□■□□□□□□□□
□□□□□□□■□□□□□□□□
□□□□□□■■■□□□□□□□
□□□□□□■■■□□□□□□□
□□□□□■■□■■□□□□□□
□□□□□■■□■■□□□□□□
□□□□□■□□□■□□□□□□
□□□□■■□□□■■□□□□□
□□□□■□□□□□■□□□□□
□□□■■■■■■■■■□□□□
□□□■■□□□□□■■□□□□
□□■■□□□□□□□■■□□□
□□■■□□□□□□□■■□□□
□■■■■□□□□□■■■■□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□

Binary 0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,
notation 0x06,0x06,0x04,0x0C,0x08,0x1F,0x18,0x30,
0x30,0x78,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0x80,0xC0,0xC0,0x40,0x60,0x20,0xF0,0x30,
0x18,0x18,0x3C,0x00,0x00,0x00,0x00,0x00,
0x00,0x00

- 950 -
B-64303EN-3/01 PROGRAMMING 3.Function References

- Full-size character ("KAN" of Japanese KANJI character)

Pattern □□□□□□□■■□□□□□■■■□■■■□□□□□□□□□□□
□□□□□□□□■■□□□□□■■□□■■□□□■■□□□□□□
□□□□□□□□■■□■■■■■■■■■■■■■■■■□□□□□
□□□□□□□□□□□□□□□■■□□■■□□□□□□□□□□□
□□□□□□□□□□□□□□□■■□□■■□□□□□□□□□□□
□□□□□□□□□□■□■□□□□□□□□□■■□□□□□□□□
□□□□□■■□□□■□■■■■■■■■■■■■■□□□□□□□
□□□□□□■■□□■□■■□□□■■□□□■■□□□□□□□□
□□□□□□■■□■■□■■□□□■■□□□■■□□□□□□□□
□□□□□□□□□■□□■■■■■■■■■■■■□□□□□□□□
□□□□□□□□□■□□□□□□□■■□□□□□□□□□□□□□
□□□□□□□□■■□□□□□□□■■□□□■■□□□□□□□□
□□□□□□□□■■□□■■■■■■■■■■■■■□□□□□□□
□□□□□□□■■□□□□□□□□■■□□□□□□□□□□□□□
□□□□□□□■■□□□□□□□□■■□□□□■■□□□□□□□
□□□□□■■■□□■■■■■■■■■■■■■■■■□□□□□□
□□□□□□■■□□□□□□□□■■■□□□□□□□□□□□□□
□□□□□□□■□□□□□□□■■□■■□□□□□□□□□□□□
□□□□□□□■□□□□□□■■□□□■■□□□□□□□□□□□
□□□□□□■■□□□□□■■□□□□□■■■■□□□□□□□□
□□□□□□■■□□□■■■□□□□□□□□■■■■■□□□□□
□□□□□□□□□■■■□□□□□□□□□□□□■■□□□□□□
□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□
□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□

Binary 0x01,0x00,0x00,0x00,0x00,0x00,0x06,0x03,
notation 0x03,0x00,0x00,0x00,0x00,0x01,0x01,0x07,
0x03,0x01,0x01,0x03,0x03,0x00,0x00,0x00,
0x00,0x83,0xC1,0xDF,0x01,0x01,0x28,0x2F,
0x2C,0x6C,0x4F,0x40,0xC0,0xDF,0x80,0x80,
0x3F,0x00,0x01,0x03,0x06,0x1C,0x70,0x00,
0x00,0x00,
0xB8,0x98,0xFF,0x98,0x98,0x03,0xFF,0x63,
0x63,0xFF,0x60,0x63,0xFF,0x60,0x61,0xFF,
0xE0,0xB0,0x18,0x0F,0x03,0x00,0x00,0x00,
0x00,0x00,0xC0,0xE0,0x00,0x00,0x00,0x80,
0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x80,
0xC0,0x00,0x00,0x00,0x00,0xE0,0xC0,0x00,
0x00,0x00

- 951 -
3.Function References PROGRAMMING B-64303EN-3/01

3-3. Character code

(1) FANUC code


Character codes from 0x4100 to 0x41FF in FANUC code set are reserved for user defined characters
and automatically assigned to the user defined character in the order of its registration. In
case of 2-byte characters, two consecutive codes are assigned to a 2-byte character, one for
left half of the dot pattern and the other for the right half, where the latter code being
the former plus one. The registered user defined characters can be accessed and displayed on
the screen by using FANUC code.

(2) JIS code


Also, JIS code can be assigned to the registered user defined characters.
Available codes are, from 0x20 to 0xDF for single byte characters and from 0x8140 to 0xEFDF shift
JIS codes for 2-byte characters.

The above single byte character codes are those in single byte user defined character mode
that can be selected by the sequence "ESC (8".

In case of 2-byte characters, one of the following two methods can be employed.

(1) When registering the JIS Kanji characters, which are not included in the FANUC Kanji
character set, as user defined characters.
Assuming that the character "TORA", not included in the FANUC Kanji character set, is
to be displayed on the screen, make dot pattern for the character, register it as an
user defined character, and assign the standard shift JIS code for the character "TORA"
(0x8CD5) to it. Thus, printing "TORA" by using printf() function as usual will display
the character "TORA" on the CNC screen.

(2) When registering new characters.


When registering new characters which are not included in the standard JIS Kanji character
set, any shift JIS code can be assigned to the characters. However, considering future
expansion of the FANUC Kanji character set, it is recommended to assign the codes greater
than 0xEB9F which are not used in Standard JIS Kanji character set.

3-4. How to register user defined characters

(1) Making dot pattern for a character

Make dot pattern of the user defined character referring to the section 3.2.

(2) Binary notation of the user defined character

After making dot patterns for all user defined characters, describe them in binary notation
and store in an unsigned character string.

(Example) unsigned char char_pattern[] = {


0x00, 0x03, ....
} ;

- 952 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Whole character patterns for all user defined characters to be registered have to be stored
in one unsigned character string. User defined characters cannot be registered separately. They
can only be registered all characters at one time. Put this character string in the user
application program.

(3) Procedures in user application program

Register the user defined characters by using crt_reguserchar() function.


And assign JIS codes to the characters by using crt_mapuch() function if necessary. These
procedures should be executed before any of the user defined characters are referred to in the
user application program. Also, once these procedures are executed, registered character set
will never be changed or modified by screen switching command or the like.

3-5. How to use user defined characters

(1) Specifying the character by the FANUC code

Registered user defined characters can be displayed by using crt_fchar() function. The
character code given to this function as an argument is the code automatically assigned to the
character in the order of its registration (0x4100,..).

(2) Specifying the character by JIS code

If JIS code is assigned to the user defined character by using crt_mapuch() function, standard
character output functions as putchar(), printf(),etc.,can be used to display the character.

In the case of single byte character, switch the code set to the single byte user character mode
by the sequence "ESC (8" to specify the user character.

(Example) printf( "\033(8ABC\033(4" ) ;


Display user defined characters assigned to the code 0x41,
0x42 and 0x43. "ESC (4" is the sequence to select standard mode.

In the case of 2-byte character, directly output the shift JIS code assigned to the user defined
character.

(Example)printf( "\x93\xC8\x96\xD8" ) ;
(This is Japanese string "TOCHI-GI".)
If the dot pattern of the character "TOCHI" is registered as an user defined character
and the code 0x93C8, which is the shift JIS code for the standard JIS character "TOCHI",
is assigned to the character, the character "TOCHI" can be output to the screen as if
it were included in the FANUC Kanji character set.

printf( "\xEB\xA0" ) ;
When the code greater than 0xEB9F (0xEBA0 in this case), which is vacant in shift JIS
code area, is assigned, directly specify the code.

- 953 -
3.Function References PROGRAMMING B-64303EN-3/01

Function reference

------------------------------------------------------------------------------------------
3.1 Register user character. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_reguserchar

[Syntax]
#include <crt.h>
int crt_reguserchar( unsigned int number, unsigned char *table ) ;

[Arguments]
number the number of registered user defined characters in
bytes ( 1-- 256)
table pointer to the character pattern table

[Return]
0 normal completion
1 invalid number of user defined characters

[Description]
Register the character pattern of the user defined character.

After the execution of this function, user defined characters will become available for
the user application program.

Character pattern table must be statically allocated. Such kind of usage that storing
the character pattern table in the memory area reserved by the malloc() function,
specifying the table as an argument of this function, and after that releasing the memory
area by free() function, is not allowed. The character pattern table should be defined
as, for example, usual constant data array. This is because the character table is
sometimes referred to again internally, when re-registration of the character pattern
become necessary inside the library as a result of screen switching.

- 954 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
3.2 Map user character. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_mapuch

[Syntax]
#include <crt.h>
int crt_mapuch( unsigned int code, unsigned int ucode ) ;

[Arguments]
code code to be assigned
0x0020 through 0x00DF for single byte character
0x8140 through 0xEFFF for 2-byte character (limited
to those allowed in shift JIS code)
ucode FANUC code for the user defined character
(0x4100 through 0x41FF)

[Return]
0 normal completion
1 illegal character code assigned

[Description]
Assign single byte character code or JIS Kanji code for the user defined character.

To put a character on the screen by using the assigned JIS code,select either "ESC (8"
mode (single byte mode) or "ESC (B" mode( 2 bytes mode).

This function does not check the validity of the specified charactercode. Care should
e taken not to specify wrong character codes.

- 955 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
3.3 Get CG pattern. <Main>
------------------------------------------------------------------------------------------

[Name]
crt_getcgpttn

[Syntax]
#include <crt.h>
int crt_getcgpttn( unsigned int code, unsigned char *buf ) ;

[Arguments]
code the FANUC code for the character of which the
character pattern is to be get
buf buffer area where character pattern is stored
( 16 bytes )

[Return]
0 normal completion
1 reading the character pattern is not supported by this version of Hardware

[Description]
Read the character pattern data stored in the character generator.

This function does not check the validity of the specified character code. Care should
be taken not to specify wrong character codes.

- 956 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3-6. Sample application program

#define UCH_NUM 10 /* number of defined characters( single byte equivalent) */

/* Character pattern */
unsigned char pattern[ UCH_NUM * CHAR_SIZE_14 ] = {
0x00,0x3F,0x02,0x02,0x02,0x3F,0x22,0x22, /* 0x4100 */
0x22,0x22,0x22,0x3F,0x02,0x02,0x02,0x7F,
0x00,0xFE,0x20,0x20,0x20,0xFE,0x22,0x22, /* 0x4101 */
0x22,0x22,0x22,0xFE,0x20,0x20,0x20,0xFF,
0x00,0x01,0x3C,0x24,0x24,0x25,0x25,0x25, /* 0x4102 */
0x25,0x25,0x25,0x25,0x3C,0x00,0x00,0x03,
0x00,0xFE,0x48,0x48,0x48,0xCE,0x02,0x02, /* 0x4103 */
0x02,0x02,0x02,0xCE,0x48,0x48,0x48,0xFF,
0x10,0x10,0x10,0x7E,0x12,0x12,0x12,0x22, /* 0x4104 */
0x22,0x24,0x24,0x14,0x08,0x14,0x22,0x41,
0x10,0x10,0x10,0xFE,0x10,0x10,0x10,0xFF, /* 0x4105 */
0x00,0x10,0x10,0xFE,0x10,0x10,0x10,0xFF,
0x00,0x3E,0x22,0x22,0x24,0x24,0x28,0x24, /* 0x4106 */
0x22,0x22,0x22,0x22,0x3C,0x20,0x20,0x20,
0x00,0xFF,0x02,0x02,0x02,0xFA,0x8A,0x8A, /* 0x4107 */
0x8A,0x8A,0x8A,0xFA,0x02,0x02,0x02,0x0E,
0x00,0x00,0x7F,0x00,0x1F,0x10,0x10,0x10, /* 0x4108 */
0x1F,0x02,0x04,0x1C,0x64,0x04,0x07,0x1C,
0x80,0x80,0xFF,0x00,0xFC,0x04,0x04,0x04, /* 0x4109 */
0xFC,0x80,0x44,0x48,0x30,0x10,0x8C,0x03,
} ;

/* Registering the Character pattern */


crt_reguserchar( UCH_NUM, pattern ) ;

/* Assigning character code */


crt_mapuch( 0xEBA0, 0x4100 ) ; /* 2-byte character */
crt_mapuch( 0xEBA1, 0x4102 ) ; /* 2-byte character */
crt_mapuch( 0xEBA2, 0x4104 ) ; /* 2-byte character */
crt_mapuch( 0x41, 0x4106 ) ; /* single byte character */
crt_mapuch( 0x42, 0x4107 ) ; /* single byte character */
crt_mapuch( 0x43, 0x4108 ) ; /* single byte character */
crt_mapuch( 0x44, 0x4109 ) ; /* single byte character */

/* display user defined character */


printf( "\xEB\xA0\xEB\xA1\xEB\xA2" ) ; /* 2-byte character */
printf( "\033(8ABCD\033(4" ) ; /* single byte character */

- 957 -
3.Function References PROGRAMMING B-64303EN-3/01

4. VGA window display library

Outline of VGA window display

"VGA window" is an overlapping window provided by VGA display device. This VGA window has the
following features.

* Overlapping on any arbitrary screen such as CNC, PMC and C-EXE screen.

* Both graphics and character overlapping.

* Simultaneous updating of the base screen and VGA window screen.

* Two independent windows.

* Arbitrary size window on arbitrary position. (with a little limitation)

* Coexistence with character windows (which displayed by "win_xxx()" functions).


Character window is a part of the base screen for VGA window.

Full screen

VGA window #0

Also VGA
window is over VGA window #1
lapped on the
other window. Both character and
graphics are
overlapped.

Displaying on the base screen is not affected by any


VGA window.

- 958 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Each two VGA windows have their own screen buffers of character and graphics display It is
possible to output to the base screen during displaying VGA windows. Output operation to hidden
area of the base screen displays nothing to the real screen but writes to the screen buffer memory.
When the VGA window closed, all contents of the base screen, including on the hidden
area, are output automatically.

VGA window has the following restrictions.

* Color palettes are common with the base screen. So, if any color palette is changed in
the base screen or the VGA window, the corresponding color palette of the other screen is changed.

* The control of graphic display enabling/disabling is common with the base screen. So,
if the graphic display is disabled in the base screen, the contents of graphics in the
VGA window are disabled at the same time.

* VGA window is available on only 16-color mode, unavailable on 256-color mode. While the
following modes are specified in "_setvideomode()" function, VGA window is unavailable.

_98RES16COLOR, _98RES8COLOR, _98RESCOLOR ,_VRES256COLOR

* Size and position of VGA window are specified by character size unit.

* VGA window size (colomn x line) is limited as follows.

Total size of all opened windows <= Full screen size

* When the screen mode is changed, all VGA windows are closed automatically.

* The VGA window cannot be used together with the CNC subscreen/help screen.
To use the VGA window, set parameter NSH(No.8654#0)=1 to hide the subscreen/help screen.

* If the VGA window is used, it is impossible to use the debug function of the macro
compiler/executor. Set parameter DBG(No.9033#0)=0.

- 959 -
3.Function References PROGRAMMING B-64303EN-3/01

Using VGA window

Usually VGA window is used in the window task. It is possible to only output to VGA window
in the window task. VGA window is used in also the main task. In the following section, usages
of VGA window is described for each cases.

(A) VGA window display in the window task.

Execute the following procedures to display VGA window in the window task.

(1) Call "vwin_open()" function to open VGA window. "vwin_open()" function doesn't always
succeed. Checking the return value of this function is needed.

(2) After successful execution of "vwin_open()" function, it is enabled to output characters


to the VGA window. Character display by "printf()" function, etc. is available as same
as the ordinary screen.

(3) Call "crt_opengr()" and "_setvideomode()" functions to draw graphics.


Specify one of following video mode for "_setvideomode()".

_98RESS16COLOR, _98RESS8COLOR,
_VRES16COLOR, _VRES16EXCOLOR

After successful execution of "_setvideomode()" function, it is enabled to draw graphics


using graphic functions.

(4) Call "vwin_close()" function to close the VGA window after required displays.

Don't execute both character and graphics output before calling "vwin_open()" function and
after calling "vwin_close()" function.

Color palettes are common with the base screen. Changing color palette in the VGA window makes
changing the same color palette in the base screen, and vice versa. Especially, take care to
change and to refer the color palettes in the VGA window on the CNC and the PMC screen. To get
the contents of color palettes in the CNC screen, use "crt_getcncpalette()" function.
Also enabling/disabling graphic output status is common with the base screen.
Graphic output must always be enable in the base screen for graphic drawing in VGA window. Note,
however, that if tool path drawing is underway in tool path drawing or background drawing
processing or if a tool path that was drawn before has not been erased, enabling graphics drawing
causes the tool path to appear on the CNC screen.

Once VGA window is opened, it keeps opened until calling "vwin_close()" function by the
application program. (except in case of changing screen mode.) Call "vwin_close()" function
positively to close the VGA window by the application program.

- 960 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(B) VGA window display in the main task.

The procedures to display VGA window in the main task is basically same asin the window task.
There are some differences as follows.

(1) Once "vwin_open()" function is called, all of the following output are displayed in the
VGA window. (both character and graphics) After closing all VGA window, output is
displayed to the base screen again.

(2) Various settings about display are taken over between the base screen and the VGA window
as they are. Generally, it is necessary to re-initialize the display environment after
changing display between the base screen and the VGA window. Call "_setvideomode()"
function after opening the VGA window, "crt_setmode()" and "_setvideomode()" functions
after returning the base window from the VGA window.

(3) The opened VGA window is still displayed as it is even if the base screen is changed
to another screen (CNC screen, etc.). It is impossible to control the VGA window on the
CNC screen by the main task.
So, it is better to disable screen switching during opening the VGA window.

How to operate VGA window

(1) How to resize VGA window.

It is impossible to resize the opened VGA window. Close the VGA window by "vwin_close()"
function first, then open with new size specification again.(Redrawing is required.)

(2) How to move VGA window.

Hide the VGA window by "vwin_hide()" function once, then call "vwin_show()" function with the
new position.

(3) How to change overlapping order.

Hide the VGA window which you want display on the top by "vwin_hide()" function once, then
display it by "vwin_show()" with the same position again.

- 961 -
3.Function References PROGRAMMING B-64303EN-3/01

Function Reference

------------------------------------------------------------------------------------------
4.1 Open VGA window. <Main,Win>
------------------------------------------------------------------------------------------

[Name]
vwin_open

[Syntax]
#include <crt.h>
int vwin_open( unsigned int widx,
unsigned int posl, unsigned int posc,
unsigned int sizev, unsigned int sizeh ) ;

[Arguments]
widx VGA window index. (=0,1)
posl Line number of the upper left corner of VGA window.
(the top line in the screen = 0)
posc Column position of the upper left corner of VGA window.
(the left-end column in the screen = 0)
sizev Line size of VGA window. (=1 - LMAX)
sizeh Column size of VGA window. (=1 - CMAX)
For the 10.4-inch LCD: CMAX = 80, LMAX = 30

[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- Incorrect window index (widx).
- Specified window has been already opened.
- Incorrect position or size of window.
- The other software already uses the VGA window.

[Description]
Makes a VGA window and displays it on the screen.

A VGA window with the specified size is opened and displayed on the screen at the specified
position. It is allowed to specify position that a part of the window is put out of the
screen.

The window created by this function is selected and is put on the other window which
is already displayed.

After successful execution of this function, the following printing and drawing are
output to the window opened by this function until closing this window or the other window
is selected.

- 962 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
4.2 Close VGA window. <Main,Win>
------------------------------------------------------------------------------------------

[Name]
vwin_close

[Syntax]
#include <crt.h>
int vwin_close( unsigned int widx ) ;

[Arguments]
widx VGA window index. (=0,1)

[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- The window specified by "widx" is not opened.

[Description]
Closes the opened VGA window.

The contents of characters and graphics in the window are destroyed.

If the other VGA window is opened, that window is selected.

When all VGA windows are closed in the main task, the base screen (ordinary screen) is
selected.

- 963 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
4.3 Select VGA window. <Main,Win>
------------------------------------------------------------------------------------------

[Name]
vwin_select

[Syntax]
#include <crt.h>
int vwin_select( unsigned int widx ) ;

[Arguments]
widx VGA window index. (=0,1)

[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- The window specified by "widx" is not opened.

[Description]
Selects the specified VGA window as the target screen of character and graphics output.

After successful execution of this function, the following printing and drawing are
output to the window opened by this function until closing this window or the other window
is selected.

- 964 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
4.4 Show VGA window. <Main,Win>
------------------------------------------------------------------------------------------

[Name]
vwin_show

[Syntax]
#include <crt.h>
int vwin_show( unsigned int widx,
unsigned int posl, unsigned int posc ) ;

[Arguments]
widx VGA window index. (=0,1)
posl Line number of the upper left corner of VGA window.
(the top line in the screen = 0)
posc Column position of the upper left corner of VGA window.
(the left-end column in the screen = 0)

[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- The window specified by "widx" is not opened.
- The window specified by "widx" is not hidden window.

[Description]
Redisplays the invisible VGA window.

The specified VGA window is displayed on the specified position again.

To move VGA window on the screen, once hide the window by "vwin_hide" function, then
display with a new position by this function again.

This function doesn't select the specified VGA window.

The VGA window redisplayed by this function is put on the top.

- 965 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
4.5 Hide VGA window. <Main,Win>
------------------------------------------------------------------------------------------

[Name]
vwin_hide

[Syntax]
#include <crt.h>
int vwin_hide( unsigned int widx ) ;

[Arguments]
widx VGA window index. (=0,1)

[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- The window specified by "widx" is not opened.

[Description]
Hides the specified VGA window.

This function makes the opened VGA window invisible with keeping the window's status.
It is possible to output characters and graphics to the invisible window.

By executing "vwin_show" function to the invisible window, the contents of the window
including contents output during being hidden are redisplayed.

This function doesn't changes selection status of VGA windows.

- 966 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
4.6 Get VGA window information. <Main,Win>
------------------------------------------------------------------------------------------

[Name]
vwin_info

[Syntax]
#include <crt.h>
int vwin_info( unsigned int widx, struct vwinfo *buf ) ;

struct vwinfo {
unsigned int stat ; /* status */
unsigned int posl ; /* line position */
unsigned int posc ; /* column position */
unsigned int sizev ; /* vertical size */
unsigned int sizeh ; /* horizontal size */
} ;

[Arguments]
widx VGA window index. (=0,1)
buf Window information buffer.

[Return]
0 Successful.
Non-0 Error. (one of the following cases)
- Incorrect window index (widx).

[Description]
Gets the status information of the specified VGA window.

The position, size and status of the specified window are stored into "buf".
The meanings of each bit of the status flag "buf.stat" are as follows.

bit0 VW_OPEN = 0 Not opened.


= 1 Opened.
bit1 VW_HIDDEN = 0 Visible.
= 1 Invisible.
(VW_HIDDEN is effective when VW_OPEN=1.)
bit2 - bit15 Undefined.

- 967 -
3.Function References PROGRAMMING B-64303EN-3/01

3.7 File Operation Library

3.7.1 Using Memory Card

The application program can access a memory card which is inserted in the card slot equipped
on the LCD/MDI panel of Series 0i-D as a disk device.

To read/write a memory card, execute the following procedures.

(1) Insert a memory card into the slot.

(2) Mount the memory card as a disk device by the application program.
(Call "aux_file_mount" function.)

(3) Open files using "fopen", "fcreate" function, etc. with drive name "B:".

(4) Read/write contents of the memory card using "fgets", "fprintf",


"fread", "fwrite", etc.

(5) Close the files using "fclose" function.

(6) Unmount the memory card. (Call "aux_file_unmount" function.)

(7) Remove the memory card from the slot.

Supported memory card and format

Supported memory cards are as follows.

128 MB to 4 GB flash ATA cards and compact flash cards recommended by FANUC or purchased
from FANUC

Logical format of a memory card that this library can handle is MS-DOS format used on the generic
MS-DOS Personal computers. C Language Library doesn't support formatting function of a memory
card. It can read/write only formatted memory cards. Format memory cards using a personal
computer with
PC card slots or the boot software of Series 0i-D.

[Note]
* The drive name to access a memory card is "B:". It is fixed.
* The C application program can't access the memory card while the other software (CNC software,
etc.) is accessing it.
* The C application program may fail to access the memory card just after insertion the memory
card (for a few minutes). ("aux_file_mount" function returns "EAUTHREJ".) The CNC program
causes this problem because it always poring the card slot to detect card insertion. In this
case, the application program must retry to access.

- 968 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.7.2 Lists of Functions

ITEM NAME FUNCTION


1 aux_file_format Format specified drive
2 aux_file_mount Mount memory card.
3 aux_file_unmount Unmount memory card.
4 aux_file_memcinfo Get memory card information.

- 969 -
3.Function References PROGRAMMING B-64303EN-3/01

3.7.3 Function Reference

------------------------------------------------------------------------------------------
1. Format specified drive <Main>
------------------------------------------------------------------------------------------

[Name]
aux_file_format

[Syntax]
#include <auxfile.h>
int aux_file_format( unsigned char drive ) ;

[Arguments]
drive Drive name ( ='A' )

[Return]
0 normal completion
9 invalid drive name

[Description]
This function formats the drive specified by the argument.

Specify the name of the drive to be formatted by the argument "drive".


When formatting S-RAM disk, call this function as aux_file_format( 'A' ) ; .

When this function is called, whole data stored in the specified drive is lost.
It is not possible to format the memory card. Don’t specify the drive B.

- 970 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2. Mount memory card. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_file_mount

[Syntax]
#include <auxfile.h>
int aux_file_mount( unsigned char drive ) ;

[Arguments]
drive Drive name. ( ='B' )

[Return]
Returns 0 if successfully mounted the memory card.
If failed, returns non-0, and store one of the following values in the global variable
"errno".

Symbol Value Meaning


ENOTMOUNT 200 Failed to mount
ENOTINSERT 201 No memory card inserted.
EBATVOLDEC 202 Battery voltage is low.
ENOTSRAM 205 Not supported card. (Not S-RAM card.)
EDRIVENAME 204 Invalid drive name.
EAUTHREJ 206 The other software already uses the memory card slot.

[Description]
Mounts the memory card.

The drive name "drive" is always "B:".


After successful execution of this function, input/output functions (such as "fopen",
"fread", "remove", "fclose", etc.) are available to use.
Don't remove or re-insert the memory card after calling this function.
Use "aux_file_memcinfo" function to check whether write-protected or not.

- 971 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
The following program reads character by character from "TESTFILE.DAT" in the memory
card and writes them to the stdout.

#include <stdio.h>
#include <auxfile.h>

int example( void )


{
FILE *fp ;
signed char ch ;
int ret ;
unsigned int stat ;

ret = aux_file_mount( 'B' ) ;


if ( ret ) {
return ( ret ) ;
}
ret = aux_file_memcinfo( &stat ) ;
if ( !ret ) {
if ( stat & 0x02 ) {
printf( "Write protect. \n" ) ;
}
}

if ( ( fp = fopen( "B:\\TESTFILE.DAT", "r" ) ) != NULL ) {


if ( ( ch = fgetc( fp ) ) != EOF ) {
if ( ( ch < '\t' ) ||
( ch == 0x0B ) ||
( ch == 0x0C ) ||
( ( ch > '\r' ) && ( ch < ' ' ) ) ||
( ch == 0x7F ) ||
( (unsigned char)ch == 0x80 ) ||
( (unsigned char)ch == 0xA0 ) ||
( (unsigned char)ch > 0xFC ) ) {
ch = '.' ;
}
putchar( ch ) ;
}
fclose( fp ) ;
}
ret = aux_file_unmount( 'B' ) ;
return ( ret ) ;
}

- 972 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
3. Unmount memory card. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_file_unmount

[Syntax]
#include <auxfile.h>
int aux_file_unmount( unsigned char drive ) ;

[Arguments]
drive Drive name. ( ='B' )

[Return]
Returns 0 if successfully unmounted the memory card.
If failed, returns non-0, and store one of the following values in
the global variable "errno".

Symbol Value Meaning


ENOTMOUNT 200 Failed to mount.
ENOTINSERT 201 No memory card inserted.
EBATVOLDEC 202 Battery voltage is low.
ENOTSRAM 205 Not supported card. (Not S-RAM card.)
EDRIVENAME 204 Invalid drive name.
EAUTHREJ 206 The other software already uses the memory card slot.

[Description]
Unmounts the memory card.

The drive name "drive" is always "B:".


Call this function to finish accessing the memory card using input/output functions (such
as "fopen", "fread", "remove", "fclose", etc.).

[Example]
See example of "Mount memory card (aux_file_mount)".

- 973 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
4. Get memory card information. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_file_memcinfo

[Syntax]
#include <auxfile.h>
int aux_file_memcinfo( unsigned int *stat ) ;

[Arguments]
stat Buffer in which memory card information is stored.

[Return]
Returns 0 if successfully got the memory card information.
If failed, returns non-0.

[Description]
Reads the status of the memory card.

Call this function after mouting the memory card.


(using "aux_file_mount" function.)

The contents of "stat" are as follows.

bit0 = 0 A memory card is inserted.


1 No memory card is inserted.
bit1 = 0 Write enable.
1 Write protect.
bit5, bit4, bit3 Memory card type identification
0, 0, 1 Flash ATA card, compact flash card.
bit6 – bit15 Undefined.

[Example]
See example of "Mount memory card (aux_file_mount)".

- 974 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.8 Serial Library

3.8.1 Library outline

1. Outline

Serial Library is a set of general functions which are used to send/receive data to/from devices
via RS-232C communication interface. Character or block type data can be handled by these
functions.

[1] Protocol

start-stop synchronization transmission ( 2 channels max.)

data bits 7 or 8 bits


stop bits 1 or 2 bits
baud rate 600, 1200, 2400, 4800, 9600, 19200 bits /sec
parity check none, even, odd
none, hardware flow ctrl (CS/RS), DC code
flow control
control

- 975 -
3.Function References PROGRAMMING B-64303EN-3/01

[2] Data path

application program

Status
Tx buffer Rx buffer
check

Serial device

Application program sends data to the serial device via transmit buffer(Tx buffer) and receives
data from the serial device through receive buffer(Rx buffer). Status information is directly
read from the serial device.

- 976 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[3] Authorization to access communication channel

Each communication channels have authorization control mechanism independent of each other.
Application program has to get authorization to use a channel by calling rs_open() function,
before using the serial communication interface. If the channel is already occupied by CNC control
program or any other task, that channel can neither be opened by rs_open() nor used. It is
allowed for the application program to use two channels at the same time.
Also, two channels can be used simultaneously if one is used by application program and the other
by CNC control program. But, while CNC control program is using serial interface, generally whole
CPU resources are dedicated to the program, so that the execution of the application program
will be stopped.

When a communication channel is opened by rs_open(), the state of the signal ER becomes ON
to announce external device that the channel is ready for communication. While ER is ON, connecting
or detaching the communication cable should not be done so as not to give damage to the hardware.

When a communication channel is closed by rs_close() function, the channel is released and
becomes free for other tasks, and the signal ER becomes OFF.

[4] Flow control

Two flow control methods are supported: one uses hardware signals (CS,ER) for handshaking and
the other uses DC code for it ( referred to as "hardware flow ctrl" and " DC code flow ctrl"
respectively). Following parameters can be selected.

Hardware flow ctrl none, bi-directional


DC code flow ctrl none, bi-directional, transmit only, receive only

Usually one of the following combination is selected.

Hardware flow control DC code flow control


Flow control yes yes
Hardware flow ctrl bi-directional none
DC code flow ctrl none bi-directional

(Note) When "none" is selected for hardware flow ctrl, RS signal becomes always ON.

When "DC code flow ctrl" is selected, data transmission is controlled by the DC codes as follows.

(1) Transmission handshake

Stop or restart sending data, according to the DC code received from destination device.

DC1 received : restart sending data is requested


DC3 received : stop sending data is requested

Received DC code is not passed to the application program.

- 977 -
3.Function References PROGRAMMING B-64303EN-3/01

(2) Receiving handshake

DC code is used to request the source device to stop or restart sending data according to the
state of receiving buffer.

Send DC1 : request to restart sending data


Send DC3 : request to stop sending data

These DC1 or DC3 codes are automatically transmitted by the serial communication driver.

[5] Communication mode

Application program can select one of the three communication modes,"transmit only", "receive
only", and "transmit and receive"

(1) Transmit only mode

Only data transmission from application program to external device can take place in this mode.
Application program cannot use library functions for receiving data. Data received from external
device are ignored except DC codes.

(2) Receive only mode

Only data transmission from external device to application program can take place in this mode.
Application program cannot use library functions for sending data. All received data from external
devices are passed to application program.

(3) Transmit and receive mode

Both data sending and receiving can take place in this mode. Application program can use all
serial library functions. Received data code from external device is interpreted as follows in
accordance with the selected flow control mode.

(a) "DC code flow ctrl" is ON for transmission

DC codes included in the receiving data from external device are interpreted as flow control
characters and they are not passed to the application program.

(b) "DC code flow ctrl" is OFF for transmission

Because external device would not send DC codes to the application program for flow control
purposes in this mode, all receiving data including DC codes are passed to the application program.

- 978 -
B-64303EN-3/01 PROGRAMMING 3.Function References

In this mode, care should be taken for the relationship between flow control method and
transmitted data. When bi-directional "DC code flow ctrl" is employed, DC codes in transmitted
data, if included as data, cannot be discriminated from flow control DC characters. And these
data not only are blocked to pass to the application program but cause flow control failure.
Moreover, the DC code to announce "send stop/send restart" cannot be sent to the destination,
if "send data" is inhibited by the hardware signal. For these reasons, only text data should
be transmitted when "DC code flow ctrl" is employed. If hardware signal handshake is employed,
there is no restriction in the code of transmitted data.

2. Interface

[1] Connection

CNC Serial device

SD RD
RD SD

RS CS
CS RS

ER DR
DR ER

CD CD

SG SG
FG FG
(Cross cable)

SD : Send data [output]


RD : Receive data [input]
RS : Request to send [output]

This signal is used for flow control by hardware signal handshake. This signal requests
or allows external serial device to send data. The serial communication driver will bring
this signal OFF, when receive buffer is full. External device must not send more than
10 characters after RS is OFF.

- 979 -
3.Function References PROGRAMMING B-64303EN-3/01

CS : Clear to send [input]


This signal is used for flow control by hardware signal handshake. This signal
indicates that external serial device is requesting or allowing data to be sent.
The serial communication driver sends data while this signal is ON.

ER : Data terminal ready [output]


This signal announces that the device is ready for operation. The serial
communication driver makes this signal ON, when communication channel is
successfully opened. If receive buffer overflows, ER is brought OFF to inform
data loss to external device.

DR : Data set ready [input]


This signal indicates that external device is ready for operation. Application
program can examine the state of this signal by using status check function,
rs_status().

[2] Signal state

Only difference between "hardware flow ctrl" and "no hardware flow ctrl" is that signals CS
and DR are deemed always ON if "no hardware flow ctrl" is selected.

(1) After channel is open

hardware flow ctrl no hardware flow ctrl


SD
RD
RS ON <-
CS don't care
ER <- <-
DR ON
CD

(2) While sending data

hardware flow ctrl no hardware flow ctrl


SD send data <-
RD
RS ON <-
CS flow control don't care
ER <- <-
DR external device status ON
CD

- 980 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(3) While receiving data

hardware flow ctrl no hardware flow ctrl


SD
RD receive data <-
RS flow control(*1) ON
CS
ER error report(*2) <-
DR external device status ON
CD

(*1) RS becomes OFF when receive buffer is full and returns to ON when there
are free space in the buffer

(*2) ER becomes OFF when receive data overflows the receive buffer. This happens,
for example, when data transmission does not stop even if RS is brought
OFF to request stopping data transmission.

(4) After channel is closed

hardware flow ctrl no hardware flow ctrl


SD
RD
RS OFF <-
CS
ER <- <-
DR
CD

- 981 -
3.Function References PROGRAMMING B-64303EN-3/01

3.8.2 List of function

ITEM NAME FUNCTION


1 rs_open Initialize communication channel
2 rs_close Close communication channel
3 rs_putc Put one byte data into transmit buffer
4 rs_getc Get one byte data from receive buffer
5 rs_write Put block of data into transmit buffer
6 rs_read Get block of data from receive buffer
7 rs_buffer Test or clear transmit/receive buffer
8 rs_status Get status of communication buffer and interface
9 rs_wait Wait for communication interface event

(Note 1) Even if communication interface is in erroneous state, the serial library functions
do not return errors. The functions, rs_putc, rs_getc, rs_write, rs_read returns error
only when inadequate manipulation of send or receive buffer is attempted. To know the
state of the communication interface, use the function, rs_status().

(Note 2) The serial library functions do not check the signal, DR. It should be checked by
application program if necessary.

- 982 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.8.3 Function Reference

------------------------------------------------------------------------------------------
1. Initialize communication channel <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
rs_open

[Syntax]
#include <bios.h>
int rs_open( int channel, ser_t *param, char *mode ) ;

struct RS_PACKET {
unsigned baud ; /* baud rate */
unsigned stop_bit ; /* stop bit length */
unsigned parity ; /* parity check */
unsigned data_bit ; /* character length */
unsigned hardflow ; /* hardware flow ctrl */
unsigned dc_enable ; /* DC code flow ctrl */
unsigned dc_put ; /* send DC code */
unsigned dc1_code ; /* DC1 code */
unsigned dc2_code ; /* DC2 code */
unsigned dc3_code ; /* DC3 code */
unsigned dc4_code ; /* DC4 code */
} ;
typedef struct RS_PACKET ser_t ;

[Arguments]
channel channel number ( = 1, 2 )
param communication parameter
mode communication mode

[Return]
Returns zero if successful. If any error, returns non-zero value.

[Description]
Specified communication channel is initialized with specified condition and opened for
data transmission.

Specify channel number, 1 or 2, by the argument "channel".

- 983 -
3.Function References PROGRAMMING B-64303EN-3/01

Specify communication conditions in the structure "param".

param->baud baud rate


BAUD_0600 600 bits/sec
BAUD_1200 1200 bits/sec
BAUD_2400 2400 bits/sec
BAUD_4800 4800 bits/sec
BAUD_9600 9600 bits/sec
BAUD_19200 19200 bits/sec

param->stop_bit stop bit length


STOP_1 1 bit
STOP_2 2 bits

param->parity parity check


PARITY_N no parity check
PARITY_E even parity
PARITY_O odd parity

param->data_bit character length


DATA_7 7 bits
DATA_8 8 bits

param->hardflow hardware flow ctrl


0 no
1 both send and receive
2 send only
3 receive only

param->dc_enable DC code flow ctrl


0 no
1 both send and receive
2 send only
3 receive only

- 984 -
B-64303EN-3/01 PROGRAMMING 3.Function References

param->dc_put send DC code


0 no
1 yes

If "1" is specified for "dc_put", following DC code is sent to


the external device whenever the channel is opened or closed.

open mode when open when close


receive mode DC1 DC3
send mode DC2 DC4
send/receive mode no DC code transmitted no DC code transmitted

param->dc1_code define DC1 code (usually 0x11 )


param->dc2_code define DC2 code (usually 0x12 )
param->dc3_code define DC3 code (usually 0x13; 0x93: when using ISO code )
param->dc4_code define DC4 code (usually 0x14 )

Specify open mode of the communication interface by the argument "mode".

mode open mode


"r" receive mode
"w" send mode
"rw" send/receive mode

Every parameter must have it's value specified. If not, correct communication will not
be done.

To utilize communication function with Serial Library, "Reader/Punch Interface A" option
has to be equipped in the CNC.

If "1" is specified for param->dc_put, DC1 code(for receive mode) or DC2 code (for send
mode) is sent via communication channel.

- 985 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2. Close communication channel <Main,Alarm,Comm >
------------------------------------------------------------------------------------------

[Name]
rs_close

[Syntax]
#include <bios.h>
int rs_close( int channel ) ;

[Arguments]
channel channel number ( = 1, 2 )

[Return]
Returns zero if successful. If any error, returns non-zero value.

[Description]
Stops using specified communication channel.

If "1" is specified for param->dc_put of rs_open() function, DC3 code(for receive mode)
or DC4 code (for send mode) is sent via communication channel.

- 986 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
3. Put one byte data into transmit buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
rs_putc

[Syntax]
#include <bios.h>
int rs_putc( int c, int channel ) ;

[Arguments]
c data to be sent
channel channel number ( = 1, 2 )

[Return]
Returns "1" if successful.
Returns zero if transmit buffer is full and has no room to accept new data. Returns "-1"
if any error. The error comes from transmit buffer and has nothing to do with the state
of communication interface.

[Description]
Puts one byte data into the transmit buffer of the specified communication channel.

This function outputs data to the transmit buffer. To know if the data is actually
transmitted , read the status of the transmit buffer by “rs_buffer” function and check
the vacancy of the buffer.

- 987 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
4. Get one byte data from receive buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
rs_getc

[Syntax]
#include <bios.h>
int rs_getc( int channel ) ;

[Arguments]
channel channel number ( = 1, 2 )

[Return]
Returns a data read from receive buffer if successful. Returns "-1" if any error occurs
or if there is no data in the buffer. The error comes from receive buffer and has nothing
to do with the state of communication interface.

[Description]
Gets one byte data from the receive buffer of the specified communication channel.

- 988 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
5. Put block of data into transmit buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
rs_write

[Syntax]
#include <bios.h>
int rs_write ( char *buffer, int size, int channel ) ;

[Arguments]
buffer output data storage area
size output data size
channel channel number ( = 1, 2 )

[Return]
Returns the size of the data output to the transmit buffer if successful. If free space
of the transmit buffer is smaller than the specified data size, returned value will be
smaller than the specified data size. Returns "-1"if any error. The error comes from
the transmit buffer and has nothing to do with the state of communication interface.

[Description]
Gets specified bytes of data from the specified buffer area and puts them into the transmit
buffer of the specified channel

This function outputs data to the transmit buffer. To know if the data is actually
transmitted, read the status of the transmit buffer by rs_buffer() function and check
the vacancy of the buffer.

- 989 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
6. Get block of data from receive buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
rs_read

[Syntax]
#include <bios.h>
int rs_read ( char *buffer, int size, int channel ) ;

[Arguments]
buffer input data storage area
size input data size
channel channel number ( = 1, 2 )

[Return]
Returns the number of data bytes read from the receive buffer if successful. If size
of the data in the receive buffer is less than specified size, return value will be smaller
than specified size. Returns "-1" if any error. This error comes from receive buffer
and has nothing to do with the state of communication interface.

[Description]
Gets specified bytes of data from the receive buffer of the specified channel and puts
them into the specified buffer area.

- 990 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
7. Test or clear transmit/receive buffer <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
rs_buffer

[Syntax]
#include <bios.h>
int rs_buffer( int channel, int cmnd ) ;

[Arguments]
channel Channel number ( = 1, 2 )
cmnd buffer command

[Return]
If successful;
RS_GET_BUF_R, RS_GET_BUF_W commands return buffer size,
RS_CHK_BUF_R, RS_CHK_BUF_W commands return data size in the buffer
RS_CLR_BUF_R, RS_CLR_BUF_W commands return zero.
Returns "-1", if any error.

[Description]
Tests or clears the specified buffer of the specified channel.

Select the communication channel (1 or 2) by the argument "channel".

Specify following buffer command in the argument "cmnd".

cmnd function
RS_GET_BUF_R return receive buffer size
RS_GET_BUF_W return transmit buffer size
RS_CHK_BUF_R return data size in receive buffer
RS_CHK_BUF_W return data size in transmit buffer
RS_CLR_BUF_R clear receive buffer
RS_CLR_BUF_W clear transmit buffer

- 991 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
8. Get status of communication buffer and interface <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
rs_status

[Syntax]
#include <bios.h>
int rs_status( int channel ) ;

[Arguments]
channel channel number ( = 1, 2 )

[Return]
Returns status of the communication interface and communication buffers.

bit position Meaning


0x8000 transmission stopped (send)
0x4000 ( reserved ) (send)
0x2000 Buffer full (send)
0x1000 ( reserved ) (send)

0x0800 receiving stopped (receive)


0x0400 ( reserved ) (receive)
0x0200 Buffer empty (receive)
0x0100 Buffer overrun (receive)

0x0080 DR ON
0x0040 ( reserved )
0x0020 Framing error
0x0010 Overrun error
0x0008 Parity error
0x0004 ( reserved )
0x0002 ( reserved )
0x0001 ( reserved )

[Description]
Gets status information of the communication interface and communication buffers of the
specified channel.

- 992 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
9. Wait for communication interface event <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
rs_wait

[Syntax]
#include <bios.h>
#include <oscall.h>
int rs_wait( int channel, int param, int mode,
unsigned long time_out ) ;

[Arguments]
channel channel number ( = 1, 2 )
param character code or number of characters
mode operation mode
time_out maximum time to wait

[Return]
Returns zero if specified condition is satisfied.
Returns "EC_TIMOUT" if time limit set by time_out has elapsed.
When mode = rtx_size, this function returns "rtx_size_ok" if the number of data bytes
in the receive buffer is greater than or equal to the specified value. When mode = trx_size,
this function returns "trx_size_ok" if the number of data bytes in the transmit buffer
is less than or equal to the specified value. Returns the value other than described
above if any error.

[Description]
Waits for the specified communication channel to become given state.

Specify the number of the channel ( 1 or 2 ) to wait for events.

Specify one of the following for the argument "mode".

mode operation mode


rtx_size wait for data to be received
trx_size wait for data to be sent
rtx_code wait for specified character to come

According to the operation mode described above, either the number of data characters
or a character code should be specified for the argument "param".

mode param
rtx_size number of data characters in the receive buffer
trx_size number of data characters in the transmit buffer
rtx_code character code

- 993 -
3.Function References PROGRAMMING B-64303EN-3/01

The maximum wait time is specified by the argument "time_out".


The unit of the wait time is Tick ( 1 Tick = 8 msec).

After this function call, the task from which this function is called is switched to
the "wait state" until specified condition is satisfied. For this reason, this function
especially suits with communication tasks.

This function is used for following purposes.

(1) Wait for transmit completion

ret = rs_wait( channel, param, trx_size, time_out ) ;

This waits for the number of untransmitted characters in the transmit buffer
to become less than or equal to the specified value given by "param".

If param = 0, above function call waits for the completion of transmission. This
is used to know that whole data is sent to the destination. By setting param
as param="Tx buffer size" - "Tx data size", above function call informs that
there is enough space in the transmit buffer to accept new data. This is useful
for efficient data transmission.

(2) Wait for data to come

ret = rs_wait( channel, param, rtx_size, time_out ) ;

This waits for the number of received characters in the receive buffer to become
greater than or equal to the specified value given by "param". This is efficient
compared to the polling method.

In case of fixed length data communication,


specify as param="packet size" to know that a set of data has been received.
If it is expected to know that a data of whatever size has been received, specify
param as "1".

(3) Wait for specified character

ret = rs_wait( channel, param, rtx_code, time_out ) ;

This function call waits for the character specified by "param" to arrive.

This function is used for the case to know the arrival of the data packet which
ends with specific code.

Above wait state finishes when receiving data ,which arrives after “rs_wait” function
is called, matches the character specified by "param".
Those data, which have arrived before the execution of this function and are not yet
read by the application, are not examined for character matching.

- 994 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Specifying the maximum wait time by "time_out" avoids application program to hang up
when no answer comes back from the external device.
There can be some problem in the communication interface when timeout error occurs.
In this case, examine the state of the interface by using “rs_buffer” function or
“rs_status” function.

- 995 -
3.Function References PROGRAMMING B-64303EN-3/01

3.9 Task management library

3.9.1 Library outline

Following functions are provided to control execution of the application programs or to manage
execution of multiple tasks.

1. Time management
2. Semaphore control
3. Event flag

1. Time management

The time management functions can suspend execution of tasks for specified period of time or
can make tasks wait for events with limited wait time option which avoids tasks to become
dead-locked. The timer which can be used by the application program is a local timer dedicated
for the task. Time unit of the timer is "Tick"(1 Tick = 8 msec).

NAME FUNCTION
os_show_tim read timer
os_set_tim set timer
os_sync_tim suspend execution of task until specified time of timer
os_wait_tim suspend execution of task for specified time period

* os_set_tim() sets specified value to the timer.


This function sets the timer of it's own task, the timer of another task cannot be
set.

* os_show_tim() reads time value from the timer of current task.

* Execution of the current task is suspended by os_sync_tim() until the timer reaches
the specified time. ( Absolute wait)

* os_wait_tim() function suspends execution of the current task for specified period
of time ,like waiting for time-out. ( Relative wait)

The time referred to in all task management library functions is based on the software-timer
of 8 msec unit. This timer is the basis of the operation of the task management programs. Note
that the contents of this timer does not always agree with the actual passage of time. This is
because the task management programs are suspended while the CNC task of higher priority is
being executed and the timer is not updated during this period.

- 996 -
B-64303EN-3/01 PROGRAMMING 3.Function References

2. Synchronization of tasks (semaphore management)

The semaphore is used to synchronize or arbitrate execution of tasks.


The semaphore consists of semaphore counter and semaphore queue. Suspended tasks which are waiting
for the semaphore to be signaled are queued in the semaphore queue, and when the semaphore is
signaled the task at the top of the queue is awaked to run. Multiple tasks can share a semaphore.

task synchronization Exclusive access control

TASK A TASK B TASK A TASK B

wait for
get release
Wait SEM Wait SEM

Signal Wait

Signal
release get

Following functions are used for semaphore management.

NAME FUNCTION
os_make_sem create semaphore
os_delt_sem delete semaphore
os_wait_sem wait until semaphore is signaled
os_sign_sem signal semaphore

* The semaphore is used to synchronize or arbitrate execution of tasks.

* The semaphore is not exclusively given to a task. (The system does not register the
task which has gotten the semaphore.) So, the semaphore can be signaled by even a task
that did not get the semaphore.

* os_make_sem() creates the semaphore.


Initial value of the semaphore counter represents total number of the tasks which can
get semaphore.

- 997 -
3.Function References PROGRAMMING B-64303EN-3/01

Waiting for signal


~~~~~~~~~~~~~~~~~~

* os_wait_sem() decrements the semaphore counter, and suspends the execution of the
calling task if the value of the semaphore counter is negative.

sem-- ==> decrement semaphore counter


if( sem < 0 ) ==> if negative counter value
==> queue the task into the semaphore queue and suspend
Wait
execution

semaphore
operation semaphore queue
counter
1 none
Wait 0 none
Wait -1 ==> ----X
Wait -2 ==> ----O----X
Wait -3 ==> ----O----O----X

Signaling semaphore
~~~~~~~~~~~~~~~~~~~

* os_sign_sem() signals the semaphore.


* If there are any suspended tasks, the task at the top of the semaphore queue is awaked
to run.

sem-- ==> increment semaphore counter


if( sem <= 0 ) ==> if counter value is 0 or negative
Ready ==> awake the task at the top of the semaphore queue

semaphore
operation semaphore queue
counter
-3 ==> ----O----O----X
Signal -2 ==> ----O----X
Signal -1 ==> ----X
Signal 0 none
Signal 1 none

- 998 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[ Example of task arbitration ]

As an example, here it is assumed that there are three sets of resources which are shared
between five tasks. The following example shows a method to manage assignment of these
resources among tasks.

Signal resources Task Queue Wait


<====== TASK-A <=== (TASK-D)==(TASK-E)==
TASK-B
TASK-C

1) Create semaphore by os_make_sem() and specify "3", which is the number of available
resource set, for the initial value of the semaphore counter.

2) Before using a set of resources, get semaphore by os_wait_sem() function.


If resources are not available, the execution of the calling task is suspended.

3) When resources have become unnecessary, release the semaphore by os_sign_sem()


function. If there are suspended tasks waiting for semaphore, the task at the top
of the queue gets semaphore and awaked from the suspended state.

In the following example, maximum three tasks can have resources assigned, and the
execution of the other tasks, for which there are no available resources, are suspended
to wait for the release of resources.

semaphore
TASK-A TASK-B TASK-C TASK-D TASK-E
counter value
3

Wait SEM 2

Wait SEM 1

Wait SEM 0
Wait SEM -1
Wait SEM
-2

Signal SEM -1

Signal SEM 0

Signal SEM 1

Signal SEM 2

Signal SEM 3

- 999 -
3.Function References PROGRAMMING B-64303EN-3/01

semaphore
TASK-A TASK-B TASK-C TASK-D TASK-E
counter value
3

Wait SEM 2

Wait SEM 1

Wait SEM 0
Wait SEM -1
Wait SEM
-2

Signal SEM -1

Signal SEM 0

Signal SEM 1

Signal SEM 2

Signal SEM 3

[Semaphore counter value (semval) and what it represents]


initial value : total number of resource sets
if semval=+n : n= number of available resource sets
if semval=-n : n= number of suspended tasks (n>=0)

- 1000 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example of task synchronization]

This is a sample case that a task is waiting for another task to complete, and assumes
that TASK-A waits for TASK-B and TASK-B waits for TASK-C. This task synchronization can
be achieved by using two semaphores.

* Priority of each task is assumed to be A>B>C (C being lowest) in the following example.

TASK-A TASK-B TASK-C SEM-D SEM-E

0 0

Wait D -1

Wait E -1

running

Signal E 0

running

Signal D 0

running

- 1001 -
3.Function References PROGRAMMING B-64303EN-3/01

[ Example of inter task communication ]

A method of sending or receiving data between tasks by means of ring buffer (or circulating
buffer) is considered in the following example.
Assume that the TASK-A writes a data into the buffer and the TASK-B reads the data from
the buffer. Writing a data into the buffer where a data is remaining unread, or reading
the buffer when no data is written, is not allowed.

Above operation is controlled by using two semaphores.

SEM C

SEM D

Wait Signal buffer(shared memory) Wait Signal

Read
TASK-A TASK-B

Write

TASK A TASK B TASK C TASK D


3 0
Wait D -1
Wait C (wait) 2
Write data
Signal D 0
Read data
Wait C (Ready) 1
Write data
Signal D 1
Wait C 0
Write data
Signal D 2
Wait C -1
Signal C 0

[semaphore counter value and what it represents]


initial value of SEM C = number of entry in the buffer
positive value of SEM C = number of available entry
positive value of SEM D = number of data written
negative value of SEM C = waiting for data to be read
negative value of SEM D = waiting for data to be written

- 1002 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3. Synchronizing tasks (Event flag)

Event flag is used to synchronize execution of tasks. The event flags relating to the specific
operation are grouped and it forms an event group.
(For example, consider a case that a task detects a signal and notifies that to other tasks.)
Maximum 32 flags can be grouped for an event group.

Execution of tasks can be suspended until the state of an event group matches a specific data
pattern.

MSB LSB

31 0

・・・・・

flag 1

:
:

flag 32

Event group
~~~~~~~~~~~

A signal can wake all of the suspended tasks of which the triggering condition is satisfied.

event flag

waiting for event


Signal

Task A Task B Task C Task D

- 1003 -
3.Function References PROGRAMMING B-64303EN-3/01

Following functions are used for event flag management.

Name Function
os_make_flg create event flag
os_delt_flg delete event flag
os_sign_flg signal event flag (modal type)
os_puls_flg signal event flag (pulse type)
os_wait_flg wait for being signaled
os_clar_flg clear event flag

(Note) The event flag signaled by modal type signal is memorized in the event flag image.
This image is retained until it is cleared by os_clar_flg().

(1) Create event flag

os_make_flg() function creates event flag.


Initial state of the event flag is OFF.

(2) Wait for being signaled

os_wait_flg() sets the wait condition and suspends execution of the calling task.
For example, to wait for the event flag 1,2,3 to become ON, specify 0x00000007 for the parameter
of os_wait_flg(). (This parameter is referred to as "wait message".) In addition, specify "AND
wait" or "OR wait" by the argument of os_wait_flg().

(a) OR wait

The execution of the calling task is suspended until at leased one of the flags 1,2 or
3 is signaled. The task is not suspended, if any of the flags 1,2 or 3 in the event flag
image is set before the function is called. (This is the case that a flag is signaled
by os_sign_flg() before.)

- 1004 -
B-64303EN-3/01 PROGRAMMING 3.Function References

Operation
~~~~~~~~~

if( wait message & image == 0 )


Wait ==> wait until "wait massage" is satisfied

image wait message


0..0000XXX 0..0000111

AND

!=0
0..0XXX NO wait

==0

wait for signal

(b) AND wait

The execution of the calling task is suspended until all three flags 1,2 and 3 are signaled.
Flags, set ON in the event flag image before the function is called, are not accounted
as flags to be waited.

For example, if flags 1 and 2 are ON in the event flag image, the task waits for only
flag 3 to be signaled.
If three flags 1,2 and 3 are all ON in the event flag image before the function is called,
the calling task is not suspended.

operation
~~~~~~~~~
wait message = ~image & wait message
if( wait message != 0 )
Wait ==> wait until "wait massage" is satisfied

- 1005 -
3.Function References PROGRAMMING B-64303EN-3/01

image wait message


0..0000XXX 0..0000111

NOT

1..1111XXX AND

==0
0..0XXX NO wait

!=0

wait for signal

(Note) Those flags signaled in the past by os_sign_flg() is memorized in the event flag
image. Whether the execution of the task is suspended or not depends on the
contents of the event flag image.

- 1006 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(3) Signaling the event flag

Functions os_sign_flg() or os_puls_flg() signals the event flag.

For example, to signal the event flag 1,2 and 3 to become ON, specify 0x00000007 for the parameter
of os_sign_flg(). (This parameter is referred to as "signal message".)

The suspended tasks which are waiting for the flags, that are specified by this function call,
to be signaled are waked.

* os_sign_flg (modal type)

os_sign_flg() memorizes the signaled flags in the event flag image.


As a result, subsequent os_wait_flg() function call specifying the signaled flags as
"wait message" would not suspend the calling task unless the event flag image is cleared.

* os_puls_flg (pulse type)

os_puls_flg() does not memorize the signaled flags in the event flag image.
Accordingly, subsequent 0s_wait_flg() function call specifying the signaled flags as
"wait message" will suspend the calling task again.

(a) Signaling the "OR waiting" task

operation
~~~~~~~~~
if( signal message & wait message != 0 )
Ready ===> waked

signal message wait message


0..0000XXX 0..0000111

AND

!=0
0..0XXX waked

==0

suspended

- 1007 -
3.Function References PROGRAMMING B-64303EN-3/01

(b) Signaling the "AND waiting" task

operation
~~~~~~~~~
wait message = ~signal message & wait message
if( wait message == 0 )
Ready ===> waked

signal message wait message


0..0000XXX 0..0000111

NOT

1..1111XXX AND

==0
0..0XXX waked

!=0

suspended

(4) Clearing the event flag

os_clar_flg() function call clears specified bit of the event flag image.

For example, to clear flag 1 ,specify "0x00000001" for the parameter of os_clar_flg(). (This
parameter is referred to as "clear message".)

operation
~~~~~~~~~
flag image = ~clear message & flag image

- 1008 -
B-64303EN-3/01 PROGRAMMING 3.Function References

clear message event flag image


0..0000001 0..0000111

NOT

1..1111110 AND

new event flag image


0..0110

(Note) Clearing the event flag image does not affect the state of suspending tasks.

- 1009 -
3.Function References PROGRAMMING B-64303EN-3/01

[Transition of flags to be waited and event flag image by signals]

Following example explains the state transition of the flags to be waited and the event
flag image when they are signaled by modal type and pulse type signaling functions.

Parameter flags to be
Function event flag image
(message) waited
os_wait_flg
11111111 11111110 00000001 (*1)
(AND wait)
↓ ↓
os_sign_flg 00000110 → 11111000 00000111 (*2)
↓ ↓
os_puls_flg 00011000 → 11100000 00000111 (*3)
↓ ↓
os_clar_flg 00000011 → 11100000 00000100 (*4)
↓ ↓
os_sign_flg 01100000 → 10000000 01100100 (*5)
↓ ↓
os_puls_flg 10000000 → 00000000 01100100 (*6)

wake up from suspended state

(*1) - os_wait_flg() specifies to wait for flags 1 to 8 to be all signaled.


However, because the flag 1 in the event flag image is already set, flag 1
is not accounted as a flag to be waited for being signaled.

(*2) - Signal the flags 2 and 3 by modal type function os_sign_flg().


- Waiting state of the flags 2 and 3 are canceled.
- It is registered in the event flag image that flags 2 and 3 are signaled.

(*3) - Signal the flags 4 and 5 by pulse type function os_puls_flg().


- Waiting state of the flags 4 and 5 are canceled.
- Flags 4 and 5 are not registered in the event flag image.

(*4) - Clear flags 1 and 2 in the event flag image.


- No change in the flags to be waited.

(*5) - Signal the flags 6 and 7 by modal type function os_sign_flg().


- Waiting state of the flags 6 and 7 are canceled.
- It is registered in the event flag image that flags 6 and 7 are signaled.

(*6) - Signal the flag 8 by pulse type function os_puls_flg().


- Waiting state of the flags 8 is canceled.
- Flag 8 is not registered in the event flag image.
- Because all the flags from 1 to 8 have been signaled and as a result there
are no flags to be waited for being signaled, suspended task wakes up and starts
running.

- 1010 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.9.2 Lists of Functions

Item Name Function


1 os_show_tim read timer
2 os_set_tim set timer
3 os_sync_tim suspend execution of task until specified time of timer
4 os_wait_tim suspend execution of task for specified time period
5 os_make_flg create event flag
6 os_delt_flg delete event flag
7 os_sign_flg signal event flag
8 os_wait_flg wait for being signaled
9 os_clar_flg clear event flag
10 os_puls_flg signal event flag (pulse type)
11 os_make_sem create semaphore
12 os_delt_sem delete semaphore
13 os_sign_sem signal semaphore
14 os_wait_sem wait until semaphore is signaled
15 os_strt_wtsk Start window task

- 1011 -
3.Function References PROGRAMMING B-64303EN-3/01

3.9.3 Function Reference

------------------------------------------------------------------------------------------
1. Read timer <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_show_tim

[Syntax]
#include <oscall.h>
void os_show_tim( unsigned long *current_timer_value ) ;

[Arguments]
current_timer_value value read from the timer

[Return]
------

[Description]
Reads current value of the timer.

The unit of the timer value is Tick while 1 Tick is 8 ms.

The time value read by this function is that of local timer dedicated for the calling
task.

The contents of the timer read by this function does not always agree with the actual
passage of time. To read the time of day, use clock() function which is more accurate.

- 1012 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
2. Set timer <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_set_tim

[Syntax]
#include <oscall.h>
void os_set_tim( unsigned long new_timer_value,
unsigned long *old_timer_value ) ;

[Arguments]
new_timer_value new timer value
old_timer_value old timer value

[Return]
------

[Description]

This function sets the specified value to the timer.

The timer set by this function is the local timer dedicated for the calling task.

The contents of the timer read by this function does not always agree with the actual
passage of time. To read the time of day, use clock() function which is more accurate.

- 1013 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
3. Suspend execution of task until specified time of timer <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_sync_tim

[Syntax]
#include <oscall.h>
unsigned short os_sync_tim( unsigned long wakeup_time ) ;

[Arguments]
wakeup_time time to wake up

[Return]
0 successful completion
EC_TIMOUT Time Out

[Description]
This function suspends the execution of the calling task until timer reaches the specified
time value.

This function cannot suspend the execution of tasks other than the calling task.

This function does not return error value, zero. When the timer reaches the specified
time, returns error value, EC_TIMOUT.

Internally, this function suspends execution of the task for a period of time
given by subtracting current time from the wakeup_time. (wakeup_time - current time)
If wakeup_time is less than current time, the task is not suspended.

Before calling this function, current time must be read by os_show_tim() function.

The maximum value of the wakeup_time is 7FFFFFFFh which corresponds to 198 days, 20 hours,
11 minutes, 9 seconds, and 180 milli seconds.

The unit of the value wakeup_time is Tick (=8 msec).

- 1014 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
4. Suspend execution of task for specified time period <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_wait_tim

[Syntax]
#include <oscall.h>
unsigned short os_wait_tim( unsigned long timeout_value ) ;

[Arguments]
timeout_value time period to wait

[Return]
0 successful completion
EC_TIMOUT Time Out

[Description]
Suspends execution of the calling task for the specified time period.

This function cannot suspend the execution of tasks other than the calling task.

This function does not return error value, zero. When specified time period is elapsed,
returns error value, EC_TIMOUT.

The calling task is suspended for the period of "timeout_value" time.

The maximum value of the timeout_value is FFFFFFFFh which corresponds to 397 days, 16
hours, 22 minutes, 18 seconds, and 360 milli seconds.

The unit of the timeout_value is Tick (=8 msec).

Note 1: The start cycle becomes waiting time when +8 msec was done from the value that
timeout_value set for 8 msec. Therefore, timeout_value=1 (waiting time 8msec)
becomes the waiting time of 16 msec. Set 0 to timeout_value when you want to
set waiting time as minimum 8 msec.
Note 2: It starts after the end of a high-ranking task is waited when a more high-ranking
task executes it even if released from the event waiting state. Therefore, the
start by the event might be delayed, and there are no guarantee at the start
cycle.

- 1015 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
5. Create event flag <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_make_flg

[Syntax]
#include <oscall.h>
unsigned short os_make_flg( unsigned char event_flag_id ) ;

[Arguments]
event_flag_id event flag ID

[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_EXSTFLG Already existing event-flag

[Description]
Creates event group with specified event flag ID.

Event group is composed of 32 event flags.

This function must be called before using event flags.

- 1016 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
6. Delete event flag <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_delt_flg

[Syntax]
#include <oscall.h>
unsigned short os_delt_flg( unsigned char event_flag_id ) ;

[Arguments]
event_flag_id event flag ID

[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag

[Description]
This function deletes the event group specified by "event_flag_id".

Error code, "EC_DELFLG", is returned to the tasks that have been waiting for the deleted
event flags to be signaled.

- 1017 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
7. Signal event flag <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_sign_flg

[Syntax]
#include <oscall.h>
unsigned short os_sign_flg( unsigned char event_flag_id,
unsigned long flag_on_message ) ;

[Arguments]
event_flag_id event flag ID
flag_on_message signal message

[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag

[Description]
Signals event flags specified by "event_flag_id" and signal message.

Signaled flags are registered in the event flag image.

- 1018 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
8. Wait for being signaled <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_wait_flg

[Syntax]
#include <oscall.h>
unsigned short os_wait_flg( unsigned char event_flag_id,
unsigned long wait_message,
unsigned short and_or, long wait_limit,
unsigned long *return_message ) ;

[Arguments]
event_flag_id event flag ID
wait_message wait message
and_or AND -- 0, OR -- 1
wait_limit Set 0.
return_message

[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag
EC_DELFLG Event-flag was deleted
EC_TIMOUT Time out

[Description]

Waits for specified signals to be signaled.

When the value of the argument "and_or" is AND_W(0), this function suspends the calling
task and waits for all the signals specified by wait_message to be signaled. This is
referred to as "AND wait" mode. Always, "0" is returned as return_message in this mode.

When the value of the argument "and_or" is OR_W(1), this function suspends the calling
task and waits for at least one of the signals specified by wait_message to be signaled.
This is referred to as "OR wait" mode. Signaled flag is returned as return_message
in this mode.

- 1019 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
9. Clear event flag <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_clar_flg

[Syntax]
#include <oscall.h>
unsigned short os_clar_flg( unsigned char event_flag_id,
unsigned long clear_message ) ;

[Arguments]
event_flag_id event flag ID
clear_message clear message

[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag

[Description]
Clears the event flag image.

This function clears the flags in the event flag image which are specified by the
clear_message.

- 1020 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
10. Signal event flag (pulse type) <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_puls_flg

[Syntax]
#include <oscall.h>
unsigned short os_puls_flg( unsigned char event_flag_id,
unsigned long puls_message ) ;

[Arguments]
event_flag_id event flag ID
puls_message signal message

[Return]
0 successful completion
EC_FLGID Event-flag ID error
EC_NXSTFLG Non-existent event-flag

[Description]
Signals the event flags specified by the puls_message argument.

Signaled flags are not registered in the event flag image.

- 1021 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
11. Create semaphore <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_make_sem

[Syntax]
#include <oscall.h>
unsigned short os_make_sem( unsigned char semaphore_id,
char initial_value ) ;

[Arguments]
semaphore_id semaphore ID
initial_value initial value of the semaphore counter

[Return]
0 successful completion
EC_SEMID Semaphore ID error
EC_EXSTSEM Already existing semaphore

[Description]
Creates a counter type semaphore.

Initial value of the semaphore counter represents the number of resources managed by
the semaphore.

- 1022 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
12. Delete semaphore <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_delt_sem

[Syntax]
#include <oscall.h>
unsigned short os_delt_sem( unsigned char semaphore_id ) ;

[Arguments]
semaphore_id semaphore ID

[Return]
0 successful completion
EC_SEMID Semaphore ID error
EC_NXSTSEM Non-existent semaphore

[Description]
Deletes semaphore.

Error code "EC_DELSEM" is returned to the tasks which have been waiting for the deleted
semaphore.

- 1023 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
13. Signal semaphore <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_sign_sem

[Syntax]
#include <oscall.h>
unsigned short os_sign_sem( unsigned char semaphore_id ) ;

[Arguments]
semaphore_id semaphore ID

[Return]
0 successful completion
EC_SEMID Semaphore ID error
EC_NXSTSEM Non-existent semaphore
EC_SEMOVF Semaphore overflow

[Description]
Signals the semaphore specified by the "semaphore_id" argument.

This function increments the semaphore counter, and runs the task at the top of the
semaphore queue if the value of the semaphore counter becomes less than or equal to zero.

- 1024 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
14. Wait until semaphore is signaled <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
os_wait_sem

[Syntax]
#include <oscall.h>
unsigned short os_wait_sem( unsigned char semaphore_id,
long wait_limit ) ;

[Arguments]
semaphore_id semaphore ID
wait_limit Set 0.

[Return]
0 successful completion
EC_SEMID Semaphore ID error
EC_NXSTSEM Non-existent semaphore
EC_DELSEM Semaphore was deleted
EC_TIMOUT Time out
EC_SEMUDF Semaphore underflow

[Description]
Waits until semaphore is signaled.

os_wait_sem() decrements the semaphore counter, and suspends the execution of the calling
task if the value of the semaphore counter is negative.

- 1025 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
15. Start window task <Main>
------------------------------------------------------------------------------------------

[Name]
os_strt_wtsk

[Syntax]
#include <oscall.h>
unsigned short os_strt_wtsk( unsigned int wghs ) ;

[Arguments]
wghs It is an argument set to be compatible with Series 16i C Language
Executor. It doesn’t have the meaning in the value of the argument.

[Return]
0 Successful.
0x010C No window task exists.
0x011B Not enough memory to start the window task.

[Description]
Starts the window task.

This function starts the window task. Until calling this function, the window task keeps
"start pending" status and is not executed.

This function must be called in the main task.

[Example]
The following program which is called in the main task starts the window task.

#include <oscall.h>
#include <stdio.h>

void example( void )


{
unsigned short ret ;
ret = os_strt_wtsk( 100 ) ;
if ( ret )
printf( "ERROR, can't start Window TASK.\n" ) ;
else
printf( "Window TASK has started.\n" ) ;
}

- 1026 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.10 FCA Library

3.10.1 Library outline

1. Outline

FCA(FANUC CASSETTE ADAPTOR) Library is a library of functions which are used to send or receive
data between CNC and FANUC's peripheral devices like FANUC Handy File or FANUC CASSETTE ADAPTOR.

[1] Function

Available functions are listed below. Note that actually available functions are limited by
the function of the connected peripheral device. For more details refer to the operating manuals
for each FCA devices.

Data Transmission : Binary, Text


File Handling : Search, Delete or Rename file
Directory Handling : Get file name and file size
Read Status : Get status of FCA devices

[2] Protocol

Following configuration is recommended.

Data bits : 8 bits


Stop bits : 2 bits
Data transmission rate : 2400, 4800(default), 9600, 19200 [bits/sec]
Parity check : none
Flow control : CNC side = Hardware control(for sending)
+ DC control(for receiving)
: FCA side = Protocol B
Data code : no conversion

- 1027 -
3.Function References PROGRAMMING B-64303EN-3/01

[3] How it works

Application

FCA Library

Serial Library

Serial Device

FCA Library controls serial devices via Serial Library.

- 1028 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[4] FCA mode

When the FCA Library Function, fca_setparam(), is called, the serial port is switched to
the FCA mode. In this mode, it is recommended not to use standard Serial Library Functions,
rs_xxx. Though these functions can be used in the FCA mode, detailed understandings of the
FCA devices are required to do that.

When a serial port is switched to the FCA mode, the port becomes being under control of
the application program and the signal "ER" becomes "ON". In this state, communication cable
should not be disconnected or connected to protect devices from hardware damage.

By calling the FCA Library Function, fca_bye(), the serial port is returned to the idle
state. That is, the port is released from the control of the application program and the
signal "ER" becomes "OFF".

fca_setparam

FCA mode
fca_bye

Idle state

rs_open

rs_close

General mode

While in FCA mode, other FCA Library Functions, fca_xxx(), can be called. If they are called
prior to the fca_setparam() function, the operation of those functions are not guaranteed.

One task can put multiple serial ports into FCA mode, but the port actually used is the one
which is specified by the last fca_setparam() function called.

- 1029 -
3.Function References PROGRAMMING B-64303EN-3/01

[5] Flow control

Though "Protocol B" is the standard protocol, the FCA Library Function does not set the
protocol automatically, because protocols other than that can also be set on the FCA devices.
Select appropriate protocol according to the setting of the connected device. As to the
setting method of the protocol,refer to the General mode function, rs_open().

[6] Communication mode

Transmit and receive mode is selected and data can be sent or received at any time when
required.

- 1030 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.10.2 List of Functions

Item Name Function


1 fca_setparam Initialize communication line.
2 fca_bye Close communication line.
3 fca_open Open a binary file on FCA device.
4 fca_close Close a binary file.
5 fca_read Read binary data from the file.
6 fca_write Write binary data to the file.
7 fca_fopen Open a text file on FCA device.
8 fca_fclose Close a text device.
9 fca_getc Read a character from the text file.
10 fca_putc Write a character to the text file.
11 fca_delete Delete a file on FCA device.
12 fca_rename Change name of a file on FCA device.
13 fca_readdir Read directory information of FCA device.
14 fca_status Read status information of FCA device.
15 fca_remains Read free space size of a floppy disk.

(Note 1) Even when an error occurs in FCA device, FCA functions do not return error status.

- 1031 -
3.Function References PROGRAMMING B-64303EN-3/01

3.10.3 Function Reference

------------------------------------------------------------------------------------------
1. Initialize communication line. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_setparam

[Syntax]
#include <bios.h>
int fca_setparam( int channel, ser_t *param ) ;

struct RS_PACKET {
unsigned baud ; /* baud rate */
unsigned stop_bit ; /* stop bit length */
unsigned parity ; /* parity check */
unsigned data_bit ; /* character length */
unsigned hardflow ; /* hardware flow ctrl */
unsigned dc_enable ; /* DC code flow ctrl */
unsigned dc_put ; /* send DC code */
unsigned dc1_code ; /* DC1 code */
unsigned dc2_code ; /* DC2 code */
unsigned dc3_code ; /* DC3 code */
unsigned dc4_code ; /* DC4 code */
} ;
typedef struct RS_PACKET ser_t ;

[Argument]
channel Channel number. ( = 1 or 2 )
param Communication parameter.

[Return]
Returns zero if successful. If any error, returns non-zero value.

[Description]
Specified communication channel is initialized with specified condition and opened for
data transmission.

When this function is called, the serial port is switched to the FCA mode. In this mode,
it is recommended not to use standard Serial Library functions, rs_xxx. Though these
functions can be used in the FCA mode, detailed understandings of the FCA devices are
required to do that. When a serial port is switched to the FCA mode, the port becomes
being under control of the application program and the signal "ER" becomes "ON". In this
state, communication cable should not be disconnected or connected to protect devices
from hardware damage.

- 1032 -
B-64303EN-3/01 PROGRAMMING 3.Function References

While in FCA mode, other FCA Library Functions, fca_xxx(), can be called. If they are
called prior to the fca_setparam() function, the operation of those functions are not
guaranteed.By calling fca_bye(), the serial port is returned to the idle state.

For the parameters set in the structure, ser_t, refer to the rs_open function. In case
"Protocol B" is used for data transmission,following settings are recommended.

param->baud = BAUD_4800 ;
param->stop_bit = STOP_2 ;
param->parity = PARITY_N ;
param->data_bit = DATA_8 ;
param->hardflow = 2 ;
param->dc_enable = 3 ;
param->dc_put = 0 ;
param->dc1_code = 0x11 ;
param->dc2_code = 0x12 ;
param->dc3_code = 0x93 ;
param->dc4_code = 0x14 ;

[Example]
Refer to the example in "Read binary data from the file. (fca_read)".

- 1033 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2. Close communication line. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_bye

[Syntax]
#include <bios.h>
int fca_bye( int channel ) ;

[Argument]
channel Channel number. (= 1, 2)

[Return]
Returns zero if successful. If any error, returns non-zero value.

[Description]
This function releases the serial port which has been put in the FCA mode by the
fca_setparam() function. Signals "RS" and "ER" of the port is set "OFF".

Call this function in the following cases.

1) When disconnecting FCA devices from the port.


2) When it become unable to recover FCA devices from error state.
3) When you use Serial Library, rs_xxx.

[Example]
Refer to the example in "Read binary data from the file. (fca_read)".

- 1034 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
3. Open a binary file on FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_open

[Syntax]
#include <bios.h>
int fca_open( char *name, int mode ) ;

[Argument]
name File name on FCA device. (max. 17 characters)
mode Access mode. (= 0: read, 1: write )

[Return]
Returns zero if successful. Returns -1 if any error occurs.

[Description]
This function opens a binary file in the FCA device under control.

This function is used in conjunction with fca_close() function.


Only functions, fca_read() and fca_write(), can be used in between fca_open() and
fca_close() functions.

When the character '#' is used for the first character of the argument "name", which
passes the file name of the FCA device, it is assumed that file number is designated.
Following formats are available.

#xxxx ( xxxx is max. 4 digit number ) : xxxxth file


#0 : first file
#N : next file
#E : last file

(Note) This function can be used only when the device connected to the port is FANUC
Handy File.It cannot be used for FANUC CASSETTE ADAPTOR etc.

[Example]
Refer to the example in "Read binary data from the file. (fca_read)".

- 1035 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
4. Close a binary file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_close

[Syntax]
#include <bios.h>
int fca_close( void ) ;

[Argument]
------

[Return]
Returns zero if successful. Returns -1 if any error occurs.

[Description]
This function closes the binary file which has been opened by fca_open() function.

This function is used in conjunction with fca_open() function.


Only functions, fca_read() and fca_write(), can be used in between fca_open() and
fca_close() functions.

(Note) This function can be used only when the device connected to the port is FANUC
Handy File.It cannot be used for FANUC CASSETTE ADAPTOR etc.

[Example]
Refer to the example in "Read binary data from the file. (fca_read)".

- 1036 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
5. Read binary data from the file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_read

[Syntax]
#include <bios.h>
int fca_read( char *buffer, unsigned int bytes ) ;

[Argument]
buffer Memory area to store read data.
bytes Number of data bytes to be read. (= 1 - 65534)

[Return]
Returns the number of data bytes actually read when successfully completed.
Returns -1 if any error occurs.

[Description]
When called this function reads data from the binary file opened by the fca_open()
function.

Because the FCA devices require the size of the transmitted data to exactly match with
the size of its unit input/output data block, it can happen, when returned from this function
call, that extra null characters ('\0') are added at the end of the data read. When a value
smaller than the specified byte count is returned, it should be assumed that the last block
of the file is read by that function call.

(Note) This function can be used only when the device connected to the port is FANUC
Handy File.It cannot be used for FANUC CASSETTE ADAPTOR etc.

- 1037 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example]
Following sample program displays the specified file in the FCA device connected to the
first channel in binary dump format.

#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
#define BUFSIZE 256

int example( void )


{
ser_t r_para ;
int ret, mode = 0, i, c ;
char name[ 18 ], buffer[ BUFSIZE ] ;
long count = 0 ;
unsigned int bytes = BUFSIZE - 2 ;

r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;

ret = fca_setparam( 1, &r_para ) ;


if ( ret ) {
printf( "error in fca_setparam\n" ) ;
return( ret ) ;
}

printf( " name?(max 17 )\n" );


scanf( "%s" , &name ) ;
ret = fca_open ( name, mode ) ;
if ( ret ) {
printf( "error in fca_open\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

for ( ;; ){
ret = fca_read( buffer, bytes ) ;
if ( ret == -1 ) {
printf( "error in fca_read\n" ) ;

- 1038 -
B-64303EN-3/01 PROGRAMMING 3.Function References

fca_close() ;
fca_bye( 1 ) ;
return( ret ) ;
}

for( i = 0 ; i < ret ; i++ ) {


c = buffer[ i ] ;
c &= 0x00ff ;
printf( "%02X", c ) ;
count++ ;
}
if ( ret < bytes ) {
printf( "\n" ) ;
printf( "ret = %d\n", ret ) ;
printf( "bytes = %d\n", bytes ) ;
printf( "ret < bytes\n", ret ) ;
break ;
}
}
printf( "\n" ) ;
printf( "%ld bytes\n", count ) ;

ret = fca_close() ;
if ( ret ) {
printf( "error in fca_close\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}

return ( ret ) ;
}

- 1039 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
6. Write binary data to the file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_write

[Syntax]
#include <bios.h>
int fca_write( char *buffer, unsigned int bytes ) ;

[Argument]
buffer Memory area to store write data.
bytes Number of data bytes to be written. (= 1 - 65534)

[Return]
Returns the number of data bytes actually written when successfully
completed. Returns -1 if any error occurs.

[Description]
This function is called to write data into a binary file opened by the fca_open() function.

Because the FCA devices require the size of the transmitted data to exactly match with
the size of its unit input/output data block, the data is padded with null characters,
'\0', when it is shorter than the unit size. As a result, it can happen that extra null
characters,'\0', are added at the end of the destination file.

(Note) This function can be used only when the device connected to the port is FANUC
Handy File. It cannot be used for FANUC CASSETTE ADAPTOR etc.

[Example]
Following sample program writes the NC part program of specified program number into
the device connected to the first channel as a file with specified name.

#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
#define BUFSIZE 256

int example( void )


{
int ret, number, i, o_num, mode = 1 ;
char name[ 18 ], c, buf[BUFSIZE+4] ;
ser_t r_para;

r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;

- 1040 -
B-64303EN-3/01 PROGRAMMING 3.Function References

r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;

ret = fca_setparam( 1, &r_para ) ;


if ( ret ) {
printf( "error in fca_setparam\n" ) ;
return ( ret ) ;
}

printf( " name?(max 17 )\n" ) ;


scanf( "%s", &name ) ;
printf( "prog. no?( ex. O1234 -> 1234 )\n" ) ;
scanf( "%d" , &o_num ) ;

ret = fca_open ( name, mode ) ;


if ( ret ) {
printf( "error in fca_open\n" ) ;
fca_bye ( 1 ) ;
return ( ret ) ;
}

ret = cnc_upstart( o_num ) ;


if ( ret ) {
printf( "error in cnc_upstart\n" ) ;
fca_close() ;
fca_bye( 1 ) ;
return ( ret ) ;
}

for (;;) {
number = BUFSIZE - 1 ;
ret = cnc_upload( (struct odbup *)(&buf), &number ) ;
if ( ret ) {
printf( "error in cnc_upload\n" ) ;
cnc_upend() ;
fca_close() ;
fca_bye( 1 ) ;
return ( ret ) ;
}
ret = fca_write( &buf[4], number ) ;
if ( ret == -1 ) {
printf( "error in fca_write\n" ) ;
cnc_upend() ;

- 1041 -
3.Function References PROGRAMMING B-64303EN-3/01

fca_close() ;
fca_bye( 1 ) ;
return ( ret ) ;
}
for ( i = 0 ; i < number ; i++ ) {
printf( "%c", buf[4+i] ) ;
}
if ( buf[4+number-1] == '%' ) {
printf( "\n" ) ;
break ;
}
}

ret = cnc_upend() ;
if ( ret ) {
printf( "error in cnc_upend\n" ) ;
fca_close() ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = fca_close() ;
if ( ret ) {
printf( "error in fca_close\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}

return ( ret ) ;
}

- 1042 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
7. Open a text file on FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_fopen

[Syntax]
#include <bios.h>
int fca_fopen( char *name, char *mode ) ;

[Argument]
name File name on FCA device. (max. 17 characters)
mode Access mode. (= "r": read, "w": write )

[Return]
Returns zero if successful. Returns -1 if any error occurrs.

[Description]
This function opens a text file in the FCA device under control.

This function is used in conjunction with fca_fclose() function.Only functions,


fca_getc() and fca_putc(), can be used in between fca_fopen() and fca_fclose() functions.

When the character '#' is used for the first character of the argument "name", which
passes the file name of the FCA device, it is assumed that file number is designated.
Following formats are available.

#xxxx ( xxxx is max. 4 digit number ) : xxxxth file


#0 : first file
#N : next file
#E : last file

(Note) When MS-DOS format is used in the FANUC Handy File, this function cannot be used.
ISO code and EIA code are the only codes that this function and fca_putc() and
fca_getc() functions can handle.

[Example]
Refer to the example in "Read a character from the text file.(fca_getc)".

- 1043 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
8. Close a text device. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_fclose

[Syntax]
#include <bios.h>
int fca_fclose( void ) ;

[Argument]
------

[Return]
Returns zero if successful. Returns -1 if any error occurrs.

[Description]
This function closes the text file which has been opened by fca_open() function.

This function is used in conjunction with fca_fopen() function.


Only functions, fca_getc() and fca_putc(), can be used in between fca_fopen() and
fca_fclose() functions.

(Note) When MS-DOS format is used in the FANUC Handy File, this function cannot be used.
ISO code and EIA code are the only codes that this function and fca_putc() and
fca_getc() functions can handle.

[Example]
Refer to the example in "Read a character from the text file. (fca_getc)".

- 1044 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
9. Read a character from the text file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_getc

[Syntax]
#include <bios.h>
int fca_getc( void ) ;

[Argument]
------

[Return]
Returns the number of characters read when successful. Return -1 if any error occurrs
or EOF is detected.

[Description]
When called, this function reads one character from the text file opened by the
fca_fopen() function.

(Note) When MS-DOS format is used in the FANUC Handy File, this function cannot be used.
ISO code and EIA code are the only codes that this function can handle.

[Example]
Following sample program reads and displays a file, character by character, from the
device connected to the first channel.

#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>

int example( void )


{
ser_t r_para ;
int ret ;
char name[ 18 ], mode = 'r', c ;

r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;

- 1045 -
3.Function References PROGRAMMING B-64303EN-3/01

r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;

ret = fca_setparam( 1, &r_para ) ;


if ( ret ) {
printf( "error in fca_setparam\n" ) ;
return( ret ) ;
}

printf( " name?(max 17 )\n" ) ;


scanf( "%s" , &name ) ;

ret = fca_fopen( name, &mode ) ;


if ( ret ) {
printf( "error in fca_fopen\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

while( ( c = fca_getc() ) != EOF ) {


if ( c != 0 ) {
printf( "%c", c ) ;
}
}
printf( "\n" ) ;

ret = fca_fclose() ;
if ( ret ) {
printf( "error in fca_fclose\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}

return ( ret ) ;

- 1046 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
10. Write a character to the text file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_putc

[Syntax]
#include <bios.h>
int fca_putc( int c ) ;

[Argument]
c A character data to be written.

[Return]
Returns the written character if successful. Returns -1 if any error occurrs.

[Description]
When called, this function writes one character into the text file opened by the
fca_fopen() function.

(Note) When MS-DOS format is used in the FANUC Handy File, this function cannot be used.
ISO code and EIA code are the only codes that this function can handle.

[Example]
Following sample program writes the NC part program of specified program number,
character by character, into the device connected to the first channel as a file with
the specified name.

#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>
#define BUFSIZE 256

int example( void )


{
int ret, number ,i ;
int o_num ;
char name[ 18 ], mode = 'w', c, buf[BUFSIZE+4] ;
ser_t r_para ;

r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;

- 1047 -
3.Function References PROGRAMMING B-64303EN-3/01

r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;

ret = fca_setparam( 1, &r_para ) ;


if ( ret ) {
printf( "error in fca_setparam\n" ) ;
return( ret ) ;
}

printf( " name?(max 17 )\n" ) ;


scanf( "%s", &name ) ;
printf( "prog. no?( ex. O1234 -> 1234 )\n" ) ;
scanf( "%d", &o_num ) ;

ret = fca_fopen( name, &mode ) ;


if ( ret ) {
printf( "error in fca_fopen\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = cnc_upstart( o_num ) ;


if ( ret ) {
printf( "error in cnc_upstart\n" ) ;
fca_fclose() ;
fca_bye( 1 ) ;
return ( ret ) ;
}

for (;;) {
number = BUFSIZE - 1 ;
ret = cnc_upload( (struct odbup *)(&buf), &number ) ;
if ( ret ) {
printf( "error in cnc_upload\n" ) ;
cnc_upend() ;
fca_fclose() ;
fca_bye( 1 ) ;
return ( ret ) ;
}

for ( i = 0 ; i < number ; i++ ) {


ret = fca_putc( buf[4+i] ) ;
if ( ret == -1 ){
printf( "error in fca_putc\n" ) ;
cnc_upend() ;
fca_fclose() ;

- 1048 -
B-64303EN-3/01 PROGRAMMING 3.Function References

fca_bye( 1 ) ;
return ( ret ) ;
}
printf( "%c", buf[4+i] ) ;
}
if ( buf[4+number-1] == '%' ) break ;
}
printf( "\n" ) ;

ret = cnc_upend() ;
if ( ret ){
printf( "error in cnc_upend()\n" ) ;
fca_fclose() ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = fca_fclose() ;
if ( ret ) {
printf( "error in fca_close()\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye()\n" ) ;
}

return ( ret ) ;
}

- 1049 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
11. Delete a file on FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_delete

[Syntax]
#include <bios.h>
int fca_delete( char *name ) ;

[Argument]
name Name of the file to be deleted. (max. 17 characters)

[Return]
Returns zero if successful. Returns -1 if any error occurrs.

[Description]
This function deletes a file from the FCA device.

When the character '#' is used for the first character of the argument "name", which
passes the file name of the FCA device, it is assumed that file number is designated.

#xxxx ( xxxx is max. 4 digit number ) : xxxxth file

[Example]
Following sample program deletes the specified file from the FCA device connected to
the first channel.

#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>

int example( void )


{
ser_t r_para ;
char name[18], steetas[2] ;
int ret, c ;

r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;

- 1050 -
B-64303EN-3/01 PROGRAMMING 3.Function References

r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;

ret = fca_setparam( 1, &r_para ) ;


if ( ret ) {
printf( "error in fca_setparam\n" ) ;
return ( ret ) ;
}

printf( "file name?(max 17 or #xxxx (file no ))\n" ) ;


scanf( "%s", &name ) ;

ret = fca_delete( name ) ;


if ( ret ) {
printf( "error in fca_delete\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = fca_status( steetas ) ;


if ( ret ) {
printf( "error in fca_status\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}
c = steetas[ 1 ] ;
c &= 0x00ff ;
printf( "status is %02X", c ) ;
c = steetas[ 0 ] ;
c &= 0x00ff ;
printf( "%02X\n", c ) ;

ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}

return ( ret ) ;
}

- 1051 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
12. Change name of a file on FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_rename

[Syntax]
#include <bios.h>
int fca_rename( char *oldname, char *newname ) ;

[Argument]
oldname Old file name. (max. 17 characters)
newname New file name. (max. 17 characters)

[Return]
Returns zero if successful. Returns -1 if any error occurrs.

[Description]
This function changes the name of the file in the FCA devices.

[Example]
Following sample program changes the name of the specified file in the device connected
to the first channel.

#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>

int example( void )


{
ser_t r_para ;
char oldname[18], newname[18], steetas[2] ;
int ret, c ;

r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;

- 1052 -
B-64303EN-3/01 PROGRAMMING 3.Function References

ret = fca_setparam( 1, &r_para ) ;


if ( ret ) {
printf( "error in fca_setparam\n" ) ;
return ( ret ) ;
}

printf( "old name?(max 17 )\n" ) ;


ret = scanf( "%s", &oldname ) ;
printf( "new name?(max 17 )\n" ) ;
ret = scanf( "%s", &newname ) ;

ret = fca_rename( oldname, newname ) ;


if ( ret ) {
printf( "error in fca_rename\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}

ret = fca_status( steetas ) ;


if ( ret ) {
printf( "error in fca_status\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}
c = steetas[ 1 ] ;
c &= 0x00ff ;
printf( "status is %02X", c ) ;
c = steetas[ 0 ] ;
c &= 0x00ff ;
printf( "%02X\n", c ) ;

ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}

return ( ret ) ;
}

- 1053 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
13. Read directory information of FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_readdir

[Syntax]
#include <bios.h>
int fca_readdir( fca_dir *buffer, int ndir, int NFILE ) ;

typedef struct {
char file_name[18] ;/* file name (max. 17 alpha numeric */
/* characters+null) */
/* first byte:0xFF->not used */
/* :0x00->deleted file */
char file_size[9] ; /* file size(8 digit + null character) */
char wrt_protect ; /* write protect */
/* 'P'-> ON */
/* ' '-> OFF */
char record_code ; /* code */
/* 'B'->Binary */
/* 'E'->EIA */
/* ' '->ISO */
char vol_no[3] ; /*volume number(2 digit+null character)*/
/* ' '->single volume */
char multi_vol ; /* multi volume */
/* ' '->single volume */
/* 'C'->succeeding volume exists */
/* 'L'->last volume */
} fca_dir;

[Argument]
buffer Pointer to the buffer which directory information is stored in.
ndir Starting file number.
NFILE Number of files to read.

[Return]
Returns the number of directory information read if successful.
Returns -1 if any error occurrs.

[Description]
This function acquires the directory information from the FCA devices.

Follow the procedure below, to use this function.

(1) Call the function with the argument (buffer,ndir,NFILE) specified as (NULL,1,0).

- 1054 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(2) The number of directory information from the "ndir"th file to the last file is given
as the return value. Allocate memory area sufficient to store above directory
information and specify the pointer to this memory area as the argument "buffer".
(3) Call this function again with the number of directory information given in (2)
specified as the argument "NFILE".

(Note) When using MS-DOS format on FANUC Handy File, information other than file name
and file size are not valid, and file size value differs from the value gotten
when read by personal computer.

[Example]
Following sample program acquires and displays the directory information of the device
connected to the first channel.

#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>

int example( void )


{
ser_t r_para ;
int i, n, ret ;
fca_dir buf[1] ;

r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;
r_para.dc4_code = 0x14 ;

ret = fca_setparam( 1, &r_para ) ;


if ( ret ) {
printf( "error in fca_setparam\n" ) ;
return( ret ) ;
}

ret = fca_readdir( NULL, 1, 0 ) ;


if ( ret == -1 ) {
printf( "error in fca_readdir 1\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;

- 1055 -
3.Function References PROGRAMMING B-64303EN-3/01

printf ( "file num = %d\n", ret ) ;


printf ( "+--+-----------------+--------+-+-+--+-+\n" ) ;
n = ret ;

for ( i = 0 ; i < n ; i++ ) {


ret = fca_readdir( &buf[0], i + 1, 1 ) ;
if ( ret == -1 ) {
printf( "error in fca_readdir 2\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}
else{
printf( " %02d %-17s %-8s %c %c %-2s %c\n"
, i+1
, buf[0].file_name
, buf[0].file_size
, buf[0].wrt_protect
, buf[0].record_code
, buf[0].vol_no
, buf[0].multi_vol ) ;
}
}

ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}

return ( ret ) ;
}

- 1056 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
14. Read status information of FCA device. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_status

[Syntax]
#include <bios.h>
int fca_status( char *buffer ) ;

[Argument]
buffer Memory area to store status information.
(Two bytes are required for this area.)

[Return]
Returns zero if successful. Returns -1 if any error occurrs.

[Description]
This function reads status information of the FCA devices.

Followings are the contents of the status data.


First byte: status information
7 6 5 4 3 2 1 0

SD 0 PT ERROR CODE

0: write protect OFF


1: write protect ON

0: completed sending whole data of a file


1: being sending data of a file

* For 'ERROR CODE', refer to the ERROR CODE TABLE.


The error code corresponding to the latest error is read as "ERROR CODE".

Second byte: type of Floppy Disk


7 6 5 4 3 2 1 0

- - - C5 - C3 C2 -

0 0 1 : single sided double density(1D)


0 1 0 : double sided double density(2D)
1 0 0 : double sided high density (2HD)

(Note) It can happen that "ERROR CODE" does not indicate correct error code.

- 1057 -
3.Function References PROGRAMMING B-64303EN-3/01

ERROR CODE TABLE


ERROR CODE CAUSE
---------------+-----------------------------------
00000(= 0) no error
00001(= 1) file search error
00010(= 2) (not used)
00011(= 3) (not used)
00100(= 4) (not used)
00101(= 5) (not used)
00110(= 6) (not used)
00111(= 7) record size over
01000(= 8) (not used)
01001(= 9) protocol error
01010(=10) (not used)
01011(=11) (not used)
01100(=12) write protect error
01101(=13) (not used)
01110(=14) (not used)
01111(=15) overrun, flaming error
10000(=16) (not used)
10001(=17) FD hard error
10010(=18) RAM error
10011(=19) ROM sum check error
10100(=20) volume sequence error
10101(=21) format error
10110(=22) label error
10111(=23) door open
11000(=24) (not used)
11001(=25) (not used)
11010(=26) code error
11011(=27) (not used)
11100(=28) file read error
11101(=29) drive not ready
11110(=30) system error
11111(=31) power off error

[Example]
Refer to the example in "Delete a file on FCA device.(fca_delete)".

- 1058 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
15. Read free space size of a floppy disk. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
fca_remains

[Syntax]
#include <bios.h>
int fca_remains( long *remains ) ;

[Argument]
remains Memory area to store the amount of remaining free space of Floppy Disk.

[Return]
Returns zero if successful. Returns -1 if any error occurrs.

[Description]
This function reads the amount of remaining free space (byte count of the free space)
in Floppy Disk.

(Note) When using MS-DOS format on FANUC Handy File, file size differs from that given
by a personal computer.

[Example]
Following sample program reads and displays the amount of remaining free Tsapce in the
Floppy Disk connected to the first channel.

#include <stdio.h>
#include <crt.h>
#include <data.h>
#include <bios.h>

int example( void )


{
int ret ;
ser_t r_para ;
long remains = 0 ;

r_para.baud = BAUD_4800 ;
r_para.stop_bit = STOP_2 ;
r_para.parity = PARITY_N ;
r_para.data_bit = DATA_8 ;
r_para.hardflow = 2 ;
r_para.dc_enable = 3 ;
r_para.dc_put = 0 ;
r_para.dc1_code = 0x11 ;
r_para.dc2_code = 0x12 ;
r_para.dc3_code = 0x93 ;

- 1059 -
3.Function References PROGRAMMING B-64303EN-3/01

r_para.dc4_code = 0x14 ;

ret = fca_setparam( 1, &r_para ) ;


if ( ret ) {
printf( "error in fca_setparam\n" ) ;
return ( ret ) ;
}

ret = fca_remains( &remains ) ;


if ( ret ) {
printf( "error in fca_remains\n" ) ;
fca_bye( 1 ) ;
return ( ret ) ;
}
printf( " remains = %ld\n", remains ) ;

ret = fca_bye( 1 ) ;
if ( ret ) {
printf( "error in fca_bye\n" ) ;
}

return ( ret ) ;
}

- 1060 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.11 F-ROM Library

3.11.1 Library outline

Included in the F-ROM Library are the functions which are used to read the data files for the
C Language Executor that are stored in the Flush ROM Module for Series 0i-D (referred to as "F-ROM"
hereafter). The data file for the C Language Executor (referred to as "C Language Executor data
file" hereafter) is the file with the format which can be read by the C Language Executor
applications.
There are following three types of C Language Executor related files which are stored in the
F-ROM.

(1) C Language Executor program

This type is a conventional C Language Executor program file.

C Language Executor
program

The contents of this file is a C Language Executor application program which is compiled and
converted to the memory card format file.

- 1061 -
3.Function References PROGRAMMING B-64303EN-3/01

(2) C Language Executor program + C Language Executor data file

This type is composed of a C Language Executor program file and C Language Executor data files
combined together.

C Language Executor
program

Data file
directory entry

Data file 1

Data file 2

:
:
:

Data file n

A C Language Executor application program is compiled and converted to the memory card format
file. Then, Data files are combined to the C Language Executor program file by executing
"dat2mem.com". When power is applied to the CNC, only program part of this type of file is
loaded into D-RAM to run.

- 1062 -
B-64303EN-3/01 PROGRAMMING 3.Function References

(3) C Language Executor data file

This type is composed of C Language Executor data files.

Data file
directory entry

Data file 1

Data file 2

:
:
:

Data file n

"dat2mem" combines multiple data files into a file and converts it to Memory_Card format file.
The C Language Executor data file is not loaded into D-RAM in CNC.

For details on creating a memory card file, see Section 5.5, "Dat2mem utility manual" in
Part II, "PROGRAMMING".

- 1063 -
3.Function References PROGRAMMING B-64303EN-3/01

3.11.2 List of functions

Item Name Function


1 aux_from_open Open the specified F-ROM file.
2 aux_from_close Close the F-ROM file.
3 aux_from_select Select data in the F-ROM file.
4 aux_from_moveptr Move read pointer.
5 aux_from_read Read data from the F-ROM file.
6 aux_from_getdir Read directory information of a F-ROM file.
7 aux_from_getinfo Read F-ROM file information.
8 aux_from_getc Read a character from the F-ROM file.
9 aux_from_gets Read a line from the F-ROM file.

- 1064 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.11.3 Function reference

------------------------------------------------------------------------------------------
1. Open the specified F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_open

[Syntax]
#include <bios.h>
int aux_from_open( char *filename, char *mode ) ;

[Arguments]
filename Specify the name of the C Language Executor file in F-ROM to open.
mode Specify access mode.
Mode should always be read mode, "r".

[Return]
0 : Successful.
-3 : The aux_from_open function has opened the F-ROM file.
This value is also returned when MANUAL GUIDEi executes this function while
accessing the F-ROM file.
-5 : The F-ROM file having the specified file name is not present.
-10 : Access was denied because another function was accessing the F-ROM file.
1 : A mode other than read mode "r" was specified for mode.

[Description]
This function opens a C Language Executor file in the F-ROM and makes it ready to be
read.

The F-ROM file which can be opened by this function is C Language Executor file only.
Following F-ROM file names can be specified.

* "CEX x.xM" ( specify either "1.0", "1.5", "2.0", "2.5", "3.0", "3.5","4.0", "6.0",
for "x.x" )

* "CEX?xxxx" ('?' represents a numeric character from '0' to '9')


("xxxx" represents max. 4 alpha-numeric characters)

F-ROM file name has to be specified only by upper case letters. Also, the name should
be specified in exactly eight characters. In case a file name is shorter than 8 characters,
add space characters (20H) to make it 8 character long.

- 1065 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2. Close the F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_close

[Syntax]
#include <bios.h>
int aux_from_close( void ) ;

[Arguments]
------

[Return]
Returns zero if successful. Returns non-zero value if any error occurs. Error occurs
in the following case.
* When no F-ROM file is opened by aux_from_open() function.

[Description]
This function closes an opened C Language Executor file.

- 1066 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
3. Select data in the F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_select

[Syntax]
#include <bios.h>
int aux_from_select( char *name ) ;

[Arguments]
name Specify file name to be selected.

[Return]
Returns zero if successful. Returns non-zero value if any error occurs. Error occurs
in the following case.
* When specified file does not exist.

[Description]
This function selects one of the data files in the C Language Executor data file.

File name argument is specified according to the MS-DOS 8.3 format.

- 1067 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
4. Move read pointer. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_moveptr

[Syntax]
#include <bios.h>
int aux_from_moveptr( long offset, int origin ) ;

[Arguments]
offset Byte count from base point.
origin Base point, see description.

[Return]
Returns zero if successful. Returns non-zero value if any error occurs. Error occurs
in the following cases.
* When pointer is moved backward beyond top of file
* When pointer is moved forward beyond end of file.

[Description]
This function moves the position of the read pointer on currently selected file.

Pointer can be moved to any position.


Specify the base point for move by "origin" as follows.

FROM_SEEK_CUR current pointer position


FROM_SEEK_END end of file
FROM_SEEK_SET top of file

Moving pointer forward beyond end of file or backward beyond top of file causes error.

- 1068 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
5. Read data from the F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_read

[Syntax]
#include <bios.h>
int aux_from_read( unsigned char *buffer, unsigned int size ) ;

[Arguments]
buffer Buffer area to store read data.
size Size of the data to be read.

[Return]
Returns size of the data being read if successful. Returns zero if any error occurs.

[Description]
This function reads data from the selected data file and stores the data in the specified
buffer area.

Before calling this function, a data file, which data is read from, must be selected
by aux_from_select() function.

- 1069 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
6. Read directory information of a F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_getdir

[Syntax]
#include <bios.h>
int aux_from_getdir( struct infodir *buf, unsigned int *num ) ;

struct infodir {
char name[13] ; /* file name */
char reserve_1[3] ; /* reserved(not used) */
unsigned long address ; /* address of the first byte of
the file */
unsigned long size ; /* file size */
char reserve_2[8] ; /* reserved(not used) */
} ;

[Arguments]
buf Area to store directory information.
num Area to store the number of directory entry.

[Return]
Returns zero if successful, and returns non-zero value if any error occurs.

[Description]
This function reads the directory information contained in C Language Executor data file.

When "NULL" is specified for "buf", only the number of directory entry is read and stored
in "num".
Directory information for one data file occupies 32 bytes.

- 1070 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
7. Read F-ROM file information. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_getinfo

[Syntax]
#include <bios.h>
int aux_from_getinfo( char *name ) ;

[Arguments]
name C Language Executor file name in the F-ROM.

[Return]
Returns following value if successful.
CEXEC C Language Executor program file
CEXEC_DATA C Language Executor program file + C Language Executor data file
C_DATA C Language Executor data file
If the specified file is absent or inappropriate for C Language
Executor, this function returns -1.

[Description]
This function reads information about files stored in the F-ROM.

There are following three types of C Language Executor files which is stored in the F-ROM.
This function gives the type of the specified file.

(1) C Language Executor program file


This type is a Conventional C Language Executor program file.
(2) C Language Executor program + C Language Executor data file
Conventional C Language Executor program file and multiple C Language Executor
data files are combined.
(3) C Language Executor data file
Data files for C Language Executor.

"name" specifies the name of the F-ROM file.


Following names can be specified as F-ROM file name.

* "CEX x.xM" ( specify either "1.0", "1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "5.0",
"6.0", for "x.x" )

* "CEX?Xxxx" ('?' represents a numeric character from '0' to '9')


("xxxx" represents max. 4 alpha-numeric characters)

F-ROM file name has to be specified only by upper case letters. Also, the name should
be specified in exactly eight characters. In case a file name is shorter than 8 characters,
add space characters (20H) to make it 8 character long.

- 1071 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
8. Read a character from the F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_getc

[Syntax]
#include <bios.h>
unsigned int aux_from_getc( void ) ;

[Arguments]
------

[Return]
Return the character being read if successful. Returns 0xFF if any error occurs.

[Description]
This function gets one character from selected data file.

This function replaces line termination code, "Carriage Return + Line Feed ( CR + LF)",
with single Line Feed character LF.
When error occurs or end of file is detected, 0xFF is returned.
Before calling this function, a data file, which data is read from, must be selected
by aux_from_select() function.

- 1072 -
B-64303EN-3/01 PROGRAMMING 3.Function References

------------------------------------------------------------------------------------------
9. Read a line from the F-ROM file. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_from_gets

[Syntax]
#include <bios.h>
int aux_from_gets( unsigned char *buffer, unsigned int size ) ;

[Arguments]
buffer Buffer area to store data being read.
size Data size to be read.

[Return]
Returns zero if successful. Returns -1 if any error occurs.

[Description]
This function reads one line of data from the selected data file and stores the data
in the specified buffer area.

A line is made up with all characters read before Line Feed character ('\n').
Line Feed character being read is stored in the buffer.
A NULL character ('\0') is added at the end of the line.
Reading character continues until Line Feed character ('\n) is encountered, end of file
is detected or "size - 1" number of characters are read. This function replaces line
termination code,
"Carriage Return + Line Feed (CR + LF)", with single Line Feed character LF.

Before calling this function, a data file, which data is read from, must be selected
by aux_from_select() function.

- 1073 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example 1]
/*
Select a file, TEST02.DAT, read and display 10 bytes of data from the beginning of the
file. Then move read pointer 50 bytes ahead of current position, and read and display
50 bytes of data.

Used functions : aux_from_open , aux_from_close , aux_from_select


aux_from_read , aux_from_moveptr

*/
void sample1(){

int i, ret ;
unsigned char read_buf[SIZE] ;
int read_size, offset ;

if ( aux_from_open( "CEX 1.0M", "r" ) ) {


printf( "Failed opening file\n" ) ;
}
else {
if ( aux_from_select( "TEST02.DAT" ) ) {
printf( "specified file not exist\n" ) ;
}
else {
read_size = 10 ;
ret = aux_from_read( read_buf, read_size ) ;
if (ret != 0 ) {
for ( i=0 ; i<ret ; i++) {
printf( "%c", read_buf[i] ) ;
}
}
printf( "\n---move pointer---\n" );
offset = 50 ;
if ( aux_from_moveptr( offset, FROM_SEEK_CUR ) ) {
printf( "Failed moving pointer\n" ) ;
}
else {
read_size = 50 ;
ret = aux_from_read( read_buf, read_size ) ;
if (ret != 0 ) {
for ( i=0 ; i<ret ; i++) {
printf( "%c", read_buf[i] ) ;
}
}
}
}
aux_from_close() ;
}
}

- 1074 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example 2]
/*
Open F-ROM file of combined C Language Executor program file and C Language Executor
data file and display directory list.

Used functions : aux_from_open , aux_from_close , aux_from_getdir

*/
void sample2() {

int dir_num, ret , i ;


typedef infodir *dirarea ;
dirarea dir_area ;

printf( "List directory information\n" ) ;

if ( aux_from_open( "CEX 1.0M", "r" ) ) {


printf( " Failed opening file\n" ) ;
}
else {
if ( aux_from_getdir( (infodir *)NULL, &dir_num ) ) {
printf( "No directory information found\n" ) ;
}
else {
if ( dir_num > 0 ) {
printf( " --- directory list --- : %d file[s]\n", dir_num ) ;
dir_area =(infodir *)malloc( 32 * (dir_num) ) ;
if ( dir_area != 0 ) {
if ( aux_from_getdir( dir_area, &dir_num ) ) {
printf( "ERROR\n" ) ;
}
else {
while ( dir_num > 0 ) {
printf ( "%10s \n", &(dir_area->name) ) ;
dir_num-- ;
(unsigned int)dir_area += 32 ;
}
}
}
else {
printf( "Could not allocate memory\n " ) ;
}
}
}
aux_from_close() ;
}
}

- 1075 -
3.Function References PROGRAMMING B-64303EN-3/01

[Example 3]
/*
Get information of F-ROM file CEX 1.0M, and display.

Used function : aux_from_getinfo

*/
void sample3() {

int file_type ;

printf( "Showing F-ROM file information\n" ) ;


file_type = aux_from_getinfo( "CEX 1.0M" ) ;
switch ( file_type ) {
case ( CEXEC ) : {
printf( "C Language Executor program \n" ) ;
break ;
}
case ( CEXEC_DATA ) : {
printf( "C Language Executor program + C Language Executor data file \n" ) ;
break ;
}
case ( C_DATA ) : {
printf( "C Language Executor data file \n" ) ;
break ;
}
default : {
printf( "ERROR !! Error code:%x \n", file_type ) ;
}
}
}

- 1076 -
B-64303EN-3/01 PROGRAMMING 3.Function References

3.12 Touch-panel Library

3.12.1 Overview of library

1. Overview

In case that the display device is "10.4-inch LCD with touch-panel", the C application can
read status of the touch-panel. The information to be read is;

Whether touch-panel is pushed or not.


The coordinate of the pushed point if pushed.

The CNC option "Touch-panel control" is required to use touch-panel library.

2. Touch-panel coordinate

The touch-panel library uses the following X-Y coordinate system whose origin is put at the
upper-left point to represent points on the touch-panel.

(0,0)

(xxxx,yyyy)

The coordinate on the touch-panel is represented as (X,Y) format using this coordinate
system.(X:horizontal position, Y:vertical position)

- 1077 -
3.Function References PROGRAMMING B-64303EN-3/01

In the 10.4-inch LCD, the whole coordinate range is (X,Y)=(0,0) - (639,479). This coordinate
corresponds with the C Language Executor screen as below.

The display screen of the C Language Executor corresponds to the coordinate range as shown below.

For the 10.4-inch LCD

(0,0)

(0,48)

B A

(639,447)

(639,479)

A: 640x480 dots (using whole screen.)

Text mode CRT_MODE_V30


Graphic mode _VRES16COLOR, _VRES16EXCOLOR, _VRES256COLOR

The touch-panel coordinate is same as the graphic coordinate (physical coordinate) for
both X and Y.

B: 640x400 dots

Text mode CRT_MODE_80X25


Graphic mode _98RESS16COLOR, _98RESS8COLOR, _98RESSCOLOR,
_98RES16COLOR, _98RES8COLOR, _98RESCOLOR

The relation of the touch-panel and the graphic (physical) coordinate is as follows.

X(touch-panel) = X(graphic)
Y(touch-panel) = Y(graphic) + 48

- 1078 -
B-64303EN-3/01 PROGRAMMING 3.Function References

The relationship between touch-panel and graphic coordinate mentioned here establishes
while the touch-panel is calibrated correctly.
If the touch-panel is not exactly calibrated, there are little differences between
display position and touch-panel coordinate.

[Note]
The touch-panel can sense only one point at a time. When multiple points are pushed
simultaneously, the center point of all pushed points (in consideration of each pressure)
is read. For example, when (100,100) and (200,300) are pushed simultaneously, touch-panel
senses that somewhere between (100,100) and (200,300) is pushed.
This is caused by the physical specification (analog sensing) of the touch-panel.

- 1079 -
3.Function References PROGRAMMING B-64303EN-3/01

3.12.2 List of Functions

Item Name Function


1 aux_tpl_read Read the status and (X,Y) coordinate of the touch-panel.
Disable the output of the key code of a soft key by the
2 aux_tpl_invalskey
touch-panel.

3.12.3 Function Reference

------------------------------------------------------------------------------------------
1. Read the status and (X,Y) coordinate of the touch-panel. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_tpl_read

[Syntax]
#include <bios.h>
int aux_tpl_read( struct tpl_xy_coord *buf ) ;

struct tpl_xy_coord {
unsigned int tpl_x_coord ; /* X-coordinate */
unsigned int tpl_y_coord ; /* Y-coordinate */
} ;

[Arguments]
buf X-Y coordinate structure of touch-panel.

[Return]
0x80 - 0x82
Touch-panel is being pushed.
0x00 Touch-panel is not being pushed, or any error occurs.

[Description]
Reads the touch-panel status and the coordinate value of the pushed point when touch-panel
is pushed.

- 1080 -
B-64303EN-3/01 PROGRAMMING 3.Function References

One of 0x80, 0x81 or 0x82 is returned as the return value when the touch-panel is pushed.
The difference of these values is as follows.

Value Status
0x80 Start pushing. (received HEAD data)
0x81 Keep pushing. (received BODY data)
0x82 End pushing. received TAIL data)

Start pushing End pushing

HEAD TAIL
BODY

The status of touch-panel is not buffered. The status at calling this function by the
application program is just returned. So, HEAD, BODY, TAIL are not exactly read as this
order according to timing of calling by the application program. Usually it is not needed
for the application program to distinguish return values, 0x80, 0x81 and 0x82. It is
possible to assume that "Touch-panel is pushed" for all return value 0x80 - 0x82. When
the return value of this function changes 0x00 -> 0x8N (N=0,1,2), assume that "start
pushing". In the same way, "0x8N -> 0x8N" is "keep pushing" and "0x8N -> 0x00" is "end
pushing".

When the touch-panel is pushed, X and Y coordinates of the pushed points are stored in
each "buf.tpl_x_coord" and "buf.tpl_y_coord" with binary format.

- 1081 -
3.Function References PROGRAMMING B-64303EN-3/01

Touch-panel without calibration

The touch-panel is used under calibrated condition usually.


"Calibrated condition" is that the calibration data is set to match the actual pushed
position with the detected coordinate. By clearing the memory of CNC (SRAM), also the
calibration data are cleared and the touch-panel is made no-calibrated condition. The
near correct pushed coordinates are read under no-calibrated condition. This function
returns the different values from the calibrated condition.

Value Status
0x88 Received HEAD data.
0x89 Received BODY data.
0x8A Received TAIL data.

That is, the bit3 of the return value indicates that the no-calibrated coordinate data
are received.

When "Touch-panel control" option doesn't exist in CNC, this function returns "0".

- 1082 -
B-64303EN-3/01 PROGRAMMING 3.Function References

[Example]
The following program wait until touch-panel is pushed, and displays coordinate of the
pushed point.

#include <bios.h>
#include <stdio.h>

void example( void )


{
struct tpl_xy_coord buf ;
int ret ;

while ( !( ret = aux_tpl_read( &buf ) ) ) ;


printf( "Touch panel is pushed at (%u,%u),",
buf.tpl_x_coord, buf.tpl_y_coord ) ;
printf( " this is " ) ;
switch ( ret & ~TPL_NOCAL ) {
case TPL_HEAD :
printf( "HEAD" ) ;
break ;
case TPL_BODY :
printf( "BODY" ) ;
break ;
case TPL_TAIL :
printf( "TAIL" ) ;
break ;
}
printf( " data.\n" ) ;
}

- 1083 -
3.Function References PROGRAMMING B-64303EN-3/01

------------------------------------------------------------------------------------------
2. Disable the output of the key code of a soft key by the touch-panel. <Main,Alarm,Comm>
------------------------------------------------------------------------------------------

[Name]
aux_tpl_invalskey

[Syntax]
#include <bios.h>
int aux_tpl_invalskey( int num ) ;

[Arguments]
num Enabling or disabling the output of the key code of a soft key by the
touch-panel

[Return]
0 Successful
1 Argument num is set incorrectly.

[Description]
This function enables or disables the output of the key code of a soft key by the
touch-panel.

The settings are as follows:

0 : Enables output.
1 : Disables output.

By default, the output of the key code of a soft key by the touch panel is enabled.

- 1084 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING
Displayable characters

4 Keycode, screen control code and


Displayable characters

- 1085 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

4.1 Keycode, screen control code

4.1.1 Keycode

0x 1x 2x 3x 4x 5x 6x 7x
x0 SP 0 @ P
x1 1 A Q
x2 2 B R
x3 # 3 C S
x4 4 D T
x5 5 E U
x6 & 6 F V
x7 7 G W
x8 CAN ( 8 H X
x9 ) 9 I Y
xA EOB * J Z
xB + K [
xC , L
xD INPUT - M ]
xE . N
xF / ? O

8x 9x Ax Bx Cx Dx Ex Fx
x0 RESET F0
x1 F1
x2 F2
x3 F3
x4 INSERT F4
x5 DELETE F5
x6 ALTER F6
x7 F7
x8 Curs→ POS F8
x9 Curs← PROG F9
xA Curs↓ HELP OFS/SET
xB Curs↑ SYSTEM
xC MESSAGE
xD GRAPH
xE Page↓ CUSTOM1 FR
xF Page↑ CUSTOM2 FL
- Usage : For example, the keycode for the key 'A' is given as "41" (hex) by combining
"4x" and "x1".
- SP stands for space(white space).
- Function keys or screen selection keys, POS .. CUSTOM2, usually cannot be read from
application program.
- Keys F0 .. F9,FR,FL are soft-keys.
- 1086 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING
Displayable characters

4.1.2 Keycode of special keys on MDI panel

(1) Cursor key, Page key

Key Symbol Code


Cursor [→] MDIKEY_CURRIGHT 0x88
Cursor [←] MDIKEY_CURLEFT 0x89
Cursor [↓] MDIKEY_CURDOWN 0x8A
Cursor [↑] MDIKEY_CURUP 0x8B
Page [↓] MDIKEY_PAGEDN 0x8E
Page [↑] MDIKEY_PAGEUP 0x8F

(2) Editing key

Key Symbol Code


[CAN] MDIKEY_CAN 0x08
[EOB] MDIKEY_EOB 0x0A
[INPUT] MDIKEY_INPUT 0x0D
[INSERT] MDIKEY_INSERT 0x94
[DELETE] MDIKEY_DELETE 0x95
[ALTER] MDIKEY_ALTER 0x96

(3) Other keys

Key Symbol Code


[RESET] MDIKEY_RESET 0x90
[HELP] MDIKEY_HELP 0x9A

- 1087 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

(4) Soft keys

[FL] [F0][F1][F2][F3][F4] [F5][F6][F7][F8][F9] [FR]

Key Symbol Code


[F0] MDIKEY_14_F0 0xF0
[F1] MDIKEY_14_F1 0xF1
[F2] MDIKEY_14_F2 0xF2
[F3] MDIKEY_14_F3 0xF3
[F4] MDIKEY_14_F4 0xF4
[F5] MDIKEY_14_F5 0xF5
[F6] MDIKEY_14_F6 0xF6
[F7] MDIKEY_14_F7 0xF7
[F8] MDIKEY_14_F8 0xF8
[F9] MDIKEY_14_F9 0xF9
[FR] MDIKEY_FR 0xFE
[FL] MDIKEY_FL 0xFF

(5) Function keys

Key Symbol Code


[POS] MDIKEY_POS 0xE8
[PROG] MDIKEY_PROG 0xE9
[OFS/SET] MDIKEY_OFFSET 0xEA
[SYSTEM] MDIKEY_SYSTEM 0xEB
[MESSAGE] MDIKEY_MESSAGE 0xEC
[GRAPH] MDIKEY_GRAPH 0xED
[CUSTOM1] MDIKEY_CUSTOM 0xEE
[CUSTOM2] MDIKEY_CUSTOM2 0xEF

- 1088 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING
Displayable characters

4.1.3 CRT display control characters

Code Symbol Function


0x08 BS Move cursor left one column.
0x09 TAB Move cursor to the next tab stop. (every 8 columns)
0x0A LF Move cursor down one line.
0x0D CR Move cursor to the beginning of the current line.
0x1B ESC Start escape sequence.
0x1E HOME Move cursor to the home position(upper left corner of the screen).

4.1.4 Display control escape sequences

(1) Cursor movement

Escape
Function
sequence
ESC [H Move cursor to the home position.
Move cursor to the c th column of the first line.
ESC [l;cH
(upper left corner of the screen is addressed as line 1, column 1)
ESC [nA Move cursor up n lines. (move 1 line if n is omitted.)
ESC [nB Move cursor down n lines. (move 1 line if n is omitted.)
ESC [nC Move cursor right n columns. (move 1 column if n is omitted.)
ESC [nD Move cursor left n columns. (move 1 column if n is omitted.)
Move cursor down 1 line. Scroll up one line if cursor is at the bottom
ESC D
line.
Move cursor to the left most column of the next line.
ESC E
Scroll up one line if cursor is at the bottom line.
ESC M Move cursor up 1 line. Scroll down one line if cursor is at the top line.
ESC [s Save current cursor position.
ESC [u Restore cursor to the position saved by "ESC [s".

(2) Deleting

Escape
Function
sequence
ESC [K Delete from current cursor position to end of line.
ESC [0K Delete from current cursor position to end of line.
ESC [1K Delete from current cursor position to beginning of line.
ESC [2K Delete current line.
ESC [J Delete from current cursor position to end of screen.
ESC [0J Delete from current cursor position to end of screen.
ESC [1J Delete from current cursor position to beginning of screen.
ESC [2J Delete whole screen.

- 1089 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

(3) Inserting/Deleting line

Escape
Function
sequence
Scroll current cursor line and succeeding lines down n lines, insert n blank
ESC [nL
lines and move cursor to the beginning of the first newly inserted blank line.
Delete n lines beginning from current cursor line to downward, scroll up
ESC [nM following lines and move cursor to the beginning of the first line of those
scrolled up.

(4) Display mode setting

Escape
Function
sequence
ESC [7h Turn on automatic wrapping around. (Default)
ESC [?7h Same as above.
ESC [7l Turn off automatic wrapping around.
ESC [?7l Same as above.
ESC [>5l Make cursor visible. (Default)
ESC [>5h Make cursor invisible.
ESC [>9l Output video signals to CRT. (Default)
ESC [>9h Not output video signals to CRT.

(5) Character attribute

Escape
Function
sequence
ESC [0m Restore default attribute. (White, no blinking, no reverse video)
ESC [5m Turn on blinking.
ESC [7m Turn on reverse video mode.
ESC [25m Turn off blinking.
ESC [27m Turn off reverse video mode.
ESC [30m Black.
ESC [31m Red.
ESC [32m Green.
ESC [33m Yellow.
ESC [34m Blue.
ESC [35m Magenta.
ESC [36m Cyan.
ESC [37m White.

- 1090 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING
Displayable characters

For VGA display device, additional escape sequences are available as follows.

Escape
Function
sequence
ESC [1m Turn on low intensity color.
ESC [2m Don't draw background part of character.
ESC [3m Turn on low intensity color for background.
ESC [21m Draw background part of character. (Default)
ESC [22m Turn off low intensity color.
ESC [23m Turn off low intensity color for background.
ESC [40m Background black.
ESC [41m Background red.
ESC [42m Background green.
ESC [43m Background yellow.
ESC [44m Background blue.
ESC [45m Background magenta.
ESC [46m Background cyan.
ESC [47m Background white.

On VGA display device, actual displayed colors for each escape sequence are defined by
setting of color palettes for character display.
The color palettes for character display are changeable by crt_setpalette function.

- 1091 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

(6) Selecting character set

Escape
Function
sequence
Select special characters and fragment set of 6x magnified numeric
ESC (1
characters.
ESC (2 Select fragment set of 6x magnified alphabetic characters.
ESC (3 Select graphic character set.
ESC (4 Select standard character set.(Default)
ESC (6 Select 6x magnified character set.
ESC (7 Select European character set (umlaut etc.)
ESC (8 Select user defined character set.
ESC (A Select JIS Kanji character set (Shift-JIS code).
ESC (B Select FANUC Kanji character set (Shift-JIS code).(Default)
ESC (C Select FANUC Kanji character set(Shift-FANUC code).
ESC (a Select JIS character set (half-size, large font).
ESC (b Select JIS character set (half-size, small font).
ESC (E Select 8.4-inch font.
ESC (F Select 10.4-inch font. (Default)

- 1092 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING Displayable characters

4.2 Displayable characters

4.2.1 Single byte characters

(1) Displayable characters

The characters, 20-7F, A0-DF, shown in the following table can be displayed on the screen.

0 1 2 3 4 5 6 7 8 9 A B C D E F
0000
0010
0020 ! " # $ % & ' ( ) * + , - . /
0030 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
0040 @ A B C D E F G H I J K L M N O
0050 P Q R S T U V W X Y Z [ ¥ ] ^ _
0060 ` a b c d e f g h i j k l m n o
0070 p q r s t u v w x y z { | } ~
0080
0090
00A0 。 「 」 、 ・ ヲ ァ ィ ゥ ェ ォ ャ ュ ョ ッ
00B0 ー ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ
00C0 タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ
00D0 ミ ム メ モ ヤ ム ヨ ラ リ ル レ ロ ワ ン ゙ ゚
00E0
00F0

(Note) Mesh mark is displayed for the character code 7F, and wave mark for A0.

Above is the code table for the standard character set. ( "ESC (4" )

(2) Control code

Following control codes are supported.

Code Symbol Function


08 BS Move cursor left one column.
09 TAB Move cursor to the next tab stop. (every 8 columns)
0A LF Move cursor down one line.
0D CR Move cursor to the beginning of the current line.
1B ESC Start escape sequence.
1E HOME Move cursor to the home position(upper left corner of the screen).

- 1093 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

4.2.2 2-byte characters

(1) JIS 1st level character set

Following KANJI characters of JIS 1st level character set are available in C Language Executor.
The characters in parentheses cannot be displayed. If these characters are output, double width
space is displayed instead. FANUC original special marks are assigned to 885F through 889D of
SJIS code. These special marks are described later.

SJIS [ JIS ] +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
8140 [2121] 、 。 , . ・ : ; ? ! ゛ ゜ ´ ` ¨ ^
8150 [2131]  ̄ _ ヽ ヾ ゝ ゞ 〃 仝 々 〆 〇 ー ― ‐ / \
8160 [2141] ~ ∥ | … ‥ ‘ ’ “ ” ( ) 〔 〕 [ ] {
8170 [2151] } 〈 〉 《 》 「 」 『 』 【 】 + - ± ×
8180 [2160] ÷ = ≠ < > ≦ ≧ ∞ ∴ ♂ ♀ ° ′ ″ ℃ ¥
8190 [2170] $ ¢ £ % # & * @ § ☆ ★ ○ ● ◎ ◇ ◆
81A0 [2222] □ ■ △ ▲ ▽ ▼ ※ 〒 → ← ↑ ↓ 〓
81B0 [2232]
81C0 [2242]
81D0 [2252]
81E0 [2262]
81F0 [2272]
8240 [2321] 0
8250 [2331] 1 2 3 4 5 6 7 8 9
8260 [2341] A B C D E F G H I J K L M N O P
8270 [2351] Q R S T U V W X Y Z
8280 [2360] a b c d e f g h i j k l m n o
8290 [2370] p q r s t u v w x y z ぁ
82A0 [2422] あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く ぐ け
82B0 [2432] げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た だ ち
82C0 [2442] ぢ っ つ づ て で と ど な に ぬ ね の は ば ぱ
82D0 [2452] ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み む め
82E0 [2462] も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ (ゐ) (ゑ)
82F0 [2472] を ん
8340 [2521] ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク グ
8350 [2531] ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ ダ
8360 [2541] チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ バ
8370 [2551] パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ
8380 [2560] ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ
8390 [2570] (ヰ) (ヱ) ヲ ン ヴ ヵ ヶ (Α)
83A0 [2622] (Β) (Γ) Δ (Ε) (Ζ) (Η) (Θ) (Ι) (Κ) (Λ) (Μ) (Ν) (Ξ) (Ο) (Π) (Ρ)
83B0 [2632] Σ (Τ) (Υ) (Φ) (Χ) (Ψ) Ω α
83C0 [2642] β γ (δ) ε (ζ) (η) θ (ι) (κ) (λ) μ (ν) (ξ) (ο) π (ρ)
83D0 [2652] (σ) (τ) (υ) φ (χ) (ψ) ω
83E0 [2662]
83F0 [2672]
8440 [2721] (А) (Б) (В) (Г) (Д) (Е) (Ё) (Ж) (З) (И) (Й) (К) (Л) (М) (Н) (О)

- 1094 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING Displayable characters

SJIS [ JIS ] +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
8450 [2731] (П) (Р) (С) (Т) (У) (Ф) (Х) (Ц) (Ч) (Ш) (Щ) (Ъ) (Ы) (Ь) (Э) (Ю)
8460 [2741] (Я)
8470 [2751] (а) (б) (в) (г) (д) (е) (ё) (ж) (з) (и) (й) (к) (л) (м) (н)
8480 [2760] (о) (п) (р) (с) (т) (у) (ф) (х) (ц) (ч) (ш) (щ) (ъ) (ы) (ь) (э)
8490 [2770] (ю) (я)
84A0 [2822]
84B0 [2832]
84C0 [2842]
84D0 [2852]
84E0 [2862]
84F0 [2872]
8840 [2F21]
8850 [2F31] 01
8860 [2F41] 02 03 04 05 06 07 08 09 10 11 12 13 14
8870 [2F51] 15 16 17
8880 [2F60] 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
8890 [2F70] 34 35 36 37 38 39 40 41 42 43 44 45 46 47 亜
88A0 [3022] (唖) (娃) 阿 哀 愛 挨 (姶) 逢 (葵) (茜) (穐) 悪 握 (渥) 旭 (葦)
88B0 [3032] 芦 (鯵) (梓) 圧 斡 扱 宛 (姐) (虻) (飴) (絢) (綾) (鮎) (或) (粟) (袷)
88C0 [3042] 安 (庵) (按) 暗 案 闇 鞍 (杏) 以 伊 位 依 偉 囲 (夷) 委
88D0 [3052] 威 尉 (惟) 意 慰 易 椅 為 (畏) 異 移 維 緯 胃 萎 衣
88E0 [3062] (謂) 違 遺 医 井 (亥) 域 育 郁 (磯) 一 壱 (溢) 逸 稲 (茨)
88F0 [3072] 芋 (鰯) (允) 印 (咽) 員 因 姻 引 飲 (淫) (胤) (蔭)
8940 [3121] 院 陰 隠 韻 (吋) 右 宇 (烏) 羽 (迂) 雨 (卯) (鵜) (窺) (丑) (碓)
8950 [3131] (臼) 渦 嘘 唄 (欝) (蔚) (鰻) (姥) (厩) 浦 瓜 (閏) 噂 (云) 運 雲
8960 [3141] (荏) (餌) (叡) 営 (嬰) 影 映 (曳) 栄 永 泳 洩 (瑛) (盈) (穎) (頴)
8970 [3151] 英 衛 詠 鋭 液 疫 益 駅 悦 謁 越 閲 (榎) (厭) 円
8980 [3160] 園 (堰) (奄) 宴 延 (怨) (掩) 援 沿 演 炎 (焔) 煙 (燕) 猿 縁
8990 [3170] (艶) (苑) (薗) 遠 鉛 (鴛) 塩 (於) 汚 (甥) 凹 央 奥 往 応 押
89A0 [3222] (旺) 横 欧 殴 王 翁 (襖) (鴬) (鴎) 黄 岡 沖 (荻) 億 屋 憶
89B0 [3232] 臆 (桶) 牡 乙 (俺) 卸 恩 温 穏 音 下 化 仮 何 (伽) 価
89C0 [3242] 佳 加 可 (嘉) 夏 嫁 家 (寡) 科 暇 果 架 歌 河 火 (珂)
89D0 [3252] 禍 (禾) 稼 箇 花 (苛) (茄) 荷 華 菓 (蝦) 課 (嘩) 貨 (迦) 過
89E0 [3262] (霞) 蚊 (俄) (峨) 我 牙 画 (臥) 芽 (蛾) 賀 雅 餓 (駕) 介 会
89F0 [3272] 解 回 塊 壊 廻 快 怪 悔 (恢) 懐 戒 拐 改
8A40 [3321] (魁) (晦) 械 海 灰 界 皆 絵 (芥) (蟹) 開 階 貝 (凱) 劾 外
8A50 [3331] (咳) 害 (崖) 慨 概 涯 (碍) (蓋) 街 該 (鎧) (骸) (浬) (馨) (蛙) 垣
8A60 [3341] (柿) (蛎) (鈎) (劃) 嚇 各 (廓) 拡 (撹) 格 核 殻 獲 確 穫 覚
8A70 [3351] 角 (赫) 較 郭 閣 隔 革 学 岳 楽 額 (顎) 掛 笠 樫
8A80 [3360] (橿) (梶) (鰍) 潟 割 喝 (恰) 括 活 渇 滑 (葛) 褐 轄 且 (鰹)
8A90 [3370] (叶) (椛) (樺) (鞄) 株 (兜) (竃) (蒲) (釜) (鎌) (噛) (鴨) (栢) (茅) (萱) (粥)
8AA0 [3422] 刈 (苅) (瓦) 乾 (侃) 冠 寒 刊 勘 勧 巻 喚 堪 (姦) 完 官
8AB0 [3432] 寛 干 幹 患 感 慣 憾 換 敢 (柑) (桓) 棺 款 歓 汗 漢
8AC0 [3442] (澗) (潅) 環 甘 監 看 (竿) 管 簡 緩 缶 (翰) 肝 艦 (莞) 観
8AD0 [3452] (諌) 貫 還 鑑 間 閑 関 陥 韓 館 (舘) 丸 含 岸 (巌) (玩)
8AE0 [3462] (癌) 眼 岩 (翫) (贋) (雁) 頑 顔 願 企 (伎) 危 喜 器 基 奇

- 1095 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

SJIS [ JIS ] +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
8AF0 [3472] (嬉) 寄 岐 希 幾 忌 揮 机 旗 既 期 棋 棄
8B40 [3521] 機 帰 毅 気 汽 (畿) 祈 季 稀 紀 徽 規 記 貴 起 軌
8B50 [3531] 輝 飢 騎 鬼 (亀) 偽 儀 (妓) 宜 戯 技 擬 欺 犠 疑 (祇)
8B60 [3541] 義 (蟻) (誼) 議 (掬) 菊 (鞠) 吉 (吃) 喫 (桔) (橘) 詰 (砧) (杵) (黍)
8B70 [3551] 却 客 脚 虐 逆 丘 久 (仇) 休 及 吸 宮 弓 急 救
8B80 [3560] 朽 求 (汲) 泣 (灸) 球 究 窮 (笈) 級 糾 給 旧 牛 去 居
8B90 [3570] 巨 拒 拠 挙 (渠) 虚 許 距 (鋸) 漁 (禦) 魚 亨 享 京 供
8BA0 [3622] (侠) (僑) (兇) 競 共 凶 協 (匡) (卿) 叫 (喬) 境 峡 強 (彊) (怯)
8BB0 [3632] 恐 恭 挟 教 橋 況 狂 狭 矯 胸 脅 興 (蕎) 郷 鏡 響
8BC0 [3642] (饗) 驚 仰 凝 (尭) 暁 業 局 曲 極 玉 桐 (粁) (僅) 勤 均
8BD0 [3652] 巾 錦 斤 (欣) (欽) 琴 禁 (禽) 筋 緊 (芹) 菌 (衿) 襟 謹 近
8BE0 [3662] 金 吟 銀 九 (倶) 句 区 (狗) (玖) 矩 苦 (躯) 駆 (駈) (駒) 具
8BF0 [3672] 愚 虞 (喰) 空 偶 (寓) 遇 隅 (串) (櫛) (釧) 屑 屈
8C40 [3721] 掘 (窟) (沓) 靴 (轡) (窪) 熊 隈 (粂) (栗) 繰 桑 (鍬) 勲 君 薫
8C50 [3731] 訓 群 軍 郡 (卦) (袈) (祁) 係 傾 刑 兄 啓 (圭) (珪) 型 契
8C60 [3741] 形 径 恵 慶 (慧) 憩 掲 携 敬 景 (桂) 渓 (畦) (稽) 系 経
8C70 [3751] 継 (繋) (罫) 茎 (荊) 蛍 計 (詣) 警 軽 (頚) 鶏 芸 迎 鯨
8C80 [3760] 劇 (戟) 撃 激 隙 桁 傑 欠 決 潔 穴 結 血 (訣) 月 件
8C90 [3770] 倹 (倦) 健 兼 券 剣 (喧) 圏 堅 嫌 建 憲 懸 拳 (捲) 検
8CA0 [3822] 権 (牽) 犬 献 研 (硯) 絹 県 肩 見 謙 賢 軒 遣 鍵 険
8CB0 [3832] 顕 験 (鹸) 元 原 厳 幻 弦 減 源 玄 現 (絃) (舷) 言 (諺)
8CC0 [3842] 限 (乎) 個 古 呼 固 (姑) 孤 己 庫 弧 戸 故 枯 湖 狐
8CD0 [3852] (糊) (袴) (股) (胡) (菰) (虎) 誇 (跨) (鈷) 雇 顧 鼓 五 互 (伍) 午
8CE0 [3862] 呉 (吾) 娯 後 御 悟 (梧) (檎) (瑚) 碁 語 誤 護 (醐) (乞) (鯉)
8CF0 [3872] 交 (佼) 侯 候 (倖) 光 公 功 効 勾 厚 口 向
8D40 [3921] 后 喉 坑 (垢) 好 孔 孝 (宏) 工 巧 (巷) 幸 広 (庚) 康 弘
8D50 [3931] 恒 慌 抗 拘 控 攻 (昂) (晃) 更 (杭) 校 (梗) 構 江 洪 浩
8D60 [3941] 港 溝 甲 皇 硬 稿 (糠) 紅 (紘) 絞 綱 耕 考 肯 (肱) (腔)
8D70 [3951] (膏) 航 荒 行 衡 講 貢 購 郊 酵 鉱 (砿) 鋼 (閤) 降
8D80 [3960] 項 香 高 (鴻) 剛 (劫) 号 合 (壕) 拷 (濠) 豪 (轟) (麹) 克 刻
8D90 [3970] 告 国 穀 酷 (鵠) 黒 獄 (漉) 腰 (甑) (忽) (惚) 骨 (狛) 込 此
8DA0 [3A22] 頃 今 困 (坤) 墾 婚 恨 懇 (昏) 昆 根 (梱) 混 (痕) 紺 (艮)
8DB0 [3A32] 魂 (些) 佐 (叉) 唆 (嵯) 左 差 査 (沙) (瑳) 砂 詐 鎖 (裟) (坐)
8DC0 [3A42] 座 挫 債 催 再 最 (哉) (塞) 妻 宰 彩 才 採 栽 歳 済
8DD0 [3A52] 災 (采) (犀) 砕 (砦) 祭 斎 細 菜 裁 載 際 剤 在 材 罪
8DE0 [3A62] 財 (冴) 坂 阪 (堺) (榊) (肴) 咲 崎 (埼) (碕) (鷺) 作 削 (咋) 搾
8DF0 [3A72] 昨 (朔) 柵 (窄) 策 索 錯 桜 (鮭) (笹) (匙) 冊 刷
8E40 [3B21] 察 拶 撮 擦 札 殺 (薩) 雑 (皐) (鯖) (捌) (錆) (鮫) 皿 (晒) 三
8E50 [3B31] 傘 参 山 惨 撒 散 桟 (燦) (珊) 産 算 (纂) 蚕 讃 賛 酸
8E60 [3B41] (餐) (斬) 暫 残 仕 (仔) 伺 使 刺 司 史 嗣 四 士 始 姉
8E70 [3B51] 姿 子 (屍) 市 師 志 思 指 支 (孜) (斯) 施 旨 枝 止
8E80 [3B60] 死 氏 (獅) 祉 私 糸 紙 紫 肢 脂 至 視 詞 詩 試 誌
8E90 [3B70] 諮 資 賜 雌 飼 歯 事 似 侍 児 字 寺 慈 持 時 次
8EA0 [3C22] 滋 治 (爾) 璽 (痔) 磁 示 (而) 耳 自 (蒔) 辞 (汐) (鹿) 式 識
8EB0 [3C32] (鴫) (竺) 軸 (宍) (雫) 七 (叱) 執 失 (嫉) 室 (悉) 湿 漆 疾 質
8EC0 [3C42] 実 (蔀) (篠) (偲) (柴) 芝 (屡) (蕊) 縞 舎 写 射 捨 赦 斜 煮

- 1096 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING Displayable characters

SJIS [ JIS ] +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
8ED0 [3C52] 社 (紗) 者 謝 車 遮 蛇 邪 借 勺 尺 (杓) (灼) 爵 酌 釈
8EE0 [3C62] (錫) 若 寂 弱 (惹) 主 取 守 手 朱 殊 狩 珠 種 (腫) 趣
8EF0 [3C72] 酒 首 儒 受 (呪) 寿 授 樹 (綬) 需 囚 収 周
8F40 [3D21] 宗 就 州 修 愁 拾 (洲) 秀 秋 終 (繍) 習 臭 舟 (蒐) 衆
8F50 [3D31] 襲 (讐) 蹴 (輯) 週 (酋) 酬 集 醜 (什) 住 充 十 従 (戎) 柔
8F60 [3D41] 汁 渋 獣 縦 重 銃 叔 (夙) 宿 淑 祝 縮 粛 塾 熟 出
8F70 [3D51] 術 述 俊 (峻) 春 瞬 (竣) (舜) (駿) 准 循 旬 (楯) 殉 (淳)
8F80 [3D60] 準 潤 盾 純 巡 遵 (醇) 順 処 初 所 暑 (曙) (渚) 庶 緒
8F90 [3D70] 署 書 (薯) (藷) 諸 助 叙 女 序 徐 (恕) (鋤) 除 傷 償 勝
8FA0 [3E22] 匠 升 召 (哨) 商 唱 (嘗) 奨 (妾) (娼) 宵 将 小 少 尚 (庄)
8FB0 [3E32] 床 (廠) 彰 承 抄 招 掌 (捷) 昇 昌 昭 晶 松 (梢) (樟) (樵)
8FC0 [3E42] 沼 消 渉 (湘) 焼 焦 照 症 省 硝 礁 祥 称 章 笑 粧
8FD0 [3E52] 紹 肖 (菖) (蒋) (蕉) 衝 (裳) 訟 証 詔 詳 象 賞 (醤) (鉦) (鍾)
8FE0 [3E62] 鐘 障 (鞘) 上 丈 (丞) 乗 冗 剰 城 場 壌 嬢 常 情 (擾)
8FF0 [3E72] 条 (杖) 浄 状 畳 (穣) 蒸 譲 醸 錠 嘱 (埴) 飾
9040 [3F21] (拭) 植 殖 (燭) 織 職 色 触 食 (蝕) 辱 (尻) 伸 信 侵 唇
9050 [3F31] 娠 寝 審 心 慎 振 新 (晋) 森 (榛) 浸 深 申 (疹) 真 神
9060 [3F41] (秦) 紳 臣 芯 薪 親 診 身 辛 進 針 震 人 仁 刃 (塵)
9070 [3F51] (壬) 尋 甚 尽 (腎) (訊) 迅 陣 靭 (笥) (諏) 須 酢 図 (厨)
9080 [3F60] (逗) 吹 垂 帥 推 水 炊 睡 粋 (翠) 衰 遂 酔 錐 錘 随
9090 [3F70] (瑞) 髄 崇 (嵩) 数 枢 (趨) (雛) 据 杉 (椙) 菅 (頗) (雀) 裾 澄
90A0 [4022] (摺) 寸 世 瀬 畝 是 (凄) 制 勢 姓 征 性 成 政 整 星
90B0 [4032] 晴 (棲) (栖) 正 清 牲 生 盛 精 聖 声 製 西 誠 誓 請
90C0 [4042] 逝 (醒) 青 静 斉 税 脆 隻 席 惜 (戚) 斥 昔 析 石 積
90D0 [4052] 籍 績 (脊) 責 赤 跡 (蹟) (碩) 切 拙 接 摂 折 設 窃 節
90E0 [4062] 説 雪 絶 舌 (蝉) 仙 先 千 占 宣 専 尖 川 戦 扇 (撰)
90F0 [4072] 栓 (栴) 泉 浅 洗 染 潜 (煎) (煽) 旋 (穿) (箭) 線
9140 [4121] 繊 (羨) (腺) (舛) 船 薦 (詮) (賎) 践 選 遷 銭 銑 (閃) 鮮 前
9150 [4131] 善 漸 然 全 禅 繕 (膳) (糎) (噌) 塑 (岨) 措 (曾) (曽) (楚) (狙)
9160 [4141] (疏) 疎 礎 祖 租 粗 素 組 (蘇) 訴 阻 (遡) (鼠) 僧 創 双
9170 [4151] (叢) 倉 喪 壮 奏 (爽) (宋) 層 (匝) (惣) 想 捜 掃 挿 (掻)
9180 [4160] 操 早 曹 巣 (槍) 槽 (漕) 燥 争 (痩) 相 窓 (糟) 総 (綜) (聡)
9190 [4170] 草 荘 葬 (蒼) 藻 装 走 送 遭 (鎗) 霜 騒 像 増 憎 臓
91A0 [4222] 蔵 贈 造 促 側 則 即 息 (捉) 束 測 足 速 俗 属 賊
91B0 [4232] 族 続 卒 (袖) 其 揃 存 孫 尊 損 村 (遜) 他 多 太 (汰)
91C0 [4242] 詑 (唾) 堕 妥 惰 打 (柁) 舵 (楕) (陀) 駄 (騨) 体 (堆) 対 耐
91D0 [4252] (岱) 帯 待 怠 態 戴 替 泰 滞 胎 (腿) (苔) 袋 貸 退 逮
91E0 [4262] 隊 (黛) (鯛) 代 台 大 第 (醍) 題 (鷹) 滝 瀧 卓 (啄) 宅 (托)
91F0 [4272] 択 拓 沢 濯 (琢) 託 (鐸) 濁 諾 (茸) (凧) (蛸) (只)
9240 [4321] 叩 但 達 (辰) 奪 脱 (巽) (竪) (辿) 棚 谷 (狸) (鱈) (樽) 誰 丹
9250 [4331] 単 嘆 (坦) 担 探 旦 (歎) 淡 (湛) 炭 短 端 (箪) (綻) (耽) 胆
9260 [4341] (蛋) 誕 鍛 団 壇 弾 断 暖 (檀) 段 男 談 値 知 地 (弛)
9270 [4351] 恥 (智) 池 痴 稚 置 致 (蜘) 遅 馳 築 畜 竹 筑 蓄
9280 [4360] 逐 秩 窒 茶 嫡 着 中 仲 宙 忠 抽 昼 柱 注 虫 衷
9290 [4370] (註) (酎) 鋳 駐 (樗) (瀦) (猪) (苧) 著 貯 丁 兆 (凋) (喋) (寵) (帖)
92A0 [4422] 帳 庁 弔 張 彫 徴 懲 挑 (暢) 朝 潮 (牒) 町 眺 聴 脹

- 1097 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

SJIS [ JIS ] +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
92B0 [4432] 腸 (蝶) 調 (諜) 超 跳 (銚) 長 頂 鳥 勅 (捗) 直 朕 沈 珍
92C0 [4442] 賃 鎮 陳 津 墜 (椎) (槌) 追 (鎚) 痛 通 塚 (栂) (掴) 槻 (佃)
92D0 [4452] 漬 (柘) (辻) (蔦) (綴) (鍔) (椿) (潰) 坪 (壷) (嬬) (紬) 爪 吊 釣 (鶴)
92E0 [4462] 亭 低 停 偵 (剃) 貞 呈 堤 定 帝 底 庭 廷 弟 (悌) 抵
92F0 [4472] (挺) 提 (梯) (汀) (碇) (禎) 程 締 艇 訂 (諦) (蹄) 逓
9340 [4521] 邸 (鄭) 釘 (鼎) 泥 摘 (擢) 敵 滴 的 笛 適 (鏑) (溺) 哲 徹
9350 [4531] 撤 (轍) 迭 鉄 典 (填) 天 展 店 添 (纏) (甜) 貼 転 (顛) 点
9360 [4541] 伝 殿 澱 田 電 (兎) 吐 (堵) 塗 (妬) (屠) 徒 斗 (杜) 渡 登
9370 [4551] (菟) (賭) 途 都 (鍍) 砥 (砺) 努 度 土 奴 怒 倒 党 冬
9380 [4560] 凍 刀 唐 塔 (塘) (套) (宕) 島 (嶋) 悼 投 搭 東 桃 (梼) 棟
9390 [4570] 盗 (淘) 湯 (涛) 灯 (燈) 当 痘 (祷) 等 答 筒 糖 統 到 (董)
93A0 [4622] (蕩) 藤 討 謄 豆 踏 逃 透 (鐙) 陶 頭 騰 闘 働 動 同
93B0 [4632] 堂 導 (憧) (撞) 洞 (瞳) 童 胴 (萄) 道 銅 峠 (鴇) 匿 得 徳
93C0 [4642] (涜) 特 督 (禿) 篤 毒 独 読 (栃) (橡) 凸 突 (椴) 届 (鳶) (苫)
93D0 [4652] (寅) (酉) (瀞) (噸) 屯 (惇) (敦) (沌) 豚 (遁) (頓) (呑) 曇 鈍 (奈) (那)
93E0 [4662] 内 (乍) (凪) (薙) 謎 (灘) (捺) 鍋 (楢) 馴 縄 (畷) 南 (楠) 軟 難
93F0 [4672] (汝) 二 尼 弐 (迩) 匂 (賑) 肉 (虹) (廿) 日 乳 入
9440 [4721] 如 尿 (韮) 任 妊 忍 認 (濡) (禰) (祢) 寧 (葱) 猫 熱 年 念
9450 [4731] (捻) (撚) 燃 粘 (乃) (廼) (之) (埜) (嚢) 悩 濃 納 能 脳 (膿) 農
9460 [4741] (覗) (蚤) (巴) 把 (播) 覇 (杷) 波 派 (琶) 破 婆 (罵) (芭) 馬 俳
9470 [4751] 廃 拝 排 敗 杯 (盃) (牌) 背 肺 輩 配 倍 培 媒 梅
9480 [4760] (楳) (煤) (狽) 買 売 賠 陪 (這) (蝿) (秤) (矧) (萩) 伯 (剥) 博 拍
9490 [4770] (柏) 泊 白 (箔) (粕) 舶 薄 迫 (曝) 漠 爆 縛 (莫) (駁) 麦 (函)
94A0 [4822] 箱 (硲) (箸) (肇) (筈) (櫨) (幡) 肌 畑 (畠) 八 鉢 (溌) 発 (醗) 髪
94B0 [4832] 伐 罰 抜 (筏) 閥 (鳩) (噺) (塙) (蛤) (隼) 伴 判 半 反 (叛) 帆
94C0 [4842] 搬 (斑) 板 (氾) 汎 版 犯 班 畔 繁 般 藩 販 範 (釆) 煩
94D0 [4852] 頒 飯 (挽) 晩 番 盤 (磐) (蕃) 蛮 (匪) 卑 否 妃 (庇) 彼 悲
94E0 [4862] 扉 批 披 (斐) 比 泌 疲 皮 碑 秘 (緋) 罷 肥 被 (誹) 費
94F0 [4872] 避 非 飛 (樋) (簸) 備 尾 微 (枇) (毘) (琵) (眉) 美
9540 [4921] 鼻 (柊) (稗) 匹 (疋) (髭) 彦 (膝) 菱 (肘) (弼) 必 (畢) 筆 (逼) (桧)
9550 [4931] 姫 (媛) (紐) 百 (謬) 俵 (彪) 標 氷 漂 (瓢) 票 表 評 (豹) (廟)
9560 [4941] 描 病 秒 苗 (錨) (鋲) (蒜) (蛭) (鰭) 品 (彬) (斌) 浜 (瀕) 貧 賓
9570 [4951] 頻 敏 瓶 不 付 (埠) 夫 婦 富 (冨) 布 府 怖 扶 敷
9580 [4960] (斧) 普 浮 父 符 腐 膚 (芙) 譜 負 賦 赴 (阜) 附 侮 (撫)
9590 [4970] 武 舞 (葡) (蕪) 部 封 (楓) 風 (葺) (蕗) 伏 副 復 幅 服 福
95A0 [4A22] 腹 複 覆 (淵) (弗) 払 沸 仏 物 (鮒) 分 (吻) 噴 墳 憤 (扮)
95B0 [4A32] (焚) 奮 粉 (糞) 紛 雰 文 聞 丙 併 兵 塀 幣 平 弊 柄
95C0 [4A42] 並 (蔽) 閉 陛 米 頁 (僻) 壁 癖 (碧) 別 (瞥) (蔑) (箆) 偏 変
95D0 [4A52] 片 (篇) 編 辺 返 遍 便 勉 (娩) 弁 (鞭) 保 舗 (鋪) (圃) 捕
95E0 [4A62] 歩 (甫) 補 (輔) 穂 募 墓 慕 (戊) 暮 母 簿 (菩) 倣 俸 包
95F0 [4A72] (呆) 報 奉 宝 峰 (峯) 崩 (庖) 抱 捧 放 方 (朋)
9640 [4B21] 法 泡 (烹) 砲 縫 胞 芳 (萌) (蓬) (蜂) 褒 訪 豊 邦 (鋒) 飽
9650 [4B31] (鳳) (鵬) 乏 亡 傍 剖 坊 妨 帽 忘 忙 房 暴 望 某 棒
9660 [4B41] 冒 紡 肪 膨 謀 (貌) 貿 (鉾) 防 (吠) (頬) 北 僕 (卜) 墨 撲
9670 [4B51] 朴 牧 (睦) (穆) 釦 (勃) 没 (殆) 堀 (幌) 奔 本 翻 凡 盆
9680 [4B60] 摩 磨 魔 麻 埋 妹 (昧) 枚 毎 (哩) (槙) 幕 膜 (枕) (鮪) (柾)

- 1098 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING Displayable characters

SJIS [ JIS ] +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
9690 [4B70] (鱒) (桝) (亦) (俣) 又 抹 末 (沫) 迄 (侭) 繭 (麿) 万 慢 満 漫
96A0 [4C22] (蔓) 味 未 魅 (巳) (箕) 岬 密 (蜜) (湊) (蓑) (稔) 脈 妙 (粍) 民
96B0 [4C32] 眠 務 夢 無 (牟) 矛 霧 (鵡) (椋) 婿 娘 (冥) 名 命 明 盟
96C0 [4C42] 迷 銘 鳴 (姪) (牝) 滅 免 (棉) 綿 (緬) 面 (麺) (摸) 模 茂 妄
96D0 [4C52] (孟) 毛 猛 盲 網 耗 (蒙) (儲) 木 黙 目 (杢) (勿) (餅) (尤) 戻
96E0 [4C62] (籾) (貰) 問 (悶) 紋 門 匁 (也) 冶 夜 (爺) (耶) 野 (弥) 矢 厄
96F0 [4C72] 役 約 薬 訳 躍 靖 柳 (薮) (鑓) 愉 (愈) 油 癒
9740 [4D21] 諭 輸 唯 (佑) 優 勇 友 (宥) 幽 悠 憂 (揖) 有 (柚) (湧) (涌)
9750 [4D31] 猶 (猷) 由 (祐) 裕 誘 遊 (邑) 郵 雄 融 夕 予 余 与 誉
9760 [4D41] (輿) 預 (傭) 幼 (妖) 容 庸 揚 揺 擁 曜 (楊) 様 洋 溶 (熔)
9770 [4D51] 用 窯 羊 (耀) 葉 (蓉) 要 謡 踊 (遥) 陽 養 (慾) 抑 (欲)
9780 [4D60] (沃) 浴 翌 翼 (淀) 羅 螺 裸 来 (莱) 頼 雷 (洛) 絡 落 酪
9790 [4D70] 乱 卵 (嵐) 欄 濫 (藍) (蘭) 覧 利 吏 履 (李) (梨) 理 (璃) 痢
97A0 [4E22] 裏 (裡) 里 離 陸 律 率 立 (葎) (掠) 略 (劉) 流 (溜) (琉) 留
97B0 [4E32] 硫 粒 隆 竜 (龍) (侶) 慮 旅 虜 了 (亮) 僚 両 (凌) 寮 料
97C0 [4E42] (梁) 涼 猟 療 (瞭) 稜 糧 良 (諒) (遼) 量 陵 領 力 緑 倫
97D0 [4E52] 厘 林 (淋) (燐) (琳) 臨 輪 隣 (鱗) (麟) (瑠) 塁 涙 累 類 令
97E0 [4E62] (伶) 例 冷 励 (嶺) (怜) (玲) 礼 (苓) 鈴 隷 零 霊 麗 齢 暦
97F0 [4E72] 歴 列 劣 烈 裂 廉 恋 (憐) (漣) (煉) (簾) 練 (聯)
9840 [4F21] (蓮) 連 錬 (呂) (魯) (櫓) 炉 (賂) 路 露 労 (婁) 廊 (弄) 朗 楼
9850 [4F31] (榔) 浪 漏 (牢) (狼) (篭) 老 (聾) (蝋) 郎 六 (麓) (禄) (肋) 録 論
9860 [4F41] (倭) 和 話 歪 賄 脇 惑 枠 (鷲) (亙) (亘) (鰐) 詫 (藁) (蕨) (椀)
9870 [4F51] 湾 (碗) 腕

(2) JIS 2nd level character set

Only following Kanji characters in JIS 2nd level character set are available for display. If
JIS 2nd level Kanji characters other than following are output, double width space is displayed
instead.

SJIS [ JIS ]
9AA0 [5422] 國
9D8A [596A] 搖
9E8A [5B6A] 條
9F4E [5D2F] 櫻
E056 [5F37] 澤
E068 [5F49] 濾
E1EF [6271] 碌
E36A [654B] 緞
E863 [6F44] 鐵

- 1099 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

(3) FANUC special marks

The FANUC special marks which are assigned to JIS 1st level character set code are shown below.

No. SJIS [ JIS ] FANUC Character


01 885F [2F40] 0752 right arrow
02 8860 [2F41] 0754 right-up arrow
03 8861 [2F42] 0756 up arrow
04 8862 [2F43] 0758 left-up arrow
05 8863 [2F44] 075A left arrow
06 8864 [2F45] 075C left-down arrow
07 8865 [2F46] 075E down arrow
08 8866 [2F47] 0760 right-down arrow
09 8867 [2F48] 0762 CW arrow
10 8868 [2F49] 0764 CCW arrow
11 8869 [2F4A] 0766 small arc
12 886A [2F4B] 0768 large arc
13 886B [2F4C] 076A small rectangle
14 886F [2F50] 077C finishing mark 1
15 8870 [2F51] 077E finishing mark 2
16 8871 [2F52] 0780 finishing mark 3
17 8872 [2F53] 0782 finishing mark 4
18 8880 [2F60] 1240 1/1
19 8881 [2F61] 1242 2/2
20 8882 [2F62] 1244 3/3
21 8883 [2F63] 1246 4/4
22 8884 [2F64] 1248 5/5
23 8885 [2F65] 124A 6/6
24 8886 [2F66] 124C
25 8887 [2F67] 124E
26 8888 [2F68] 1250 millimeter (mm)
27 8889 [2F69] 1252 centimeter (cm)
28 888A [2F6A] 1254 kilometer (km)
29 888B [2F6B] 1256 square centimeter (cm^2)
30 888C [2F6C] 1258 square meter (m^2)
31 888D [2F6D] 125A square kilometer (km^2)
32 888E [2F6E] 125C cubic centimeter (cm^3)
33 888F [2F6F] 125E cubic meter (m^3)
34 8890 [2F70] 1260 milligram (mg)
35 8891 [2F71] 1262 kilogram (kg)
36 8892 [2F72] 1264 (cc)

- 1100 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING Displayable characters

No. SJIS [ JIS ] FANUC Character


37 8893 [2F73] 1266 deciliter (dl)
38 8894 [2F74] 1268 liter (l)
39 8895 [2F75] 126A kiloliter (kl)
40 8896 [2F76] 126C millisecond (ms)
41 8897 [2F77] 126E microsecond
42 8898 [2F78] 1270 nanosecond (ns)
43 8899 [2F79] 1272 horse power (HP)
44 889A [2F7A] 1274 horse power (ps)
45 889B [2F7B] 1276 hertz (Hz)
46 889C [2F7C] 1278 joint-stock corporation
47 889D [2F7D] 127A copyright ((c))

- 1101 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

(4) Describing 2-byte characters in source-codes

The DIAB-SDS compiler does not support Japanese language. If a 2-byte character whose second
byte happens to be 5Ch is included directly in a source file, it is not recognized as correct
data.

Example) printf("表示") ; NG
printf("表\示") ; OK

The characters that need to be followed by '\' are shown in the figure on the left side.
* Note
The JIS 2nd level characters cannot be displayed even if followed by '\'.

JIS 1st level character set JIS 2nd level character set
SJIS [ JIS ] SJIS [ JIS ]
815C [213D] ― 995C [513D] (兔)
835C [253D] ソ 9A5C [533D] (喀)
845C [273D] (Ы) 9B5C [553D] (媾)
875C [2F3D] (Ⅸ) 9C5C [573D] (彌)
895C [313D] 噂 9D5C [593D] (拿)
8A5C [333D] (浬) 9E5C [5B3D] (杤)
8B5C [353D] 欺 9F5C [5D3D] (歃)
8C5C [373D] (圭) E05C [5F3D] (濬)
8D5C [393D] 構 E15C [613D] (畚)
8E5C [3B3D] 蚕 E25C [633D] (秉)
8F5C [3D3D] 十 E35C [653D] (綵)
905C [3F3D] 申 E45C [673D] (臀)
915C [413D] (曾) E55C [693D] (藹)
925C [433D] (箪) E65C [6B3D] (觸)
935C [453D] 貼 E75C [6D3C] (軆)
945C [473D] 能 E85C [6F3D] (鐔)
955C [493D] 表 E95C [713D] (饅)
965C [4B3D] 暴 EA5C [733D] (鷭)
975C [4D3D] 予 ED5C [793D] (偆)
985C [4F3D] (禄) EE5C [7B3D] (砡)
FA5C [933D] (纊)
FB5C [953D] (犾)

- 1102 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING Displayable characters

4.2.3 Display code for single byte characters

In the following tables, the code of the FANUC characters in each character set selected by
the escape sequences, "ESC (x", are shown. . If , for example,0x20 (space) is output in the "ESC
(1" mode, FANUC character of the code 0x00E0 is displayed on the screen.

(1) "ESC (1" Special characters, Fragments of 6x magnified numeric characters

2x 3x 4x 5x 6x 7x Ax Bx Cx Dx
x0 00E0 00F8 0108 0118 0128 0138 0760 0770 01F0
x1 00E1 00F9 0109 0119 0129 0139 0761 0771 01F1
x2 00E2 00FA 010A 011A 012A 013A 0752 0762 0772 01F2
x3 00E3 00FB 010B 011B 012B 013B 0753 0763 0773 01F3
x4 00E4 00FC 010C 011C 012C 01D8 0754 0764 01E4 01F4
x5 00E5 00FD 010D 011D 012D 01D9 0755 0765 01E5 01F5
x6 00E6 00FE 010E 011E 012E 01DA 0756 0766 01E6 01F6
x7 00E7 00FF 010F 011F 012F 01DB 0757 0767 01E7 01F7
x8 00F0 0100 0110 0120 0130 01DC 0758 0768 01E8 01F8
x9 00F1 0101 0111 0121 0131 01DD 0759 0769 01E9 01F9
xA 00F2 0102 0112 0122 0132 01DE 075A 076A 01EA 01FA
xB 00F3 0103 0113 0123 0133 01DF 075B 076B 01EB 01FB
xC 00F4 0104 0114 0124 0134 01E0 075C 076C 01EC 01FC
xD 00F5 0105 0115 0125 0135 01E1 075D 076D 01ED 01FD
xE 00F6 0106 0116 0126 0136 01E2 075E 076E 01EE 01FE
xF 00F7 0107 0117 0127 0137 01E3 075F 076F 01EF 01FF

- 1103 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

(2) "ESC (2" Fragments of 6x magnified alphabetic characters

2x 3x 4x 5x 6x 7x Ax Bx Cx Dx
x0 013C 014C 015C 016C 017C 018C 019C 01AC 01BC 01CC
x1 013D 014D 015D 016D 017D 018D 019D 01AD 01BD 01CD
x2 013E 014E 015E 016E 017E 018E 019E 01AE 01BE 01CE
x3 013F 014F 015F 016F 017F 018F 019F 01AF 01BF 01CF
x4 0140 0150 0160 0170 0180 0190 01A0 01B0 01C0 01D0
x5 0141 0151 0161 0171 0181 0191 01A1 01B1 01C1 01D1
x6 0142 0152 0162 0172 0182 0192 01A2 01B2 01C2 01D2
x7 0143 0153 0163 0173 0183 0193 01A3 01B3 01C3 01D3
x8 0144 0154 0164 0174 0184 0194 01A4 01B4 01C4 01D4
x9 0145 0155 0165 0175 0185 0195 01A5 01B5 01C5 01D5
xA 0146 0156 0166 0176 0186 0196 01A6 01B6 01C6 01D6
xB 0147 0157 0167 0177 0187 0197 01A7 01B7 01C7 01D7
xC 0148 0158 0168 0178 0188 0198 01A8 01B8 01C8
xD 0149 0159 0169 0179 0189 0199 01A9 01B9 01C9
xE 014A 015A 016A 017A 018A 019A 01AA 01BA 01CA
xF 014B 015B 016B 017B 018B 019B 01AB 01BB 01CB

- 1104 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING Displayable characters

(3) "ESC (3" Graphic characters

2x 3x 4x 5x 6x 7x Ax Bx Cx Dx
x0 1D50 1D60 1D70 1D80 1D90 1DA0 1DB0 1DC0 1DD0 1DE0
x1 1D51 1D61 1D71 1D81 1D91 1DA1 1DB1 1DC1 1DD1 1DE1
x2 1D52 1D62 1D72 1D82 1D92 1DA2 1DB2 1DC2 1DD2 1DE2
x3 1D53 1D63 1D73 1D83 1D93 1DA3 1DB3 1DC3 1DD3 1DE3
x4 1D54 1D64 1D74 1D84 1D94 1DA4 1DB4 1DC4 1DD4 1DE4
x5 1D55 1D65 1D75 1D85 1D95 1DA5 1DB5 1DC5 1DD5 1DE5
x6 1D56 1D66 1D76 1D86 1D96 1DA6 1DB6 1DC6 1DD6 1DE6
x7 1D57 1D67 1D77 1D87 1D97 1DA7 1DB7 1DC7 1DD7 1DE7
x8 1D58 1D68 1D78 1D88 1D98 1DA8 1DB8 1DC8 1DD8 1DE8
x9 1D59 1D69 1D79 1D89 1D99 1DA9 1DB9 1DC9 1DD9 1DE9
xA 1D5A 1D6A 1D7A 1D8A 1D9A 1DAA 1DBA 1DCA 1DDA 1DEA
xB 1D5B 1D6B 1D7B 1D8B 1D9B 1DAB 1DBB 1DCB 1DDB 1DEB
xC 1D5C 1D6C 1D7C 1D8C 1D9C 1DAC 1DBC 1DCC 1DDC 1DEC
xD 1D5D 1D6D 1D7D 1D8D 1D9D 1DAD 1DBD 1DCD 1DDD 1DED
xE 1D5E 1D6E 1D7E 1D8E 1D9E 1DAE 1DBE 1DCE 1DDE 1DEE
xF 1D5F 1D6F 1D7F 1D8F 1D9F 1DAF 1DBF 1DCF 1DDF 1DEF

(4) "ESC (4" Standard character set

2x 3x 4x 5x 6x 7x Ax Bx Cx Dx
x0 0020 0030 0040 0050 0F80 0F90 00A0 00B0 00C0 00D0
x1 0021 0031 0041 0051 0F81 0F91 00A1 00B1 00C1 00D1
x2 0022 0032 0042 0052 0F82 0F92 00A2 00B2 00C2 00D2
x3 0023 0033 0043 0053 0F83 0F93 00A3 00B3 00C3 00D3
x4 0024 0034 0044 0054 0F84 0F94 00A4 00B4 00C4 00D4
x5 0025 0035 0045 0055 0F85 0F95 00A5 00B5 00C5 00D5
x6 0026 0036 0046 0056 0F86 0F96 00A6 00B6 00C6 00D6
x7 0027 0037 0047 0057 0F87 0F97 00A7 00B7 00C7 00D7
x8 0028 0038 0048 0058 0F88 0F98 00A8 00B8 00C8 00D8
x9 0029 0039 0049 0059 0F89 0F99 00A9 00B9 00C9 00D9
xA 002A 003A 004A 005A 0F8A 0F9A 00AA 00BA 00CA 00DA
xB 002B 003B 004B 005B 0F8B 0F9B 00AB 00BB 00CB 00DB
xC 002C 003C 004C 005C 0F8C 0F9C 00AC 00BC 00CC 00DC
xD 002D 003D 004D 005D 0F8D 0F9D 00AD 00BD 00CD 00DD
xE 002E 003E 004E 005E 0F8E 0F9E 00AE 00BE 00CE 00DE
xF 002F 003F 004F 005F 0F8F 0F9F 00AF 00BF 00CF 00DF

- 1105 -
4. Keycode, screen control code
and Displayable characters PROGRAMMING B-64303EN-3/01

(5) "ESC (6" Fragments of 6x magnified characters

2x 3x 4x 5x 6x 7x Ax Bx Cx Dx
x0 0100 0196
x1 0106 013C 019C
x2 010C 0142 01A2 1CE0
x3 0112 0148 01A8 1CE6
x4 0118 014E 01AE 1CEC
x5 011E 0154 01B4
x6 0124 015A 01BA
x7 012A 0160 01C0
x8 0130 0166 01C6
x9 0136 016C 01CC
xA 0172 01D2
xB 0178
xC 017E
xD 01D8 0184
xE 01DE 018A
xF 0190

(*) A 6x magnified character is displayed combining 6 consecutive single byte characters,


beginning with the code in above table.

(6) "ESC (7" European character set (umlaut , etc.)

2x 3x 4x 5x 6x 7x Ax Bx Cx Dx
x0 0020 0030 0040 0050 0F80 0F90 0FC0 0FD0 0FE0 0FF0
x1 0021 0031 0041 0051 0F81 0F91 0FC1 0FD1 0FE1 0FF1
x2 0022 0032 0042 0052 0F82 0F92 0FC2 0FD2 0FE2 0FF2
x3 0023 0033 0043 0053 0F83 0F93 0FC3 0FD3 0FE3 0FF3
x4 0024 0034 0044 0054 0F84 0F94 0FC4 0FD4 0FE4 0FF4
x5 0025 0035 0045 0055 0F85 0F95 0FC5 0FD5 0FE5 0FF5
x6 0026 0036 0046 0056 0F86 0F96 0FC6 0FD6 0FE6 0FF6
x7 0027 0037 0047 0057 0F87 0F97 0FC7 0FD7 0FE7 0FF7
x8 0028 0038 0048 0058 0F88 0F98 0FC8 0FD8 0FE8 0FF8
x9 0029 0039 0049 0059 0F89 0F99 0FC9 0FD9 0FE9 0FF9
xA 002A 003A 004A 005A 0F8A 0F9A 0FCA 0FDA 0FEA 0FFA
xB 002B 003B 004B 005B 0F8B 0F9B 0FCB 0FDB 0FEB 0FFB
xC 002C 003C 004C 005C 0F8C 0F9C 0FCC 0FDC 0FEC 0FFC
xD 002D 003D 004D 005D 0F8D 0F9D 0FCD 0FDD 0FED 0FFD
xE 002E 003E 004E 005E 0F8E 0F9E 0FCE 0FDE 0FEE 0FFE
xF 002F 003F 004F 005F 0F8F 0F9F 0FCF 0FDF 0FEF 0FFF

- 1106 -
4.Keycode, screen control code and
B-64303EN-3/01 PROGRAMMING Displayable characters

4.2.4 Kanji character code

Following two types of codes are used in the application program.

Shift-JIS code selected by "ESC (B" (default)


Shift-FANUC code selected by "ESC (C"

In the "ESC (B" mode, application programs can specify Shift-JIS code Kanji characters in
character strings, similar to the MS-DOS applications.
Shift-JIS code is converted to the FANUC code internally by the library.

In the "ESC (C" mode, specified Kanji character code is converted to the FANUC code according
to the following rule. Hangul characters or graphic characters can be displayed in this mode.

code_high -= 0x6B ;
if ( code_low >= 0x80 )
code_low -= 0x60 ;
else
code_low -= 0x40 ;
code_low <<= 1 ;

For example, by specifying the code 0x8140, the Hangul character of the FANUC code 0x1600 is
displayed on the screen.

- 1107 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5 C Language Executor Function

- 1108 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.1 Multitasking

5.1.1 Task classes

Application programs are composed of five independent task classes.

High

(E) High-Level Task

(D) Window Task


Task
Priority (C) Alarm Task

(B) Communication Task

(A) Main Task

Low

(A) Main task


Most tasks, like writing onto the screen, reading keys or up-loading/down-loading CNC
data, are classed as this task class. All library functions can be used in this task
class.

(B) Alarm task


Normally, the task of this class runs periodically to watch various status information.

(C) Communication task


Usually, this task class is used to execute tasks related to the Reader/Punch Interface
independent of the main task. But it can also be used for tasks other than communications.
Similarly, communication tasks can also be accomplished by the tasks of other task
classes.

(D) Window task


This task runs in the same way as the alarm task or communication task, and is mainly
used to display a window on an arbitrary screen. This task allows almost the same screen
display operations as the main task.

(E) High-Level task


This task is executed independently at certain start periods. The start periods are fixed.
This task is used to perform operations such as real-time processing with the highest
priority and high-speed data monitoring.

- 1109 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

Both the alarm task and the communication task are referred to as auxiliary task.
Because these two tasks are executed in the background of the main task, they are also referred
to as background task.

The auxiliary tasks are explained below.

For the window task, see Section 5.6, "Window task" in Part II, "PROGRAMMING".
For the high-level task, see Section 5.8, "High-Level task" in Part II, "PROGRAMMING".

The main task is executed only while user screens are displayed. The alarm task and the
communication task is executed background without any relation to the screen display.

When user application program is composed of only one task, this task should be the main
task.

(supplement) Each task class corresponds to the macro-program of the Macro Executor as follows.

Macro Executor C Language Executor


Conversational Macro Main task
Auxiliary Macro Alarm task , Communication task
Execution Macro none

- 1110 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.1.2 Difference of each task class

The auxiliary task is limited in available functions compared to the main task.

Communication
Main task Alarm task
task
Standard functions ○ ○ ○
Key input ○ × ×
Character display ○ × ×
Graphic display ○ × ×
File I/O ○ ○(*1) ○(*1)
CNC/PMC window
○ ○(*2) ×
function
Reader/Punch
○ ○(*3) ○(*3)
Interface

○ : can be used × : cannot be used

(*1) A file cannot be accessed simultaneously by more than two tasks.


File accesses arbitration should be considered by application program.
(*2) Simultaneous access with main task will cause busy error.
However, the return value (busy error in the above example) does not depend on the
combination of tasks (for example, the main task, an auxiliary task and the high
level task).
In addition, busy error does not occur in some functions such as the pmc_rdpmcrng
function or pmc_wrpmcrng function.
(*3) Accesses to the I/O port should be arbitrated by application program.

- 1111 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.1.3 Task switching

Task switching between the main task and the auxiliary task is executed by calling task
management library functions in the application program. To run the auxiliary task periodically,
the period is also specified by the application program.

The priority of the task class is as follows.

task class priority


Main task low
Communication task mid
Alarm task high

Auxiliary tasks are executed by interrupting the main task.


Task switching from the auxiliary task to the task of lower priority is accomplished by calling
functions which wait for certain events to happen.
There are following functions which are used for this purpose.

Event Function
Time os_sync_tim(), os_wait_tim()
Event flag os_wait_flg()
Semaphore os_wait_sem()
Status of serial port rs_wait()

This type of task management is called "event driven" task management.

auxiliary task (run)


(実行) (wait for event)

main task (wait) (run)


↑ ↑
system start Event happens

- 1112 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.1.4 Data access between tasks

To exchange data between tasks, the inter-task common variable is to be used.


The variables defined in the special source files, dramver.c and sramver.c, are located in the
inter-task common memory as the common variables.

When defining the common variables in the files, dramver.c or sramver.c,specify the attribute
"volatile" for the variables in the definition statement.

Memory address space

Memory address space

common variable (sramver.c)

common variable (dramver.c)

Main Communication Alarm Window High level


task task task task task CNC system
software

C Language Executor Library(interface)

C Language Executor Library(kernel)

Data cannot be accessed between memory address spaces which are not connected by arrows in
above figure.

- 1113 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.1.5 Task Management

Kind of tasks

(1) CNC task

* CNC interruption tasks


Automatic or manual operation, servo control, spindle control, I/O transfer of PMC
and execution of the ladder, MDI control,program editing, etc. are realized by these
tasks. They are triggered by the timer interruptions and run periodically. There are
actually multiple tasks which are waked by the timer interruptions.
They are assumed to be single task for simplification in the following explanation.

* CNC display task


Displaying of the CNC screen, background editing, CNC window processing, etc. are
realized by this task. This task is executed in the idle CPU time which is not used
by the CNC interruption tasks.

(2) User task

* Main task
Almost all processing of the user application, such as displaying of the user screen,
are executed in this task. The TASK1 is the main task.

* Background tasks
These tasks are usually waked by various events and they are executed independently
of the main task. The TASK2 (the communication task) and the TASK3 (the alarm task)
are background tasks. These tasks execute the processing about the related events,
then suspend execution to wait for the next event again, and give the CPU to the main
task.
TASK2 (the communication task) and TASK3 (the alarm task) are temporarily interrupted
processing when the processing time exceeds 1 msec, and change to the task (for instance,
main task) at the level of the subordinate position.
Next, when TASK2 (the communication task) and TASK3 (the alarm task) are started,
execution is restarted from the interrupted processing.
It changes to the task at the level of the subordinate position without waiting for
1 msec when the function of the event waiting (for instance, os_wait_tim function etc.)
is executed.
It starts after the end of a high-ranking task is waited when a more high-ranking task
executes it even if TASK2 (the communication task) and TASK3 (the alarm task) are
released from the event waiting state.
Therefore, the start by the event of TASK2 (the communication task) and TASK3 (the
alarm task) might be delayed, and there are no guarantee at the start cycle.

Both the main task and the background tasks are executed in the idle CPU time which
is not used by the CNC interruption tasks.

- 1114 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.2 File system

The File system compatible with MS-DOS is included in C Language Executor library.

(1) File definition

The entire format is as follows. This supports the layered directories.

[drive name:][\][directory name \...]name[.extension]

The parts enclosed by [] can be omitted.

(2) Drive name

This is a English character (one character) indicating the drive in which files are stored.
The available drive in C Language Executor library is as follows.

Device Drive name Capacity


SS-RAM disk A: Maximum 59 Kbytes
S-RAM card
or 256Kbytes to 2Mbytes
B:
ATA compatible flash card, 128Mbytes to 4Gbytes
Compact flash card

The each drive names are fixed.

(3) File name


This contains a Drive name indicated by a character and a name by maximum 8 characters and
an extension by maximum 3 characters. The drive name and the file name are separated with
':', and the name and the extension are separated with '.'. The Drive name and the extension
are options.

The File name is changed to one with capital characters and is discerned.
The following characters can be used for a File name. (The 2 bytes characters can not be
used.)

Alphabetic characters A .. Z
Numeric characters 0 .. 9
Special characters $ & # % ' ( ) - @ ^ { } ~ ` ! _

- 1115 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(4) Reserved file name

The following names are reserved for system.

CON console device This is used for the input from key
board or the output to display unit.
NUL null device When this is specified, the objective
file is not created.

The following names can not be used.

AUX..AUX4, COMx, PRN, LPTx, CLOCK, CLOCK$

(5) Wild card

The following Wild card characters can be used for the File name and extension.

? The meaning of any one character


* The meaning of any plural characters (contain nulls)

As using Wild card characters, the file can be flexibly specified.


But in case of the file specification with '*', the characters after '*' are neglected.

(example 1) "TEST?.C"
"TEST1.C" , "TEST2.C" , "TESTA.C" , "TESTB.C" etc. are applied.

(example 2) "TEST*.C"
"TEST1.C" , "TEST12.C" , "TESTA.C" , "TESTAB.C" etc. are applied.

(example 3) "TEST*A.C"
The character 'A' is neglected and so this example is the same as example 2).

(6) Directory

For the file information, names, sizes and update times are registered in the directory.
The directory itself is a kind of files and can be layered.
The basic directory of layered directories is called "Root directory".
The Root directory is automatically created at initializing the device.
The directory created below the root one is called "Sub directory".
Within the range of the path name length(lower than 64 bytes), the Sub directories are created
in so many layers.

- 1116 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(7) Path name

The following parts in a file definition is named "Path name".


The Path name specifies a definite directory in the layered structure of directories.

[\][directory name \...]directory name

In the above, "[\]" of the head indicates a Root directory.


Next "[directory name \...]" is the stretch of directory names continued until the objective
directory.
A Path name is need to be within 64 bytes.

The separator among directories is normally specified with '\' and '/' may be used for the
separator. So the latter is supported too.

(8) Practicable number of files for opening simultaneously

The number of files which the application can open simultaneously is fixed 60 as a whole.
I/O Control buffers which are used by High level input/output Functions
(fopen, fclose, fprintf,...) are prepared respectively 15 for each task.
At launching of each task, following three standard input/output functions are opened.

stdin console(MDI) input


stdout console(CRT) output
stderr console(CRT) output

(9) S-RAM disk

The C Language Executor application can access a S-RAM disk.


A S-RAM disk is a file device built on battery back upped RAM of CNC. Set the size by the unit
of KByte in parameter No.8662 for the utilization of S-RAM.
A S-RAM disk(max 59 KB) is automatically initialized at power on right after changing the set
data in parameter No.8662. And it is possible to initialize it by calling aux_file_format
function in the application program.

(10) ATA flash card, compact flash card

It is available for the application program to access a S-RAM card or ATA flash card which
is inserted in the card slot beside LCD display device of Series 0i-D.

For the method of using the cards, see Section 3.7, "File operation library" in Part II,
"PROGRAMMING".

- 1117 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.3 Power-on procedure

5.3.1 Key operation at power on

On Series 0i-D with C Language Executor, the special procedure is executed when the power is
turned on with pushing the definite MDI keys.

Key pushed at power on Execution


The System starts up without executing C Language Executor.
The CNC is executed in the same condition as no C Language
[M] + [0](numeric key 0)
Executor installed. This is used for disregarding C Language
Executor function transiently.

(note)

* [M]+[0] means that [M] key and [0] key are pushed at one time.
* Please continue to push these keys till the normal NC screen or the user screen of C Language
Executor is displayed after power on.

- 1118 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.4 Parameter setting on CNC

#7 #6 #5 #4 #3 #2 #1 #0
8650 CNA RSK

[Input type] Parameter input


[Data type] Bit

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

#0 RSK After the reset key is pressed, the key code is:
0: Not passed to the application program.
1: Passed to the application program.

#1 CNA When a CNC alarm is issued while the user screen of C Language
Executor is being displayed, automatic switching to the alarm screen is:
0: Determined by the setting of bit 7 (NPA) of parameter No. 3111.
1: Not performed, regardless of the setting of bit 7 (NPA) of parameter
No. 3111.

#7 #6 #5 #4 #3 #2 #1 #0
8654 CGC

[Input type] Parameter input


[Data type] Bit

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

#2 CGC When the crt_setmode function is called, the graphic plane is:
0: Cleared.
1: Not cleared.

- 1119 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

#7 #6 #5 #4 #3 #2 #1 #0
8655 RCC

[Input type] Parameter input


[Data type] Bit

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

#7 RCC When the rs_close function is executed in RS-232C communication of C


Language Executor with DC control exercised in the
transmission/reception mode:
0: Communication is ended after checking the DC code of the
communication destination device.
1: Communication is ended without checking the DC code of the
communication destination device.

8661 Size of variable area

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

[Input type] Parameter input


[Data type] Word
[Unit of data] KByte
[Valid data range] 0 to 59
When C Language Executor is used, this parameter sets the size of the
static variable area sharable among tasks. Set a size in steps of 1K bytes.
The maximum specifiable size is 59K bytes. However, ensure that the sum
of this size and the size of the SRAM disk does not exceed (usable SRAM
size - 1)K bytes (namely, 63K bytes).
When the setting of this parameter is modified, the variable area and
SRAM disk are initialized.

- 1120 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

8662 Size of SRAM disk

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

[Input type] Parameter input


[Data type] Word
[Unit of data] K bytes
[Valid data range] 4 to 63
When C Language Executor is used, this parameter sets the size of the
SRAM disk. Set a size not smaller than 4K bytes in steps of 1K bytes. The
maximum specifiable size is 63K bytes. However, ensure that the sum of
this size and the size of the variable area does not exceed (usable SRAM
size - 1)K bytes (namely, 63K bytes).
When the setting of this parameter is modified, the SRAM disk is
initialized.

8663 Setting of time zone

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

[Input type] Parameter input


[Data type] 2-word
[Unit of data] sec
[Valid data range] -12 × 3600 to 12 × 3600
This parameter sets the time difference from the Greenwich time in
seconds.
The time difference of Japan is -9 hours. So, set -32400 (= -9 × 3600)
seconds.

- 1121 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

8781 Size of DRAM used with C Language Executor

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

[Input type] Parameter input


[Data type] Word
[Unit of data] 64K bytes
[Valid data range] 16 to 96
This parameter sets the size of the DRAM used with C Language Executor.
Set a value not smaller than 1024K bytes in steps of 64K bytes. If a value
not within the valid data range is set, the specification of 0 is assumed.
When the specified value is 0, C Language Executor is not started.

NOTE
The actually usable size is limited by the RAM capacity and selected
option(s).

- 1122 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.5 Dat2mem utility manual

-------------------------------------------------------------------------------------------
Data file to Memory_Card file conversion utility
-------------------------------------------------------------------------------------------

The "dat2mem.com" is a utility program which converts arbitrary MS-DOS data file to Memory_Card
file that is used for CNC. It reads multiple data files to make a Memory_Card file which can
be directly loaded into CNC. It can also combine data files with existing Memory_Card file of
a C Language Executor program to make up new Memory_Card file.

(1) C Language Executor data file

C Language Executor Library supports functions which make application programs capable of
reading data files stored in the F-ROM of CNC controls. The data file of the format which can
be read by C Language Executor applications is referred to as C Language Executor data file.
Multiple MS-DOS data files can be combined and stored in a C Language Executor data file. C
Language Executor application program can read
individual MS-DOS files by specifying its file name.

There are following two types of C Language Executor data file.

(a) Data only file

Memory_Card file
header

Data file
directory entry

Data file 1

Data file 2

Data file n

Multiple MS-DOS data files are combined in this file. F-ROM file identification name
for this type of file is "CEXnxxxx" where 'n' is a number from 0 to 9 and "xxxx" is any
combination of max. 4 alpha-numeric characters. Ten C Language Executor data files
( "CEX0xxxx" --"CEX9xxxx") can be stored in the F-ROM at maximum. Files stored in the
F-ROM are identified by using leftmost 4 characters of the identification name. As a
result, the files with identification names "CEX1DATA" and "CEX1TEXT" are assumed as
the same file.

- 1123 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

That is, if a file "CEX1TEXT" is written to the F-ROM in which a file "CEX1DATA" is stored,
the file "CEX1DATA" is deleted and only the file "CEX1TEXT" remains.

The size of the C Language Executor data file is calculated by

Memory_Card header size (416 bytes) +


directory entry size (16 + number of data files * 32 bytes) +
total size of all data files,

and the F-ROM memory blocks of 128KB unit is allocated to the file.

In this type of file are general data or machine tool dependent data
(system parameters or offset data).

(b) File with C Language Executor program and data

Memory_Card file
header

C Language Executor Loaded into DRAM


program when power ON

Data file
directory entry

Data file 1

Data file 2

Data file n

Multiple MS-DOS data files are combined with existing C Language Executor program file,
in this type of file. F-ROM file identification name for this type of file is "CEX xxxM"
where "xxx" stands for "1.0", "1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "5.0", "6.0",
etc. Only one file of this type can be stored in F-ROM. It is also not allowed to put
both this type of file and a C Language Executor program file without data file in the
F-ROM.

- 1124 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

The size of this type of file is calculated by

size of existing C Language Executor program file +


directory entry size (16 + number of data file * 32 bytes) +
total size of all data files

and the F-ROM memory blocks of 128KB unit is allocated to the file.

This type of file is suited to store the data closely related to the C Language Executor
program, screen data for example.

For both types C Language Executor data file, C Language Executor application program opens
a C Language Executor data file by specifying file identification name, "CEXnxxxx" or "CEX
xxxM", then selects and reads one of the data files in it.

In the directory entry, the "8.3 format" file name, data size and origin address in F-ROM
file for each MS-DOS files are stored. C Language Executor application program can read the
contents of this directory entry.

There are no specific limitations for the size or type of the MS-DOS data file which is
converted by this utility. The contents of the MS-DOS data file is stored in the C Language
Executor data file as it is.

(2) Necessary hardware

* Personal computer executable for Windows98, Windows 2000, Windows XP Home Edition, or Windows
XP Home Professional
* Free disk space larger than twice of the Memory_Card file size being created.

(3) How to execute

Type as follows after prompt.

C:\> dat2mem xxx [Enter]

"xxx" stands for the name of the Command file mentioned later.

(4) Command file

Command file is the file in which names of the related files are written.
The format of the Command file is as follows.

* A line beginning with semicolon is assumed as a comment line and ignored.


* A line with spaces only is ignored.
* Only the first word of the line other than above is valid.
* Leading space characters(space or tab character) of a line are ignored.
* Necessary information is written in the following order.

- 1125 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(a) Name of the Memory_Card file being created


Specify the name( usually *.mem) of the Memory_Card file to be created. The
format of the file name part should be "CEXnxxxx", where 'n' is a number from
0 to 9 and "xxxx" is any combination of max.4 alpha-numeric
characters,"CEX1TOOL.MEM" or "CEX3DOC.MEM" for example.
When creating new Memory_Card file by combining data files to the existing C
Language Executor Memory_Card file, arbitrary
Memory_Card file name can be specified. Drive name or directory name can be added
as necessary.

(b) Name of the existing C Language Executor Memory_Card file


Specify the name (usually *.mem) of the existing Memory_Card file in which C
Language Executor program is stored. Add drive name or directory name as
necessary. It is not necessary to specify this file name, when creating a C
Language Executor data file which is composed of data file only.

(c) Name of the data file


Specify the name of the data file to be converted. Add drive name or directory
name as necessary. Wild card characters,'*' or '?', can also be specified. When
wild card characters are used, all files which match with the specified name
are converted. File name cannot contain multi-byte characters or katakana
characters. Only single byte alpha-numeric characters cam be used for the file
name.
Name of the data file may be specified in multiple lines.
Maximum of 2000 data files can be combined in a Memory_Card file.

- 1126 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

[Example 1]
Command file which combines all "*.dat" files in the directory "c:\data" and creates
"CEX1PARM.MEM".

--<< from the next line >>----------------------------------------------------


;================================
; DAT2MEM Specification file
;================================

;----------------------------------------------------------------
CEX1PARM.MEM
;----------------------------------------------------------------
c:\data\*.dat
;----------------------------------------------------------------
; end of spec file
--<< to the previous line >>--------------------------------------------------

[Example 2]
Command file which combines data files, "\work\scrn1.dat","\work\scrn2.dat" and
"\text\msg.txt", with existing file "cexec.mem" and creates new Memory_Card file
"cexec_d.mem".

--<< from the next line >>----------------------------------------------------


;================================
; DAT2MEM Specification file
;================================

;----------------------------------------------------------------
cexec_d.mem
;----------------------------------------------------------------
cexec.mem
;----------------------------------------------------------------
\work\scrn1.dat
\work\scrn2.dat
\text\msg.txt
;----------------------------------------------------------------
; end of spec file
--<< to the previous line >>--------------------------------------------------

- 1127 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(5) Error messages

It can happen that following error messages are displayed.

"insufficient memory"
Cannot allocate enough memory to execute the program.

"file open error xxx (??H)"


Cannot open the file xxx.

"file create error xxx (??H)"


Cannot create the file xxx.

"file read error xxx (??H)"


Encountered an error while reading the file xxx.

"file write error xxx (??H)"


Encountered an error while writing into the file xxx.

"insufficient disk space for xxx"


Lack of free disk space to create the file xxx.

"unexpected EOF xxx, line#??"


Detected the end of file when attempted to read the ??th line of the file xxx.
This can happen when command file is described incompletely.

"invalid Memory_Card filename xxx"


Invalid Memory_Card file name is specified. In case of data only Memory_Card file, the only
acceptable file name format is "CEXnxxxx" where 'n' is a number from 0 to 9 and "xxxx" is any
combination of alpha-numeric characters. There is no restrictions for the name of the Memory_Card
file which contains C Language Executor program and data.

"file xxx not found (??H)"


Cannot fine the file xxx.

"file searching error xxx (??H)"


Encountered an error while searching for the file xxx.

"too many input file"


Attempted to convert more than 2000data files.

"invalid filename xxx"


Invalid characters, katakana characters or multi-byte characters, are included in the name of
the data file. Files should be named with single-byte alpha-numeric characters only.

"not a simple Memory_Card file xxx"


Data files are already combined in the specified C Language Executor Memory_Card file.
Specify the Memory_Card file which contains C Language Executor program file only.

- 1128 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.6 Window task

5.6.1 Overview

The window task is the task that operates after the CNC display task.

High

CNC interrupt Tasks


(Axis control,PMC
execution,etc.)

High-Level Task

CNC interrupt Tasks


Task
(Preparing, Automatic
priority
operation)

CNC display Task

Window Task

Alarm Task
Auxiliary Tasks
Communication task

Main task Task for display

Low

The window task runs with the tree tasks of C Language Executor and the CNC's display task
simultaneously.
This task is like the auxiliary tasks, but it can display to the screen unlike them.
About displaying screen, the window task is similar to the main task except that the target
screen to display is only the VGA windows. So, it is impossible to display without VGA display
device. (The execution itself is available even if any display device is equipped.) The
window task can't read MDI key unlike the main task. It can read the status of touch-panel.

The window task is provided for the following purposes.

On the CNC with VGA display device, it opens VGA windows on the screen and controls them,
and receives the commands of the operator via input signals of PMC or touch-panel.

Such as controlling "Software machine control panel" on the screen with touch-panel. It can
be applied to the general purposes, but it is most suitable task to the above purpose.

- 1129 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.6.2 Window task's execution

The window task is loaded on the memory with the other tasks in the power-up sequence of
CNC. This task is not automatically started. To start the window task, call "os_strt_wtsk()"
function by the main task. When this function is executed successfully, the window task starts
running simultaneously with the other 3 tasks and the CNC's display task.

5.6.3 Usage of the window task

The typical processing flow of the window task is as follows.

(1) Start

(2) Initialize

(3) Wait the trigger


to display
no trigger

(4) Open VGA window

(5) Display and read


commands

(6) If display end


not end

(7) Close VGA window

(1) Start
The window task starts from "main()" function by calling "os_strt_wtsk()" in the main
task.

(2) Initialize
General initialization such as variable setting, etc.

(3) Wait the trigger to display


The application program checks whether it should display VGA window or not.
There are some conditions for the trigger to start displaying.

- 1130 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

Input signal from PMC. (using "pmc_rdpmcrng()" function) Status of touch-panel


(using "aux_tpl_read()" function) Status of CNC (using "cnc_statinfo()"
function,etc.) Notification of the other tasks (notify via DRAM/SRAM common
variables)

It is possible to always display the VGA window.

(4) Open VGA window


The application program opens VGA window using "vwin_open()" function.

(5) Display and read commands


The application program displays to the VGA window. It also receives operator's commands.
To receive commands, use the following method;(because the application can't read MDI
keys.)

Input signal from PMC. (using "pmc_rdpmcrng()" function)


Status of touch-panel (using "aux_tpl_read()" function)
Notification of the other tasks (notify via DRAM/SRAM common variables)

(6) If display end


The application program detects the trigger to close the VGA window.
It checks informations as same as "(3) Wait the trigger to display".

(7) Close VGA window


The application program closes the VGA window using "vwin_close()" function.

It is possible to always open VGA windows on the screen rather than the application program
opens them on demands. Also it is possible to open the invisible VGA window.

- 1131 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.6.4 Available functions for the window task

The following functions are available for the window task.

(1) ANSI C Standard library


All functions which are available for the main task are available.

(2) MS-C extended C standard library


All functions which are available for the main task are available.

(3) Graphic library


All functions which are available for the main task are available.
The target screen to display is not the ordinary screen but VGA window.

(4) CNC/PMC window library


All functions which are available for the main task are available.
Some functions require exclusive control between the other tasks.

(5) MDI operation library


Unavailable.

(6) CRT operation library


All functions which are available for the main task are available.
The target screen to display is not the ordinary screen but VGA window.

(7) File operation library


Unavailable.

(8) Serial library


Unavailable.

(9) Task management library


Available except "os_strt_wtsk()". But it is ineffective to send/receive events with
the other tasks.

(10) FCA library


Unavailable.

(11) F-ROM library


Unavailable.

(12) Touch-panel library


Available.

(13) Inter-task common variables (DRAM/SRAM)


Available.

- 1132 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.6.5 How to make application program

The procedure to make window task application is mentioned below.


Basically, it is same as the ordinary application which is composed of main task, alarm task
and communication task.

(1) Making main/alarm/communication tasks.


"os_strt_wtsk" function must be called in the main task.
Except this, there is nothing to especially take case. Description of MAKEFILE about
these tasks is same as usual.

(2) Making window task.


Make source modules (*.c) which include a "main()" function and other functions called
from main() as same as the other tasks.

(3) Definition modules of window task in MAKEFILE.


Define object module names of the window task in the module definition
line "TASK4 = " in MAKEFILE.

(Example) TASK4 = winmain.o wintsk1.o wintsk2.o

(4) Compile and link by "nmake" command.

(5) Load the created memory card file into the CNC and run it.
There is no special parameter setting about window task.

5.6.6 Notes

Take case of the followings for using window task.

(1) Task structure

The task number of the window task is '4'. The window task is called "TASK4". All tasks
of whole application including window task are as below.

TASK1 Main task


TASK2 Communication task
TASK3 Alarm task
TASK4 Window task
TASK5 High-Level Task

- 1133 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.7 Conforming CNC screen display function

5.7.1 Overview

It is possible to run C Language Executor on the following equipments on which "CNC screen
display" application (optional function).

Series 0i-D connected with a personal computer via a Ethernet


(Displayed on the screen of the CNC or personal computer)

It is possible to display on the virtual CNC screen displayed on PC's screen by "CNC screen
display" application as same as on the ordinary CNC screen. The virtual CNC screen is
equivalent to VGA display device. C Language Executor application program which runs on
the ordinary CNC equipment can also run on these equipments by re-compiling and linking
as it is. (Some source codes might be modified.) Some screen display functions are
restricted by "CNC screen display" application, and some function's behaviors are different
from ordinary specifications on the true CNC.

The "CNC screen display" application is abbreviated as "CNCscrnFunc" in the following


sections of this document.

- 1134 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.7.2 How do application program run on each equipment

In this section, how each task of the application program runs is described.

(1) 0i-D with Ethernet

Status of CNC & PC Status of C Language application program

CNC starts Auxiliary tasks start [1]

Main task starts [2]

Window task starts [3]


CNC side display

"CNCscrnFunc" starts [4] [5]

PC side display

"CNCscrnFunc" ends [6] [7]

CNC side display

[1] Auxiliary tasks start at CNC system start-up time. After started, they run as same as
on the ordinary Series 0i-D. It is not necessary for auxiliary tasks to take care of
whether CNC screen is displayed on PC or not. (Auxiliary tasks may not exist.)

[2] The main task starts after the auxiliary tasks started. It runs as same as on the ordinary
Series 0i-D until "CNCscrnFunc" is opened on PC.
For this duration, the main task operates while the C Language Executor application screen
is displayed and the main task stops while the CNC screen is displayed.

[3] The window task starts when "os_strt_wtsk()" function is called in the main task. Then,
the window task continues running regardless of whether the C Language Executor
application screen is displayed. (The window task may not exist.)

[4] When "CNCscrnFunc" starts on PC, the main task goes sleeping once. This is because the
CNC position screen is always selected when display is switched between the CNC and the
PC. When an attempt is made to switch to the C Language Executor application screen
after display on the PC side starts, the main task is executed again and the C Language
Executor application screen is displayed. If an application program of C Language
Executor prohibits screen switching, screen switching to the PC is not completed. The
application program should sometimes enable to change the screen.
- 1135 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

※NOTE
When using the CNC screen display function, do not allocate the C Language Executor
application screen to the NC position screen.

[5] The window task should close already opened VGA windows when "CNCscrnFunc" starts up.
VGA windows opened on CNC side screen are still displayed after starting "CNCscrnFunc"
on PC side. To display VGA windows on PC side screen, once close VGA windows after starting
"CNCscrnFunc", then open them again. It is possible to test on which of CNC side or PC
side the current screen is displayed by "crt_pcinfo()" function.

[6] When "CNCscrnFunc" is closed on PC and CNC side screen wakes up again, the main task
goes sleeping once. This is because the CNC position screen is always selected when
display is switched between the CNC and the PC. When an attempt is made to switch to
the C Language Executor application screen after display on the PC side restarts, the
main task is executed again and the C Language Executor application screen is displayed.
If an application program of C Language Executor prohibits screen switching, the CNC
screen display function cannot be terminated.
The application program should sometimes enable to change the screen.

※NOTE
When using the CNC screen display function, do not allocate the C Language Executor
application screen to the NC position screen.

[7] The window task must close already opened VGA windows when "CNCscrnFunc" is terminated.
"CNCscrnFunc" can't close itself while any VGA windows keep opening. It is possible to
test whether "CNCscrnFunc" is going closed or not by "crt_pcinfo()" function. After
changing to CNC side, the window task opens VGA windows again.

- 1136 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.7.3 Restrictions on specification

In this section, differences from C Language Executor on the ordinary Series 0i-D are
described. You can regard the specifications which are not listed below as same as on
the ordinary Series 0i-D with VGA display device. The following descriptions are applied
to PC side screen if no special comment. They runs on 0i-D with Ethernet as same as the
ordinary Series 0i-D.

[*] mark which is added to "unavailable ..." etc. means that no error occurs and nothing
is done even if the function is used.

(1) It is impossible to start or terminate "CNCscrnFunc" while C Language Executor


application inhibits screen changing. If starting or terminating "CNCscrnFunc"
is attempted during screen changing inhibition, the CNC equipment goes hung-up
and "CNCscrnFunc" can't run newly on PC.
To recover this, it is required to restart both CNC equipment and PC.

(2) The screen is initialized by changing screen between CNC side and PC side. At this
time, all contents already displayed are cleared. So the application program must
redraw the screen.

(3) Overlapping method about text and graphics in 16-color graphics (in which both
text and graphics are displayed overlapping each other) is different from the
ordinary Series 0i-D. "Composite" mode is not supported. [*] Only "Character over
graphics" or "Graphics over character" can be selected. The default mode if
"Character over graphics".

crt_setpalette( _PAL_COMP, CRT_PAL_COMP ) unavailable


crt_setpalette( _PAL_COMP, CRT_PAL_CHAR ) available(default)
crt_setpalette( _PAL_COMP, CRT_PAL_GRPH ) available

(4) 256-color graphics is unavailable. [*] The following graphic modes which select
256-color graphics can't be specified in "_setvideomode()" function.

_98RES16COLOR, _98RES8COLOR, _98RESCOLOR, _VRES256COLOR

(5) Automatic key repeating is always effective for key-input from both PC's keyboard
and MDI keyboard while PC side screen is alive. (It is independent of the
application program setting.) While CNC side screen is alive on Series 0i-D with
Ethernet, whether automatic key repeating is effective or not depends on the
application program setting.

(6) Customizing of MDI key for CNC's screen is unavailable. [*]


"aux_mdi_putmatrix()" or "aux_mdi_altmatrix()" functions take no effect to CNC
side key matrix.

(7) It is impossible to turn ON and OFF back-light of LCD screen by "ESC [>9l" and
"ESC [>9h" while PC side screen is alive. [*]

- 1137 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(8) It is impossible to set LCD screen reverse. [*]


That is, "crt_setpalette( _PAL_RVS, xxx )" is unavailable.

(9) It is impossible to start or terminate "CNCscrnFunc" while VGA windows are opened.

(10) It is unavailable to control function-keys on MDI panel by C Language Executor


application with "crt_setswt( CRT_SWT_MFKY )". [*]
It is impossible to read function-key information even if "crt_readfkey()"
function is executed. [*]

(11) When using the CNC screen display function, do not allocate the C Language Executor
application screen to the NC position screen.

- 1138 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.7.4 Making application program

A) Alterations

It is required for the already existing application program to modify the source codes
as it avoids specification restrictions if you want to display the CNC’s screen by CNC screen
display function. You should take care of the following notices for making new application
program.
Index number of the following notices corresponds to the previous section's each item number.

(1) An application program which runs on CNC screen display function should not make screen
changing inhibited. For example, don't execute "crt_setswt(CRT_SWT_DIS )" (don't inhibit
screen changing actively), execute "crt_setswt( CRT_SWT_GREN )" while it draws graphics
(enable to change screen during drawing graphics), etc.

(2) Redraw all contents in the user screen if the screen is switched between CNC side and
PC side. For example, get the current output device, CNC or PC, using "crt_pcinfo()"
function, and if it switches, redraw whole screen.

(3) The application program which uses "Composite" graphic mode doesn't correctly draw
graphics on CNC screen display function. It is needed to redesign color specification
for application screen using "Character over graphics" mode.

(4) Don't use 256-color graphics mode. Modify the application program to use only 16 colors.

(5) If you want not to use automatic key repeating on PC side screen, set delay time and
interval time for key repeating both as max value (1024[msec]) using "aux_mdi_repeat()"
function.

(6) If you want to customize MDI key mapping for CNC's screen, alter key mapping on PC side
("CNCscrnFunc").

(7),(8) To control LCD display (turning ON/OFF the back-light, reversing the screen), use
the ordinary screen control feature of PC.

(9) While the application program is displaying VGA windows, call "crt_pcinfo()" function
periodically and close all VGA windows when PC side application is terminated.

(10) Basically, leave CNC screen switching control to CNC software. C Language Executor
application program should not touch screen switching process.

- 1139 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

B) Application building process

The procedure for creating an application for the Series 0i-D connected via the Ethernet is
the same as in the normal Series 0i-D. An application is created according to the procedure
for creating a C Language Executor application program for the normal Series 0i-D.

Created memory card files are stored in F-ROM of the CNC unit. In the Series 0i-D connected
via the Ethernet, the boot menu is called and writing to F-ROM is performed according to the
same procedure as in the normal Series 0i-D.

C) Other notices

Screen refresh speed may slow down while PC side screen is alive according to its PC's
processor performance. But CNC internal process executions which is independent of screen
displaying (such as auxiliary tasks execution) run as same speed as the ordinary Series 0i-D.

- 1140 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.7.5 Function reference

-------------------------------------------------------------------------------------------
1. Get status of CNC screen display function <Main>
-------------------------------------------------------------------------------------------

[Name]
crt_pcinfo

[Syntax]
#include <crt.h>
unsigned short crt_pcinfo( void ) ;

[Arguments]
------

[Return]
Returns status of CNC screen display function.

[Description]
Gets status of "CNC screen display" function (optional function) program which runs on
PC of Series 0i-D.

To display CNC screens (including the C Language Executor application screen) on the
PC of the Series 0i-D, use the CNC screen display function. Only when this application
program is being executed, a CNC screen can be displayed on the PC. This function is
used to test if CNC screen is available or not when C Language Executor application program
runs on Series 0i-D.

This function returns the following data as return value.

Upper byte Lower byte

CNC system type Status of "CNCscrnFunc"

(1) CNC system type

Always 0x00 for the FS0i-D

- 1141 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(2) Status of "CNCscrnFunc"

This is a pack of bit-flags which indicates the status of "CNC screen display"
function on PC.
"1" means "effective" for each bit.

CRT_PC_ENB 0x01 "CNC screen display" is available.


CRT_ETH_SIDE 0x08 CNC screen is displayed now.
CRT_PC_END 0x10 PC application terminated.
CRT_PC_PWON 0x20 PC application is starting up now.
CRT_PC_DWN 0x40 PC is down now.
CRT_PC_SIDE 0x80 CNC screen is displayed now.

You can get the current output device using CRT_PC_SIDE and
CRT_ETH_SIDE.

CRT_PC_SIDE CRT_ETH_SIDE Output device


0 0 CNC's display unit
1 0 undefined
1 1 PC (Ethernet) display unit
0 1 undefined

This function is used to test if screen function is available or not. For example, "if
CNC screen goes closed, the window task closes VGA windows", for this case, this function
is used.

Screen switching must be enabled when "CNCscrnFunc" starts up and ends. (If screen
switching is disabled, "CNCscrnFunc" can't start/end.) Call this function periodically,
and enable screen switching when CRT_PC_PWON or CRT_PC_END flag rises up.

- 1142 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

[Example]
The following program closes VGA windows when "CNCscrnFunc" goes closed on PC. (This
is executed in the window task.)

#include <crt.h>

void example( void )


{
unsigned short pcinfo ;
pcinfo = crt_pcinfo() ;
if ( pcinfo & CRT_PC_ENB ) {
/* Has PC app closed or been down ? */
if ( pcinfo & ( CRT_PC_END + CRT_PC_DWN ) ) {
vwin_close( 0 ) ;
vwin_close( 1 ) ;
}
}
}

5.7.6 Specification of the memory card on the personal computer

The memory card installed on the personal computer can be accessed.


The memory card on the personal computer is referred to as the "drive on the personal
computer".

5.7.6.1 Using the drive on the personal computer

By using the procedure below, access a file on the personal computer where the CNC screen
display function operates.

(1) Start the CNC screen display function.

(2) Set bit 0 (PCM) of parameter No. 300 to 1.

(3) Choose [File] then [Data I/O] from the menu of the CNC screen display function then
set a desired memory card drive name in the displayed dialog box.

(4) With a C Language Executor application program, perform a file input/output operation
by specifying drive C:. Drive C: used with C Language Executor is installed on the
personal computer. By executing input/output processing with drive C:, a file in
the memory card on the personal computer can be read from and written to.

[Supplement] In (3) above, an arbitrary folder on the hard disk may be set instead of a memory
card drive. In such a case, a file in the folder set for input/output processing
with drive C: is read from and written to.
For example, when the "C:\DATA.TXT" file is opened from a C Language Executor
application program in the state where the "D:\USER" folder on the hard disk is set
as a data input/output folder, the "D:\USER\DATA.TXT" file on the personal computer
is opened.

- 1143 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.7.6.2 Notes on application program creation

(1) When a drive on the personal computer is accessed, the following functions cannot
be used:

Name Function
chdir Change the current directory
getcwd Acquire the current directory
mkdir Create a new directory(*1)
rmdir Delete a directory(*1)
rename Rename a file(*2)
fgetpos Acquire a stream file position indicator
fseek Move the file pointer
fsetpos Set a stream position indicator
ftell Acquire the current file pointer position
rewind Return the file pointer to the start of a file
eof Check whether the position is the end of a file
lseek Move the file pointer to a specified position
tell Acquire the current file pointer position
_chdrive Change the current drive
_getdrive Acquire the current drive
_dos_getdiskfree Acquire disk information
aux_file_format Format a specified drive(*3)
aux_file_memcinfo Acquire memory card status

(*1) Create or delete a subdirectory on the personal computer (Windows).


(*2) Rename a file on the personal computer (Windows).
(*3) Format a memory card on the personal computer (Windows).

(2) To access a drive on the personal computer, execute an ordinary file input/output
function (such as fopen, fcreate, fgets, fprintf, and fclose) by specifying drive
C:.

(3) To access a file on the drive (drive C:) on the personal computer, be sure to include
the drive name ("C:") in the file name. (Example: "C:\DATA.DAT")

(4) With a drive on the personal computer, no subdirectory can be handled.


For example, a file name including a directory name such as "C:\DATA\DATA1.DAT" is
not specifiable. To change the input/output destination directory, change the drive
assignment destination by choosing [File] then [Data I/O] from the menu of the CNC
screen display function.

(5) Only one file on the drive (drive C:) on the personal computer can be opened at a
time.

- 1144 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(6) As the access mode for opening a file, only the read mode or creation mode may be
specified. Specifically, only "r" or "w" can be specified as the access mode of the
fopen function. "a", "r+", "w+", and "a+" cannot be specified.

5.7.6.3 Others

(1) When a file is accessed during execution of the CNC screen display function by
specifying drive B:, a file on the memory card inserted into the memory card slot
of the CNC is read from and written to.

- 1145 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.8 High-Level Task

5.8.1 Overview of High-Level Task

High-Level Task is the independent task of C Language Executor ordinary tasks (Main Task,
Auxiliary Tasks and Window Task) and is called at fixed intervals.

High

CNC interrupt Tasks


(Axis control,PMC
execution,etc.)

High-Level Task

CNC interrupt Tasks


(Preparing, Automatic
Task operation)
priority
CNC display Task

Window Task

Alarm Task
Auxiliary Tasks
Communication task

Main task Task for display

Low

- 1146 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.8.2 Specification

(1) Execution spec.

Execution 8 msec(*1)
interval
(Interval time is not always fixed. Refer following "Task execution
rule".)

Maximum execution time 0.8 msec (at intervals of 8 msec)

(Actually, an execution time that is about 80% of the maximum


execution time is recommended. For details, see "Task execution
rule".)

(2) Available variable types and operators

The following variable types are available in High-Level task.

Type char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned
long, array of these types and pointers to these type variables.

Kind auto variable, static variable, global variable, D-RAM/S-RAM shared variable.

The following operations are available in High-Level task.

arithmetical operations (+,-,*,/,%) and logical operations (>>,<<,&,|,^,~) and kindred


operations (++,--,&&,||, etc.) to char, unsigned char, short, unsigned short, int,
unsigned int, long, unsigned long types.

(3) Available library functions

Only the following functions are available in High-Level Task.

Name Function
rettask() Stop execution of a high-level task
Start and stop acquiring high-level task execution
cnc_hldata()
management data
cnc_rdprgnum() Read the program number of a program being executed
Read the sequence number of a sequence being
cnc_rdseqnum()
executed
cnc_actf() Read the actual feed rate (F) of a controlled axis
cnc_acts() Read the actual rotation speed of the spindle
cnc_absolute() Read the absolute position of a controlled axis
cnc_machine() Read the machine position of a controlled axis
cnc_relative() Read the relative position of a controlled axis
cnc_distance() Read the distance-yet-to-go of a controlled axis

- 1147 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

Name Function
cnc_skip() Read the skip position of a controlled axis
cnc_srvdelay() Read the servo delay amount for a controlled axis
Read the acceleration/deceleration delay amount for a
cnc_accdecdly()
controlled axis
cnc_alarm() Read alarm status
cnc_rdspload() Read information about the load on the serial spindle
cnc_adcnv() Read A/D conversion data
pmc_rdpmcrng() Read arbitrary PMC data (input range specified)
pmc_wrpmcrng() Output arbitrary PMC data (output range specified)
pmc_getpmcptr() Acquire "address information" of PMC memory
Check the validity of "address information" of PMC
pmc_isvalidpmcptr
memory
pmc_rdpmcchar Read signed 1-byte data of PMC memory
pmc_rdpmcshort Read signed 2-byte data of PMC memory
pmc_rdpmclong Read signed 4-byte data of PMC memory
pmc_wrpmcchar Write signed 1-byte data of PMC memory
pmc_wrpmcshort Write signed 2-byte data of PMC memory
pmc_wrpmclong Write signed 4-byte data of PMC memory
pmc_get_current_pmc_unit() Acquire the unit type of the current operation target PMC
pmc_get_number_of_pmc() Acquire the number of PMC paths
pmc_get_pmc_unit_types() Acquire PMC unit type
pmc_select_pmc_unit() Select an operation target PMC unit
acos() Calculate arccosine
asin() Calculate arcsine
atan() Calculate arctangent
atan2() Calculate arctangent
ceil() Round upward to an integer
cos() Calculate cosine
cosh() Calculate hyperbolic cosine
exp() Calculate an exponential function
fabs() Calculate the absolute value of a floating-point number
floor() Discard decimal places
fmod() Calculate the remainder of a floating-point number
frexp() Divide a number to a mantissa part and exponent part
ldexp() Calculate a product of 2 raised to a power
log() Calculate natural logarithm
log10() Calculate common logarithm
modf() Divide a number to an integer part and fraction part
pow() Make a power calculation
sin() Calculate sine
sinh() Calculate hyperbolic sine
sqrt() Calculate square root

- 1148 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

Name Function
tan() Calculate tangent
tanh() Calculate hyperbolic tangent

Library functions other than those listed above are unusable. For example, ANSI
standard functions (such as printf, malloc, and strcpy) other than the above and FANUC
proprietary CNC/PMC window library functions other than the above are unusable.
For explanation of the functions other than rettask() and cnc_hldata(), see Section
3.4, "CNC/PMC window library" in Part II, "PROGRAMMING".

(4) Reading/Writing PMC data

Using pmc_rdpmcrng() and pmc_wrpmcrng() can, respectively, read and write PMC data (internal
relays (R) and keep relays (K)).
Refer to 34window.man for descriptions about pmc_rdpmcrng() or pmc_wrpmcrng().

(5) Data sharing with the other tasks

High-Level Task can share data with the other tasks via D-RAM common variables (dramver.c)
or S-RAM common variables (sramver.c).

- 1149 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.8.3 Task execution rule

High-Level Task is called after CNC task in the periodical interrupt procedure at 8msec
intervals.

8msec 8msec 8msec

(A) (B)

(A) CNC task


(B) C Language Executor High-Level Task

High-Level Task (B) is surely called once at each 8 msec. But execution intervals are not
always exact 8 msec.

(T1) 8msec 8msec 8msec 8msec

(T2) Interval Interval Interval

T1 Interval of interrupt procedure ( == 8 msec )


T2 Interval of High-Level Task ( != 8 msec )

The timing of calling High-Level Task changes according to execution time of CNC task (A) as
mentioned above. Generally, each tasks on CNC system, such as CNC, PMC, Servo, etc., run
synchronously by hand-shaking each other. Therefore, nothing must be considered about
relationship to the other tasks even if the execution intervals change.

Total processing time of above-mentioned (B) is limited up to 0.8 msec for each interruption.
When the task attempts to run over 0.8 msec, the execution is forcedly interrupted by timer
interruption. The interrupted task will restart its execution from the interrupted instruction
in the next timer interruption procedure.

8msec 8msec 8msec

(B) (B’)

INTERRUPTED RESTART

16msec (actual interval)

- 1150 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

In this case, a series of process is divided into multiple parts that are executed on separate
interruptions. Therefore, it makes actual interval of the task longer than 8 msec. To avoid
this, it is recommended to keep reserve of execution time for High-Level Task, not to reach
the upper limit 0.8 msec. For example, keep actual max. execution time of High-Level task up
to approximately 0.8 msec. C Language Executor management procedure takes approx. 0.02 msec
for calling High-Level task.
This time is included in the execution time of High-Level task.

High-Level Task has priority over the other CNC tasks such as preparing task. If High-Level
task runs long time, CPU time for CNC preparing task,etc. may be reduced. (In this case, any
harmful effect, such as machining time by CNC's automatic operation increases, etc., may occur.)
To avoid influence to the other tasks, it is better to keep execution time of High-
Level task as short as possible

The following variables (management data) are defined for looking over the execution time of
High-Level Task.

extern struct HL_MNGDATA HL_DATA ;

The detail of this management data is mentioned below.

- 1151 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

Each task of C Language Executor application that includes High-Level task starts as following
order.

Task start-up order

Initialize CNC soft

Initialize C Language Executor

Prepare all tasks


(Interruption procedure
for every 8 msec)
Start Window task
Start High-Level task

Start Alarm task

Start Communication task

Start Main task

(Alarm/Communication/Window tasks may not exists.)

High-Level task starts on the 1st 8 msec interrupt procedure just after completion of
preparation for all tasks. This execution doesn't link to any other tasks' start-up. Therefore,
start-up order of High-Level task and the other tasks if not fixed.

- 1152 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.8.4 Application programming

The following sections mention development process of application including High-Level Task.

(1) Source module(s)

The structure of High-Level Task's source modules is same as the other tasks. That is, it has
one or more source modules ( "*.c" file ) and one "main()" function is included in them. The
structure of "main()" function is as follows.

void main( void )


{
[Initialization] <-- This is executed only at 1st
interruption.

for(;;) {
[Process for each 8 msec]
rettask() ; <-- This function interrupts the
} execution of High-Level Task.
}

A series of process that is executed at each 8 msec makes a loop program flow. "rettask()"
function must be called in the loop.

(2) Describing makefile

List the module names of High-Level Task on "TASK5=" line in module definition section on
the top of "makefile". List depending relationship of each modules in module dependency block
on the bottom of "makefile".
These describing format is same as the other tasks.

(3) Compiling and linking

Compiling and linking process is same as the ordinary application program.

(4) Setting, etc.

No special settings (such as CNC parameter, etc.) are required for application program including
High-Level Task. It is loaded into CNC and run as same as the ordinary application program.

- 1153 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.8.5 Function reference

-------------------------------------------------------------------------------------------
1. Interrupt execution of High-Level Task <HILEV>
-------------------------------------------------------------------------------------------

[Name]
rettask

[Syntax]
#include <hilev.h>
void rettask( void ) ;

[Arguments]
------

[Return]
------

[Description]
Interrupts High-Level Task's process.

This function is called at the end of a series of process (for each 8 msec) in High-Level
Task. The execution will restart just after this function in the next High-Level Task
(after 8 msec).

The program structure of High-Level Task is generally as follows.

void main( void )


{
[Initialization]

for(;;) {
[Process for each 8 msec]
rettask() ;
}
}

This function must be called in the main loop like this.

- 1154 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

-------------------------------------------------------------------------------------------
2. Start and End of getting the High-Level task execution management data <HILEV>
-------------------------------------------------------------------------------------------

[Name]
cnc_hldata

[Syntax]
#include <hilev.h>
int cnc_hldata( int mode ) ;

[Arguments]
mode execution mode (DATA_START/DATA_END)

[Return]
Always 0 returns.

[Description]
The start and end of execution management data getting.

The program structure of High-Level Task is generally as follows.

void main( void )


{
[Initialization]

for(;;) {
cnc_hldata( DATA_START );
[Process for each 8 msec]]
cnc_hldata( DATA_END );
rettask() ;
}
}

Make sure that the desired processing is executed between cnc_hldata calls, as shown
above.

[Attention]
Please do not call this function in the case that don't get execution management data,
to economize on processing time.

- 1155 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.8.6 High-Level task execution management data

"High-Level task execution management data" are variables in where how High-Level task runs
is stored. The following structure is defined.

struct HL_MNGDATA {
unsigned long HL_COUNT ;
unsigned int HL_STIME ;
unsigned int HL_ETIME ;
unsigned int HL_MAXETIME ;
unsigned int HL_MAXPROCTIME ;
unsigned int HL_TIMEOVER ;
unsigned int HL_RETFLAG ;
unsigned int HL_BUFCTRL ;
unsigned int HL_BUFSIZE ;
unsigned int HL_BUFIDX ;
unsigned long HL_PTRBUF ;
} ;

extern struct HL_MNGDATA HL_DATA ;

All tasks can access this "HL_MNGDATA". All members are readable and writable.

HL_COUNT High-Level task calling count (accumulated value).

HL_STIME High-Level task's execution start time.


HL_ETIME High-Level task's execution end time.

When High-Level task starts and ends in each 4/8 msec interruption
process are recorded in these members.
This value is elapsed time ([micro-sec]) from the top of each 4/8 msec
interruption process.

And the next operation shows execution time of High-Level task


([micro-sec]).

HL_ETIME - HL_STIME

HL_MAXETIME Maximum value of HL_ETIME.

This is the maximum value of end time of High-Level task's execution.


This indicates the maximum elapsed time of interruption process.
The unit of this value is [micro-sec].

- 1156 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

HL_MAXPROCTIME Maximum value of (HL_ETIME - HL_STIME)

This is the maximum execution time of High-Level task.


The unit of this value is [micro-sec].

HL_TIMEOVER Total counts that execution time exceeds the limit(0.8 msec).

This is total count that High-Level task attempts to exceeds 0.8 msec
execution time and is forcibly terminated.

HL_RETFLAG "rettask()" function execution flag.

This is internal flag.

HL_BUFCTRL Execution time logging control flag.


HL_BUFSIZE Execution time logging buffer size.
HL_BUFIDX Execution time logging buffer index.
HL_PTRBUF Pointer to execution time logging buffer.

These are control variables for logging High-Level task's execution


time (HL_STIME and HL_ETIME). To set command value in HL_BUFCTRL starts
logging function.

HL_BUFCTRL = 0 Stop logging (initial state)


1 Start logging (one shot)
2 Start logging (repeat)

Before starting logging function, set address of buffer memory in


HL_PTRBUF and byte size of it in HL_BUFSIZE. Buffer size must be multiple
of 8. HL_BUFIDX is index which indicates writing position. At start time
of logging, set HL_BUFIDX = 0. After starting logging, HL_STIME and
HL_ETIME are stored in buffer memory for each High-Level task calling.
When the index encounters the end of buffer, one of the following process
will be done.

HL_BUFCTRL = 1 Stop logging.


HL_BUFCTRL is set as 0.
HL_BUFCTRL = 2 Continue logging from the top of
buffer memory with setting writing index
(HL_BUFIDX) as
0.

- 1157 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

Data format stored in buffer memory is as follows.

Byte offset from the top of buffer Stored data


+0000 HL_STIME (0)
+0004 HL_ETIME (0)
+0008 HL_STIME (1)
+0012 HL_ETIME (1)
: :

- 1158 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.9 Use with MANUAL GUIDE i

5.9.1 Overview

A C Language Executor application program created by the user can be used together with
MANUAL GUIDE i. However, some restrictions are imposed on use with MANUAL GUIDE i (for
example, a source code modification may need to be made). This section describes those
restrictions. For the MANUAL GUIDE i specification and use method, refer to "FANUC MANUAL
GUIDE i Operator's Manual" (B-63874EN).

5.9.2 Screen display after power-on

After power-on, the screen for a C Language Executor application created by the user
is usually displayed. However, when MANUAL GUIDE i is used together, the MANUAL GUIDE
i screen can be displayed after power-on.
In this case, make a source code modification as described below. Moreover, set bit 0
(PWD) of parameter No. 14700 for MANUAL GUIDE i to 1.
For details of the parameter for MANUAL GUIDE i, refer to Appendix, "PARAMETERS", in
"FANUC MANUAL GUIDE i Operator's Manual" (B-63874EN).

- 1159 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

- Example: When MANUAL GUIDE i is assigned to the GRAPH key

C language executor
MANUAL GUIDE i
application program

(Halt) Power-on

Graphic initialization, title display,


initialization at power-on time

Graphic initialization, title display, (Halt)


initialization at power-on time

Modify source as follows:


MANUAL GUIDE i used with
cnc_rdsyssoft3?

No Yes

MANUAL GUIDE i Yes crt_cncscrn(CRT_GRH_GRP)


screen displayed?

No

MANUAL GUIDE i screen


(GRAPH key)

- 1160 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.9.3 Restrictions for Use with MANUAL GUIDE i

1. Functions on which restrictions are imposed

Set and use the functions below so that no conflict with MANUAL GUIDE i occurs.

(a) User screen number setting


Ensure that the screen numbers set in the parameters (No. 14794 and No. 14795)
for MANUAL GUIDE i are not used.

crt_setuserscrn Register a user screen number


crt_setuserskey Customize soft keys on the CNC screen

(b) Screen setting


Be sure to make settings again before the screen for a C Language Executor
application created by the user is displayed.

_setvideomode Set the video mode


crt_setmode Set the CRT display mode
_remappalette Set a palette
_remapallpalette Set all palettes
crt_setpalette Set a palette for a VGA character
crt_setallpalette Set palettes for all VGA characters
crt_reguserchar Register user-defined characters
crt_mapuch Map user-defined characters

(c) MDI key customization

aux_mdi_putmatrix Write an MDI key matrix


aux_mdi_rstmatrix Reset an MDI key matrix
aux_mdi_altmatrix Modify an MDI key matrix
aux_mdi_repeat Set a key input auto-repeat time

For the functions above, MANUAL GUIDE i has key customization performed as indicated
below. When the user customizes MDI keys with a C Language Executor application
program created by the user, ensure that a setting that duplicates the settings
below is not made.
If a duplicate setting is made, MDI key input on the MANUAL GUIDE i side is disabled.
Use sufficient care.

- 1161 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

- MDI key matrix of MANUAL GUIDE i

(1) ONG MDI key (machining center system) code table

+0 +2 +4 +6 +8 +A +C +E

60 30 3D 31*D1 32*D2 33*D3 34*D4 35*D5 36*D6 37*D7


70 38*D8 39*D9 2D 2D 2E 2E 9B 9B 95*C5 0A 0A 97 97
80 96 99 94 94 9C 9C 0D 0D 9A 9A 84 85 88*B8 89*B9
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 EE E1 EF E1
A0 8A FB 8B FD 8E 9D 8F 9E 46 5B 44 5D 48 26 42 20
B0 FF FF F0 F0 F1 F1 F2 F2 E4 E4 00 00 00 00 90 90
C0 F3 F3 F4 F4 F5 F5 F6 F6 F7 F7 F8 F8 F9 F9 FE FE
D0 4F 28 4E 29 47 45 50 43 58 55 59 56 5A 57 51 3F
E0 49 2C 4A 41 4B 40 52 5F 4D 23 53 3D 54 2A 4C 2B
F0 00 00 00 00 00 00 00 00 00 00 2F 2F 09 09 08*C8
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

*: Customized key code

- 1162 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(2) ONG MDI key (lathe system) code table

+0 +2 +4 +6 +8 +A +C +E

60 30 3D 31*D1 32*D2 33*D3 34*D4 35*D5 36*D6 37*D7


70 38*D8 39*D9 2D 2D 2E 2E 9B 9B 95*C5 0A 0A 97 97
80 96 99 94 94 9C 9C 0D 0D 9A 9A 84 85 88*B8 89*B9
90 E8 E1 E9 E1 EA E1 EB E1 EC E1 ED E1 EE E1 EF E1
A0 8A FB 8B FD 8E 9D 8F 9E 49 5B 4B 5D 52 26 46 20
B0 FF FF F0 F0 F1 F1 F2 F2 E4 E4 00 00 00 00 90 90
C0 F3 F3 F4 F4 F5 F5 F6 F6 F7 F7 F8 F8 F9 F9 FE FE
D0 4F 28 4E 29 47 45 50 51 58 41 5A 42 43 44 59 3F
E0 55 2C 57 4A 48 40 56 5F 4D 23 53 3D 54 2A 4C 2B
F0 00 00 00 00 00 00 00 00 00 00 2F 2F 09 09 08*C8
100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

*: Customized key code

- Changing of the character attribute of MANUAL GUIDE i

Key type Character attribute Description


Readable by both of the CNC and application
RESET key MDI_TO_BOTH
program
Cursor key MDI_REPEAT_ON Repeatable
Page key MDI_REPEAT_ON Repeatable
CAN key MDI_REPEAT_ON Repeatable

- Setting of a key input auto-repeat time for MANUAL GUIDE i

Auto-repeat delay time delay : 240 [msec]


Auto-repeat interval repeat: 32 [msec]

2. VGA window display


A VGA window created by the user on the MANUAL GUIDE i screen cannot be displayed with
the window task.
When using a VGA window with the window task, ensure that the VGA window is closed
immediately after the MANUAL GUIDE i screen is selected.

- 1163 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.10 Use with TURN MATE i

5.10.1 Overview

A C Language Executor application program created by the user can be used together with
TURN MATE i. However, some restrictions are imposed on use with TURN MATE i (for example,
a source code modification may need to be made). This section describes those restrictions.
For the TURN MATE i specification and use method, refer to "FANUC TURN MATE i Operator's
Manual" (B-64254EN).

5.10.2 Screen display after power-on

After power-on, the screen for a C Language Executor application created by the user
is usually displayed. However, when TURN MATE i is used together, the TURN MATE i screen
can be displayed after power-on.
In this case, make a source code modification as described below. Moreover, set bit 0
(PWD) of parameter No. 9101 for TURN MATE i to 1.
For details of the parameter for TURN MATE i, refer to Appendix, "PARAMETERS", in "FANUC
TURN MATE i Operator's Manual" (B-64254EN).

- 1164 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

- Example: When TURN MATE i is assigned to the GRAPH key

C Language Executor
TURN MATE i
application program

(Halt) Power-on

Graphic initialization, title display,


initialization at power-on time

Graphic initialization, title display, (Halt)


initialization at power-on time

Modify source as follows:


TURN MATE i used with
cnc_rdsyssoft3?

No Yes

TURN MATE i screen Yes crt_cncscrn(CRT_GRH_GRP)


displayed?

No

TURN MATE i screen


(GRAPH key)

- 1165 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.10.3 Restrictions for Use with TURN MATE i

(1) Functions on which restrictions are imposed

Set and use the functions below so that no conflict with TURN MATE i occurs.

(a) User screen number setting


Ensure that the screen numbers set in the parameters (No. 9100) for TURN MATE i
are not used.

crt_setuserscrn Register a user screen number


crt_setuserskey Customize soft keys on the CNC screen

(b) Screen setting


Be sure to make settings again before the screen for a C Language Executor
application created by the user is displayed.

_setvideomode Set the video mode


crt_setmode Set the CRT display mode
_remappalette Set a palette
_remapallpalette Set all palettes
crt_setpalette Set a palette for a VGA character
crt_setallpalette Set palettes for all VGA characters
crt_reguserchar Register user-defined characters
crt_mapuch Map user-defined characters

(2) VGA window display


A VGA window created by the user on the TURN MATE i screen cannot be displayed with
the window task.
When using a VGA window with the window task, ensure that the VGA window is closed
immediately after the TURN MATE i screen is selected.

- 1166 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.11 Display language switching

5.11.1 Overview

The display language of the CNC screen can be switched by a C Language Executor
application program without turning off then on the power.

Function name Description


cnc_chglang witches the display language on the
CNC screen.

5.11.2 Explanation

5.11.2.1 Dynamic language switching

The cnc_chglang function can be used when bit 0 (NLC) of parameter No.
3280 is set to 0. For details of bit 0 (NLC) of parameter No. 3280, see
Subsection 5.11.3, "Parameters".

5.11.2.2 Usable languages

With the cnc_chglang function, the display language can be switched to any of the
following:
English
Japanese
German
French
Chinese (traditional)
Italian
Korean
Spanish
Dutch
Danish
Portuguese
Polish
Hungarian
Swedish
Czech
Chinese (simplified)
Russian
Turkish

- 1167 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.11.2.3 cnc_chglang function reference

[Name]
cnc_chglang

[Syntax]
#include < fwindow.h>
short cnc_chglang(char lang_no);

[Arguments]
lang_no
Language number. A number is assigned to each language.
0 : English
1 : Japanese
2 : German
3 : French
4 : Chinese (traditional)
5 : Italian
6 : Korean
7 : Spanish
8 : Dutch
9 : Danish
10 : Portuguese
11 : Polish
12 : Hungarian
13 : Swedish
14 : Czech
15 : Chinese (simplified)
16 : Russian
17 : Turkish

[Return]
One of the following values is returned:
EW_OK(0) Normal termination
EW_FUNC(1) The function is unusable. Bit 0 (NLC) of parameter No. 3280
for dynamic language switching is set to 1. Alternatively, the
cnc_chglang function is used by other than the main task.
EW_NUMBER(3) The data number is incorrect. A nonexistent language
number is specified.

- 1168 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

[Description]
The display language of the CNC screen is switched by specifying a desired language
number.
If a value other than EW_OK(0) is returned, the display language of the CNC screen
remains unchanged from the one used before the execution of the function.
The cnc_chglang function can be used only with the main task.
For details of tasks, see Subsection 5.1.1, "Task classes" in Section 5.1,
"Multitasking" of Part II, "PROGRAMMING".

NOTE
1 To enable dynamic display language switching with the cnc_chglang function, set
bit 0 (NLC) of parameter No. 3280 to 0.
2 The cnc_chglang function does not write a language number to parameter No.
3281. For details of parameter No. 3281, see Subsection 5.11.3, "Parameters".
3 To check the current display language of the CNC screen, read diagnosis data No.
43 with the cnc_diagnoss function. For details of the cnc_diagnoss function, see
Section 3.4, "CNC/PMC window library" in Chapter 3, "Function References" of
Part II, "PROGRAMMING". For details of diagnosis data No. 43, see Subsection
5.11.4, "Diagnosis data".
4 When executing the cnc_chglang function, disable screen switching with the
crt_setswt function. For the crt_setswt function, see Section 3.6, "CRT operation
library" in Chapter 3, "Function References" of Part II, "PROGRAMMING".

- 1169 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

[Example]
The following program switches the display language to English:
#include <data.h>
#include <fwindow.h>
#include <crt.h>

/* Switch to English */
short example()
{
struct iodbpsd buf, diag;
short ret ;
unsigned int save_mode ;
char lang_no ;
lang_no = 0 ; /* Switch to English (0) */

/* Check current display language */


ret = cnc_diagnoss(43, 0, 4+1, &diag) ;
if(ret){
return ret ;
}

if(lang_no != diag.u.cdata){
/* Disable screen switching */
save_mode = crt_setswt(CRT_SWT_DIS) ;
ret = cnc_chglang(lang_no) ;
if(ret) {
crt_setswt(save_mode) ;
return ret ;
}
crt_setswt(save_mode) ;
//* Hold switched language after power-off */
buf.datano = 3281 ;
buf.type = 0 ;
buf.u.cdata = lang_no ;
ret = cnc_wrparam(4+1, &buf) ;
return ret ;
}
}

For details of the cnc_wrparam function, see Section 3.4, "CNC/PMC


window library" in Chapter 3, "Function References" of Part II,
"PROGRAMMING".

- 1170 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.11.3 Parameters

#7 #6 #5 #4 #3 #2 #1 #0
03280 NLC

[Input type] Parameter input


[Data type] Bit system common type

#0 NLC
Dynamic display language switching is:
0 : Enabled.
1 : Disabled.

03281 Display language

[Input type] Parameter input


[Data type] Byte system common type
[Valid data range] 0 to 17

Select a desired display language.


0 : English
1 : Japanese
2 : German
3 : French
4 : Chinese (traditional)
5 : Italian
6 : Korean
7 : Spanish
8 : Dutch
9 : Danish
10 : Portuguese
11 : Polish
12 : Hungarian
13 : Swedish
14 : Czech
15 : Chinese (simplified)
16 : Russian
17 : Turkish
If a number other than those listed above is set, English is selected.

NOTE
If the value of parameter No. 3281 is changed, the new setting is not reflected
until the power is turned off then back on.

- 1171 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.11.4 Diagnosis data

00043 Current display language of CNC screen

[Data type] Byte system common type


[Unit of data] None
[Valid data range] 0 to 255

The current display language of the CNC screen is displayed.


0 : English
1 : Japanese
2 : German
3 : French
4 : Chinese (traditional)
5 : Italian
6 : Korean
7 : Spanish
8 : Dutch
9 : Danish
10 : Portuguese
11 : Polish
12 : Hungarian
13 : Swedish
14 : Czech
15 : Chinese (simplified)
16 : Russian
17 : Turkish

- 1172 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.12 Display of Simplified Chinese messages

5.12.1 Overview

- Standard output function printf()


- Graphic display function gr_displaychar (), gr_dispstr ()
gr_disp9ifchar (), gr_disp9ifstr ()
- Soft key character string definition function crt_setuserskey ()

For details on the functions, see Section 3.3, "Graphic library", Section 3.4,
"CNC/PMC window library", and Section 3.6, "CRT operation library".

5.12.2 Explanation

5.12.2.1 Function overview

With a C Language Executor application program, Simplified Chinese display is


enabled in the following case:

- When the Simplified Chinese mode is set by using the crt_setmode function

When the Simplified Chinese mode is set, full-size characters (such as kanji of
Japanese) other than the Simplified Chinese characters cannot be displayed. To
display full-size characters other than the Simplified Chinese characters, cancel the
Simplified Chinese mode by using the crt_setmode function.
For details of the crt_setmode function, see Subsection 5.12.2.2, "Simplified Chinese
mode setting function (crt_setmode function)".
The Simplified Chinese character codes supported by C Language Executor are
GB2312 codes. For the Simplified Chinese character codes, see Appendix D,
"Simplified Chinese Character Code List".

- 1173 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.12.2.2 Simplified Chinese mode setting function (crt_setmode function)

When the Simplified Chinese mode is set by using crt_setmode function, Simplified
Chinese messages can be displayed on the screen for a C Language Executor
application program. For the supported functions, see Subsection 5.12.2.3,
"Simplified Chinese display function".

(1) crt_setmode function reference


------------------------------------------------------------------------------
CRT display mode setting <Main, Alarm>
------------------------------------------------------------------------------
[Name]
crt_setmode

[Syntax]
#include<crt.h>
int crt_setmode( unsigned int mode ) ;

[Arguments]
mode CRT display mode
To set the Simplified Chinese mode, specify:
CRT_MODE_CFLAG + CFLAG_GBCODE
CRT_MODE_CFLAG Display operation flag setting
flag
CFLAG_GBCODE Simplified Chinese mode setting
flag
To cancel the Simplified Chinese mode, specify CRT_MODE_CFLAG.

[Return]
When crt_setmode(CRT_MODE_CFLAG + CFLAG_GBCODE) or
crt_setmode(CRT_MODE_CFLAG) is executed, one of the following values is
returned:
0 : Normal termination (The Simplified Chinese mode is set/canceled.)

[Description]
The crt_setmode function is originally used to set the number of display characters
and set the color/monochrome mode. However, even when
crt_setmode(CRT_MODE_CFLAG + CFLAG_GBCODE) or
crt_setmode(CRT_MODE_CFLAG) is executed, the setting of the number of display
characters and the setting of the color/monochrome mode remain unchanged.
For the setting of the number of display characters and the setting of the
color/monochrome mode, see "1.5 crt_setmode" in Section 3.6, "CRT operation
library".

- 1174 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.12.2.3 Simplified Chinese display function

The table below indicates the names and descriptions of the functions that support
Simplified Chinese message display.

Type Function name Description


Standard output function printf Outputs a series of formatted data to the standard output
stream (stdout).
Graphic display function gr_displaychar Displays characters of 8 dots by 16 dots on the graphic
screen.
gr_dispstr Displays character strings of 8 dots by 16 dots on the
graphic screen.
gr_disp9ifchar Displays characters of 16 dots by 25 dots on the graphic
screen by using a 9-inch font.
gr_disp9ifstr Displays character strings of 16 dots by 25 dots on the
graphic screen by using a 9-inch font.
Soft key character string crt_setuserskey Adds user screen selection items to soft keys displayed on
definition function the CNC screen, or moves or deletes existing CNC screen
selection items.

For details of each function, see Section 3.1, "ANSI C standard library", Section 3.3,
"Graphic library", and Section 3.6, "CRT operation library".

- 1175 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.12.2.4 Example of use

Examples of using functions supporting Simplified Chinese message display are


given below.

[Example]
printf

void Printf_GBcode( void )


{
int ret ;
char msg[]={ 0xCA, 0xB5, 0xBC, 0xCA, 0xCE, 0xBB, 0xD6, 0xC3, 0x00 };
/* 实(0xCAB5) 际(0xBCCA) 位(0xCEBB) 置(0xD6C3) */

ret = crt_setmode(CRT_MODE_CFLAG + CFLAG_GBCODE); /* Set Simplified Chinese mode */

if (!ret){
printf("%s¥n", msg); /* Display in Simplified Chinese */
}
crt_setmode(CRT_MODE_CFLAG); /* Cancel Simplified Chinese mode */
}

Execute the program above.

Fig. 1 Example of display (standard output function)

- 1176 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

[Example]
gr_displaychar(), gr_dispstr(), gr_disp9ifchar(), gr_disp9ifstr()

void Dispstr_GBcode( void )


{

char msg[]={ 0xCA, 0xB5, 0xBC, 0xCA, 0xCE, 0xBB, 0xD6, 0xC3, 0x00 };
/* 实(0xCAB5) 际(0xBCCA) 位(0xCEBB) 置(0xD6C3) */

crt_opengr() ;

crt_setmode(CRT_MODE_CFLAG + CFLAG_GBCODE); /* Set Simplified Chinese mode */


gr_displaychar( 0xCAB5, 10, 100, _WHITE_16, _BLACK_16); /* Display in Simplified Chinese */
gr_dispstr ( msg, 10, 130, _WHITE_16, _BLACK_16); /* Display in Simplified Chinese */
gr_disp9ifchar( 0xCAB5, 10, 160, _WHITE_16, _BLACK_16); /* Display in Simplified Chinese */
gr_disp9ifstr ( msg, 10, 190, _WHITE_16, _BLACK_16); /* Display in Simplified Chinese */
crt_setmode(CRT_MODE_CFLAG); /* Cancel Simplified Chinese mode */
_clearscreen( _GVIEWPORT );

crt_closegr();
}

Execute the program above.

Fig. 2 Example of display (graphic display function)

- 1177 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

[Example]
crt_setuserskey()

void SoftKey_GBcode( void )


{
static int crt_table[] = { CRT_POS_ALL ,CRT_POS_CEXE } ;
static unsigned int skey_str[] = {
0xD6D0,0xB9FA,0xD3EF,0xBCF2,0xCCE5,0xD7D6, /* 中(0xD6D0) 国(0xB9FA) 语(0xD3EF) */
0x002A,0x002A,0x002A,0x002A,0x002A,0x002A /* 简(0xBCF2) 体(0xCCE5) 字(0xD7D6) */
};
static struct user_softkey skey_table[] = {
{ 3, SKEY_OP_USER, 3, skey_str }
};

crt_setmode(CRT_MODE_CFLAG + CFLAG_GBCODE); /* Set Simplified Chinese mode */


crt_setuserskey( SKEY_POS, skey_tbl_size( skey_table ), skey_table) ;
crt_setuserscrn( scrn_tbl_size( crt_table ), crt_table ) ;
crt_setmode(CRT_MODE_CFLAG); /*Cancel Simplified Chinese mode */
}

Execute the program above.

Fig. 3 Example of display (soft key character string

definition function)

- 1178 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

NOTE
For Simplified Chinese display, a character string to be displayed on a soft key can be
defined by directly specifying Simplified Chinese character codes (GB2312 codes)
instead of FANUC codes as a display character string after setting the Simplified
Chinese mode with the crt_setmode function.
For display of a full-size character such as a kanji character of Japanese, two 2-byte
codes are specified using FANUC codes. For display of a Simplified Chinese
character (full-size character), however, one 2-byte code listed in Appendix E,
"Simplified Chinese Character Code List" is specified. Codes that extend beyond the
display area are ignored.

Example 1) When Japanese full-size characters are displayed


static unsigned int skey_str[] = {
0x02D8, 0x02D9, 0x0A40, 0x0A41, 0x05C2, 0x05C3,
0x0528, 0x0529, 0x067A, 0x067B, 0x0AB6, 0x0AB7
};
/* 中(0x02D8, 0x02D9) 国(0x0A40, 0x0A41) 語(0x05C2, 0x05C3) */
/* 簡(0x0528, 0x0529) 体(0x067A, 0x067B) 字(0x0AB6, 0x0AB7) */

中 国 語

簡 体 字

Example 2) When Simplified Chinese characters are displayed (1)


static unsigned int skey_str[] = {
0xD6D0, 0xB9FA, 0xD3EF, 0xBCF2, 0xCCE5, 0xD7D6,
0xD6D0, 0xB9FA, 0xD3EF, 0xBCF2, 0xCCE5, 0xD7D6
};
/* 中(0xD6D0) 国(0xB9FA) 语(0xD3EF) 简(0xBCF2) 体(0xCCE5) 字(0xD7D6) */
/* 中(0xD6D0) 国(0xB9FA) 语(0xD3EF) 简(0xBCF2) 体(0xCCE5) 字(0xD7D6) */

中 国 语

简 体 字

The codes for the first six words ( portions) only are displayed. The codes for
the remaining six words are ignored.

- 1179 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

Example 3) When Simplified Chinese characters are displayed (2)


static unsigned int skey_str[] = {
0x002A, 0xD6D0, 0xB9FA, 0x002A,0xD3EF, 0xBCF2,
0xCCE5, 0xD7D6, 0x002A, 0x002A, 0x002A, 0x002A
};
/* *(0x002A) 中(0xD6D0) 国(0xB9FA) *(0x002A) 语(0xD3EF) 简(0xBCF2) */
/* 体(0xCCE5) 字(0xD7D6) *(0x002A) *(0x002A) *(0x002A) *(0x002A) */

* 中 国 *

语 简 体

The codes for the first seven words ( portions) only are displayed. The codes
for the remaining five words including the code 0xD7D6 for "字" are ignored.

- 1180 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.13 Display/acquisition of Russian messages

5.13.1 Overview

Russian can be displayed with the following functions:


- Standard output function printf()
- Graphic display function gr_displaychar (), gr_dispstr ()
gr_disp9ifchar (), gr_disp9ifstr ()
- Soft key character string definition function crt_setuserskey ()

A Russian alarm message displayed on the alarm screen of the CNC can be acquired
with the following function:
- Alarm message acquisition function cnc_rdalminfo()

Russian alarm history data displayed on the alarm history screen of the CNC can be
acquired with the following functions:
- Alarm history data acquisition function cnc_rdalmhistry5(),

A Russian operator message displayed on the external operator message screen of the
CNC can be acquired with the following functions:
- Operator message acquisition function cnc_rdopmsg(), cnc_rdopmsg2(),
cnc_rdopmsg3()

Russian PMC message data set at message display PMC address A can be acquired
with the following function:
- PMC message acquisition function pmc_rdpcmsg()

For details of the each function, see Section 3.3, "Graphic library", Section 3.4,
"CNC/PMC window library", and Section 3.6, "CRT operation library".

- 1181 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.13.2 Explanation

5.13.2.1 Function overview

With a C Language Executor application program, Russian display is enabled in the


following case:
- When the Russian mode is set by using the crt_setmode function
When the Russian mode is set, full-size characters (such as kanji of Japanese) cannot
be displayed. To display full-size characters, cancel the Russian mode by using the
crt_setmode function.

With a C Language Executor application program, a Russian alarm message


displayed on the alarm screen of the CNC can be acquired using the alarm message
acquisition function in one of the following cases:
- When the Russian mode is set by using the crt_setmode function
- When the display language of the CNC screen is Russian

With a C Language Executor application program, Russian alarm history data


displayed on the alarm history screen of the CNC can be acquired using the alarm
history data acquisition function in one of the following cases:
- When the Russian mode is set by using the crt_setmode function
- When the display language of the CNC screen is Russian

With a C Language Executor application program, a Russian operator message


displayed on the external operator message screen of the CNC can be acquired using
the operator message acquisition function in one of the following cases:
- When the Russian mode is set by using the crt_setmode function
- When the display language of the CNC screen is Russian

With a C Language Executor application program, a Russian PMC message displayed


at message display PMC address A can be acquired using the PMC message
acquisition function in one of the following cases:
- When the Russian mode is set by using the crt_setmode function
- When the display language of the CNC screen is Russian

For details of the crt_setmode function, see Subsection 5.13.2.2, "Russian mode
setting function (crt_setmode function)".
The Russian character codes supported by C Language Executor are Cyrillic
character codes. For the Cyrillic character codes, see Appendix E, "Russian (Cyrillic)
Character Code List".

- 1182 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.13.2.2 Russian mode setting function (crt_setmode function)

When the Russian mode is set by using the crt_setmode function, Russian messages
can be displayed/acquired on the screen for a C Language Executor application
program. For the supported functions, see Subsection 5.13.2.3, "Russian display
function".

(1) crt_setmode function reference


------------------------------------------------------------------------------
CRT display mode setting <Main, Alarm>
------------------------------------------------------------------------------
[Name]
crt_setmode

[Syntax]
#include<crt.h>
int crt_setmode( unsigned int mode ) ;

[Arguments]
mode CRT display mode
To set the Russian mode, specify:
CRT_MODE_CFLAG + CFLAG_CYRILLIC
CRT_MODE_CFLAG Display operation flag setting flag
CFLAG_CYRILLIC Russian mode setting flag
To cancel the Russian mode, specify CRT_MODE_CFLAG.

[Return]
When crt_setmode(CRT_MODE_CFLAG + CFLAG_CYRILLIC) or
crt_setmode(CRT_MODE_CFLAG) is executed, one of the following values is returned:
0 : Normal termination (The Russian mode is set/canceled.)
Other values: Error

[Description]
The crt_setmode function is originally used to set the number of display characters and set the
color/monochrome mode. However, even when crt_setmode(CRT_MODE_CFLAG +
CFLAG_CYRILLIC) or crt_setmode(CRT_MODE_CFLAG) is executed, the setting of the
number of display characters and the setting of the color/monochrome mode remain unchanged.
For the setting of the number of display characters and the setting of the color/monochrome mode,
see "1.5 crt_setmode" in Section 3.6, "CRT operation library".

- 1183 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.13.2.3 Russian display/get function

The table below indicates the names and descriptions of the functions that support
Russian message display/acquisition.

Type Function name Description


Standard output function printf Outputs a series of formatted data to the standard output
stream (stdout).
Graphic display function gr_displaychar Displays characters of 8 dots by 16 dots on the graphic
screen.
gr_dispstr Displays character strings of 8 dots by 16 dots on the
graphic screen.
gr_disp9ifchar Displays characters of 16 dots by 25 dots on the graphic
screen by using a 9-inch font.
gr_disp9ifstr Displays character strings of 16 dots by 25 dots on the
graphic screen by using a 9-inch font.
Soft key character string crt_setuserskey Adds user screen selection items to soft keys displayed on
definition function the CNC screen, or moves or deletes existing CNC screen
selection items.

For details of each function, see Section 3.1, "ANSI C standard library", Section 3.3,
"Graphic library", and Section 3.6, "CRT operation library".

Type Function name Description


Alarm message cnc_rdalminfo Reads detail information about alarms issued from the CNC.
acquisition function
Alarm history data cnc_rdalmhistry5 Reads CNC alarm history data.
acquisition function
Operator message cnc_rdopmsg Reads a CNC operator message.
acquisition function cnc_rdopmsg2 Reads a CNC operator message.
cnc_rdopmsg3 Reads a CNC operator message.
PMC message acquisition pmc_rdpcmsg Acquires specified PMC message data. A PMC message
function consists of the same ASCII code character string as
displayed on the alarm screen of the CNC. A NULL
character (’¥0’) is added to the end of a character string.

For details of each function, see Section 3.4, "CNC/PMC window library".

- 1184 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.13.2.4 Examples of use

Examples of using functions supporting Russian message display/acquisition are


given below.

[Example]
printf()

void Printf_CYcode( void )


{
char msg[]={0xC3, 0xC1, 0xC6, 0xC4, 0xC8, 0xC7, 0x00};
/*ГБЖДИЗ(0xC3, 0xC1, 0xC6, 0xC4, 0xC8, 0xC7) */

ret = crt_setmode(CRT_MODE_CFLAG + CFLAG_CYRILLIC); /* Set Russian */

if (!ret){
printf("%s¥n", msg); /* Display in Russian */
}
crt_setmode(CRT_MODE_CFLAG); /* Cancel Russian */
}

Execute the program above.

Fig. 1 Example of display (standard output function)

- 1185 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

[Example]
gr_displaychar(), gr_dispstr(), gr_disp9ifchar(), gr_disp9ifstr()

void Dispstr_CYcode( void )


{
char msg[]={0xC3, 0xC1, 0xC6, 0xC4, 0xC8, 0xC7, 0x00};
/*ГБЖДИЗ(0xC3, 0xC1, 0xC6, 0xC4, 0xC8, 0xC7) */

crt_opengr() ;

crt_setmode(CRT_MODE_CFLAG + CFLAG_CYRILLIC); /* Set Russian */


gr_displaychar( 0xC3, 10, 100, _WHITE_16, _BLACK_16); /* Display in Russian */
gr_dispstr ( msg, 10, 130, _WHITE_16, _BLACK_16); /* Display in Russian */
gr_disp9ifchar( 0xC3, 10, 160, _WHITE_16, _BLACK_16); /* Display in Russian */
gr_disp9ifstr ( msg, 10, 190, _WHITE_16, _BLACK_16); /* Display in Russian */
crt_setmode(CRT_MODE_CFLAG); /* Cancel Russian */
crt_closegr();
}

Execute the program above.

Fig. 2 Example of display (graphic display function)

- 1186 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

[Example]
crt_setuserskey()

void SoftKey_CYcode( void )


{
static int crt_table[] = { CRT_POS_ALL ,CRT_POS_CEXE } ;
static unsigned int skey_str[] = {
0x0020,0x00C0,0x00C1,0x00C2,0x00C3,0x0020, /* АБВГ */
};
static struct user_softkey skey_table[] = {
{ 3, SKEY_OP_USER, 3, skey_str }
};
crt_setmode(CRT_MODE_CFLAG + CFLAG_CYRILLIC); /* Set Russian */
crt_setuserskey( SKEY_POS, skey_tbl_size( skey_table ), skey_table ) ;
crt_setuserscrn( scrn_tbl_size( crt_table ), crt_table ) ;
crt_setmode(CRT_MODE_CFLAG); /* Cancel Russian */
}

Execute the program above.

Fig. 3 Example of display (soft key

character string definition function)

- 1187 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

[Example]
cnc_rdalminfo()

void Rdalminfo_CYcode( void )


{
static alminfo buf;
char msgbuf[32]
char msgbuf2[32]
int ialm_type, cnt, ret;

crt_setmode( CRT_MODE_CFLAG + CFLAG_CYRILLIC ); /* Set Russian */


for( ialm_type = 0; ialm_type < 1; ialm_type++){
ret = cnc_rdalminfo( 1, ialm_type, 40*1+4, &buf );
if( !ret ){
for( cnt = 0; cnt < 1; cnt++ ){
if( buf.u.alm2.alm[cnt].alm_len ){
strncpy( msgbuf, buf.u.alm2.alm[cnt].alm_msg, buf.u.alm2.alm[cnt].msg_len );
printf( "%s¥n", msgbuf );
strncpy( msgbuf, magbuf2, 32 );
}
}
}
} crt_setmode( CRT_MODE_CFLAG ); /* Cancel Russian */
}

Execute the program above.

Fig. 4 Example of display (alarm message acquisition function)

- 1188 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

[Example]
cnc_rdalmhistry5()

void Rdalmhistry_CYcode( void )


{
static odbahis5 almhis;
char msgbuf[32] = {‘¥0’}
char msgbuf2[32] = {‘¥0’}
int i, ret;

crt_setmode( CRT_MODE_CFLAG + CFLAG_CYRILLIC ); /* Set Russian */


ret = cnc_stopophis();
if( !ret ){
ret = cnc_rdalmhistry5( 1, 1, sizeof( almhis ), &almhis );
if( !ret ){
strncat( msg, almhis.alm_his[0].alm_msg, almhis.alm_his[0].len_msg );
printf( “%s¥n”, msg );
strncpy( msg, msg2, 32 );
}
}
crt_setmode( CRT_MODE_CFLAG ); /* Cancel Russian */
}

Execute the program above.

Fig. 5 Example of display (alarm history data acquisition function)

- 1189 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

[Example]
cnc_rdopmsg()

void Rdalmhistry_CYcode( void )


{
static msg buf;

crt_setmode( CRT_MODE_CFLAG + CFLAG_CYRILLIC ); /* Set Russian */


cnc_rdopmsg( 0, 6+256, &buf );
if( buf.datano != -1 ){
printf( “%04d %s¥n”, buf.datano, buf.data );
}else{
printf( “No operator message.¥n” );
}
crt_setmode( CRT_MODE_CFLAG ); /* Cancel Russian */
}

Execute the program above.

Fig. 6 Example of display (operator message acquisition function)

- 1190 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

[Example]
pmc_rdpcmsg()

void sample( void )


{
short ret ;
unsigned short idx = 0, bit = 0 ;
struct pmcmsg *buf ;

buf = (struct pmcmsg *)malloc( sizeof( struct pmcmsg ) ) ;


if( buf == NULL ){
return;
}
ret = pmc_rdpcmsg( idx, bit, buf ) ;
crt_setmode(CRT_MODE_CFLAG + CFLAG_CYRILLIC); /* Set Russian */
if ( !ret ) printf( "A%02u.%u ¥"%s¥"¥n", idx, bit, buf->pmc_msg ) ;
crt_setmode(CRT_MODE_CFLAG); /* Cancel Russian */
free( buf ) ;
}

Execute the program above.

Fig. 7 Example of display (PMC message acquisition function)

- 1191 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.14 Display/acquisition of Turkish messages

5.14.1 Overview

Turkish can be displayed with the following functions:


- Standard output function printf()
- Graphic display function gr_displaychar (), gr_dispstr ()
gr_disp9ifchar (), gr_disp9ifstr ()
- Soft key character string definition function crt_setuserskey ()

A Turkish alarm message displayed on the alarm screen of the CNC can be acquired
with the following function:
- Alarm message acquisition function cnc_rdalminfo()

Turkish alarm history data displayed on the alarm history screen of the CNC can be
acquired with the following functions:
- Alarm history data acquisition function cnc_rdalmhistry5(),

A Turkish operator message displayed on the external operator message screen of the
CNC can be acquired with the following functions:
- Operator message acquisition function cnc_rdopmsg(), cnc_rdopmsg2(),
cnc_rdopmsg3()

Turkish PMC message data set at message display PMC address A can be acquired
with the following function:
- PMC message acquisition function pmc_rdpcmsg()

For details of each function, see Chapter 3, "Function References".

- 1192 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.14.2 Explanation

5.14.2.1 Function overview

With a C Language Executor application program, Turkish display is enabled in the


following case:
- When the Turkish mode is set by using the crt_setmode function
When the Turkish mode is set, full-size characters (such as kanji of Japanese)
cannot be displayed. To display full-size characters, cancel the Turkish mode by
using the crt_setmode function.

With a C Language Executor application program, a Turkish alarm message displayed


on the alarm screen of the CNC can be acquired using the alarm message acquisition
function in one of the following cases:
- When the Turkish mode is set by using the crt_setmode function
- When the display language of the CNC screen is Turkish

With a C Language Executor application program, Turkish alarm history data


displayed on the alarm history screen of the CNC can be acquired using the alarm
history data acquisition function in one of the following cases:
- When the Turkish mode is set by using the crt_setmode function
- When the display language of the CNC screen is Turkish

With a C Language Executor application program, a Turkish operator message


displayed on the external operator message screen of the CNC can be acquired using
the operator message acquisition function in one of the following cases:
- When the Turkish mode is set by using the crt_setmode function
- When the display language of the CNC screen is Turkish

With a C Language Executor application program, a Turkish PMC message displayed


at message display PMC address A can be acquired using the PMC message
acquisition function in one of the following cases:
- When the Turkish mode is set by using the crt_setmode function
- When the display language of the CNC screen is Turkish

For details of the crt_setmode function, see Subsection 5.14.2.2, "Turkish mode
setting function (crt_setmode function)".
For the Turkish character codes supported by C Language Executor, see Appendix F,
"Turkish Character Code List".

- 1193 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.14.2.2 Turkish mode setting function (crt_setmode function)


When the Turkish mode is set by using the crt_setmode function, Turkish messages
can be displayed/acquired on the screen for a C Language Executor application
program. For the supported functions, see Subsection 5.14.2.3, "Turkish display
function".

(1) crt_setmode function reference


------------------------------------------------------------------------------
CRT display mode setting <Main,Alarm>
------------------------------------------------------------------------------
[Name]
crt_setmode

[Syntax]
#include<crt.h>
int crt_setmode( unsigned int mode ) ;

[Arguments]
mode CRT display mode
To set the Turkish mode, specify:
CRT_MODE_CFLAG + CFLAG_TURKISH
CRT_MODE_CFLAG Display operation flag setting flag
CFLAG_TURKISH Turkish mode setting flag
To cancel the Turkish mode, specify CRT_MODE_CFLAG.

[Return]
When crt_setmode(CRT_MODE_CFLAG + CFLAG_TURKISH) or
crt_setmode(CRT_MODE_CFLAG) is executed, one of the following values is returned:
0 : Normal termination (The Turkish mode is set/canceled.)

[Description]
The crt_setmode function is originally used to set the number of display characters and set the
color/monochrome mode. However, even when crt_setmode(CRT_MODE_CFLAG +
CFLAG_TURKISH) or crt_setmode(CRT_MODE_CFLAG) is executed, the setting of the
number of display characters and the setting of the color/monochrome mode remain unchanged.
For the setting of the number of display characters and the setting of the color/monochrome mode,
see "1.5 crt_setmode" in Section 3.6, "CRT operation library".

- 1194 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.14.2.3 Turkish display/get function

The table below indicates the names and descriptions of the functions that support
Turkish message display/acquisition.

Type Function name Description


Standard output function printf Outputs a series of formatted data to the standard output
stream (stdout).
Graphic display function gr_displaychar Displays characters of 8 dots by 16 dots on the graphic
screen.
gr_dispstr Displays character strings of 8 dots by 16 dots on the
graphic screen.
gr_disp9ifchar Displays characters of 16 dots by 25 dots on the graphic
screen by using a 9-inch font.
gr_disp9ifstr Displays character strings of 16 dots by 25 dots on the
graphic screen by using a 9-inch font.
Soft key character string crt_setuserskey Adds user screen selection items to soft keys displayed on
definition function the CNC screen, or moves or deletes existing CNC screen
selection items.

For details of each function, see Section 3.1, "ANSI C standard library", Section 3.3,
"Graphic library", and Section 3.6, "CRT operation library".

- 1195 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

Type Function name Description


Alarm message cnc_rdalminfo Reads detail information about alarms issued from the
acquisition function CNC.
Alarm history data cnc_rdalmhistry5 Reads CNC alarm history data.
acquisition function
Operator message cnc_rdopmsg Reads a CNC operator message. For the difference from
acquisition function the cnc_rdopmsg2 function and the cnc_rdopmsg3 function,
see Section 3.2, "Function references".
cnc_rdopmsg2 Reads a CNC operator message. For the difference from
the cnc_rdopmsg function and the cnc_rdopmsg3 function,
see Section 3.2, "Function references".
cnc_rdopmsg3 Reads a CNC operator message. For the difference from
the cnc_rdopmsg function and the cnc_rdopmsg2 function,
see Section 3.2, "Function references".
PMC message acquisition pmc_rdpcmsg Acquires specified PMC message data. A PMC message
function consists of the same ASCII code character string as
displayed on the alarm screen of the CNC. A null character
(’¥0’) is added to the end of a character string.

For details of each function, see Section 3.4, "CNC/PMC window library".

- 1196 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.15 Checking operation restart after program editing

5.15.1 Overview

When a halted or stopped automatic operation is restarted after editing the program in
the haled or stopped state, the program may not be executed as displayed on the
screen. If bit 7 (RSC) of parameter No. 10330 is set to 1, the CNC screen displays a
confirmation message to attract the operator's attention so that operation after editing
can be restarted only when the operator gives permission.
When this function is enabled, a similar confirmation message needs to be displayed
on all CNC screens including C Language Executor application screen. This section
describes the procedure for incorporating this function in C Language Executor
application screen.

5.15.2 Explanation

5.15.2.1 Outline of processing

When the C Language Executor application screen is displayed, the application


program performs the following processing:
<1> The application program calls the cnc_statinfo2 function and reads the value of
"restart" at all times to check whether a confirmation message needs to be
displayed.

<2> If display of a confirmation message is found to be necessary (restart=1), the


following message is displayed in red:
"PROGRAM MIGHT BE EDITED. RESTART?"

<3> 「YES」・「NO」 is displayed at the same time as <2>.

<4> When "YES" is pressed, the application program sets 1 in the argument "restart"
and calls the cnc_confirm_restart function.
When the program start button is pressed again, operation is restarted.
<5> When "NO" is pressed, the application program sets 0 in the argument "restart"
and calls the cnc_confirm_restart function.
When the program start button is pressed again, the cnc_statinfo2 function reads
1 from "restart", so that the confirmation message is displayed.

- 1197 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.15.2.2 Function references

This function is called at all times to check whether the confirmation message needs to be displayed.

(1) Reading CNC status information

[Name]
cnc_statinfo2

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_statinfo2( struct odbst2 *statinfo ) ;

[Arguments]
statinfo
Pointer to the odbst2 structure where CNC status information is returned

struct odbst2 {
short hdck ; /* Manual handle retrace status */
short tmmode ; /* Not used */
short aut ; /* Automatic/manual operation mode selection */
short run ; /* Automatic operation status */
short motion ; /* Axis movement/dwell status */
short mstb ; /* M, S, T, and B function status */
short emergency ; /* Emergency stop status */
short alarm ; /* Alarm status */
short edit ; /* Program editing status */
short warning; /* Warning message status */
short o3dchk; /* Not used */
short ext_opt; /* Option status */
short restart; /* Status of restart check after program editing */
};
* For a 2-path system, all statuses are available for each path.
hdck Manual handle retrace status
0 : Manual handle retrace is disabled.
1 : M.H.RTR. (Manual handle retrace)
2 : NO RVRS. (Reverse movement is disabled.)
3 : NO CHAG. (Direction switching is disabled.)

- 1198 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

aut Automatic/manual operation mode selection


0 : MDI 1 : MEMory
2 : **** 3 : EDIT
4 : HaNDle 5 : JOG
6 : Teach in JOG 7 : Teach in HaNDle
8 : INC・feed 9 : REFerence
10 : ReMoTe
run Automatic operation status
0 : ****(reset) 1 : STOP
2 : HOLD 3 : STaRT
motion Axis movement/dwell status
0 : *** 1 : MoTioN
2 : DWeLl
mstb M, S, T, or B function status
0 : ***(Others) 1 : FIN
emergency Emergency stop status
0 : (Emergency stop canceled) 1 : EMerGency
2 : ReSET
alarm Alarm status
0 : ***(Others) 1 : ALarM
2 : BATtery low
edit Other status
- Machining center system
0 : ****(No editing)
1 : EDIT (Editing being performed)
2 : SeaRCH (Search being performed)
3 : OUTPUT (Data output being performed)
4 : INPUT (Data input being performed)
5 : COMPARE (Comparison being performed)
6 : Label SKip (Label skip status)
7 : ReSTaRt (Program being restarted)
13 : HANDLE (Handle interrupt being made)
16 : AICC (AI contour control operation being performed)

17 : MEmory-CHecK (Part program storage check being made)

- Lathe system
0 : ****(No editing)
1 : EDIT (Editing being performed)
2 : SeaRCH (Search being performed)
3 : OUTPUT (Data output being performed)
4 : INPUT (Data input being performed)
5 : COMPARE (Comparison being performed)

- 1199 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

6 : Label SKip (Label skip status)


8 : Work ShiFT (Workpiece shift amount write mode)
9 : ReSTaRt (Program being restarted)
17 : MEmory-CHecK (Part program storage check being made)

warning Warning status


0 : (No warning)
1 : WaRNing (Started in the middle of a program)
restart Confirmation for restarting automatic operation after program editing
0 : One of the following statuses is present:
- The program is not edited.
- Bit 7 (RSC) of parameter No. 10330 for displaying the confirmation
message for restarting automatic operation is not enabled.
- The function is not supported by the NC.
1 : The program has been edited.
[Return]
When the function has been executed normally, EW_OK is returned. When an error
occurs, a value other than EW_OK is returned.

[Description]
CNC status information is read. Information items are stored in the members within
odbst2.

- 1200 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(2) Confirmation for restarting after program editing

When "YES" or "NO" is pressed in response to the confirmation message, this function is called to
post whether "YES" or "NO" is pressed to the CNC.

[Name]
cnc_confirm_restart

[Syntax]
#include <data.h>
#include <fwindow.h>
short cnc_confirm_restart( unsigned short restart ) ;

[Arguments]
restart
Specify whether to restart automatic to after program editing.

0 : Disables automatic operation (when "NO" is pressed on the screen).


1 : Enables automatic operation (when "YES" is pressed on the screen).

[Return]
When the function has been executed normally, EW_OK is returned. If an error
occurs, a value other than EW_OK is returned.
Major errors are listed below.
EW_NUMBER(3) The specification of "restart" is incorrect.
A value other than 0 and 1 is specified in "restart".
EW_PARAM(9) Parameter error
Set the parameter as follows:
Bit 7 (RSC) of parameter No. 10330 = 1
EW_REJECT(9) The program is not edited.

- 1201 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.16 Eight-level data protection

5.16.1 Overview

By using eight functions of the 8-level data protection function, operations such as
operation level acquisition and operation level password input/change can be
performed with a C Language Executor application program.
The table below lists the functions of the 8-level data protection function.

Function name Description


cnc_rdope_lvl Acquires the current operation level.
cnc_prot_pswinp Sets/changes the operation level.
cnc_prot_pswcan Changes the operation level to a level from 0 to 3.
cnc_prot_pswchg Changes the operation level password.
cnc_prot_pswinit Initializes the operation level password.
cnc_rdprt_lvl Acquires the change protection level/output protection
level of each data item.
cnc_wrprt_lvl Changes the change protection level/output protection
level of each data item.
cnc_rdprt_data Acquires the use permission information of each data
item.

NOTE
1 For details of the 8-level data protection function, refer to
Subsection, "Eight-Level Data Protection Function" in "Connection
Manual: Function" (B-64303EN-1) , "Eight-Level Data Protection
Function" in “User’s Manual (Common to T/M)” (B-64304EN/01)
and "Eight-Level Data Protection Function" in "PMC Programming
Manual" (B-64393EN).
2 The 8-level data protection function is an optional function.

- 1202 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.16.2 Explanation

With a C Language Executor application program, operations (1) through (8) below
can be performed using the functions of the 8-level data protection function.

(1) Acquisition of the current operation level


(2) Setting/changing of the operation level
(3) Changing of the operation level to a level from 0 to 3
(4) Changing of the operation level password
(5) Initialization of the operation level password
(6) Acquisition of the change protection level/output protection level of each data
item
(7) Changing of the change protection level/output protection level of each data item
(8) Acquisition of the use permission information of each data item

For the references of the functions that perform operations (1) to (8), see Subsection
5.16.2.1, "Function references".

- 1203 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.16.2.1 Function references

(1) Acquisition of the current operation level

[Name]
cnc_rdope_lvl

[Syntax]
#include <fwindow.h>
short cnc_rdope_lvl( short *ope_level ) ;

[Arguments]
ope_level Pointer for indicating a variable where the current operation
level is returned
A value from 0 to 7 is set.

[Return]
One of the following values is returned:
EW_OK (0) Normal termination
EW_NOOPT(6) The necessary function is not specified.
Enable the 8-level data protection function (bit 4 (NLV) of
parameter No. 8131 = 1).

[Description]
This function acquires the current operation level ([1] in the figure below).

[1]

- 1204 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(2) Setting/changing of the operation level

[Name]
cnc_prot_pswinp

[Syntax]
#include <fwindow.h>
short cnc_prot_pswinp( char *pswd ) ;

[Arguments]
pswd Pointer to a password character string
Specify a password character string consisting of 3 to 8
characters. Only uppercase letters and numeric characters can
be used.
Add a NULL character (as the fourth to ninth character) to the
end of the character string.

[Return]
One of the following values is returned:
EW_OK (0) Normal termination
EW_DATA(5) The data is incorrect.
Check the password character string.
Add a NULL character (as the fourth to ninth character) to the
end of the character string.
EW_NOOPT(6) The necessary option is not specified.
Enable the 8-level data protection function (bit 4 (NLV) of
parameter No. 8131 = 1).

[Description]
This function inputs a password for the operation level to be set/changed.
The operation level can be changed when the validity of the password is confirmed.

- 1205 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(3) Changing of the operation level to a level from 0 to 3

[Name]
cnc_prot_pswcan

[Syntax]
#include <fwindow.h>
short cnc_prot_pswcan( void ) ;

[Arguments]
------

[Return]
One of the following values is returned:
EW_OK (0) Normal termination
EW_NOOPT(6) The necessary option is not specified.
Enable the 8-level data protection function (bit 4 (NLV) of
parameter No. 8131 = 1).
EW_MODE(12) The mode of the CNC is incorrect.
Place the CNC in the MDI mode.

[Description]
This function changes the operation level to a level from 0 to 3 when the current
operation level is a level from 4 to 7.
If the current operation level is a level from 0 to 3, this function returns EW_OK
without performing any operation.
This function can be used only when the CNC is placed in the MDI mode.

- 1206 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(4) Changing of the operation level password

[Name]
cnc_prot_pswchg

[Syntax]
#include <fwindow.h>
short cnc_prot_pswchg( short ope_level, char *pswd_old,
char *pswd_new, char *pswd_cnf ) ;

[Arguments]
ope_level Specify an operation level whose password is to be changed. (4
to 7)
Only the current operation level can be set.
pswd_old Pointer to the previous password character string
Specify a password character string consisting of 3 to 8
characters.
Only uppercase letters and numeric characters can be used.
Add a NULL character (as the fourth to ninth character) to the
end of the character string.
pswd_new Pointer to a new password character string
Specify a password character string consisting of 3 to 8
characters.
Only uppercase letters and numeric characters can be used.
Add a NULL character (as the fourth to ninth character) to the
end of the character string.
pswd_cnf Pointer to a new password confirmation character string
Specify a password character string consisting of 3 to 8
characters.
Only uppercase letters and numeric characters can be used.
Add a NULL character (as the fourth to ninth character) to the
end of the character string.

[Return]
One of the following values is returned:
EW_OK (0) Normal termination
EW_DATA(5) The data is incorrect.
Check the password character string.
Add a NULL character (as the fourth to ninth character) to the
end of the character string.
Check the current operation level.
EW_NOOPT(6) The necessary option is not specified.
Enable the 8-level data protection function (bit 4 (NLV) of
parameter No. 8131 = 1).

- 1207 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

EW_MODE(12) The mode of the CNC is incorrect.


Place the CNC in the MDI mode.

[Description]
This function changes the password for the operation level.
The password can be changed when the validity of the previous password is
confirmed, the new password and new password for confirmation are found to be
identical, and the format is correct.
Only the password for the current operation level can be changed.
This function can be used only when the CNC is placed in the MDI mode.

- 1208 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(5) Initialization of the operation level password

[Name]
cnc_prot_pswinit

[Syntax]
#include <fwindow.h>
short cnc_prot_pswinit( short ope_level ) ;

[Arguments]
ope_level Set an operation level whose password is to be initialized. (4 to
7)

[Return]
One of the following values is returned:
EW_OK (0) Normal termination
EW_DATA(5) The data is incorrect.
Check the current operation level and the operation level whose
password is to be initialized.
EW_NOOPT(6) The necessary option is not specified.
Enable the 8-level data protection function (bit 4 (NLV) of
parameter No. 8131 = 1).
EW_MODE(12) The mode of the CNC is incorrect.
Place the CNC in the MDI mode.

[Description]
This function initializes the password of a specified operation level.
This function can initialize the password of only an operation level that is lower
than the current operation level.
This function can be used only when the CNC is placed in the MDI mode.

- 1209 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(6) Acquisition of the change protection level/output protection level of each data
item

[Name]
cnc_rdprt_lvl

[Syntax]
#include <fwindow.h>
short cnc_rdprt_lvl( short item_id, short *chg_level, short *out_level ) ;

[Arguments]
item_id Set a data ID.
For information about a data ID, see Subsection 5.16.2.2, "Data
ID list".
chg_level Pointer to a variable where a change protection level value is
returned
A change protection level is set. (0 to 7)
out_level Pointer to a variable where an output protection level value is
returned
An output protection level is set. (0 to 7)
[Return]
One of the following values is returned:
EW_OK (0) Normal termination
EW_DATA(5) The data is incorrect.
Check the data ID.
EW_NOOPT(6) The necessary option is not specified.
Enable the 8-level data protection function (bit 4 (NLV) of
parameter No. 8131 = 1).

- 1210 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

[Description]
For the data of a specified data ID ([1] in the figure below), the change protection
level ([2] in the figure below) and the output protection level ([3] in the figure below)
are acquired.
As the output protection level for data with no output function applied, the value 0
is set.

[1] [2] [3]

- 1211 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(7) Changing of the change protection level/output protection level of each data item

[Name]
cnc_wrprt_lvl

[Syntax]
#include <fwindow.h>
short cnc_wrprt_lvl( short item_id, short chg_level, short out_level ) ;

[Arguments]
item_id Set a data ID.
For information about a data ID, see Subsection 5.16.2.2, "Data
ID list".
chg_level Set a change protection level. (0 to 7)
Set -1 when making no protection level change.
out_level Set an output protection level. (0 to 7)
Set -1 when making no protection level change.

[Return]
One of the following values is returned:
EW_OK (0) Normal termination
EW_DATA(5) The data is incorrect.
Check the data ID.
Check the current operation level and the operation level to be
changed.
EW_NOOPT(6) The necessary option is not specified.
Enable the 8-level data protection function (bit 4 (NLV) of
parameter No. 8131 = 1).
EW_MODE(12) The mode of the CNC is incorrect.
Place the CNC in the MDI mode.
[Description]
This function changes the change protection level and output protection level for the
data of a specified data ID.
This function can change the protection level for only data whose protection level is
the same as or lower than the current operation level.
The protection level cannot be changed to a level higher than the current operation
level.
The change protection level and output protection level cannot be changed
simultaneously.
Be sure to set -1 in one of the two arguments.
If the output protection level of data with no output function applied is changed, this
function returns EW_OK without performing any operation.
This function can be used only when the CNC is placed in the MDI mode.

- 1212 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(8) Acquisition of the use permission information of each data item

[Name]
cnc_rdprt_data

[Syntax]
#include <fwindow.h>
short cnc_rdprt_data( short item_id, short *item_res ) ;

[Arguments]
item_id Set a data ID.
For information about a data ID, see Subsection 5.16.2.2, "Data
ID list".
item_res Pointer to a variable where whether the data may be used is
returned
When the data may be used, 0 is set. When the data may not be
used, 1 is set.

[Return]
One of the following values is returned:
EW_OK (0) Normal termination
EW_DATA(5) The data is incorrect.
Check the data ID.
EW_NOOPT(6) The necessary option is not specified.
Enable the 8-level data protection function (bit 4 (NLV) of
parameter No. 8131 = 1).

[Description]
This function acquires information about whether the data of a specified data ID
may be used in connection with the system configuration and so forth.

- 1213 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.16.2.2 Data ID list

The tables below provide a CNC data ID list and a PMC data ID list.

(1) CNC data


Table 2.2.1 CNC data ID list (○: Possible, ×: Impossible)
Data Data
Data ID Data type/operation type
change output
1 Parameter data ○ ○
2 Setting data ○ ○
3 Pitch error compensation data ○ ○
4 Clock data ○ ○
Custom macro variable data (including the macro variable data of the ○ ○
5
macro executor)
6 Periodic maintenance information ○ ○
7 Tool life management data ○ ○
8 Workpiece origin shift data ○ ○
9 Workpiece origin offset data ○ ○
13 Power Mate CNC manager function parameter data ○ ○
14 Part program edit operation ○ ○
15 Absolute coordinate present operation ○ ○
16 Tool offset data (common) ○ ○
17 Tool offset data (geometry) ○ ○
18 Tool offset data (wear) ○ ○
19 Tool offset data (cutter, geometry) ○ ○
20 Tool offset data (cutter, wear) ○ ○
21 Tool offset data (tool length, geometry) ○ ○
22 Tool offset data (tool length, wear) ○ ○

- 1214 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

(2) PMC data


Table 2.2.2 PMC data ID list (○: Possible, ×: Impossible)
Data Data
Data ID Data type/operation type
change output
121 Configuration parameter data ○ ×
122 Setting (online) data ○ ×
141 1st PMC: Setting (path-by-path) data ○ ×
142 1st PMC: Sequence program edit operation ○ ○
143 1st PMC: PMC parameter data ○ ○
144 1st PMC: Timer data ○ ×
145 1st PMC: Counter data ○ ×
146 1st PMC: Keep relay (user) change operation ○ ×
147 1st PMC: Keep relay (system) change operation ○ ×
148 1st PMC: Data table change operation ○ ×
149 1st PMC: Data table control change operation ○ ×
150 1st PMC: PMC memory data ○ ×

- 1215 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.17 FTP transfer

5.17.1 Overview

In C Language Executor application, FTP Transfer function between CNC and host
computers (hereinafter referred to as "host") is available. By using this function, it is
possible to put the data to the host and get the data from the host in C Language
Executor application.

CNC Host

File
C Language Executor

Data
Embedded
Ethernet
or
PCMCIA
LAN

Ethernet

The following 6 functions for putting / getting data are added in C Language Executor
Library.

Function name Description


eth_putopen Open the communication interface in putting mode
eth_put Put the data to the host
eth_putclose Close the communication interface in putting mode
eth_getopen Open the communication interface in getting mode
eth_get Get the data from the host
eth_getclose Close the communication interface in getting mode

- 1216 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.17.2 Explanation

In C Language Executor application, the following operation (1) – (6) can be executed.

(1) Open the communication interface in putting mode ( eth_putopen() )


(2) Put the data to the host ( eth_put() )
(3) Close the communication interface in putting mode ( eth_putclose() )
(4) Open the communication interface in getting mode ( eth_getopen() )
(5) Get the data from the host ( eth_get() )
(6) Close the communication interface in getting mode ( eth_getclose() )

For details of the functions for performing operations (1) through (6), see Subsection
5.17.2.1, "Function references".

NOTE
1 It is necessary to set the following parameters that relate to connect
host to CNC.
- Host name
- Port number
- User name
- Password
- Login folder
For details of the method of setting the items above, refer to
Subsection, "Setting of the FTP File Transfer Function” in
"MAINTENANCE MANUAL (B-64305EN)".
2 This function performs communication with the FTP server of the
host. So, an FTP server must be set beforehand on the host.
For details of the method of setting up an FTP server, refer to
Appendix B, "EXAMPLE OF FTP SERVER SETUP", in "FANUC
FAST Ethernet, FANUC FAST DataServer OPERATOR’S MANUAL
(B-64414EN)".

- 1217 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.17.2.1 Function references

(1) Open the communication interface in putting mode < Main, Comm, Alarm, Win >

[Name]
eth_putopen

[Syntax]
#include <ethernet.h>
short eth_putopen( short type, char *file_name ) ;

[Arguments]
type
Specify the kind of the communication function used for FTP transfer.
0 : Embedded Ethernet port or PCMCIA Ethernet card.

file_name
Specify the pointer to the file name of the host file in which the putting data is
written.
Strings of the file name are 256 characters or less including NULL in the terminal.
Please set NULL in the terminal.

[Return]
The return values are as follows.
EW_OK(0) Successful.
EW_BUSY(-1) The communication interface has already been opened.
EW_FUNC(1) It was executed by the task that can't be used other
than thefollowing tasks.
- Main task (TASK1)
- Communication task (TASK2)
- Alarm task (TASK3)
- Window task (TASK4)
EW_ATTRIB(4) The specification of "type" is wrong.
EW_REJECT(13) The communication interface has already been used by
other functions.

[Description]
The communication interface specified with "type" is opened in putting mode.
It is necessary to execute this function before putting data to the host.
When this function is executed specifying only the file name with "file_name", the
file of the specified name is made for host's current directory.
When this function is executed specifying the file name in which "file_name"
contains passing for the host that can specify the file name that contains passing, the
file is made for the specified directory.

- 1218 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

By executing the function eth_put(), it is possible to put the data to the file made for
the host by this function.
The current directory of the connected host can be checked and changed on the host
file list screen. For details of the host file list screen, refer to Section, "EMBEDDED
ETHERNET OPERATIONS", in "Common to Lathe System/Machining Center
System USER’S MANUAL (B-64304EN)".

The basic procedure for transmitting data is indicated below.

Open the communication interface


eth_putopen()

= EW_OK

= EW_DTSRVR
Putting data
eth_put() = EW_BUFFER

= EW_OK

Data exists?
YES

NO

Close the communication interface


eth_putclose()

NOTE
1. The file might be overwrited and "EW_OK(0)" might be returned
according to the host's setting when the function eth_putopen() is
executed specifying the file name of file that the host has already.
2. When the function eth_putopen() is executed specifying the file
name that contains passing for the host that can't specify the file
name that contains passing, "EW_OK(0)" is returned.
Afterwards, when the function eth_put function() is executed,
"EW_DTSRVR(14)" is returned. At this time, when the function
cnc_getdtailerr() is executed, it gets error No.502 "It failed in the
putting of data" as detailed status.

- 1219 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(2) Put the data to the host < Main, Comm, Alarm, Win >

[Name]
eth_put

[Syntax]
#include <ethernet.h>
short eth_put( long *length, char *data ) ;

[Arguments]
length
Specify the pointer to the variable of the long type in which the number of
characters of data put to the transmit buffer is set.
When this function is executed with no error, the number of characters actually put
to the transmit buffer is set.

data
Specify the first address in the area where the data put to the transmit buffer is set.

[Return]
The return values are as follows.
EW_OK(0) Successful.
EW_FUNC(1) The function eth_putopen() is not executed.
Or, it was executed by the task that can't be used other
than the following tasks.
- Main task (TASK1)
- Communication task (TASK2)
- Alarm task (TASK3)
- Window task (TASK4)
EW_LENGTH(2) "0" or less is specified for "length".
EW_BUFFER(10) Transmit buffer full. Retry the putting of data.
EW_DTSRVR(14) Communication error occurs.
Close the communication interface.

[Description]
The data for the specified size is put to the transmit buffer.
When the empty size in the transmit buffer is less than the specified size with
"length", the data of the empty size is put and the number of characters is set in
"length".
When there is no empty size in the transmit buffer and the character cannot be put,
"EW_BUFFER(10)" is returned. Please retry the putting of data in this case.
When the communication error occurs while putting data to the host,
"EW_DTSRVR(14)" is returned. Please execute the function eht_putclose() and
close the communication interface in this case.

- 1220 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

To collect more detailed information about a return value, execute the


cnc_getdtailerr function. For details of the cnc_getdtailerr function, see Subsection
3.4.1, "CNC/PMC window library".
A detail status is set in the ODBERR structure member err_no. For details of statuses,
see Subsection 5.17.3, "Communication error detail status".

- 1221 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(3) Close the communication interface in putting mode < Main, Comm, Alarm, Win >

[Name]
eth_putclose

[Syntax]
#include <ethernet.h>
short eth_putclose( char cancel ) ;

[Arguments]
cancel
Specify the type of the close of the communication interface when the data exists
in the transmit buffer.
0 : When the data exist in the transmit buffer, it keeps putting without closing the
communication interface.
1 : When the data exists in the transmit buffer, the putting is canceled and the
communication interface is closed.

[Return]
The return values are as follows.
EW_OK(0) Successful.
EW_BUSY(-1) Data in the transmit buffer is putting to the host.
Retry the close of the communication interface until
the putting ends.
EW_FUNC(1) The function eth_putopen() is not executed.
Or, it was executed by the task that can't be used other
than the following tasks.
- Main task (TASK1)
- Communication task (TASK2)
- Alarm task (TASK3)
- Window task (TASK4)
EW_DTSRVR(14) Communication error occurs.
Retry the close of communication interface.

[Description]
The communication interface that opened in putting mode is closed.
If "0" is specified for "cancel", this function is executed when the data exists in the
transmit buffer, "EW_BUSY(-1)" is returned without closing the communication
interface. Please wait until the putting ends or retry the close of communication
interface.
If "1" is specified for "cancel", the putting is canceled even if the data exists in the
transmit buffer, and the communication interface is closed. In this case, the data
exists in the transmit buffer is discarded, and "EW_OK(0)" is returned.

- 1222 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

When the communication error occurs while putting the data to the host or closing
the communication interface, "EW_DTSRVR(14)" is returned. Please retry the close
of communication interface until "EW_OK(0)" is returned.
For detailed information about a return value, execute the cnc_getdtailerr function.
For details of the cnc_getdtailerr function, see Subsection 3.4.1, "CNC/PMC window
library".
A detail status is set in the ODBERR structure member err_no. For details of statuses,
see Subsection 5.17.3, "Communication error detail status".

- 1223 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(4) Open the communication interface in getting mode < Main, Comm, Alarm, Win >

[Name]
eth_getopen

[Syntax]
#include <ethernet.h>
short eth_getopen( short type, char *file_name ) ;

[Arguments]
type
Specify the kind of the communication function used for FTP transfer.
0 : Embedded Ethernet port or PCMCIA Ethernet card.

file_name
Specify the pointer to the file name of the host file that is get.
Strings of the file name are 256 characters or less including NULL in the terminal.
Please set NULL in the terminal.

[Return]
The return values are as follows.
EW_OK(0) Successful.
EW_BUSY(-1) The communication interface has already been opened.
EW_FUNC(1) It was executed by the task that can't be used other than
the following tasks.
- Main task (TASK1)
- Communication task (TASK2)
- Alarm task (TASK3)
- Window task (TASK4)
EW_ATTRIB(4) The specification of "type" is wrong.
EW_REJECT(13) The communication interface has already been used by
other functions.

[Description]
The communication interface specified with "type" is opened in getting mode.
It is necessary to execute this function before getting data from the host.
When this function is executed specifying only the file name with "file_name", the
file of the specified name stored in host's current directory is opened.
When this function is executed specifying the file name in which "file_name"
contains passing for the host that can specify the file name that contains passing, the
file stored in the specified directory is opened.
By executing the function eth_get(), it is possible to get the data to the file made for
the host by this function.

- 1224 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

The current directory of the connected host can be checked and changed on the host
file list screen. For details of the host file list screen, refer to Section, "EMBEDDED
ETHERNET OPERATIONS", in "Common to Lathe System/Machining Center
System USER’S MANUAL (B-64304EN)".

The basic procedure for receiving data is indicated below.

Open the communication interface


eth_getopen()

= EW_OK

= EW_DTSRVR
Getting data
eth_get() = EW_BUFFER

= EW_OK or EW_RESET

Getting completion?
EW_RESET NO

YES

Close the communication interface


eth_getclose()

NOTE
1. When the function eth_getopen() is executed specifying the file
name of file that host doesn't have, "EW_OK(0)" is returned.
Afterwards, when the function eth_get function() is executed,
"EW_DTSRVR(14)" is returned. At this time, when the function
cnc_getdtailerr() is executed, it gets error No.503 "It failed in the
getting of data" as detailed status.
2. When the function eth_getopen() is executed specifying the file
name that contains passing for the host that can't specify the file
name that contains passing, "EW_OK(0)" is returned.
Afterwards, when the function eth_get function() is executed,
"EW_DTSRVR(14)" is returned. At this time, when the function
cnc_getdtailerr() is executed, it gets error No.503 "It failed in the
getting of data" as detailed status.

- 1225 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(5) Get the data from the host < Main, Comm, Alarm, Win >

[Name]
eth_get

[Syntax]
#include <ethernet.h>
short eth_get( long *length, char *data ) ;

[Arguments]
length
Specify the pointer to the variable of the long type where the number of characters
of data get from the receive buffer is set.
When this function is executed with no error, the number of characters actually get
from the receive buffer is set.

data
Specify the first address in the area where the data get from the receive buffer is set.

[Return]
The return values are as follows.
EW_OK(0) Successful.
EW_RESET(-2) No getting data.
Close the communication interface.
EW_FUNC(1) The function eth_getopen() is not executed.
Or, it was executed by the task that can't be used other
than the following tasks.
- Main task (TASK1)
- Communication task (TASK2)
- Alarm task (TASK3)
- Window task (TASK4)
EW_LENGTH(2) "0" or less is specified for "length".
EW_BUFFER(10) Receive buffer empty. Retry the getting of data.
EW_DTSRVR(14) Communication error occurs.
Close the communication interface.

[Description]
The data for the specified size is get from the receive buffer.
When the data size in the receive buffer is less than the specified size with "length",
all data in the receive size is get and the number of characters is set in "length".
When there is no data in the receive buffer and the character cannot be get,
"EW_BUFFER(10)" is returned. Please retry the getting of data in this case.

- 1226 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

When this function is executed after all host's data is get, "EW_RESET" is returned.
Please execute the function eth_getclose(), and close the communication interface in
this case.
When the communication error occurs while getting data from the host,
"EW_DTSRVR(14)" is returned. Please execute the function eht_getclose() and
close the communication interface in this case.
To collect more detailed information about a return value, execute the cnc_getdtailerr
function. For details of the cnc_getdtailerr function, see Subsection 3.4.1,
"CNC/PMC window library".
A detail status is set in the ODBERR structure member err_no. For details of statuses,
see Subsection 5.17.3, "Communication error detail status".

- 1227 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

(6) Close the communication interface in getting mode < Main, Comm, Alarm, Win >

[Name]
eth_getclose

[Syntax]
#include <ethernet.h>
short eth_getclose( void ) ;

[Arguments]
------

[Return]
The return values are as follows.
EW_OK(0) Successful.
EW_RESET(-2) Getting data was canceled, and the communication was
closed.
EW_BUSY(-1) The communication interface is closed.
Retry the close of the communication interface.
EW_FUNC(1) The function eth_getopen() is not executed.
Or, it was executed by the task that can't be used other
than the following tasks.
- Main task (TASK1)
- Alarm task (TASK3)
- Communication task (TASK2)
- Window task (TASK4)
EW_DTSRVR(14) Communication error occurs.
Retry the close of the communication interface.

[Description]
The communication interface that opened in getting mode is closed.
When this function is executed while getting the data from the host, the getting is
canceled and the communication interface is closed. In this case, "EW_RESET(-2)"
is returned.
For this reason, please execute the function eth_get() until it returns
"EW_RESET(-2)" , and execute this function afterwards for getting of the all data.
When the communication error occurs while getting the data from the host or closing
the communication interface, "EW_DTSRVR(14)" is returned. Please retry the close
of communication interface until "EW_OK(0)" or "EW_RESET(-2)" is returned.
To collect more detailed information about a return value, execute the cnc_getdtailerr
function. For details of the cnc_getdtailerr function, see Subsection 3.4.1,
"CNC/PMC window library".
A detail status is set in the ODBERR structure member err_no. For details of statuses,
see Subsection 5.17.3, "Communication error detail status".

- 1228 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.17.3 Detailed status of communication error

The function cnc_getdtailerr() can get detailed status of the communication error, when
the communication error occurs, and "EW_DTSRVR(14)" is returned.
Error No. of detailed status and the description are as follows.

Error No. Description


468 Connect host is not found.
Please confirm the setting of IP address etc.
502 It failed in the putting of data.
503 It failed in the getting of data.
507 It failed in the change in the current directory.
Please confirm the setting of the login folder.
508 It failed in login of connect host.
Please confirm the setting of the login user and the login
password.
509 It failed in the connection to connect host.
Please confirm whether the FTP server starts.
511 The mistake is found in the setting of connect host's
parameter.

An acquired detail status is set in the ODBERR structure member err_no.


For details of the cnc_getdtailerr function, see Subsection 3.4.1, "CNC/PMC window
library".

NOTE
The function cnc_getdtailerr() gets detailed status of the error that occurs
when the CNC/PMC window library function of C Language Executor and
the FOCAS2 function are executed.
Therefore, detailed status of the error that occurred when the function for
the FTP Transfer function is executed might be changed in executing the
CNC/PMC window library function of C Language Executor and the
FOCAS2 function before the function cnc_getdtailerr() is executed.

- 1229 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.17.4 Reference items

FANUC Series 0i-MODEL D Common to Lathe System/Machining EMBEDDED ETHERNET


0i Mate-MODEL D Center System USER’S MANUAL OPERATIONS
(B-64304EN)
FANUC Series 0i-MODEL D MAINTENANCE MANUAL Setting of the FTP File
0i Mate-MODEL D (B-64305EN) Transfer Function
FANUC Series 0i-MODEL D FANUC FAST Ethernet EXAMPLE OF FTP SERVER
FANUC FAST DataServer SETUP
OPERATOR’S MANUAL
(B-64414EN)

- 1230 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.18 C language data file series and edition display

5.18.1 Overview

This function displays, on the system configuration screen, the series and edition of a
C language data file used with a C Language Executor application program or a
customization data file used for customization of the MANUAL GUIDE i screen.
In this section, a C language data file used with a C Language Executor application
program and a customization data file used for customization of the MANUAL
GUIDE i screen are collectively referred to as a user data file.

- 1231 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.18.2 Explanation

5.18.2.1 Conditions for displaying the series and editions of user data files on
the system configuration screen

To display the series and editions of user data files on the system configuration screen,
a series and edition information file and data files need to be converted and linked to
create a user data file as shown below.
By describing, in a command file for DAT2MEM.COM, the names of all data files
and a series and edition information file to be converted and linked and by using the
user data file conversion utility "DAT2MEM.COM", a user data file incorporating
series and edition information to be displayed on the system configuration screen can
be created.
For details of the formats of a command file and series and edition information file,
see Subsection 5.18.2.3, "Method of specifying a series and edition information file".

Data file

User data file

DAT2MEM.COM
Series and
Series and edition
edition
information
file

To display the series and edition information of a user data file on the system
configuration screen, all of the following conditions need to be satisfied in addition to
the condition above:

<1> C Language Executor (including FANUC PICTURE where a C Language


Executor application program created by the machine tool builder is
incorporated) or MANUAL GUIDE i must already be started.
<2> A user data file incorporating series and edition information must already
be loaded to the FROM.

- 1232 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.18.2.2 Series and edition information file format

To display the series and edition information of a user data file on the system
configuration screen, a user data file needs to be created by converting and linking
data files and a series and edition information file describing series and edition
information.
For details of the method of creating a user data file by converting and linking data
files and a series and edition information file, see Subsection 5.18.2.3, "Method of
specifying a series and edition information file".

Create a series and edition information file as a text file under the following name and
format:

[File name]
The name of a series and edition information file varies, depending on whether the
software name displayed on the system configuration screen is "CEXEDATAn" for C
language data files or "MGIDATAn" for customization data files. In each case,
specify the name of a series and edition information as described below.
− When the software name "CEXEDATAn" for C language data files is
displayed on the system configuration screen
CEXDATn.VER
n : One-digit number (0 to 9)
− When the software name "MGIDATAn" for customization data files is
displayed on the system configuration screen
MGIDATn.VER
n : One-digit number (0 to 9)

[Format]
Describe series and editions to be displayed on the system configuration screen,
starting at the beginning of the first line on a series and edition information file, in the
format below.
SSSSEEEE
SSSS : Series
EEEE : Edition

- 1233 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

When creating a series and edition information file, note the following:
− The file name, "CEXDATn.VER" or "MGIDATn.VER", of a series and edition
information file is fixed. If a user data file is created by specifying another file
name, series and edition information is not displayed on the system
configuration screen.
− In the file name of a series and edition information file, "n" must be the same
number as "n" in the file name, CEXnxxxx.MEM, of a user data file to be
created.
− Ensure that series and editions to be displayed on the system configuration
screen are described starting at the beginning of the first line of the file. If series
and editions are described starting on a second or subsequent line, series and
edition information is not displayed on the system configuration screen.
− If a series longer than four characters and an edition longer than four characters
are described, the first four characters from the beginning of the file are
displayed as a series and the subsequent four characters are displayed as an
edition on the system configuration screen.
− When describing series SSSS and edition EEEE, use the character codes 0x20
to 0x5F (see the table below).

0 1 2 3 4 5 6 7 8 9 A B C D E F
20 ! “ # $ % & ‘ ( ) * + , - . /
30 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
40 @ A B C D E F G H I J K L M N O
50 P Q R S T U V W X Y Z [ ¥ ] ^ _

- 1234 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

Example 1) When a series and edition information file for displaying the series
ABCD and the edition 01.0 of the C language data file
CEX0DATA.MEM on the system configuration screen is created

File name: CEXDAT0.VER Describe the series to be


displayed on the system
ABCD01.0 configuration screen,
starting at the beginning of
the series and edition
information file.

Example 2) When a series and edition information file for displaying the series EFG
and edition 0001 of the customization data file CEX2DATU.MEM on
the system configuration screen is created

File name: MGIDAT2.VER

EFG 0001 Insert a space or spaces for


displaying a series or edition
shorter than four characters.

NOTE
If the number n used in the file name, CEXDATn.VER or
MGIDATn.VER, of a series and edition information file differs from the
number n used in the file name, CEXnxxxx.MEM, of a user data file to
be created, the series and edition information of the user data file is
not displayed on the system configuration screen.
When the C language data file CEX0DATA.MEM is created, for
example, the series and edition information of the C language data file
is not displayed on the system configuration screen if the file name of
a series and edition information file is CEXDAT1.VER.
To display the series and edition information, the file name of the
series and edition information file must be CEXDAT0.VER.

- 1235 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.18.2.3 Method of specifying a series and edition information file

By creating a user data file incorporating series and edition information by converting
and linking data files and a series and edition information file describing series and
edition information through the user data file conversion utility DAT2MEM.COM,
the series and edition information of the user data file is displayed on the system
configuration screen.
To incorporate the series and edition information of a series and edition information
file in a user data file, the series and edition information file must be specified at the
start of a command file specified by DAT2MEM.COM.
For the method of using DAT2MEM.COM and details of a command file for
DAT2MEM.COM, see Section 5.5, "dat2mem utility manual" in Part II,
"PROGRAMMING".

Example) When series and edition information is incorporated into the C language
data file CEX0DATA.MEM

;================================
; DAT2MEM Specification file
;================================

;-------------------------------------------------------
CEX0DATA.MEM Be sure to specify
;------------------------------------------------------- a series and
CEXDAT0.VER edition
STRING.TXT information file at
OFSDATA.TXT the start of the
PRMDATA.TXT command file.

;-------------------------------------------------------
; end of spec file

NOTE
If a series and edition information file is specified not at the start of a
command file, the series and edition information file and data files are
converted and linked to create a user data file. However, the series
and edition information is not incorporated correctly and is not
displayed on the system configuration screen.

- 1236 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

5.18.2.4 User data file that enables series and edition information to be
displayed

Only when a user data file indicated below has series and edition information
incorporated, the series and edition information is displayed on the system
configuration screen.
When a user data file has no series and edition information incorporated, the system
configuration screen displays no software name, series, and edition.

CEXnxxxx.MEM
n : One-digit number (0 to 9)
x : One alphabetic character

NOTE
1 An extension other than ”*.MEM” may be used with a user data file.
2 If a C language data file created by converting and linking a series
and edition information file and data files through DAT2MEM.COM is
linked with a C Language Executor application program, the system
configuration screen displays the series and edition of the C
Language Executor application program but does not display the
series and edition information of the C language data file.

- 1237 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.18.2.5 System configuration screen display

Among all user data files loaded to the FROM, the series and edition information of
those user data files incorporating series and edition information is displayed on the
system configuration screen.
In the SYSTEM column (<1> in the figure below) on the system configuration screen,
a software names indicated below is displayed according to the user data file and
series and edition information file name, and the series and edition incorporated in the
user data file are displayed using four characters respectively.

Series and edition


User data file Software name
information file name
CEX0xxxx.MEM CEXDAT0.VER CEXEDATA0
MGIDAT0.VER MGIDATA0
CEX1xxxx.MEM CEXDAT1.VER CEXEDATA1
MGIDAT1.VER MGIDATA1
CEX2xxxx.MEM CEXDAT2.VER CEXEDATA2
MGIDAT2.VER MGIDATA2
CEX3xxxx.MEM CEXDAT3.VER CEXEDATA3
MGIDAT3.VER MGIDATA3
CEX4xxxx.MEM CEXDAT4.VER CEXEDATA4
MGIDAT4.VER MGIDATA4
CEX5xxxx.MEM CEXDAT5.VER CEXEDATA5
MGIDAT5.VER MGIDATA5
CEX6xxxx.MEM CEXDAT6.VER CEXEDATA6
MGIDAT6.VER MGIDATA6
CEX7xxxx.MEM CEXDAT7.VER CEXEDATA7
MGIDAT7.VER MGIDATA7
CEX8xxxx.MEM CEXDAT8.VER CEXEDATA8
MGIDAT8.VER MGIDATA8
CEX9xxxx.MEM CEXDAT9.VER CEXEDATA9
MGIDAT9.VER MGIDATA9

- 1238 -
B-64303EN-3/01 PROGRAMMING 5.C Language Executor Function

Example) When series and edition information is incorporated into user data files as
indicated below

Series and Items displayed on the system configuration


Series and
edition screen
User data file edition
information file
information Software name Series Edition
name
CEX2xxxx.MEM MGIDAT2.VER ABCD02.0 MGIDATA2 ABCD 02.0
CEX3xxxx.MEM MGIDAT3.VER EFGH03.0 MGIDATA3 EFGH 03.0
CEX6xxxx.MEM CEXDAT6.VER IJK 06.0 CEXEDATA6 IJK 06.0
CEX7xxxx.MEM CEXDAT7.VER LMNO07.0 CEXEDATA7 LMNO 07.0
CEX9xxxx.MEM MGIDAT0.VER PQRS09.0 The number "9" in the user data file name does
not match the number "0" in the series and edition
information file name, so that these items are not
displayed on the system configuration screen.

<1>

- 1239 -
5.C Language Executor Function PROGRAMMING B-64303EN-3/01

5.18.2.6 Restrictions

− Even if series and edition information is incorporated into a C language data file
by specifying "CEXDATn.VER" as the file name of the series and edition
information file, the series and edition information is not displayed on the
system configuration screen when C Language Executor (including FANUC
PICTURE where a C Language Executor application program created by the
machine tool builder is incorporated) is not started.

− Even if series and edition information is incorporated into a customization data


file by specifying "MGIDATn.VER" as the file name of the series and edition
information file, the series and edition information is not displayed on the
system configuration screen when MANUAL GUIDE i is not started.

− The software names "CEXEDATAn" and "MGIDATAn" with "n" representing


the same number cannot be simultaneously displayed on the system
configuration screen.

− If a C language data file is linked with a C Language Executor application


program and series and edition information is incorporated in the C language
data file, the system configuration screen displays the series and edition
information of the C Language Executor application program but does not
display the series and edition information of the C language data file.

− When C Language Executor is disabled by pressing the keys [M]+[0] at


power-on time or when C Language Executor or MANUAL GUIDE i cannot be
started because of an incorrect parameter setting, the series and edition
information of a user data file is not displayed on the system configuration
screen.

- 1240 -
B-64303EN-3/01 PROGRAMMING 6.Programming Technique

6 Programming Technique

- 1241 -
6.Programming Technique PROGRAMMING B-64303EN-3/01

6.1 Various techniques

(1) Executing application programs at higher speed

Much overhead is imposed on calling of C Language Executor Library functions (when compared with
application programs running on the personal computer) for two major reasons:

1. A transition may be made to a privileged level in some cases.


When a screen is displayed or a CNC window is called, a transition is made to a system
privilege. A transition to this privileged level consumes much CPU clock time.

2. CNC system software may be requested to perform processing in some cases.


Among the CNC window functions, some read functions (such as a macro variable read
function) and write functions request CNC system software to perform processing and wait for
processing completion. This requires an average time of 8 msec or more.

So, the processing speed of an application program can be lowered if functions are called frequently. The
processing speed of an application program can be improved if the frequency of library function calls by the
application program is decreased, for example, by performing as many operations as possible in a batch.

(Example) - Character output


Characters should be displayed as a character string with “puts” function and “printf” function,
instead of being displayed one by one with “putchar” function.

- Reading and writing of NC data


Contiguous data should be read or written in a batch with a function of range specification
type.

When characters are displayed on an LCD display unit, characters are displayed at lower speed if the
ESC[>5l mode is specified to set the cursor display state. To avoid this slow display, specify usually the
ESC[>5h mode to set the cursor non-display state.

- 1242 -
B-64303EN-3/01 PROGRAMMING 6.Programming Technique

(2) Using variables sharable among tasks

A C Language Executor application program can access two types of variables (memories).

Local memory Memory accessible by only the task that owns the memory
Memory sharable among tasks Memory accessible by all tasks

< C language executor memory>

Memory for libraries

Local memory for task 1

Local memory for task 2

Local memory for task 3 Accessible only by respective


task
Local memory for task 4

Local memory for task 5

Memory sharable among Accessible by all tasks


tasks

In the local memory for each task, the program code, global variables, static variables, and stack area
(including local variables) of each task are located.

<Local memory for each task>

Program code

Global variables
Static variables

Stack area (local variables)

To share information with other tasks when a multitasking application program is used, variables sharable
among tasks placed in a memory area sharable among tasks are used. C Language Executor has two memory
areas sharable among tasks, one on the S-RAM and the other on the D-RAM. Variables defined by
SRAMVER.C and DRAMVER.C of an application are placed in the memory areas sharable among tasks on
S-RAM and D-RAM, respectively.

- 1243 -
6.Programming Technique PROGRAMMING B-64303EN-3/01

<Memory area sharable among tasks>

S-RAM sharable memory Variables defined by SRAMVER.C

D-RAM sharable memory Variables defined by DRAMVER.C

These sharable memory objects in this area can be accessed by all tasks. Ensure that data to be exchanged
among tasks is placed in the memory area sharable among tasks (variables defined by SRAMVER.C or
DRAMVER.C).

Use care when exchanging a pointer among tasks. A pointer value stored in a sharable variable can be
exchanged among tasks. In this case, however, the real object pointed to by such a pointer must not be
placed in the local memory area of a particular task. If a task that has received such a pointer accesses the
local memory of another task, the access is regarded as an illegal memory access. A pointer pointing to an
object in a sharable memory may be exchanged among tasks.

- 1244 -
B-64303EN-3/01 PROGRAMMING 6.Programming Technique

6.2 Application of C Language Executor to machines

(1) Machine maintenance

With C Language Executor, man-machine interfaces such as FANUC CNC screen display and operation can
be customized to meet the particular needs of the machine tool builder. In many cases, this customization is
desirable for the machine tool builder and end users. However, note the following:

Maintenance of FANUC CNCs used in the field for machine tools is performed by FANUC service staff.
FANUC service staff is thoroughly familiar with the standard operations of FANUC CNCs but is not
familiar with the particular operation system of the machine tool builder. In some cases, FANUC service
staff may not be able to carry out maintenance smoothly if FANUC service staff cannot perform the
particular operations of the machine tool builder properly. The machine tool builder is requested to pay
attention to the following to avoid trouble in maintenance:

- Ensure that a document describing the method of application program operation is attached.

- Ensure that the NC screens (mainly screens related to the "system") needed for CNC maintenance can
be displayed.

- Ensure that basic machine operations can be performed by not operating a C Language Executor
application program (for example, ensure that basic machine operations can be performed by turning on
the power to the CNC while holding down the keys [M]+[0]).

(2) Applications that requires good response

The response of an auxiliary task to an event is not so good because of the task management specification.
With an application program that starts an auxiliary task periodically, for example, the execution interval of
the auxiliary task may vary from about 10 to 20 msec. The reason is that an auxiliary task coexists with a
task of the CNC system software and the execution priority of the auxiliary task is lower than that of the NC
task. Sufficient response is provided for general man-machine interface processing. For processing that
needs to be executed at regular intervals without fail, however, use a PMC ladder. Specifically, the PMC is
more suitable than C Language Executor for applications used, for example, to sample machine signals and
motor loads at certain intervals and to communicate with other devices periodically.

- 1245 -
APPENDIX
A. Troubleshooting If a System Alarm
Occurs in the C Language Executor
B-64303EN-3/01 APPENDIX Application Program

A Troubleshooting If a System Alarm Occurs


in the C Language Executor Application
Program
This appendix describes troubleshooting steps you can use if a system alarm occurs in the C Language
Executor application program. Typical system alarms that may occur in the C Language Executor
application program are explained below.

SYS_ALM001 DATA ACCESS EXCEPTION


SYS_ALM411 CPU BUS ILLEGAL TRANSACTION

Either of these system alarms occurs if the program tries to reference a nonexistent address or an
address to which the program does not have access. A possible cause is that the application program
uses a pointer improperly or an argument is set incorrectly for a function call.

SYS_ALM015 FPU-ZERO DIVIDE EXCEPTION

This system alarm occurs if the divisor for floating-point division is 0.


When an integer is divided by 0, SYS_ALM015 does not occur.

- 1249 -
A. Troubleshooting If a System Alarm
Occurs in the C Language Executor
Application Program APPENDIX B-64303EN-3/01

Explanation of the SOFTWARE INFORMATION 1 screen

The SOFTWARE INFORMATION 1 screen shows the information that is set in the registers in CONTROL
REGISTERS, GENERAL PURPOSE REGISTERS, and FLOATING POINT REGISTERS at the occurrence of a system alarm.
If SYS_ALM001 or SYS_ALM411 occurs, the address that has actually been referenced is shown in the
lower right portion (<1> in the figure below) of the CONTROL REGISTERS area. If the system alarm occurs
because the address 00000000H has been referenced, 00000000 is displayed in the lower light portion
of the CONTROL REGISTERS area as shown below.

D4F1-01.0
SYS_ALM001 DATA ACCESS EXCEPTION
CPU CARD
2008/04/01 12:34:56

SOFTWARE INFORMATION 1
CONTROL REGISTERS <1>
8090C024 00003030 50000388 0000F930 40000000 00000000 50000388 1023E514
70000203 30000000 0A000000 000000D0 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
GENERAL PURPOSE REGISTERS
50000388 500C8364 103DA530 00000000 00000000 00000001 0000000A 00000000
01000000 500C7DD0 01000027 00000000 500C83E8 108A8EC8 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000001 108A0090 30000000 00000028
FLOATING POINT REGISTERS
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

PAGE UP OR DOWN (PAGE 2/5)

Fig. 1 SOFTWARE INFORMATION 1 screen

If a system alarm occurs in the code of the C Language Executor application program, the values of
the registers used by the application program at that time are shown in GENERAL PURPOSE RESISTERS.
The values of the registers in GENERAL PURPOSE RESISTERS are related to the registers specified in
a list file automatically generated during creation of the application program, as shown below.

- 1250 -
A. Troubleshooting If a System Alarm
Occurs in the C Language Executor
B-64303EN-3/01 APPENDIX Application Program

GENERAL PURPOSE REGISTERS


r0 r1 r2 r3 r4 r5 r6 r7
r8 r9 r10 r11 r12 r13 r14 r15
r16 r17 r18 r19 r20 r21 r22 r23
r24 r25 r26 r27 r28 r29 r30 r31

199 # while( 1 ) {
200 # *error = disp_pos() ;
201 #$$tl 0x0 0x0 0x0
202 #$$rs 2
00000164 00 4800 0001 203 bl disp_pos
00000168 00 b07e 0000 204 sth r3,0(r30)
0000016c 00 4bff fff8 205 b .L11
206 # }
207 # }

Fig. 2 Register codes displayed in the GENERAL PURPOSE RESISTERS

If a system alarm occurs in the C Language Executor application program, use the following steps for
troubleshooting.

STEP 1: Check the address in PROGRAM COUNTER on the system alarm screen

On the system alarm screen, PROGRAM COUNTER shows the address used at the occurrence of the system
alarm. The C Language Executor application program is mapped onto DRAM memory from 50000000H by the
application program size.
If the address shown in PROGRAM COUNTER is not the address of the C Language Executor application
program, move through the pages of the system alarm screen. Check whether the address of the C Language
Executor application program is shown in CONTROL REGISTERS on the SOFTWARE INFORMATION 1 screen or
STACK DATA on the SOFTWARE INFORMATION 2 screen.
If none of these screen pages shows the address of the C Language Executor application program, the
system alarm may have occurred in the CNC system software.
In this case, contact FANUC and provide the following information.

System configuration information (SYS-CONF.TXT)


SRAM data used when the system alarm has occurred
All files related to the C Language Executor application program
(MEM file, source file, and makefile)
Other information
(Such as the procedure in which the system alarm has occurred, and the procedure for operating
the application program)

- 1251 -
A. Troubleshooting If a System Alarm
Occurs in the C Language Executor
Application Program APPENDIX B-64303EN-3/01

STEP 2: Check the start address of each task in the C Language Executor application program

The start address of each task is shown in the line next to _cex_romhead_f in each of the map files
taskn.map (n: 1 to 5) automatically generated during creation of the application program.

STEP 3: Determine in which module the system alarm has occurred

Check the address you checked in STEP 1 against the start addresses of the tasks you checked in STEP
2 to determine the module in which the system alarm has occurred.
Then, open the map file of the task in which the system alarm has occurred. Check the lines below
_cex_romhead_f to determine in which object file the address you checked in STEP 1 is included.
Write down the start address of the appropriate object.

STEP 4: Determine the system alarm location

After determining the object file, open the list file corresponding to the source file from which
the object file has been generated.
The system alarm has occurred in the code at the address obtained by subtracting, from the address
you checked in STEP 1, the start address of the object file you wrote down.

Example of troubleshooting

The following describes troubleshooting steps to use if a system alarm shown below occurs.

D4F1-01.0
SYS_ALM001 DATA ACCESS EXCEPTION
CPU CARD
2008/04/01 12:34:56

PROGRAM COUNTER : 50000388H


ACT TASK : 01000027H
ACCESS ADDRESS : -
ACCESS DATA : -
ACCESS OPERATION : -

+----------------------------------------------------------+
+ THE SYSTEM ALARM HAS OCCURRED, THE SYSTEM HAS STOPPED. +
+----------------------------------------------------------+

PAGE UP OR DOWN (PAGE 1/5)

Fig. 3 System alarm screen

- 1252 -
A. Troubleshooting If a System Alarm
Occurs in the C Language Executor
B-64303EN-3/01 APPENDIX Application Program

STEP 1: Check the address in PROGRAM COUNTER on the system alarm screen

Check the address shown in <1> in the figure below.


If this address falls within the range between 0x50000000 and the end address of the C Language
Executor application program, the system alarm has occurred in the C Language Executor
application program.

D4F1-01.0
SYS_ALM001 DATA ACCESS EXCEPTION
CPU CARD
2008/04/01 12:34:56 <1>
PROGRAM COUNTER : 50000388H
ACT TASK : 01000027H
ACCESS ADDRESS : -
ACCESS DATA : -
ACCESS OPERATION : -

+----------------------------------------------------------+
+ THE SYSTEM ALARM HAS OCCURRED, THE SYSTEM HAS STOPPED. +
+----------------------------------------------------------+

Fig. 4 PROGRAM COUNTER indication

The end address of the C Language Executor application program is specified in the .romfoot
line in the map file task1.map automatically generated during creation of the application
program.

_dram_end 500a83c0 00000001

.romfoot 500a83c1 00000001


.romfoot 500a83c1
00000001 ..\lib\cexe_lib.o

Fig. 5 End address of the C Language Executor application program

STEP 2: Check the start address of each task in the C Language Executor application
program

Open task1.map and check the start address of Task1.

_cex_romhead_f 500001bc 00000064

.text 50000220 00000580


.text 50000220 0000019a tsk1main.o
main 50000220 00000170

.text 500003bc 000003a9 tsk1sub.o

Fig. 6 Start address of Task1

- 1253 -
A. Troubleshooting If a System Alarm
Occurs in the C Language Executor
Application Program APPENDIX B-64303EN-3/01

Open task2.map and check the start address of Task2.

_cex_romhead_f 500001bc 00000064

.text 50000a64 0000005c


.text 50000a64 00000024 tsk2main.o
main 50000a64 00000024

Fig. 7 Start address of Task2

If Task3 to Task5 have been provided, you should also check the start addresses of these tasks.

STEP 3: Determine in which module the system alarm has occurred

The address 50000388H you checked in STEP 1 falls within the range between the start address
50000220H of Task1 you checked in STEP 2 and the start address 50000a64H of Task2, so the
system alarm has occurred in the Task1 code.
As can be seen in task1.map, the address 50000388H you checked in STEP 1 falls within the
range between the start address 50000220H of tsk1main.o and the start address 500003bcH of
tsk1sub.o.
The system alarm has therefore occurred in the code within tsk1main.c.

_cex_romhead_f 500001bc 00000064

.text 50000220 00000580


.text 50000220 0000019a tsk1main.o
The system alarm has
main 50000220 00000170
occurred in between
tsk1main.o and tsk1sub.o. .text 500003bc 000003a9 tsk1sub.o

Fig. 8 System alarm location (module)

- 1254 -
A. Troubleshooting If a System Alarm
Occurs in the C Language Executor
B-64303EN-3/01 APPENDIX Application Program

STEP 4: Determine the system alarm location

Obtain an offset address by subtracting the start address 50000220 of tsk1main.o from the
address 50000388H you checked in STEP 1.
Open tsk1main.l and check the code at the offset address 168H obtained as described above.

199 # while( 1 ) {
200 # *error = disp_pos() ;
201 #$$tl 0x0 0x0 0x0
202 #$$rs 2
The system alarm 00000164 00 4800 0001 203 bl disp_pos
has occurred on 00000168 00 b07e 0000 204 sth r3,0(r30)
this line. 0000016c 00 4bff fff8 205 b .L11
206 # }
207 # }

Fig. 9 System alarm location (code)

The system alarm has occurred in this assembly code.


Investigate the C Language Executor application program from which the assembly code has been
generated, in which the system alarm has occurred.

- 1255 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

B Additional Information on C Compiler


Installation

- 1256 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

B.1 Installing the C compiler

Use the procedure below to install Wind River Compiler C/C++.

This section describes the procedure for installing Wind River Compiler C/C++, using version 4.4b
as an example. For details of items, refer to the manual for the compiler.
Insert the Wind River Compiler C/C++ CD into your computer's CD-ROM drive. The installer starts
automatically. If the installer does not start automatically, double-click SETUP.EXE on the CD
to start the installer.

1) DIAB Installation Directory


Specify the installation folder. Select the desired folder.

2) Installation Options
Check all items shown below.

- 1257 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

3) Tools Selection
Specify the compiler types.
Check Diab C Compiler and Diab C++ Compiler.
You will not use RTA Tools, Diab FastJ Compiler, and Library Source.

4) Target Architectures
Select the target system shown below.
Target : PowerPC
Components: PowerPC ELF Target (EABI)

- 1258 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

5) Select program folder


Specify one of the available program folders from the Windows start menu.
Select the desired folder.

6) License Key Option Selection


Select the license key entry option specified at the time of purchase of the compiler.
Select "I have an eval key and I will enter it now."

(Note: The entry option may vary depending on the license type. For details, contact the supplier
of your compiler.)

7) Enter eval key


Enter your license key.

- 1259 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

8) File Selection
Specify the file for saving the license key.

9) Enter Information
Set the specified environment variable.
Check the path.

- 1260 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

10) PowerPC
Select PPC603.

11) PPC603
Select Hardware Floating Point.

- 1261 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

12) PowerPC ELF Target (EABI)


Select cross.

Note) You may have to set the license manager (FLEXlm License Manager) depending on the license type. For
details, contact the supplier of your compiler.

- 1262 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

B.2 Installing the linker

The linker is installed along with the compiler.

B.3 Installing the C Language Library

Use the procedure below to install the FANUC-provided C Language Library on the hard disk.
The description is given below assuming that the following are set:

E: drive CD-ROM
C: drive Hard disk

Installation directory C:\cexe

During installation, copy the directory configuration from the CD-ROM to c:\cexe without
modification as shown below.

E:\ C:\
├Inc └cexe
├Lib ├Inc
├Tool =====> ├Lib
└User ├Tool
└User

The makefile has been created with the Inc/Lib/Tool/User locations.


Do not modify this file because an application program cannot be created properly if these locations
are changed.

- 1263 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

B.4 Obtaining and installing other tools

Use the procedure below to obtain and install the tools needed for creating a C Language Executor
application program.

1) Go to the following URL.


http://gnuwin32.sourceforge.net/packages.html
2) Click the following links and download the binaries.
- gawk
- sed
- libintl
- libiconv
3) Extract the downloaded files, and copy gawk.exe, sed.exe, libintl3.dll, and libiconv2.dll from
the bin folders created in the extracted folders.
4) In the C:\cexe\Tool folder created in Section B.3, store the four files you copied in step 3).

- 1264 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

B.5 Customization procedure

Use the procedure below to create an application program.

Create a working directory.

Copy the makefile and Copy the two files (templates) from the ¥User folder to the
version.c. working directory.

Create source programs.

Define the information including the name of an object to


Modify the makefile.
be executed in each task.

Set the name and edition of an application program that are


Modify version.c.
to be displayed on the NC screen.

With the Series 0i-D, an object is converted to memory card


Execute nmake. format by executing nmake.

Transfer the file to


Use the COPY command.
the memory card.

Set NC parameters.

Write to the F-ROM with the BOOT function.

Check the operation.

- 1265 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

1) Set the path.

During installation of the Diab compiler, the installer automatically set the path. You do not
need to take any special action.
Execute path from the DOS prompt, and ensure that the path is set to include the folders shown
below.

Path example (when Diab compiler 4.4b is installed in C:\diab)

2) Create a working directory.

Create the working directory in the directory where the C Language Library has been installed.

Root directory example


(Example) Folder names
C:\
└diab (compiler, linker)
└cexe
├Inc
├Lib
├Tool
├user
└work (working directory)

- 1266 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

3) Copy required files.

Copy the minimum required files shown below from their directory to the working directory.

(Files you must copy)


<1> makefile
<2> version.c

4) Create source files.

Create the source files (*.C and *.h) for an application program in the working directory. Edit
the files by using a text editor.
Any file name can be used.

- 1267 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

5) Modify the makefile to suite the application program.

Modify the following portions of the makefile.

Beginning of the makefile

Specify the size of the F-ROM or SRAM for storing object programs.

# Select one of the following FROMSIZE variables according to F-ROM size.


# Remove the leading comment mark (#) of the selected FROMSIZE variable.

Specify the F-ROM size.


FROMSIZE = 1_0M # MEMORY CARD 1.0MB
#FROMSIZE = 1_5M # MEMORY CARD 1.5MB In the left example, 1.0 MB is
#FROMSIZE = 2_0M # MEMORY CARD 2.0MB specified.
#FROMSIZE = 2_5M # MEMORY CARD 2.5MB
#FROMSIZE = 3_0M # MEMORY CARD 3.0MB
#FROMSIZE = 3_5M # MEMORY CARD 3.5MB
#FROMSIZE = 4_0M # MEMORY CARD 4.0MB
#FROMSIZE = 5_0M # MEMORY CARD 5.0MB
#FROMSIZE = 6_0M # MEMORY CARD 6.0MB

#------------------------------------------------------------------------------
# Task definition block. Modify here for your application.
#------------------------------------------------------------------------------

TASK1 = <- List the names of object files making up the main task.
TASK2 = <- List the names of object files making up the communication task.
TASK3 = <- List the names of object files making up the alarm task.
TASK4 = <- List the names of object files making up the window task.
TASK5 = <- List the names of object files making up the High-Level task.

Ending of the makefile

#------------------------------------------------------------------------------
# .O and .C dependency block.
#------------------------------------------------------------------------------
<- Specify the file dependency.
#------------------------------------------------------------------------------
# End of .O and .C dependency block.
#------------------------------------------------------------------------------

Modification examples are given below.


#------------------------------------------------------------------------------
# Task definition block. Modify here for your application.

- 1268 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

#------------------------------------------------------------------------------
TASK1 = main.o sub1.o sub2.o
TASK2 = comm.o
TASK3 = alarm.o alm_sub.o
TASK4 =
TASK5 =

#------------------------------------------------------------------------------
# .O and .C dependency block.
#------------------------------------------------------------------------------

main.o : main.c prog1.h


sub1.o : sub1.c prog1.h
sub2.o : sub2.c prog1.h
comm.o : comm.c prog1.h
alarm.o : alarm.c prog1.h
alarm.o : alm_sub.c prog1.h

#------------------------------------------------------------------------------
# End of .O and .C dependency block.
#------------------------------------------------------------------------------

Additional information on the makefile data

Beginning of the makefile

In the TASK macros, specify object files making up tasks.


When task 1 contains two files, S1.C and S2.C, write the following:
TASK1 = s1.o s2.o
If your entry extends beyond one line, use \ to continue on the next line.
TASK1 = s1.o s2.o \
s3.o
For an application program with the main task only, set the TASK1 macro alone.
TASK1 = s1.o s2.o
TASK2 =
TASK3 =
TASK4 =
TASK5 =

For a multi-task program, set the macros for the required number of tasks.
TASK1 = s1.o s2.o
TASK2 = x.o
TASK3 = y1.o y2.o y3.o
TASK4 =

- 1269 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

TASK5 =

Ending of the makefile

Dependency block
#------------------------------------------------------------------------------
# .O and .C dependency block.
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# End of .O and .C dependency block.
#------------------------------------------------------------------------------

Specify the relationships among object files, source files, and include files.

When S1.C includes ABC.H and S2.C includes DEF.H, write the following:

#------------------------------------------------------------------------------
# .O and .C dependency block.
#------------------------------------------------------------------------------

s1.o : s1.c abc.h


s2.o : s2.c def.h

#------------------------------------------------------------------------------
# End of .O and .C dependency block.
#------------------------------------------------------------------------------

- 1270 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

6) Modify the series and edition of a user application program in version.c.

Modify the following definition statement in version.c.

char version[ ] = "TEST0001" ;

For example, set the series and edition of the application program as PROG-A001.

char version[ ] = "PROGA001" ;

7) Execute NMAKE.

Change the working directory to the current directory and execute the nmake command.

- 1271 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

(Example) C:\C\CEXE\WORK>nmake
(The following shows the result of execution of nmake with the source files and makefile
on the library disk.)

If a compile error or link error has occurred, modify the source files and execute
nmake again.

- 1272 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

(Note 1: If an error as shown below has occurred during compilation, increase the size of the
F-ROM for storing object programs, which is specified at the beginning of the makefile,
or decrease the size of the source code.)

sizecheck : mem_size=0x100000, app_size=0x131cab


Application size check Error !
Application size exceeds FROM size.

NMAKE : fatal error U1077: '.\STEP3\SIZE_CHK.BAT' : return code '0x1'


Stop.

(Note 2: If a warning as shown below has occurred during compilation, check whether an array
declared as an automatic variable has been initialized upon declaration.)

warning: lswi: including RA in sequence is not portable between PPC implementations

This warning occurs if an array declared as an automatic variable is initialized upon


declaration.
(For example, short a[2] = {1, 2};)
This restriction is included in the Wind River Compiler C/C++ specifications. Ensure that
the array is not initialized upon declaration.

When nmake has been completed successfully, a file called cexec.mem is created.
This file is a memory card file to be stored in the CNC.
Copy the file to the memory card.

- 1273 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

8) Set CNC parameters.

Set the parameters for running the C Language Executor.


The following describes the variable area size, SRAM disk size, and the size of the DRAM used
with the C Language Executor. For an explanation of other C Language Executor parameters, see
Section 5.4, "Parameter setting on CNC" above.

8661 Size of variable area

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

[Input type] Parameter input


[Data type] Word type
[Unit of data] K bytes
[Valid data range] 0 to 59
When the C Language Executor is used, this parameter sets the size of the static
variable area sharable among tasks. Set a size in steps of 1K bytes. The maximum
specifiable size is 59K bytes. However, ensure that the sum of this size and the size of
the SRAM disk does not exceed (usable SRAM size - 1)K bytes (namely, 63K bytes).
When the setting of this parameter is modified, the variable area and SRAM disk are
initialized.

8662 Size of SRAM disk

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

[Input type] Parameter input


[Data type] Word type
[Unit of data] K bytes
[Valid data range] 4 to 63
When the C Language Executor is used, this parameter sets the size of the SRAM
disk. Set a size not smaller than 4K bytes in steps of 1K bytes. The maximum
specifiable size is 63K bytes. However, ensure that the sum of this size and the size of
the variable area does not exceed (usable SRAM size - 1)K bytes (namely, 63K
bytes).
When the setting of this parameter is modified, the SRAM disk is initialized.

- 1274 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

8781 Size of DRAM used with C Language Executor

NOTE
When this parameter has been set, the power must be turned off
before operation is continued.

[Input type] Parameter input


[Data type] Word type
[Unit of data] 64K bytes
[Valid data range] 16 to 96
This parameter sets the size of the DRAM used with the C Language Executor. Set a
value not smaller than 1024K bytes in steps of 64K bytes. If a value not within the
valid data range is set, the specification of 0 is assumed.
When the specified value is 0, the C Language Executor is not started.

NOTE
The actually usable size is limited by the RAM capacity and selected
option(s).

- 1275 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

9) Store the created application program on the F-ROM in the CNC and check the operation.

Use the procedure for operating the boot software for the CNC so that the cexec.mem file copied
to the memory card is stored on the F-ROM in the CNC as the application program.
Then, check the operation.

10) Sample program


(This sample is contained on the library disk.)

When the cexec.mem file is created from the sample program (tsk1main.c) stored in C:\cexe\user
and executed in the CNC unit, if the power is turned on or soft key [CEXE] under function key
<POSITION> is pressed, the following screen appears.

- 1276 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

/********** Sample program tsk1main.c **********/


#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <mdi.h>
#include <crt.h>
#include <fwindow.h>
#include <data.h>
#include <errno.h>
#include <bios.h>
#include <time.h>
#include <oscall.h>
#include <graph.h>

#include "escape.h"

int task1_var1;
int task1_var2 = 0;
//const task1_var3 = 0;

void main( void )


{
int ret, line, col, i, key_code;

- 1277 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

int crt_table[] = { CRT_POS_REL };


struct odbdy all_data;

/* setting video mode */


ret = _setvideomode( _VRES16COLOR );
/* usee screen setting */
crt_setuserscrn( scrn_tbl_size(crt_table),crt_table );
crt_cncscrn(CRT_POS_ALL) ;

cls();
crt_opengr() ;
crt_graphic(CRT_ON_BEAM);
_clearscreen( _GCLEARSCREEN );

/* graphics sample */
_setlinestyle(0xFFEA);
for (i = 0 ; i < 40 ; i++) {
_setcolor((short)(i % 7 + 1)) ;
_moveto((short)(8 * i), (short)(6 * i)) ;
_lineto((short)(639 - 8 * i), (short)(6 * i)) ;
_lineto((short)(639 - 8 * i), (short)(479 - 6 * i)) ;
_lineto((short)(8 * i), (short)(479 - 6 * i)) ;
_lineto((short)(8 * i), (short)(6 * i)) ;
}

printf("\n") ;
printf("PRESS INPUT KEY\n") ;

for (;;) {
/* key read */
key_code = _kbhit() ;
if (key_code) break;
}

cls();
_clearscreen( _GCLEARSCREEN );
crt_closegr();

/* position sample */
cursor_off();
while( 1 ) {
cnc_rddynamic( -1, sizeof(all_data), &all_data );
line = 2;

- 1278 -
B. Additional Information on C
B-64303EN-3/01 APPENDIX
Compiler Installation

col = 20;
locate( line++, col );
printf( "ABSOLUTE" ) ;
locate( line++, col );
printf( "1:%8ld", all_data.pos.faxis.absolute[0] );
locate( line++, col );
printf( "2:%8ld", all_data.pos.faxis.absolute[1] );
locate( line++, col );
printf( "3:%8ld", all_data.pos.faxis.absolute[2] );
locate( line++, col );
printf( "4:%8ld", all_data.pos.faxis.absolute[3] );
line++;
locate( line++, col );
printf( "MACHINE" );
locate( line++, col );
printf( "1:%8ld", all_data.pos.faxis.machine[0] );
locate( line++, col );
printf( "2:%8ld", all_data.pos.faxis.machine[1] );
locate( line++, col );
printf( "3:%8ld", all_data.pos.faxis.machine[2] );
locate( line++, col );
printf( "4:%8ld", all_data.pos.faxis.machine[3] );
line++;
locate( line++, col );
printf( "RELATIVE" ) ;
locate( line++, col );
printf( "1:%8ld", all_data.pos.faxis.relative[0] );
locate( line++, col );
printf( "2:%8ld", all_data.pos.faxis.relative[1] );
locate( line++, col );
printf( "3:%8ld", all_data.pos.faxis.relative[2] );
locate( line++, col );
printf( "4:%8ld", all_data.pos.faxis.relative[3] );
line++;
locate( line++, col );
printf( "DIST" );
locate( line++, col );
printf( "1:%8ld", all_data.pos.faxis.distance[0] );
locate( line++, col );
printf( "2:%8ld", all_data.pos.faxis.distance[1] );
locate( line++, col );
printf( "3:%8ld", all_data.pos.faxis.distance[2] );
locate( line++, col );
printf( "4:%8ld", all_data.pos.faxis.distance[3] );

- 1279 -
B. Additional Information on C
Compiler Installation APPENDIX B-64303EN-3/01

}
}

/*----- end of main.c -----*/

- 1280 -
B-64303EN-3/01 APPENDIX C.Character Code List

C Character Code List


The characters that can be displayed with the C Language Executor are listed below.

D.1 Half-size character code list (for 8.4-inch color LCD) .................................. 1282
D.2 Half-size character code list (for 10.4-inch color LCD) ................................ 1283
D.3 FANUC character code list (for 8.4-inch color LCD) ................................... 1289
D.4 FANUC character code list (for 10.4-inch color LCD) ................................. 1294

The character pattern dot sizes are as follows.

Width x length
Half-size characters for 8.4-inch color LCD 16 x 25
Full-size characters for 8.4-inch color LCD 32 x 25
Half-size characters for 10.4-inch color LCD 8 x 16
Full-size characters for 10.4-inch color LCD 16 x 16

Different scales are used in the printed characters for the 8.4-inch color LCD and
those for the 10.4-inch color LCD.

- 1281 -
C.Character Code List APPENDIX B-64303EN-3/01

C.1 Half-size character code list (for 8.4-inch color LCD)

(1) Graphic character set #1 (graphic character #1)


(2) Graphic character set #2 (graphic character #2)
(3) Graphic character set #3 (graphic character #3)
(4) Standard character set (standard character set, default)
(5) Small character set (reduced character set)
(6) European character set (European character set)
(7) Large character set (6x sized character set)
(The scale in the 6x sized character set is different from that in any of the other
character sets.)
(8) Graphic character set #1 (80 × 25)
(9) Standard character set (80 × 25)

- 1282 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1283 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1284 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1285 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1286 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1287 -
C.Character Code List APPENDIX B-64303EN-3/01

C.2 Half-size character code list (for 10.4-inch color LCD)

(1) Graphic character set #1 (graphic character #1)


(2) Graphic character set #2 (graphic character #2)
(3) Graphic character set #3 (graphic character #3)
(4) Standard character set (standard character set, default)
(5) Small character set (reduced character set)
(6) European character set (European character set)
(7) Large character set (6x sized character set)
(The scale in the 6x sized character set is different from that in any of the other
character sets.)

- 1288 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1289 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1290 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1291 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1292 -
B-64303EN-3/01 APPENDIX C.Character Code List

C.3 FANUC character code list (for 8.4-inch color LCD)

- 1293 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1294 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1295 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1296 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1297 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1298 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1299 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1300 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1301 -
C.Character Code List APPENDIX B-64303EN-3/01

C.4 FANUC character code list (for 10.4-inch color LCD)

- 1302 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1303 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1304 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1305 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1306 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1307 -
C.Character Code List APPENDIX B-64303EN-3/01

- 1308 -
B-64303EN-3/01 APPENDIX C.Character Code List

- 1309 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

D Simplified Chinese Character Code List


The simplified Chinese character code (GB2312 code) list is given below.

- 1310 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a1a0 、 。 · ˉ ˇ ¨ 〃 々 — ~ ‖ … ‘ ’
a1b0 “ ” 〔 〕 〈 〉 《 》 「 」 『 』 〖 〗 【 】
a1c0 ± × ÷ ∶ ∧ ∨ Σ Π ∪ ∩ ∈ ∷ √ ⊥ ∥ ∠
a1d0 ⌒ ⊙ ∫ ∮ ≡ ≌ ≈ ∽ ∝ ≠ ≮ ≯ ≤ ≥ ∞ ∵
a1e0 ∴ ♂ ♀ ° ′ ″ ℃ $ ¤ ¢ £ ‰ § № ☆ ★
a1f0 ○ ● ◎ ◇ ◆ □ ■ △ ▲ ※ → ← ↑ ↓ 〓

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a2a0
a2b0 ⒈ ⒉ ⒊ ⒋ ⒌ ⒍ ⒎ ⒏ ⒐ ⒑ ⒒ ⒓ ⒔ ⒕ ⒖
a2c0 ⒗ ⒘ ⒙ ⒚ ⒛ ⑴ ⑵ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⑽ ⑾
a2d0 ⑿ ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ ① ② ③ ④ ⑤ ⑥ ⑦
a2e0 ⑧ ⑨ ⑩ ㈠ ㈡ ㈢ ㈣ ㈤ ㈥ ㈦ ㈧ ㈨ ㈩
a2f0 Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ Ⅺ Ⅻ

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a3a0 ! " # ¥ % & ' ( ) * + , - . /
a3b0 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
a3c0 @ A B C D E F G H I J K L M N O
a3d0 P Q R S T U V W X Y Z [ \ ] ^ _
a3e0 ` a b c d e f g h i j k l m n o
a3f0 p q r s t u v w x y z { | }  ̄

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a4a0 ぁ あ ぃ い ぅ う ぇ え ぉ お か が き ぎ く
a4b0 ぐ け げ こ ご さ ざ し じ す ず せ ぜ そ ぞ た
a4c0 だ ち ぢ っ つ づ て で と ど な に ぬ ね の は
a4d0 ば ぱ ひ び ぴ ふ ぶ ぷ へ べ ぺ ほ ぼ ぽ ま み
a4e0 む め も ゃ や ゅ ゆ ょ よ ら り る れ ろ ゎ わ
a4f0 ゐ ゑ を ん

- 1311 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a5a0 ァ ア ィ イ ゥ ウ ェ エ ォ オ カ ガ キ ギ ク
a5b0 グ ケ ゲ コ ゴ サ ザ シ ジ ス ズ セ ゼ ソ ゾ タ
a5c0 ダ チ ヂ ッ ツ ヅ テ デ ト ド ナ ニ ヌ ネ ノ ハ
a5d0 バ パ ヒ ビ ピ フ ブ プ ヘ ベ ペ ホ ボ ポ マ ミ
a5e0 ム メ モ ャ ヤ ュ ユ ョ ヨ ラ リ ル レ ロ ヮ ワ
a5f0 ヰ ヱ ヲ ン ヴ ヵ ヶ

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a6a0 Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο
a6b0 Π Ρ Σ Τ Υ Φ Χ Ψ Ω
a6c0 α β γ δ ε ζ η θ ι κ λ μ ν ξ ο
a6d0 π ρ σ τ υ φ χ ψ ω
a6e0
a6f0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a7a0 А Б В Г Д Е Ё Ж З И Й К Л М Н
a7b0 О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э
a7c0 Ю Я
a7d0 а б в г д е ё ж з и й к л м н
a7e0 о п р с т у ф х ц ч ш щ ъ ы ь э
a7f0 ю я

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a8a0 ā á ǎ à ē é ě è ī í ǐ ì ō ó ǒ
a8b0 ò ū ú ǔ ù ǖ ǘ ǚ ǜ ü ê ɑ  ń ň 
a8c0 ɡ ㄅ ㄆ ㄇ ㄈ ㄉ ㄊ ㄋ ㄌ ㄍ ㄎ ㄏ
a8d0 ㄐ ㄑ ㄒ ㄓ ㄔ ㄕ ㄖ ㄗ ㄘ ㄙ ㄚ ㄛ ㄜ ㄝ ㄞ ㄟ
a8e0 ㄠ ㄡ ㄢ ㄣ ㄤ ㄥ ㄦ ㄧ ㄨ ㄩ
a8f0

- 1312 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
a9a0 ─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋
a9b0 ┌ ┍ ┎ ┏ ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛
a9c0 ├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫
a9d0 ┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻
a9e0 ┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋
a9f0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
aaa0
aab0
aac0
aad0
aae0
aaf0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
aba0
abb0
abc0
abd0
abe0
abf0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
aca0
acb0
acc0
acd0
ace0
acf0

- 1313 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
ada0
adb0
adc0
add0
ade0
adf0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
aea0
aeb0
aec0
aed0
aee0
aef0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
afa0
afb0
afc0
afd0
afe0
aff0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b0a0 啊 阿 埃 挨 哎 唉 哀 皑 癌 蔼 矮 艾 碍 爱 隘
b0b0 鞍 氨 安 俺 按 暗 岸 胺 案 肮 昂 盎 凹 敖 熬 翱
b0c0 袄 傲 奥 懊 澳 芭 捌 扒 叭 吧 笆 八 疤 巴 拔 跋
b0d0 靶 把 耙 坝 霸 罢 爸 白 柏 百 摆 佰 败 拜 稗 斑
b0e0 班 搬 扳 般 颁 板 版 扮 拌 伴 瓣 半 办 绊 邦 帮
b0f0 梆 榜 膀 绑 棒 磅 蚌 镑 傍 谤 苞 胞 包 褒 剥

- 1314 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b1a0 薄 雹 保 堡 饱 宝 抱 报 暴 豹 鲍 爆 杯 碑 悲
b1b0 卑 北 辈 背 贝 钡 倍 狈 备 惫 焙 被 奔 苯 本 笨
b1c0 崩 绷 甭 泵 蹦 迸 逼 鼻 比 鄙 笔 彼 碧 蓖 蔽 毕
b1d0 毙 毖 币 庇 痹 闭 敝 弊 必 辟 壁 臂 避 陛 鞭 边
b1e0 编 贬 扁 便 变 卞 辨 辩 辫 遍 标 彪 膘 表 鳖 憋
b1f0 别 瘪 彬 斌 濒 滨 宾 摈 兵 冰 柄 丙 秉 饼 炳

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b2a0 病 并 玻 菠 播 拨 钵 波 博 勃 搏 铂 箔 伯 帛
b2b0 舶 脖 膊 渤 泊 驳 捕 卜 哺 补 埠 不 布 步 簿 部
b2c0 怖 擦 猜 裁 材 才 财 睬 踩 采 彩 菜 蔡 餐 参 蚕
b2d0 残 惭 惨 灿 苍 舱 仓 沧 藏 操 糙 槽 曹 草 厕 策
b2e0 侧 册 测 层 蹭 插 叉 茬 茶 查 碴 搽 察 岔 差 诧
b2f0 拆 柴 豺 搀 掺 蝉 馋 谗 缠 铲 产 阐 颤 昌 猖

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b3a0 场 尝 常 长 偿 肠 厂 敞 畅 唱 倡 超 抄 钞 朝
b3b0 嘲 潮 巢 吵 炒 车 扯 撤 掣 彻 澈 郴 臣 辰 尘 晨
b3c0 忱 沉 陈 趁 衬 撑 称 城 橙 成 呈 乘 程 惩 澄 诚
b3d0 承 逞 骋 秤 吃 痴 持 匙 池 迟 弛 驰 耻 齿 侈 尺
b3e0 赤 翅 斥 炽 充 冲 虫 崇 宠 抽 酬 畴 踌 稠 愁 筹
b3f0 仇 绸 瞅 丑 臭 初 出 橱 厨 躇 锄 雏 滁 除 楚

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b4a0 础 储 矗 搐 触 处 揣 川 穿 椽 传 船 喘 串 疮
b4b0 窗 幢 床 闯 创 吹 炊 捶 锤 垂 春 椿 醇 唇 淳 纯
b4c0 蠢 戳 绰 疵 茨 磁 雌 辞 慈 瓷 词 此 刺 赐 次 聪
b4d0 葱 囱 匆 从 丛 凑 粗 醋 簇 促 蹿 篡 窜 摧 崔 催
b4e0 脆 瘁 粹 淬 翠 村 存 寸 磋 撮 搓 措 挫 错 搭 达
b4f0 答 瘩 打 大 呆 歹 傣 戴 带 殆 代 贷 袋 待 逮

- 1315 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b5a0 怠 耽 担 丹 单 郸 掸 胆 旦 氮 但 惮 淡 诞 弹
b5b0 蛋 当 挡 党 荡 档 刀 捣 蹈 倒 岛 祷 导 到 稻 悼
b5c0 道 盗 德 得 的 蹬 灯 登 等 瞪 凳 邓 堤 低 滴 迪
b5d0 敌 笛 狄 涤 翟 嫡 抵 底 地 蒂 第 帝 弟 递 缔 颠
b5e0 掂 滇 碘 点 典 靛 垫 电 佃 甸 店 惦 奠 淀 殿 碉
b5f0 叼 雕 凋 刁 掉 吊 钓 调 跌 爹 碟 蝶 迭 谍 叠

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b6a0 丁 盯 叮 钉 顶 鼎 锭 定 订 丢 东 冬 董 懂 动
b6b0 栋 侗 恫 冻 洞 兜 抖 斗 陡 豆 逗 痘 都 督 毒 犊
b6c0 独 读 堵 睹 赌 杜 镀 肚 度 渡 妒 端 短 锻 段 断
b6d0 缎 堆 兑 队 对 墩 吨 蹲 敦 顿 囤 钝 盾 遁 掇 哆
b6e0 多 夺 垛 躲 朵 跺 舵 剁 惰 堕 蛾 峨 鹅 俄 额 讹
b6f0 娥 恶 厄 扼 遏 鄂 饿 恩 而 儿 耳 尔 饵 洱 二

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b7a0 贰 发 罚 筏 伐 乏 阀 法 珐 藩 帆 番 翻 樊 矾
b7b0 钒 繁 凡 烦 反 返 范 贩 犯 饭 泛 坊 芳 方 肪 房
b7c0 防 妨 仿 访 纺 放 菲 非 啡 飞 肥 匪 诽 吠 肺 废
b7d0 沸 费 芬 酚 吩 氛 分 纷 坟 焚 汾 粉 奋 份 忿 愤
b7e0 粪 丰 封 枫 蜂 峰 锋 风 疯 烽 逢 冯 缝 讽 奉 凤
b7f0 佛 否 夫 敷 肤 孵 扶 拂 辐 幅 氟 符 伏 俘 服

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b8a0 浮 涪 福 袱 弗 甫 抚 辅 俯 釜 斧 脯 腑 府 腐
b8b0 赴 副 覆 赋 复 傅 付 阜 父 腹 负 富 讣 附 妇 缚
b8c0 咐 噶 嘎 该 改 概 钙 盖 溉 干 甘 杆 柑 竿 肝 赶
b8d0 感 秆 敢 赣 冈 刚 钢 缸 肛 纲 岗 港 杠 篙 皋 高
b8e0 膏 羔 糕 搞 镐 稿 告 哥 歌 搁 戈 鸽 胳 疙 割 革
b8f0 葛 格 蛤 阁 隔 铬 个 各 给 根 跟 耕 更 庚 羹

- 1316 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
b9a0 埂 耿 梗 工 攻 功 恭 龚 供 躬 公 宫 弓 巩 汞
b9b0 拱 贡 共 钩 勾 沟 苟 狗 垢 构 购 够 辜 菇 咕 箍
b9c0 估 沽 孤 姑 鼓 古 蛊 骨 谷 股 故 顾 固 雇 刮 瓜
b9d0 剐 寡 挂 褂 乖 拐 怪 棺 关 官 冠 观 管 馆 罐 惯
b9e0 灌 贯 光 广 逛 瑰 规 圭 硅 归 龟 闺 轨 鬼 诡 癸
b9f0 桂 柜 跪 贵 刽 辊 滚 棍 锅 郭 国 果 裹 过 哈

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
baa0 骸 孩 海 氦 亥 害 骇 酣 憨 邯 韩 含 涵 寒 函
bab0 喊 罕 翰 撼 捍 旱 憾 悍 焊 汗 汉 夯 杭 航 壕 嚎
bac0 豪 毫 郝 好 耗 号 浩 呵 喝 荷 菏 核 禾 和 何 合
bad0 盒 貉 阂 河 涸 赫 褐 鹤 贺 嘿 黑 痕 很 狠 恨 哼
bae0 亨 横 衡 恒 轰 哄 烘 虹 鸿 洪 宏 弘 红 喉 侯 猴
baf0 吼 厚 候 后 呼 乎 忽 瑚 壶 葫 胡 蝴 狐 糊 湖

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
bba0 弧 虎 唬 护 互 沪 户 花 哗 华 猾 滑 画 划 化
bbb0 话 槐 徊 怀 淮 坏 欢 环 桓 还 缓 换 患 唤 痪 豢
bbc0 焕 涣 宦 幻 荒 慌 黄 磺 蝗 簧 皇 凰 惶 煌 晃 幌
bbd0 恍 谎 灰 挥 辉 徽 恢 蛔 回 毁 悔 慧 卉 惠 晦 贿
bbe0 秽 会 烩 汇 讳 诲 绘 荤 昏 婚 魂 浑 混 豁 活 伙
bbf0 火 获 或 惑 霍 货 祸 击 圾 基 机 畸 稽 积 箕

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
bca0 肌 饥 迹 激 讥 鸡 姬 绩 缉 吉 极 棘 辑 籍 集
bcb0 及 急 疾 汲 即 嫉 级 挤 几 脊 己 蓟 技 冀 季 伎
bcc0 祭 剂 悸 济 寄 寂 计 记 既 忌 际 妓 继 纪 嘉 枷
bcd0 夹 佳 家 加 荚 颊 贾 甲 钾 假 稼 价 架 驾 嫁 歼
bce0 监 坚 尖 笺 间 煎 兼 肩 艰 奸 缄 茧 检 柬 碱 硷
bcf0 拣 捡 简 俭 剪 减 荐 槛 鉴 践 贱 见 键 箭 件

- 1317 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
bda0 健 舰 剑 饯 渐 溅 涧 建 僵 姜 将 浆 江 疆 蒋
bdb0 桨 奖 讲 匠 酱 降 蕉 椒 礁 焦 胶 交 郊 浇 骄 娇
bdc0 嚼 搅 铰 矫 侥 脚 狡 角 饺 缴 绞 剿 教 酵 轿 较
bdd0 叫 窖 揭 接 皆 秸 街 阶 截 劫 节 桔 杰 捷 睫 竭
bde0 洁 结 解 姐 戒 藉 芥 界 借 介 疥 诫 届 巾 筋 斤
bdf0 金 今 津 襟 紧 锦 仅 谨 进 靳 晋 禁 近 烬 浸

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
bea0 尽 劲 荆 兢 茎 睛 晶 鲸 京 惊 精 粳 经 井 警
beb0 景 颈 静 境 敬 镜 径 痉 靖 竟 竞 净 炯 窘 揪 究
bec0 纠 玖 韭 久 灸 九 酒 厩 救 旧 臼 舅 咎 就 疚 鞠
bed0 拘 狙 疽 居 驹 菊 局 咀 矩 举 沮 聚 拒 据 巨 具
bee0 距 踞 锯 俱 句 惧 炬 剧 捐 鹃 娟 倦 眷 卷 绢 撅
bef0 攫 抉 掘 倔 爵 觉 决 诀 绝 均 菌 钧 军 君 峻

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
bfa0 俊 竣 浚 郡 骏 喀 咖 卡 咯 开 揩 楷 凯 慨 刊
bfb0 堪 勘 坎 砍 看 康 慷 糠 扛 抗 亢 炕 考 拷 烤 靠
bfc0 坷 苛 柯 棵 磕 颗 科 壳 咳 可 渴 克 刻 客 课 肯
bfd0 啃 垦 恳 坑 吭 空 恐 孔 控 抠 口 扣 寇 枯 哭 窟
bfe0 苦 酷 库 裤 夸 垮 挎 跨 胯 块 筷 侩 快 宽 款 匡
bff0 筐 狂 框 矿 眶 旷 况 亏 盔 岿 窥 葵 奎 魁 傀

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c0a0 馈 愧 溃 坤 昆 捆 困 括 扩 廓 阔 垃 拉 喇 蜡
c0b0 腊 辣 啦 莱 来 赖 蓝 婪 栏 拦 篮 阑 兰 澜 谰 揽
c0c0 览 懒 缆 烂 滥 琅 榔 狼 廊 郎 朗 浪 捞 劳 牢 老
c0d0 佬 姥 酪 烙 涝 勒 乐 雷 镭 蕾 磊 累 儡 垒 擂 肋
c0e0 类 泪 棱 楞 冷 厘 梨 犁 黎 篱 狸 离 漓 理 李 里
c0f0 鲤 礼 莉 荔 吏 栗 丽 厉 励 砾 历 利 傈 例 俐

- 1318 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c1a0 痢 立 粒 沥 隶 力 璃 哩 俩 联 莲 连 镰 廉 怜
c1b0 涟 帘 敛 脸 链 恋 炼 练 粮 凉 梁 粱 良 两 辆 量
c1c0 晾 亮 谅 撩 聊 僚 疗 燎 寥 辽 潦 了 撂 镣 廖 料
c1d0 列 裂 烈 劣 猎 琳 林 磷 霖 临 邻 鳞 淋 凛 赁 吝
c1e0 拎 玲 菱 零 龄 铃 伶 羚 凌 灵 陵 岭 领 另 令 溜
c1f0 琉 榴 硫 馏 留 刘 瘤 流 柳 六 龙 聋 咙 笼 窿

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c2a0 隆 垄 拢 陇 楼 娄 搂 篓 漏 陋 芦 卢 颅 庐 炉
c2b0 掳 卤 虏 鲁 麓 碌 露 路 赂 鹿 潞 禄 录 陆 戮 驴
c2c0 吕 铝 侣 旅 履 屡 缕 虑 氯 律 率 滤 绿 峦 挛 孪
c2d0 滦 卵 乱 掠 略 抡 轮 伦 仑 沦 纶 论 萝 螺 罗 逻
c2e0 锣 箩 骡 裸 落 洛 骆 络 妈 麻 玛 码 蚂 马 骂 嘛
c2f0 吗 埋 买 麦 卖 迈 脉 瞒 馒 蛮 满 蔓 曼 慢 漫

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c3a0 谩 芒 茫 盲 氓 忙 莽 猫 茅 锚 毛 矛 铆 卯 茂
c3b0 冒 帽 貌 贸 么 玫 枚 梅 酶 霉 煤 没 眉 媒 镁 每
c3c0 美 昧 寐 妹 媚 门 闷 们 萌 蒙 檬 盟 锰 猛 梦 孟
c3d0 眯 醚 靡 糜 迷 谜 弥 米 秘 觅 泌 蜜 密 幂 棉 眠
c3e0 绵 冕 免 勉 娩 缅 面 苗 描 瞄 藐 秒 渺 庙 妙 蔑
c3f0 灭 民 抿 皿 敏 悯 闽 明 螟 鸣 铭 名 命 谬 摸

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c4a0 摹 蘑 模 膜 磨 摩 魔 抹 末 莫 墨 默 沫 漠 寞
c4b0 陌 谋 牟 某 拇 牡 亩 姆 母 墓 暮 幕 募 慕 木 目
c4c0 睦 牧 穆 拿 哪 呐 钠 那 娜 纳 氖 乃 奶 耐 奈 南
c4d0 男 难 囊 挠 脑 恼 闹 淖 呢 馁 内 嫩 能 妮 霓 倪
c4e0 泥 尼 拟 你 匿 腻 逆 溺 蔫 拈 年 碾 撵 捻 念 娘
c4f0 酿 鸟 尿 捏 聂 孽 啮 镊 镍 涅 您 柠 狞 凝 宁

- 1319 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c5a0 拧 泞 牛 扭 钮 纽 脓 浓 农 弄 奴 努 怒 女 暖
c5b0 虐 疟 挪 懦 糯 诺 哦 欧 鸥 殴 藕 呕 偶 沤 啪 趴
c5c0 爬 帕 怕 琶 拍 排 牌 徘 湃 派 攀 潘 盘 磐 盼 畔
c5d0 判 叛 乓 庞 旁 耪 胖 抛 咆 刨 炮 袍 跑 泡 呸 胚
c5e0 培 裴 赔 陪 配 佩 沛 喷 盆 砰 抨 烹 澎 彭 蓬 棚
c5f0 硼 篷 膨 朋 鹏 捧 碰 坯 砒 霹 批 披 劈 琵 毗

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c6a0 啤 脾 疲 皮 匹 痞 僻 屁 譬 篇 偏 片 骗 飘 漂
c6b0 瓢 票 撇 瞥 拼 频 贫 品 聘 乒 坪 苹 萍 平 凭 瓶
c6c0 评 屏 坡 泼 颇 婆 破 魄 迫 粕 剖 扑 铺 仆 莆 葡
c6d0 菩 蒲 埔 朴 圃 普 浦 谱 曝 瀑 期 欺 栖 戚 妻 七
c6e0 凄 漆 柒 沏 其 棋 奇 歧 畦 崎 脐 齐 旗 祈 祁 骑
c6f0 起 岂 乞 企 启 契 砌 器 气 迄 弃 汽 泣 讫 掐

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c7a0 恰 洽 牵 扦 钎 铅 千 迁 签 仟 谦 乾 黔 钱 钳
c7b0 前 潜 遣 浅 谴 堑 嵌 欠 歉 枪 呛 腔 羌 墙 蔷 强
c7c0 抢 橇 锹 敲 悄 桥 瞧 乔 侨 巧 鞘 撬 翘 峭 俏 窍
c7d0 切 茄 且 怯 窃 钦 侵 亲 秦 琴 勤 芹 擒 禽 寝 沁
c7e0 青 轻 氢 倾 卿 清 擎 晴 氰 情 顷 请 庆 琼 穷 秋
c7f0 丘 邱 球 求 囚 酋 泅 趋 区 蛆 曲 躯 屈 驱 渠

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c8a0 取 娶 龋 趣 去 圈 颧 权 醛 泉 全 痊 拳 犬 券
c8b0 劝 缺 炔 瘸 却 鹊 榷 确 雀 裙 群 然 燃 冉 染 瓤
c8c0 壤 攘 嚷 让 饶 扰 绕 惹 热 壬 仁 人 忍 韧 任 认
c8d0 刃 妊 纫 扔 仍 日 戎 茸 蓉 荣 融 熔 溶 容 绒 冗
c8e0 揉 柔 肉 茹 蠕 儒 孺 如 辱 乳 汝 入 褥 软 阮 蕊
c8f0 瑞 锐 闰 润 若 弱 撒 洒 萨 腮 鳃 塞 赛 三 叁

- 1320 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
c9a0 伞 散 桑 嗓 丧 搔 骚 扫 嫂 瑟 色 涩 森 僧 莎
c9b0 砂 杀 刹 沙 纱 傻 啥 煞 筛 晒 珊 苫 杉 山 删 煽
c9c0 衫 闪 陕 擅 赡 膳 善 汕 扇 缮 墒 伤 商 赏 晌 上
c9d0 尚 裳 梢 捎 稍 烧 芍 勺 韶 少 哨 邵 绍 奢 赊 蛇
c9e0 舌 舍 赦 摄 射 慑 涉 社 设 砷 申 呻 伸 身 深 娠
c9f0 绅 神 沈 审 婶 甚 肾 慎 渗 声 生 甥 牲 升 绳

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
caa0 省 盛 剩 胜 圣 师 失 狮 施 湿 诗 尸 虱 十 石
cab0 拾 时 什 食 蚀 实 识 史 矢 使 屎 驶 始 式 示 士
cac0 世 柿 事 拭 誓 逝 势 是 嗜 噬 适 仕 侍 释 饰 氏
cad0 市 恃 室 视 试 收 手 首 守 寿 授 售 受 瘦 兽 蔬
cae0 枢 梳 殊 抒 输 叔 舒 淑 疏 书 赎 孰 熟 薯 暑 曙
caf0 署 蜀 黍 鼠 属 术 述 树 束 戍 竖 墅 庶 数 漱

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
cba0 恕 刷 耍 摔 衰 甩 帅 栓 拴 霜 双 爽 谁 水 睡
cbb0 税 吮 瞬 顺 舜 说 硕 朔 烁 斯 撕 嘶 思 私 司 丝
cbc0 死 肆 寺 嗣 四 伺 似 饲 巳 松 耸 怂 颂 送 宋 讼
cbd0 诵 搜 艘 擞 嗽 苏 酥 俗 素 速 粟 僳 塑 溯 宿 诉
cbe0 肃 酸 蒜 算 虽 隋 随 绥 髓 碎 岁 穗 遂 隧 祟 孙
cbf0 损 笋 蓑 梭 唆 缩 琐 索 锁 所 塌 他 它 她 塔

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
cca0 獭 挞 蹋 踏 胎 苔 抬 台 泰 酞 太 态 汰 坍 摊
ccb0 贪 瘫 滩 坛 檀 痰 潭 谭 谈 坦 毯 袒 碳 探 叹 炭
ccc0 汤 塘 搪 堂 棠 膛 唐 糖 倘 躺 淌 趟 烫 掏 涛 滔
ccd0 绦 萄 桃 逃 淘 陶 讨 套 特 藤 腾 疼 誊 梯 剔 踢
cce0 锑 提 题 蹄 啼 体 替 嚏 惕 涕 剃 屉 天 添 填 田
ccf0 甜 恬 舔 腆 挑 条 迢 眺 跳 贴 铁 帖 厅 听 烃

- 1321 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
cda0 汀 廷 停 亭 庭 挺 艇 通 桐 酮 瞳 同 铜 彤 童
cdb0 桶 捅 筒 统 痛 偷 投 头 透 凸 秃 突 图 徒 途 涂
cdc0 屠 土 吐 兔 湍 团 推 颓 腿 蜕 褪 退 吞 屯 臀 拖
cdd0 托 脱 鸵 陀 驮 驼 椭 妥 拓 唾 挖 哇 蛙 洼 娃 瓦
cde0 袜 歪 外 豌 弯 湾 玩 顽 丸 烷 完 碗 挽 晚 皖 惋
cdf0 宛 婉 万 腕 汪 王 亡 枉 网 往 旺 望 忘 妄 威

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
cea0 巍 微 危 韦 违 桅 围 唯 惟 为 潍 维 苇 萎 委
ceb0 伟 伪 尾 纬 未 蔚 味 畏 胃 喂 魏 位 渭 谓 尉 慰
cec0 卫 瘟 温 蚊 文 闻 纹 吻 稳 紊 问 嗡 翁 瓮 挝 蜗
ced0 涡 窝 我 斡 卧 握 沃 巫 呜 钨 乌 污 诬 屋 无 芜
cee0 梧 吾 吴 毋 武 五 捂 午 舞 伍 侮 坞 戊 雾 晤 物
cef0 勿 务 悟 误 昔 熙 析 西 硒 矽 晰 嘻 吸 锡 牺

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
cfa0 稀 息 希 悉 膝 夕 惜 熄 烯 溪 汐 犀 檄 袭 席
cfb0 习 媳 喜 铣 洗 系 隙 戏 细 瞎 虾 匣 霞 辖 暇 峡
cfc0 侠 狭 下 厦 夏 吓 掀 锨 先 仙 鲜 纤 咸 贤 衔 舷
cfd0 闲 涎 弦 嫌 显 险 现 献 县 腺 馅 羡 宪 陷 限 线
cfe0 相 厢 镶 香 箱 襄 湘 乡 翔 祥 详 想 响 享 项 巷
cff0 橡 像 向 象 萧 硝 霄 削 哮 嚣 销 消 宵 淆 晓

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d0a0 小 孝 校 肖 啸 笑 效 楔 些 歇 蝎 鞋 协 挟 携
d0b0 邪 斜 胁 谐 写 械 卸 蟹 懈 泄 泻 谢 屑 薪 芯 锌
d0c0 欣 辛 新 忻 心 信 衅 星 腥 猩 惺 兴 刑 型 形 邢
d0d0 行 醒 幸 杏 性 姓 兄 凶 胸 匈 汹 雄 熊 休 修 羞
d0e0 朽 嗅 锈 秀 袖 绣 墟 戌 需 虚 嘘 须 徐 许 蓄 酗
d0f0 叙 旭 序 畜 恤 絮 婿 绪 续 轩 喧 宣 悬 旋 玄

- 1322 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d1a0 选 癣 眩 绚 靴 薛 学 穴 雪 血 勋 熏 循 旬 询
d1b0 寻 驯 巡 殉 汛 训 讯 逊 迅 压 押 鸦 鸭 呀 丫 芽
d1c0 牙 蚜 崖 衙 涯 雅 哑 亚 讶 焉 咽 阉 烟 淹 盐 严
d1d0 研 蜒 岩 延 言 颜 阎 炎 沿 奄 掩 眼 衍 演 艳 堰
d1e0 燕 厌 砚 雁 唁 彦 焰 宴 谚 验 殃 央 鸯 秧 杨 扬
d1f0 佯 疡 羊 洋 阳 氧 仰 痒 养 样 漾 邀 腰 妖 瑶

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d2a0 摇 尧 遥 窑 谣 姚 咬 舀 药 要 耀 椰 噎 耶 爷
d2b0 野 冶 也 页 掖 业 叶 曳 腋 夜 液 一 壹 医 揖 铱
d2c0 依 伊 衣 颐 夷 遗 移 仪 胰 疑 沂 宜 姨 彝 椅 蚁
d2d0 倚 已 乙 矣 以 艺 抑 易 邑 屹 亿 役 臆 逸 肄 疫
d2e0 亦 裔 意 毅 忆 义 益 溢 诣 议 谊 译 异 翼 翌 绎
d2f0 茵 荫 因 殷 音 阴 姻 吟 银 淫 寅 饮 尹 引 隐

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d3a0 印 英 樱 婴 鹰 应 缨 莹 萤 营 荧 蝇 迎 赢 盈
d3b0 影 颖 硬 映 哟 拥 佣 臃 痈 庸 雍 踊 蛹 咏 泳 涌
d3c0 永 恿 勇 用 幽 优 悠 忧 尤 由 邮 铀 犹 油 游 酉
d3d0 有 友 右 佑 釉 诱 又 幼 迂 淤 于 盂 榆 虞 愚 舆
d3e0 余 俞 逾 鱼 愉 渝 渔 隅 予 娱 雨 与 屿 禹 宇 语
d3f0 羽 玉 域 芋 郁 吁 遇 喻 峪 御 愈 欲 狱 育 誉

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d4a0 浴 寓 裕 预 豫 驭 鸳 渊 冤 元 垣 袁 原 援 辕
d4b0 园 员 圆 猿 源 缘 远 苑 愿 怨 院 曰 约 越 跃 钥
d4c0 岳 粤 月 悦 阅 耘 云 郧 匀 陨 允 运 蕴 酝 晕 韵
d4d0 孕 匝 砸 杂 栽 哉 灾 宰 载 再 在 咱 攒 暂 赞 赃
d4e0 脏 葬 遭 糟 凿 藻 枣 早 澡 蚤 躁 噪 造 皂 灶 燥
d4f0 责 择 则 泽 贼 怎 增 憎 曾 赠 扎 喳 渣 札 轧

- 1323 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d5a0 铡 闸 眨 栅 榨 咋 乍 炸 诈 摘 斋 宅 窄 债 寨
d5b0 瞻 毡 詹 粘 沾 盏 斩 辗 崭 展 蘸 栈 占 战 站 湛
d5c0 绽 樟 章 彰 漳 张 掌 涨 杖 丈 帐 账 仗 胀 瘴 障
d5d0 招 昭 找 沼 赵 照 罩 兆 肇 召 遮 折 哲 蛰 辙 者
d5e0 锗 蔗 这 浙 珍 斟 真 甄 砧 臻 贞 针 侦 枕 疹 诊
d5f0 震 振 镇 阵 蒸 挣 睁 征 狰 争 怔 整 拯 正 政

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d6a0 帧 症 郑 证 芝 枝 支 吱 蜘 知 肢 脂 汁 之 织
d6b0 职 直 植 殖 执 值 侄 址 指 止 趾 只 旨 纸 志 挚
d6c0 掷 至 致 置 帜 峙 制 智 秩 稚 质 炙 痔 滞 治 窒
d6d0 中 盅 忠 钟 衷 终 种 肿 重 仲 众 舟 周 州 洲 诌
d6e0 粥 轴 肘 帚 咒 皱 宙 昼 骤 珠 株 蛛 朱 猪 诸 诛
d6f0 逐 竹 烛 煮 拄 瞩 嘱 主 著 柱 助 蛀 贮 铸 筑

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d7a0 住 注 祝 驻 抓 爪 拽 专 砖 转 撰 赚 篆 桩 庄
d7b0 装 妆 撞 壮 状 椎 锥 追 赘 坠 缀 谆 准 捉 拙 卓
d7c0 桌 琢 茁 酌 啄 着 灼 浊 兹 咨 资 姿 滋 淄 孜 紫
d7d0 仔 籽 滓 子 自 渍 字 鬃 棕 踪 宗 综 总 纵 邹 走
d7e0 奏 揍 租 足 卒 族 祖 诅 阻 组 钻 纂 嘴 醉 最 罪
d7f0 尊 遵 昨 左 佐 柞 做 作 坐 座

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d8a0 亍 丌 兀 丐 廿 卅 丕 亘 丞 鬲 孬 噩 丨 禺 丿
d8b0 匕 乇 夭 爻 卮 氐 囟 胤 馗 毓 睾 鼗 丶 亟 鼐 乜
d8c0 乩 亓 芈 孛 啬 嘏 仄 厍 厝 厣 厥 厮 靥 赝 匚 叵
d8d0 匦 匮 匾 赜 卦 卣 刂 刈 刎 刭 刳 刿 剀 剌 剞 剡
d8e0 剜 蒯 剽 劂 劁 劐 劓 冂 罔 亻 仃 仉 仂 仨 仡 仫
d8f0 仞 伛 仳 伢 佤 仵 伥 伧 伉 伫 佞 佧 攸 佚 佝

- 1324 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
d9a0 佟 佗 伲 伽 佶 佴 侑 侉 侃 侏 佾 佻 侪 佼 侬
d9b0 侔 俦 俨 俪 俅 俚 俣 俜 俑 俟 俸 倩 偌 俳 倬 倏
d9c0 倮 倭 俾 倜 倌 倥 倨 偾 偃 偕 偈 偎 偬 偻 傥 傧
d9d0 傩 傺 僖 儆 僭 僬 僦 僮 儇 儋 仝 氽 佘 佥 俎 龠
d9e0 汆 籴 兮 巽 黉 馘 冁 夔 勹 匍 訇 匐 凫 夙 兕 亠
d9f0 兖 亳 衮 袤 亵 脔 裒 禀 嬴 蠃 羸 冫 冱 冽 冼

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
daa0 凇 冖 冢 冥 讠 讦 讧 讪 讴 讵 讷 诂 诃 诋 诏
dab0 诎 诒 诓 诔 诖 诘 诙 诜 诟 诠 诤 诨 诩 诮 诰 诳
dac0 诶 诹 诼 诿 谀 谂 谄 谇 谌 谏 谑 谒 谔 谕 谖 谙
dad0 谛 谘 谝 谟 谠 谡 谥 谧 谪 谫 谮 谯 谲 谳 谵 谶
dae0 卩 卺 阝 阢 阡 阱 阪 阽 阼 陂 陉 陔 陟 陧 陬 陲
daf0 陴 隈 隍 隗 隰 邗 邛 邝 邙 邬 邡 邴 邳 邶 邺

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
dba0 邸 邰 郏 郅 邾 郐 郄 郇 郓 郦 郢 郜 郗 郛 郫
dbb0 郯 郾 鄄 鄢 鄞 鄣 鄱 鄯 鄹 酃 酆 刍 奂 劢 劬 劭
dbc0 劾 哿 勐 勖 勰 叟 燮 矍 廴 凵 凼 鬯 厶 弁 畚 巯
dbd0 坌 垩 垡 塾 墼 壅 壑 圩 圬 圪 圳 圹 圮 圯 坜 圻
dbe0 坂 坩 垅 坫 垆 坼 坻 坨 坭 坶 坳 垭 垤 垌 垲 埏
dbf0 垧 垴 垓 垠 埕 埘 埚 埙 埒 垸 埴 埯 埸 埤 埝

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
dca0 堋 堍 埽 埭 堀 堞 堙 塄 堠 塥 塬 墁 墉 墚 墀
dcb0 馨 鼙 懿 艹 艽 艿 芏 芊 芨 芄 芎 芑 芗 芙 芫 芸
dcc0 芾 芰 苈 苊 苣 芘 芷 芮 苋 苌 苁 芩 芴 芡 芪 芟
dcd0 苄 苎 芤 苡 茉 苷 苤 茏 茇 苜 苴 苒 苘 茌 苻 苓
dce0 茑 茚 茆 茔 茕 苠 苕 茜 荑 荛 荜 茈 莒 茼 茴 茱
dcf0 莛 荞 茯 荏 荇 荃 荟 荀 茗 荠 茭 茺 茳 荦 荥

- 1325 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
dda0 荨 茛 荩 荬 荪 荭 荮 莰 荸 莳 莴 莠 莪 莓 莜
ddb0 莅 荼 莶 莩 荽 莸 荻 莘 莞 莨 莺 莼 菁 萁 菥 菘
ddc0 堇 萘 萋 菝 菽 菖 萜 萸 萑 萆 菔 菟 萏 萃 菸 菹
ddd0 菪 菅 菀 萦 菰 菡 葜 葑 葚 葙 葳 蒇 蒈 葺 蒉 葸
dde0 萼 葆 葩 葶 蒌 蒎 萱 葭 蓁 蓍 蓐 蓦 蒽 蓓 蓊 蒿
ddf0 蒺 蓠 蒡 蒹 蒴 蒗 蓥 蓣 蔌 甍 蔸 蓰 蔹 蔟 蔺

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
dea0 蕖 蔻 蓿 蓼 蕙 蕈 蕨 蕤 蕞 蕺 瞢 蕃 蕲 蕻 薤
deb0 薨 薇 薏 蕹 薮 薜 薅 薹 薷 薰 藓 藁 藜 藿 蘧 蘅
dec0 蘩 蘖 蘼 廾 弈 夼 奁 耷 奕 奚 奘 匏 尢 尥 尬 尴
ded0 扌 扪 抟 抻 拊 拚 拗 拮 挢 拶 挹 捋 捃 掭 揶 捱
dee0 捺 掎 掴 捭 掬 掊 捩 掮 掼 揲 揸 揠 揿 揄 揞 揎
def0 摒 揆 掾 摅 摁 搋 搛 搠 搌 搦 搡 摞 撄 摭 撖

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
dfa0 摺 撷 撸 撙 撺 擀 擐 擗 擤 擢 攉 攥 攮 弋 忒
dfb0 甙 弑 卟 叱 叽 叩 叨 叻 吒 吖 吆 呋 呒 呓 呔 呖
dfc0 呃 吡 呗 呙 吣 吲 咂 咔 呷 呱 呤 咚 咛 咄 呶 呦
dfd0 咝 哐 咭 哂 咴 哒 咧 咦 哓 哔 呲 咣 哕 咻 咿 哌
dfe0 哙 哚 哜 咩 咪 咤 哝 哏 哞 唛 哧 唠 哽 唔 哳 唢
dff0 唣 唏 唑 唧 唪 啧 喏 喵 啉 啭 啁 啕 唿 啐 唼

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e0a0 唷 啖 啵 啶 啷 唳 唰 啜 喋 嗒 喃 喱 喹 喈 喁
e0b0 喟 啾 嗖 喑 啻 嗟 喽 喾 喔 喙 嗪 嗷 嗉 嘟 嗑 嗫
e0c0 嗬 嗔 嗦 嗝 嗄 嗯 嗥 嗲 嗳 嗌 嗍 嗨 嗵 嗤 辔 嘞
e0d0 嘈 嘌 嘁 嘤 嘣 嗾 嘀 嘧 嘭 噘 嘹 噗 嘬 噍 噢 噙
e0e0 噜 噌 噔 嚆 噤 噱 噫 噻 噼 嚅 嚓 嚯 囔 囗 囝 囡
e0f0 囵 囫 囹 囿 圄 圊 圉 圜 帏 帙 帔 帑 帱 帻 帼

- 1326 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e1a0 帷 幄 幔 幛 幞 幡 岌 屺 岍 岐 岖 岈 岘 岙 岑
e1b0 岚 岜 岵 岢 岽 岬 岫 岱 岣 峁 岷 峄 峒 峤 峋 峥
e1c0 崂 崃 崧 崦 崮 崤 崞 崆 崛 嵘 崾 崴 崽 嵬 嵛 嵯
e1d0 嵝 嵫 嵋 嵊 嵩 嵴 嶂 嶙 嶝 豳 嶷 巅 彳 彷 徂 徇
e1e0 徉 後 徕 徙 徜 徨 徭 徵 徼 衢 彡 犭 犰 犴 犷 犸
e1f0 狃 狁 狎 狍 狒 狨 狯 狩 狲 狴 狷 猁 狳 猃 狺

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e2a0 狻 猗 猓 猡 猊 猞 猝 猕 猢 猹 猥 猬 猸 猱 獐
e2b0 獍 獗 獠 獬 獯 獾 舛 夥 飧 夤 夂 饣 饧 饨 饩 饪
e2c0 饫 饬 饴 饷 饽 馀 馄 馇 馊 馍 馐 馑 馓 馔 馕 庀
e2d0 庑 庋 庖 庥 庠 庹 庵 庾 庳 赓 廒 廑 廛 廨 廪 膺
e2e0 忄 忉 忖 忏 怃 忮 怄 忡 忤 忾 怅 怆 忪 忭 忸 怙
e2f0 怵 怦 怛 怏 怍 怩 怫 怊 怿 怡 恸 恹 恻 恺 恂

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e3a0 恪 恽 悖 悚 悭 悝 悃 悒 悌 悛 惬 悻 悱 惝 惘
e3b0 惆 惚 悴 愠 愦 愕 愣 惴 愀 愎 愫 慊 慵 憬 憔 憧
e3c0 憷 懔 懵 忝 隳 闩 闫 闱 闳 闵 闶 闼 闾 阃 阄 阆
e3d0 阈 阊 阋 阌 阍 阏 阒 阕 阖 阗 阙 阚 丬 爿 戕 氵
e3e0 汔 汜 汊 沣 沅 沐 沔 沌 汨 汩 汴 汶 沆 沩 泐 泔
e3f0 沭 泷 泸 泱 泗 沲 泠 泖 泺 泫 泮 沱 泓 泯 泾

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e4a0 洹 洧 洌 浃 浈 洇 洄 洙 洎 洫 浍 洮 洵 洚 浏
e4b0 浒 浔 洳 涑 浯 涞 涠 浞 涓 涔 浜 浠 浼 浣 渚 淇
e4c0 淅 淞 渎 涿 淠 渑 淦 淝 淙 渖 涫 渌 涮 渫 湮 湎
e4d0 湫 溲 湟 溆 湓 湔 渲 渥 湄 滟 溱 溘 滠 漭 滢 溥
e4e0 溧 溽 溻 溷 滗 溴 滏 溏 滂 溟 潢 潆 潇 漤 漕 滹
e4f0 漯 漶 潋 潴 漪 漉 漩 澉 澍 澌 潸 潲 潼 潺 濑

- 1327 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e5a0 濉 澧 澹 澶 濂 濡 濮 濞 濠 濯 瀚 瀣 瀛 瀹 瀵
e5b0 灏 灞 宀 宄 宕 宓 宥 宸 甯 骞 搴 寤 寮 褰 寰 蹇
e5c0 謇 辶 迓 迕 迥 迮 迤 迩 迦 迳 迨 逅 逄 逋 逦 逑
e5d0 逍 逖 逡 逵 逶 逭 逯 遄 遑 遒 遐 遨 遘 遢 遛 暹
e5e0 遴 遽 邂 邈 邃 邋 彐 彗 彖 彘 尻 咫 屐 屙 孱 屣
e5f0 屦 羼 弪 弩 弭 艴 弼 鬻 屮 妁 妃 妍 妩 妪 妣

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e6a0 妗 姊 妫 妞 妤 姒 妲 妯 姗 妾 娅 娆 姝 娈 姣
e6b0 姘 姹 娌 娉 娲 娴 娑 娣 娓 婀 婧 婊 婕 娼 婢 婵
e6c0 胬 媪 媛 婷 婺 媾 嫫 媲 嫒 嫔 媸 嫠 嫣 嫱 嫖 嫦
e6d0 嫘 嫜 嬉 嬗 嬖 嬲 嬷 孀 尕 尜 孚 孥 孳 孑 孓 孢
e6e0 驵 驷 驸 驺 驿 驽 骀 骁 骅 骈 骊 骐 骒 骓 骖 骘
e6f0 骛 骜 骝 骟 骠 骢 骣 骥 骧 纟 纡 纣 纥 纨 纩

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e7a0 纭 纰 纾 绀 绁 绂 绉 绋 绌 绐 绔 绗 绛 绠 绡
e7b0 绨 绫 绮 绯 绱 绲 缍 绶 绺 绻 绾 缁 缂 缃 缇 缈
e7c0 缋 缌 缏 缑 缒 缗 缙 缜 缛 缟 缡 缢 缣 缤 缥 缦
e7d0 缧 缪 缫 缬 缭 缯 缰 缱 缲 缳 缵 幺 畿 巛 甾 邕
e7e0 玎 玑 玮 玢 玟 珏 珂 珑 玷 玳 珀 珉 珈 珥 珙 顼
e7f0 琊 珩 珧 珞 玺 珲 琏 琪 瑛 琦 琥 琨 琰 琮 琬

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e8a0 琛 琚 瑁 瑜 瑗 瑕 瑙 瑷 瑭 瑾 璜 璎 璀 璁 璇
e8b0 璋 璞 璨 璩 璐 璧 瓒 璺 韪 韫 韬 杌 杓 杞 杈 杩
e8c0 枥 枇 杪 杳 枘 枧 杵 枨 枞 枭 枋 杷 杼 柰 栉 柘
e8d0 栊 柩 枰 栌 柙 枵 柚 枳 柝 栀 柃 枸 柢 栎 柁 柽
e8e0 栲 栳 桠 桡 桎 桢 桄 桤 梃 栝 桕 桦 桁 桧 桀 栾
e8f0 桊 桉 栩 梵 梏 桴 桷 梓 桫 棂 楮 棼 椟 椠 棹

- 1328 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
e9a0 椤 棰 椋 椁 楗 棣 椐 楱 椹 楠 楂 楝 榄 楫 榀
e9b0 榘 楸 椴 槌 榇 榈 槎 榉 楦 楣 楹 榛 榧 榻 榫 榭
e9c0 槔 榱 槁 槊 槟 榕 槠 榍 槿 樯 槭 樗 樘 橥 槲 橄
e9d0 樾 檠 橐 橛 樵 檎 橹 樽 樨 橘 橼 檑 檐 檩 檗 檫
e9e0 猷 獒 殁 殂 殇 殄 殒 殓 殍 殚 殛 殡 殪 轫 轭 轱
e9f0 轲 轳 轵 轶 轸 轷 轹 轺 轼 轾 辁 辂 辄 辇 辋

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
eaa0 辍 辎 辏 辘 辚 軎 戋 戗 戛 戟 戢 戡 戥 戤 戬
eab0 臧 瓯 瓴 瓿 甏 甑 甓 攴 旮 旯 旰 昊 昙 杲 昃 昕
eac0 昀 炅 曷 昝 昴 昱 昶 昵 耆 晟 晔 晁 晏 晖 晡 晗
ead0 晷 暄 暌 暧 暝 暾 曛 曜 曦 曩 贲 贳 贶 贻 贽 赀
eae0 赅 赆 赈 赉 赇 赍 赕 赙 觇 觊 觋 觌 觎 觏 觐 觑
eaf0 牮 犟 牝 牦 牯 牾 牿 犄 犋 犍 犏 犒 挈 挲 掰

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
eba0 搿 擘 耄 毪 毳 毽 毵 毹 氅 氇 氆 氍 氕 氘 氙
ebb0 氚 氡 氩 氤 氪 氲 攵 敕 敫 牍 牒 牖 爰 虢 刖 肟
ebc0 肜 肓 肼 朊 肽 肱 肫 肭 肴 肷 胧 胨 胩 胪 胛 胂
ebd0 胄 胙 胍 胗 朐 胝 胫 胱 胴 胭 脍 脎 胲 胼 朕 脒
ebe0 豚 脶 脞 脬 脘 脲 腈 腌 腓 腴 腙 腚 腱 腠 腩 腼
ebf0 腽 腭 腧 塍 媵 膈 膂 膑 滕 膣 膪 臌 朦 臊 膻

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
eca0 臁 膦 欤 欷 欹 歃 歆 歙 飑 飒 飓 飕 飙 飚 殳
ecb0 彀 毂 觳 斐 齑 斓 於 旆 旄 旃 旌 旎 旒 旖 炀 炜
ecc0 炖 炝 炻 烀 炷 炫 炱 烨 烊 焐 焓 焖 焯 焱 煳 煜
ecd0 煨 煅 煲 煊 煸 煺 熘 熳 熵 熨 熠 燠 燔 燧 燹 爝
ece0 爨 灬 焘 煦 熹 戾 戽 扃 扈 扉 礻 祀 祆 祉 祛 祜
ecf0 祓 祚 祢 祗 祠 祯 祧 祺 禅 禊 禚 禧 禳 忑 忐

- 1329 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
eda0 怼 恝 恚 恧 恁 恙 恣 悫 愆 愍 慝 憩 憝 懋 懑
edb0 戆 肀 聿 沓 泶 淼 矶 矸 砀 砉 砗 砘 砑 斫 砭 砜
edc0 砝 砹 砺 砻 砟 砼 砥 砬 砣 砩 硎 硭 硖 硗 砦 硐
edd0 硇 硌 硪 碛 碓 碚 碇 碜 碡 碣 碲 碹 碥 磔 磙 磉
ede0 磬 磲 礅 磴 礓 礤 礞 礴 龛 黹 黻 黼 盱 眄 眍 盹
edf0 眇 眈 眚 眢 眙 眭 眦 眵 眸 睐 睑 睇 睃 睚 睨

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
eea0 睢 睥 睿 瞍 睽 瞀 瞌 瞑 瞟 瞠 瞰 瞵 瞽 町 畀
eeb0 畎 畋 畈 畛 畲 畹 疃 罘 罡 罟 詈 罨 罴 罱 罹 羁
eec0 罾 盍 盥 蠲 钅 钆 钇 钋 钊 钌 钍 钏 钐 钔 钗 钕
eed0 钚 钛 钜 钣 钤 钫 钪 钭 钬 钯 钰 钲 钴 钶 钷 钸
eee0 钹 钺 钼 钽 钿 铄 铈 铉 铊 铋 铌 铍 铎 铐 铑 铒
eef0 铕 铖 铗 铙 铘 铛 铞 铟 铠 铢 铤 铥 铧 铨 铪

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
efa0 铩 铫 铮 铯 铳 铴 铵 铷 铹 铼 铽 铿 锃 锂 锆
efb0 锇 锉 锊 锍 锎 锏 锒 锓 锔 锕 锖 锘 锛 锝 锞 锟
efc0 锢 锪 锫 锩 锬 锱 锲 锴 锶 锷 锸 锼 锾 锿 镂 锵
efd0 镄 镅 镆 镉 镌 镎 镏 镒 镓 镔 镖 镗 镘 镙 镛 镞
efe0 镟 镝 镡 镢 镤 镥 镦 镧 镨 镩 镪 镫 镬 镯 镱 镲
eff0 镳 锺 矧 矬 雉 秕 秭 秣 秫 稆 嵇 稃 稂 稞 稔

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f0a0 稹 稷 穑 黏 馥 穰 皈 皎 皓 皙 皤 瓞 瓠 甬 鸠
f0b0 鸢 鸨 鸩 鸪 鸫 鸬 鸲 鸱 鸶 鸸 鸷 鸹 鸺 鸾 鹁 鹂
f0c0 鹄 鹆 鹇 鹈 鹉 鹋 鹌 鹎 鹑 鹕 鹗 鹚 鹛 鹜 鹞 鹣
f0d0 鹦 鹧 鹨 鹩 鹪 鹫 鹬 鹱 鹭 鹳 疒 疔 疖 疠 疝 疬
f0e0 疣 疳 疴 疸 痄 疱 疰 痃 痂 痖 痍 痣 痨 痦 痤 痫
f0f0 痧 瘃 痱 痼 痿 瘐 瘀 瘅 瘌 瘗 瘊 瘥 瘘 瘕 瘙

- 1330 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f1a0 瘛 瘼 瘢 瘠 癀 瘭 瘰 瘿 瘵 癃 瘾 瘳 癍 癞 癔
f1b0 癜 癖 癫 癯 翊 竦 穸 穹 窀 窆 窈 窕 窦 窠 窬 窨
f1c0 窭 窳 衤 衩 衲 衽 衿 袂 袢 裆 袷 袼 裉 裢 裎 裣
f1d0 裥 裱 褚 裼 裨 裾 裰 褡 褙 褓 褛 褊 褴 褫 褶 襁
f1e0 襦 襻 疋 胥 皲 皴 矜 耒 耔 耖 耜 耠 耢 耥 耦 耧
f1f0 耩 耨 耱 耋 耵 聃 聆 聍 聒 聩 聱 覃 顸 颀 颃

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f2a0 颉 颌 颍 颏 颔 颚 颛 颞 颟 颡 颢 颥 颦 虍 虔
f2b0 虬 虮 虿 虺 虼 虻 蚨 蚍 蚋 蚬 蚝 蚧 蚣 蚪 蚓 蚩
f2c0 蚶 蛄 蚵 蛎 蚰 蚺 蚱 蚯 蛉 蛏 蚴 蛩 蛱 蛲 蛭 蛳
f2d0 蛐 蜓 蛞 蛴 蛟 蛘 蛑 蜃 蜇 蛸 蜈 蜊 蜍 蜉 蜣 蜻
f2e0 蜞 蜥 蜮 蜚 蜾 蝈 蜴 蜱 蜩 蜷 蜿 螂 蜢 蝽 蝾 蝻
f2f0 蝠 蝰 蝌 蝮 螋 蝓 蝣 蝼 蝤 蝙 蝥 螓 螯 螨 蟒

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f3a0 蟆 螈 螅 螭 螗 螃 螫 蟥 螬 螵 螳 蟋 蟓 螽 蟑
f3b0 蟀 蟊 蟛 蟪 蟠 蟮 蠖 蠓 蟾 蠊 蠛 蠡 蠹 蠼 缶 罂
f3c0 罄 罅 舐 竺 竽 笈 笃 笄 笕 笊 笫 笏 筇 笸 笪 笙
f3d0 笮 笱 笠 笥 笤 笳 笾 笞 筘 筚 筅 筵 筌 筝 筠 筮
f3e0 筻 筢 筲 筱 箐 箦 箧 箸 箬 箝 箨 箅 箪 箜 箢 箫
f3f0 箴 篑 篁 篌 篝 篚 篥 篦 篪 簌 篾 篼 簏 簖 簋

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f4a0 簟 簪 簦 簸 籁 籀 臾 舁 舂 舄 臬 衄 舡 舢 舣
f4b0 舭 舯 舨 舫 舸 舻 舳 舴 舾 艄 艉 艋 艏 艚 艟 艨
f4c0 衾 袅 袈 裘 裟 襞 羝 羟 羧 羯 羰 羲 籼 敉 粑 粝
f4d0 粜 粞 粢 粲 粼 粽 糁 糇 糌 糍 糈 糅 糗 糨 艮 暨
f4e0 羿 翎 翕 翥 翡 翦 翩 翮 翳 糸 絷 綦 綮 繇 纛 麸
f4f0 麴 赳 趄 趔 趑 趱 赧 赭 豇 豉 酊 酐 酎 酏 酤

- 1331 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f5a0 酢 酡 酰 酩 酯 酽 酾 酲 酴 酹 醌 醅 醐 醍 醑
f5b0 醢 醣 醪 醭 醮 醯 醵 醴 醺 豕 鹾 趸 跫 踅 蹙 蹩
f5c0 趵 趿 趼 趺 跄 跖 跗 跚 跞 跎 跏 跛 跆 跬 跷 跸
f5d0 跣 跹 跻 跤 踉 跽 踔 踝 踟 踬 踮 踣 踯 踺 蹀 踹
f5e0 踵 踽 踱 蹉 蹁 蹂 蹑 蹒 蹊 蹰 蹶 蹼 蹯 蹴 躅 躏
f5f0 躔 躐 躜 躞 豸 貂 貊 貅 貘 貔 斛 觖 觞 觚 觜

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f6a0 觥 觫 觯 訾 謦 靓 雩 雳 雯 霆 霁 霈 霏 霎 霪
f6b0 霭 霰 霾 龀 龃 龅 龆 龇 龈 龉 龊 龌 黾 鼋 鼍 隹
f6c0 隼 隽 雎 雒 瞿 雠 銎 銮 鋈 錾 鍪 鏊 鎏 鐾 鑫 鱿
f6d0 鲂 鲅 鲆 鲇 鲈 稣 鲋 鲎 鲐 鲑 鲒 鲔 鲕 鲚 鲛 鲞
f6e0 鲟 鲠 鲡 鲢 鲣 鲥 鲦 鲧 鲨 鲩 鲫 鲭 鲮 鲰 鲱 鲲
f6f0 鲳 鲴 鲵 鲶 鲷 鲺 鲻 鲼 鲽 鳄 鳅 鳆 鳇 鳊 鳋

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f7a0 鳌 鳍 鳎 鳏 鳐 鳓 鳔 鳕 鳗 鳘 鳙 鳜 鳝 鳟 鳢
f7b0 靼 鞅 鞑 鞒 鞔 鞯 鞫 鞣 鞲 鞴 骱 骰 骷 鹘 骶 骺
f7c0 骼 髁 髀 髅 髂 髋 髌 髑 魅 魃 魇 魉 魈 魍 魑 飨
f7d0 餍 餮 饕 饔 髟 髡 髦 髯 髫 髻 髭 髹 鬈 鬏 鬓 鬟
f7e0 鬣 麽 麾 縻 麂 麇 麈 麋 麒 鏖 麝 麟 黛 黜 黝 黠
f7f0 黟 黢 黩 黧 黥 黪 黯 鼢 鼬 鼯 鼹 鼷 鼽 鼾 齄

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f8a0
f8b0
f8c0
f8d0
f8e0
f8f0

- 1332 -
D.Simplified Chinese Character
B-64303EN-3/01 APPENDIX Code List

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
f9a0
f9b0
f9c0
f9d0
f9e0
f9f0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
faa0
fab0
fac0
fad0
fae0
faf0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
fba0
fbb0
fbc0
fbd0
fbe0
fbf0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
fca0
fcb0
fcc0
fcd0
fce0
fcf0

- 1333 -
D.Simplified Chinese Character
Code List APPENDIX B-64303EN-3/01

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
fda0
fdb0
fdc0
fdd0
fde0
fdf0

code +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
fea0
feb0
fec0
fed0
fee0
fef0

* A space is output for a blank.

- 1334 -
B-64303EN-3/01 APPENDIX E.Russian (Cyrillic) Character Code List

E Russian (Cyrillic) Character Code List


The Russian (Cyrillic) character code list is given below.
Russian character Cyrillic character code

А 0xC0
Б 0xC1
В 0xC2
Г 0xC3
Д 0xC4
Е 0xC5
Ё 0xA8
Ж 0xC6
З 0xC7
И 0xC8
Й 0xC9
К 0xCA
Л 0xCB
М 0xCC
Н 0xCD
О 0xCE
П 0xCF
Р 0xD0
С 0xD1
Т 0xD2
У 0xD3
Ф 0xD4
Х 0xD5
Ц 0xD6
Ч 0xD7
Ш 0xD8
Щ 0xD9
Ъ 0xDA
Ы 0xDB
Ь 0xDC
Э 0xDD
Ю 0xDE
Я 0xDF

- 1335 -
F.Turkish Character Code List APPENDIX B-64303EN-3/01

F Turkish Character Code List


The Turkish code list is given below.
Character Code Character Code Character Code Character Code Character Code
` 0x60 0x80 0xA0 À 0xC0 à 0xE0
a 0x61 0x81 ¡ 0xA1 Á 0xC1 á 0xE1
b 0x62 0x82 0xA2 Â 0xC2 â 0xE2
c 0x63 0x83 0xA3 Ã 0xC3 ã 0xE3
d 0x64 0x84 0xA4 Ä 0xC4 ä 0xE4
e 0x65 0x85 \ 0xA5 Å 0xC5 å 0xE5
f 0x66 0x86 0xA6 Æ 0xC6 æ 0xE6
g 0x67 0x87 0xA7 Ç 0xC7 ç 0xE7
h 0x68 0x88 0xA8 È 0xC8 è 0xE8
i 0x69 0x89 0xA9 É 0xC9 é 0xE9
j 0x6A Š 0x8A 0xAA Ê 0xCA ê 0xEA
k 0x6B < 0x8B 0xAB Ë 0xCB ë 0xEB
l 0x6C Œ 0x8C 0xAC Ì 0xCC ì 0xEC
m 0x6D 0x8D 0xAD Í 0xCD í 0xED
n 0x6E 0x8E 0xAE Î 0xCE î 0xEE
o 0x6F 0x8F 0xAF Ï 0xCF ï 0xEF
p 0x70 0x90 0xB0 Ğ 0xD0 ğ 0xF0
q 0x71 0x91 0xB1 Ñ 0xD1 ñ 0xF1
r 0x72 0x92 0xB2 Ò 0xD2 ò 0xF2
s 0x73 0x93 0xB3 Ó 0xD3 ó 0xF3
t 0x74 0x94 0xB4 Ô 0xD4 ô 0xF4
u 0x75 0x95 µ 0xB5 Õ 0xD5 õ 0xF5
v 0x76 0x96 0xB6 Ö 0xD6 ö 0xF6
w 0x77 0x97 0xB7 x 0xD7 ÷ 0xF7
x 0x78 ~ 0x98 0xB8 Ø 0xD8 ø 0xF8
y 0x79 0x99 0xB9 Ù 0xD9 ù 0xF9
z 0x7A š 0x9A 0xBA Ú 0xDA ú 0xFA
{ 0x7B > 0x9B 0xBB Û 0xDB û 0xFB
: 0x7C œ 0x9C 0xBC Ü 0xDC ü 0xFC
} 0x7D 0x9D 0xBD İ 0xDD ı 0xFD
0x7E 0x9E 0xBE Ş 0xDE ş 0xFE
0x7F Ÿ 0x9F ¿ 0xBF ß 0xDF ÿ 0xFF
NOTE) A space is output for a blank.

- 1336 -
B-64303EN-3/01 INDEX

INDEX
Display control escape sequences ...............................1089
<Number>
Display language switching ........................................1167
2-byte characters ......................................................... 1094
Display of Simplified Chinese messages.....................1173
<A> Display/acquisition of Russian messages ....................1181
Additional Information on C Compiler Installation .... 1256 Display/acquisition of Turkish messages ....................1192
ANSI C standard library............................................. 19,69 Displayable characters ................................................1093
ANSI C Standard library ................................................. 38 Dynamic language switching ......................................1167
Application of C Language Executor to machines...... 1245
<E>
Application program .........................................................9
Eight-level data protection ..........................................1202
Application program development environment ............. 14
Example of use............................................................1176
Application programming ........................................... 1153
Examples of use ..........................................................1185
Available functions for the window task..................... 1132
Explanation ...1167,1173,1182,1193,1197,1203,1217,1232
<C>
<F>
C language data file series and edition display ........... 1231
FANUC character code list (for 10.4-inch color LCD)1302
C Language Executor........................................................7
FANUC character code list (for 8.4-inch color LCD) .1293
C Language Executor Function................................... 1108
FCA Library ................................................................1027
C Language Library ..........................................................8
Feature...............................................................................4
C Language Library function list .................................... 19
File Operation Library...................................................968
Character Code List..................................................... 1281
File system ..................................................................1115
Checking operation restart after program editing........ 1197
F-ROM Library ...........................................................1061
CNC/PMC window library.................................. 24,50,306
FTP transfer.................................................................1216
cnc_chglang function reference .................................. 1168
Function overview..................................... 1173,1182,1193
Composition of development system .............................. 15
Function reference..................................... 1065,1141,1154
Conditions for displaying the series and editions of user
Function Reference
data files on the system configuration screen.............. 1232
.............74,212,278,314,828,865,970,983,1012,1032,1080
Conforming CNC screen display function .................. 1134
Function references ................................... 1198,1204,1218
CRT display control characters ................................... 1089
Function References........................................................67
CRT operation library ................................................... 861
Customization procedure............................................. 1265 <G>
Graphic library .................................................... 22,47,208
<D>
Dat2mem utility manual.............................................. 1123 <H>
Data access between tasks........................................... 1113 Half-size character code list
Data ID list .................................................................. 1214 (for 10.4-inch color LCD) ........................................... 1288
DEFINITION OF WARNING, CAUTION, AND Half-size character code list
NOTE............................................................................. s-1 (for 8.4-inch color LCD) ............................................. 1282
Describing 2-byte characters in source-codes ................. 65 High-Level Task..........................................................1146
Detailed status of communication error ...................... 1229 High-Level task execution management data..............1156
Development procedure .................................................. 17 How do application program run on each equipment..1135
Diagnosis data ............................................................. 1172 How to make application program ......................... 62,1133
Difference of each task class....................................... 1111
<I>
Display code for single byte characters....................... 1103
Installing the C compiler .............................................1257

i-1
INDEX B-64303EN-3/01

Installing the C Language Library .............................. 1263 Overview of library ..................................................... 1077
Installing the linker ..................................................... 1263
<P>
<J> Parameter setting on CNC...........................................1119
Japanese(Multi-byte character) functions........................ 61 Parameters ................................................................... 1171
Power-on procedure ....................................................1118
<K>
PREFACE ......................................................................p-1
Kanji character code.................................................... 1107
Programming Technique .............................................1241
Key code table............................................................... 841
Key operation at power on .......................................... 1118 <R>
Keycode ...................................................................... 1086 Reading extension MDI keys ........................................843
Keycode of special keys on MDI panel....................... 1087 Reference items...........................................................1230
Keycode, screen control code...................................... 1086 Remarks ..........................................................................66
Keycode, screen control code and Displayable Restrictions..................................................................1240
characters .................................................................... 1085 Restrictions for Use with MANUAL GUIDE i ...........1161
Restrictions for Use with TURN MATE i...................1166
<L>
Restrictions on specification .......................................1137
Library outline .............................. 824,975,996,1027,1061
Return values of data window functions .......................313
List of function.............................................................. 982
Russian (Cyrillic) Character Code List .......................1335
List of functions .......................................................... 1064
Russian display/get function .......................................1184
List of Functions ........................................... 37,1031,1080
Russian mode setting function (crt_setmode function)1183
Lists of C Language Executor original graphic
functions........................................................................ 277 <S>
Lists of Functions................ 69,204,306,827,863,969,1011 Screen display after power-on............................ 1159,1164
Lists of MS-C compatible functions.............................. 210 Serial Library ................................................................975
Series and edition information file format...................1233
<M>
Simplified Chinese Character Code List .....................1310
Making application program ....................................... 1139
Simplified Chinese display function ...........................1175
MDI operation library ................................................... 824
Simplified Chinese mode setting function
Method of specifying a series and edition information
(crt_setmode function) ................................................ 1174
file ............................................................................... 1236
Single byte characters .................................................1093
MS-C extended C standard library...................... 21,42,204
Special files .....................................................................64
MS-C graphic function compatibility list...................... 275
Specification................................................................1147
Multitasking ................................................................ 1109
Specification of the memory card on the personal
<N> computer......................................................................1143
Notes ........................................................................... 1133 Supported display device ..............................................861
Notes on application program creation........................ 1144 System components...........................................................6
System configuration screen display ...........................1238
<O>
Obtaining and installing other tools ............................ 1264 <T>
Other libraries ............................................................ 30,56 Task classes.................................................................1109
Others.......................................................................... 1145 Task execution rule .....................................................1150
Outline of processing .................................................. 1197 Task Management .......................................................1114
Overview of High-Level Task..................................... 1146 Task management library ..............................................996
Overview of installing the C Language Library and Task switching ............................................................1112
creating an application program ...................................... 63

i-2
B-64303EN-3/01 INDEX

The hardwares of CNC which are used in C Language


Executor .......................................................................... 12
Touch-panel Library ................................................... 1077
Troubleshooting If a System Alarm Occurs in the C
Language Executor Application Program ................... 1249
Turkish Character Code List ....................................... 1336
Turkish display/get function........................................ 1195
Turkish mode setting function (crt_setmode function) 1194

<U>
Usable languages......................................................... 1167
Usage of graphic functions............................................ 208
Usage of the window task ........................................... 1130
Use with MANUAL GUIDE i..................................... 1159
Use with TURN MATE i ............................................ 1164
User data file that enables series and edition
information to be displayed......................................... 1237
Using compiler libraries .................................................. 65
Using Memory Card...................................................... 968
Using the drive on the personal computer ................... 1143

<V>
Variables of type 'int' ...................................................... 64
Various techniques ...................................................... 1242

<W>
Wind River Compiler C/C++ installation ....................... 63
Window task ............................................................... 1129
Window task's execution............................................. 1130

i-3
Revision Record
FANUC Series 0i-MODEL D C Language Executor PROGRAMMIG MANUAL (B-64303EN-3)

01 Jun., 2008

Edition Date Contents Edition Date Contents

You might also like