Sunteți pe pagina 1din 447

GE Fanuc Automation

PowerMotion™ Products

Power Mate H Motion Controller


(High Speed Serial Bus Function)

Operator's Manual

GFZ-62684EN-1/01 January 1997


(with Supplementary Information)
GFL-001
Warnings, Cautions, and Notes
as Used in this Publication

Warning
Warning notices are used in this publication to emphasize that hazardous voltages, currents,
temperatures, or other conditions that could cause personal injury exist in this equipment or
may be associated with its use.
In situations where inattention could cause either personal injury or damage to equipment, a
Warning notice is used.

Caution
Caution notices are used where equipment might be damaged if care is not taken.

Note
Notes merely call attention to information that is especially significant to understanding and
operating the equipment.

This document is based on information available at the time of its publication. While efforts
have been made to be accurate, the information contained herein does not purport to cover all
details or variations in hardware or software, nor to provide for every possible contingency in
connection with installation, operation, or maintenance. Features may be described herein
which are not present in all hardware and software systems. GE Fanuc Automation assumes
no obligation of notice to holders of this document with respect to changes subsequently made.

GE Fanuc Automation makes no representation or warranty, expressed, implied, or statutory


with respect to, and assumes no responsibility for the accuracy, completeness, sufficiency, or
usefulness of the information contained herein. No warranties of merchantability or fitness for
purpose shall apply.

PowerMotion is a trademark of GE Fanuc Automation North America, Inc.

©Copyright 1997-1998 GE Fanuc Automation North America, Inc.


All Rights Reserved.
SAFETY PRECAUTIONS

This section describes the safety precautions related to the use of CNC units. It is essential that these precautions
be observed by users to ensure the safe operation of machines equipped with a CNC unit (all descriptions in this
section assume this configuration). Note that some precautions are related only to specific functions, and thus
may not be applicable to certain CNC units.
Users must also observe the safety precautions related to the machine, as described in the relevant manual supplied
by the machine tool builder. Before attempting to operate the machine or create a program to control the operation
of the machine, the operator must become fully familiar with the contents of this manual and relevant manual
supplied by the machine tool builder.

Contents

1. DEFINITION OF WARNING, CAUTION, AND NOTE . . . . . . . . . . . . . . . . . . . . . . . . s–2

2. GENERAL WARNINGS AND CAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s–3

3. WARNINGS AND CAUTIONS RELATED TO PROGRAMMING . . . . . . . . . . . . . . s–5

4. WARNINGS AND CAUTIONS RELATED TO HANDLING . . . . . . . . . . . . . . . . . . . . s–7

5. WARNINGS RELATED TO DAILY MAINTENANCE . . . . . . . . . . . . . . . . . . . . . . . . . s–9

s–1
SAFETY PRECAUTIONS B–62684EN–1/01

1 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 damage 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–2
B–62684EN–1/01 SAFETY PRECAUTIONS

2 GENERAL WARNINGS AND CAUTIONS

WARNING

1. Never attempt to machine a workpiece without first checking the operation of the machine.
Before starting a production run, ensure that the machine is operating correctly by performing
a trial run using, for example, the single block, feedrate override, or machine lock function or
by operating the machine with neither a tool nor workpiece mounted. Failure to confirm the
correct operation of the machine may result in the machine behaving unexpectedly, possibly
causing damage to the workpiece and/or machine itself, or injury to the user.

2. Before operating the machine, thoroughly check the entered data.


Operating the machine with incorrectly specified data may result in the machine behaving
unexpectedly, possibly causing damage to the workpiece and/or machine itself, or injury to the
user.

3. Ensure that the specified feedrate is appropriate for the intended operation. Generally, for each
machine, there is a maximum allowable feedrate. The appropriate feedrate varies with the
intended operation. Refer to the manual provided with the machine to determine the maximum
allowable feedrate. If a machine is run at other than the correct speed, it may behave
unexpectedly, possibly causing damage to the workpiece and/or machine itself, or injury to the
user.

4. When using a tool compensation function, thoroughly check the direction and amount of
compensation.
Operating the machine with incorrectly specified data may result in the machine behaving
unexpectedly, possibly causing damage to the workpiece and/or machine itself, or injury to the
user.

5. The parameters for the CNC and PMC are factory–set. Usually, there is not need to change them.
When, however, there is not alternative other than to change a parameter, ensure that you fully
understand the function of the parameter before making any change.
Failure to set a parameter correctly may result in the machine behaving unexpectedly, possibly
causing damage to the workpiece and/or machine itself, or injury to the user.

6. Immediately after switching on the power, do not touch any of the keys on the MDI panel until
the position display or alarm screen appears on the CNC unit.
Some of the keys on the MDI panel are dedicated to maintenance or other special operations.
Pressing any of these keys may place the CNC unit in other than its normal state. Starting the
machine in this state may cause it to behave unexpectedly.

7. The operator’s manual and programming manual supplied with a CNC unit provide an overall
description of the machine’s functions, including any optional functions. Note that the optional
functions will vary from one machine model to another. Therefore, some functions described
in the manuals may not actually be available for a particular model. Check the specification of
the machine if in doubt.

s–3
SAFETY PRECAUTIONS B–62684EN–1/01

WARNING

8. Some functions may have been implemented at the request of the machine–tool builder. When
using such functions, refer to the manual supplied by the machine–tool builder for details of their
use and any related cautions.

NOTE

Programs, parameters, and macro variables are stored in nonvolatile memory in the CNC unit.
Usually, they are retained even if the power is turned off. Such data may be deleted inadvertently,
however, or it may prove necessary to delete all data from nonvolatile memory as part of error
recovery.
To guard against the occurrence of the above, and assure quick restoration of deleted data, backup
all vital data, and keep the backup copy in a safe place.

s–4
B–62684EN–1/01 SAFETY PRECAUTIONS

3 WARNINGS AND CAUTIONS RELATED TO


PROGRAMMING

This section covers the major safety precautions related to programming. Before attempting to
perform programming, read the supplied operator’s manual and programming manual carefully
such that you are fully familiar with their contents.

WARNING

1. Coordinate system setting


If a coordinate system is established incorrectly, the machine may behave unexpectedly as a
result of the program issuing an otherwise valid move command.
Such an unexpected operation may damage the tool, the machine itself, the workpiece, or cause
injury to the user.
2. Positioning by nonlinear interpolation
When performing positioning by nonlinear interpolation (positioning by nonlinear movement
between the start and end points), the tool path must be carefully confirmed before performing
programming.
Positioning involves rapid traverse. If the tool collides with the workpiece, it may damage the
tool, the machine itself, the workpiece, or cause injury to the user.
3. Function involving a rotation axis
When programming polar coordinate interpolation or normal–direction (perpendicular) control,
pay careful attention to the speed of the rotation axis. Incorrect programming may result in the
rotation axis speed becoming excessively high, such that centrifugal force causes the chuck to
lose its grip on the workpiece if the latter is not mounted securely.
Such mishap is likely to damage the tool, the machine itself, the workpiece, or cause injury to
the user.
4. Inch/metric conversion
Switching between inch and metric inputs does not convert the measurement units of data such
as the workpiece origin offset, parameter, and current position. Before starting the machine,
therefore, determine which measurement units are being used. Attempting to perform an
operation with invalid data specified may damage the tool, the machine itself, the workpiece, or
cause injury to the user.
5. Constant surface speed control
When an axis subject to constant surface speed control approaches the origin of the workpiece
coordinate system, the spindle speed may become excessively high. Therefore, it is necessary
to specify a maximum allowable speed. Specifying the maximum allowable speed incorrectly
may damage the tool, the machine itself, the workpiece, or cause injury to the user.

s–5
SAFETY PRECAUTIONS B–62684EN–1/01

WARNING

6. Stroke check
After switching on the power, perform a manual reference position return as required. Stroke
check is not possible before manual reference position return is performed. Note that when stroke
check is disabled, an alarm is not issued even if a stroke limit is exceeded, possibly damaging
the tool, the machine itself, the workpiece, or causing injury to the user.
7. Tool post interference check
A tool post interference check is performed based on the tool data specified during automatic
operation. If the tool specification does not match the tool actually being used, the interference
check cannot be made correctly, possibly damaging the tool or the machine itself, or causing
injury to the user.
After switching on the power, or after selecting a tool post manually, always start automatic
operation and specify the tool number of the tool to be used.
8. Absolute/incremental mode
If a program created with absolute values is run in incremental mode, or vice versa, the machine
may behave unexpectedly.
9. Plane selection
If an incorrect plane is specified for circular interpolation, helical interpolation, or a canned cycle,
the machine may behave unexpectedly. Refer to the descriptions of the respective functions for
details.
10. Torque limit skip
Before attempting a torque limit skip, apply the torque limit. If a torque limit skip is specified
without the torque limit actually being applied, a move command will be executed without
performing a skip.
11. Programmable mirror image
Note that programmed operations vary considerably when a programmable mirror image is
enabled.
12. Compensation function
If a command based on the machine coordinate system or a reference position return command
is issued in compensation function mode, compensation is temporarily canceled, resulting in the
unexpected behavior of the machine.
Before issuing any of the above commands, therefore, always cancel compensation function
mode.

s–6
B–62684EN–1/01 SAFETY PRECAUTIONS

4 WARNINGS AND CAUTIONS RELATED TO HANDLING

This section presents safety precautions related to the handling of machine tools. Before attempting
to operate your machine, read the supplied operator’s manual and programming manual carefully,
such that you are fully familiar with their contents.

WARNING

1. Manual operation
When operating the machine manually, determine the current position of the tool and workpiece,
and ensure that the movement axis, direction, and feedrate have been specified correctly.
Incorrect operation of the machine may damage the tool, the machine itself, the workpiece, or
cause injury to the operator.
2. Manual reference position return
After switching on the power, perform manual reference position return as required. If the
machine is operated without first performing manual reference position return, it may behave
unexpectedly. Stroke check is not possible before manual reference position return is performed.
An unexpected operation of the machine may damage the tool, the machine itself, the workpiece,
or cause injury to the user.
3. Manual numeric command
When issuing a manual numeric command, determine the current position of the tool and
workpiece, and ensure that the movement axis, direction, and command have been specified
correctly, and that the entered values are valid.
Attempting to operate the machine with an invalid command specified may damage the tool, the
machine itself, the workpiece, or cause injury to the operator.
4. Manual handle feed
In manual handle feed, rotating the handle with a large scale factor, such as 100, applied causes
the tool and table to move rapidly. Careless handling may damage the tool and/or machine, or
cause injury to the user.
5. Disabled override
If override is disabled (according to the specification in a macro variable) during threading, rigid
tapping, or other tapping, the speed cannot be predicted, possibly damaging the tool, the machine
itself, the workpiece, or causing injury to the operator.
6. Origin/preset operation
Basically, never attempt an origin/preset operation when the machine is operating under the
control of a program. Otherwise, the machine may behave unexpectedly, possibly damaging the
tool, the machine itself, the tool, or causing injury to the user.

s–7
SAFETY PRECAUTIONS B–62684EN–1/01

WARNING

7. Workpiece coordinate system shift

Manual intervention, machine lock, or mirror imaging may shift the workpiece coordinate
system. Before attempting to operate the machine under the control of a program, confirm the
coordinate system carefully.
If the machine is operated under the control of a program without making allowances for any shift
in the workpiece coordinate system, the machine may behave unexpectedly, possibly damaging
the tool, the machine itself, the workpiece, or causing injury to the operator.

8. Software operator’s panel and menu switches

Using the software operator’s panel and menu switches, in combination with the MDI panel, it
is possible to specify operations not supported by the machine operator’s panel, such as mode
change, override value change, and jog feed commands.
Note, however, that if the MDI panel keys are operated inadvertently, the machine may behave
unexpectedly, possibly damaging the tool, the machine itself, the workpiece, or causing injury
to the user.

9. Manual intervention

If manual intervention is performed during programmed operation of the machine, the tool path
may vary when the machine is restarted. Before restarting the machine after manual intervention,
therefore, confirm the settings of the manual absolute switches, parameters, and
absolute/incremental command mode.

10. Feed hold, override, and single block

The feed hold, feedrate override, and single block functions can be disabled using custom macro
system variable #3004. Be careful when operating the machine in this case.

11. Dry run

Usually, a dry run is used to confirm the operation of the machine. During a dry run, the machine
operates at dry run speed, which differs from the corresponding programmed feedrate. Note that
the dry run speed may sometimes be higher than the programmed feed rate.

12. Cutter and tool nose radius compensation in MDI mode

Pay careful attention to a tool path specified by a command in MDI mode, because cutter or tool
nose radius compensation is not applied. When a command is entered from the MDI to interrupt
in automatic operation in cutter or tool nose radius compensation mode, pay particular attention
to the tool path when automatic operation is subsequently resumed. Refer to the descriptions of
the corresponding functions for details.

13. Program editing

If the machine is stopped, after which the machining program is edited (modification, insertion,
or deletion), the machine may behave unexpectedly if machining is resumed under the control
of that program. Basically, do not modify, insert, or delete commands from a machining program
while it is in use.

s–8
B–62684EN–1/01 SAFETY PRECAUTIONS

5 WARNINGS RELATED TO DAILY MAINTENANCE

WARNING

1. Memory backup battery replacement


When replacing the memory backup batteries, keep the power to the machine (CNC) turned on,
and apply an emergency stop to the machine. Because this work is performed with the power
on and the cabinet open, only those personnel who have received approved safety and
maintenance training may perform this work.
When replacing the batteries, be careful not to touch the high–voltage circuits (marked and
fitted with an insulating cover).
Touching the uncovered high–voltage circuits presents an extremely dangerous electric shock
hazard.

NOTE

The CNC uses batteries to preserve the contents of its memory, because it must retain data such as
programs, offsets, and parameters even while external power is not applied.
If the battery voltage drops, a low battery voltage alarm is displayed on the machine operator’s panel
or CRT screen.
When a low battery voltage alarm is displayed, replace the batteries within a week. Otherwise, the
contents of the CNC’s memory will be lost.
Refer to the maintenance section of the operator’s manual or programming manual for details of the
battery replacement procedure.

s–9
SAFETY PRECAUTIONS B–62684EN–1/01

WARNING

2. Absolute pulse coder battery replacement


When replacing the memory backup batteries, keep the power to the machine (CNC) turned on,
and apply an emergency stop to the machine. Because this work is performed with the power
on and the cabinet open, only those personnel who have received approved safety and
maintenance training may perform this work.
When replacing the batteries, be careful not to touch the high–voltage circuits (marked and
fitted with an insulating cover).
Touching the uncovered high–voltage circuits presents an extremely dangerous electric shock
hazard.

NOTE

The absolute pulse coder uses batteries to preserve its absolute position.
If the battery voltage drops, a low battery voltage alarm is displayed on the machine operator’s panel
or CRT screen.
When a low battery voltage alarm is displayed, replace the batteries within a week. Otherwise, the
absolute position data held by the pulse coder will be lost.
Refer to the maintenance section of the operator’s manual or programming manual for details of the
battery replacement procedure.

s–10
B–62684EN–1/01 SAFETY PRECAUTIONS

WARNING

3. Fuse replacement
For some units, the chapter covering daily maintenance in the operator’s manual or programming
manual describes the fuse replacement procedure.
Before replacing a blown fuse, however, it is necessary to locate and remove the cause of the
blown fuse.
For this reason, only those personnel who have received approved safety and maintenance
training may perform this work.
When replacing a fuse with the cabinet open, be careful not to touch the high–voltage circuits
(marked and fitted with an insulating cover).
Touching an uncovered high–voltage circuit presents an extremely dangerous electric shock
hazard.

s–11
B–62684EN–1/01 INTRODUCTION

INTRODUCTION

This manual describes the specification of FANUC High Speed Serial


Bus (HSSB) function of the following FANUC Power Motion controller.

Use this manual together with the operator’s manual, the connecting and
maintenance manual for High Speed Serial Bus.

The application model is as follows with Power Mate of this manual if


there is no refusal.
Application model

Product Name Abbreviation

FANUC Power Mate–MODEL H Power Mate–H Power Mate

 High Speed Serial Bus requires the IBM PC compatible personal


computer, which must be purchased and maintained by the customer
(Machine Tool Builder or End User).
 When a personal computer on the market is chosen, it must be the
IBM–PC or the full compatible computer.
 Every personal computer should be operated by MS–DOS ( V6.2 or
later) and Windows3.1. The copyright of these operating system are
owned by Microsoft Corporation.
 FANUC LTD. has the copyright of the driver to use with High Speed
Serial Bus.
 FANUC LTD. has the copyright of the API library software and this
manual.
 The main body and the manual of the above–mentioned software are
used without permission and cannot be copied.
Microsoft, MS–DOS, Windows are the registered trademarks of
Microsoft Corporation.
Visual C++, Visual Basic are the trademark of Microsoft Corporation.
IBM is a registered trademark of IBM corporation, U.S.A.
Company name and product name mentioned in this manual are
(registered) trademarks of each company

p–1
B–62684EN–1/01 Table of Contents
SAFETY PRECAUTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s–1

INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . p–1

I. GENERAL

1. GENERAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 1

2. CONFIGURATION OF HARDWARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 3
2.1 NOTICE ABOUT THE SELECTION OF THE PERSONAL COMPUTER . . . . . . . . . . . . . . . . . . 1 – 4
2.2 ENVIRONMENTAL REQUIREMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 4

3. CONFIGURATION OF SOFTWARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 5
3.1 SOFTWARE OF HIGH SPEED SERIAL BUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 6
3.2 PRODUCT DISTRIBUTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 6
3.3 SPECIFICATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 7
3.4 HIGH SPEED SERIAL BUS DRIVER SOFTWARE FOR WINDOWS 3.1 . . . . . . . . . . . . . . . . . . 1 – 7
3.5 API LIBRARY FOR HSSB (FOR WINDOWS 3.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 8
3.6 PACKAGE SOFTWARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 13
3.6.1 Boot Application Software (for Windows 3.1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 13
3.6.2 Maintenance Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 13
3.6.3 Basic Operation Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 13

4. SET UP POWER MATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 – 14

II. API LIBRARY

1. GENERAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 1

2. GENERAL DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 2

3. FUNCTION LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 4
3.1 RELATED TO THE COMMUNICATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 8
3.2 RELATED TO THE CONTROL AXES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 12
3.3 RELATED TO PROGRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 34
3.4 RELATED TO NC DATA FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 69
3.5 RELATED TO OPERATION HISTORY DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 115
3.6 RELATED TO THE AXIS MOVEMENT CONTROL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 131
3.7 OTHERS FUNCTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 150
3.8 RELATED TO THE PMC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 – 196

c–1
TABLE OF CONTENTS B–62684EN–1/01

III. BOOT APPLICATION SOFTWARE


1. FUNCTION OUTLINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 1

2. INSTALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 2

3. OPERATION EXPLANATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 3

4. OPERATION SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 4
4.1 MACHINE SELECT SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 5
4.2 PROCESSING SELECT SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 6
4.3 BOOT PROCESSING SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 8
4.4 IPL PROCESSING SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 9
4.5 SYSTEM ALARM SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 11
4.6 HSSB BOARD TEST SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 12
4.7 HSSB REGISTERS SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 13
4.8 CONTENT C–RAM SCREEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 – 15

c–2
I. GENERAL
B–62684EN–1/01 GENERAL 1. GENERAL

1 

“High Speed Serial Bus” connects the FANUC Power Mate with the
commercial personal computer via an optical fiber cable, so that the
personal computer can handles the following functions.
1) Related to the communication
initialize, communication establishment, etc
2) Reading of data related to controlled axes
These data include the absolute position, relative position, machine
position, remaining travel distance, actual feedrate, and so forth.
3) Operations related to CNC program
Operations include upload/download, search, and deletion of NC
programs, read NC program directory.
4) Reading/writing of CNC file data
These data include tool offset data, parameters, settings, custom macro
variables, and P–code macro variables.
5) Reading of operation history data
These data include operation history data and alarm history data.
6) Related to the axis movement control
These command include reference point return, positioning
absolute/incremental, dwell, etc.
7) Reading of other data
These data include continuous–state data, diagnostic data, alarm
information, and operator messages.
8) Reading/writing of data related to PMC
These data include addresses G, F, Y, X, A, R, T, C, and D.

Features
 Can use IBM PC compatible personal computer as a operation unit of
Power Mate.
 Various kinds of personal computers, with variety of processors, video
display type, hard disk size, extension slots, an so on,,, which match
the needs of the customer can be used.
 By using multiple HSSB boards, Power Mate corresponding to the
number of the boards can be controlled.
Up to four Power Mate can be connected with one personal computer.
However, the number of axes which can be controlled changes
according to the performance of the personal–computer and the
content of the application software.
 Power Mate can work alone, even if a personal computer is not
connected with Power Mate.
 Connecting or disconnecting the personal computer from Power Mate
can be done while the power of Power Mate is on.

1–1
1. GENERAL GENERAL B–62684EN–1/01

 MS–DOS(V6.2 or later) and Windows3.1 is used as the operating


system. Enjoy the various application software for these operating
systems on the personal computer with High Speed Serial Bus.
 Personal computer and Power Mate system are connected via an
optical fiber cable. HSSB adapter and HSSB interface board provided
by FANUC.
This ensures the quick data communication between personal
computer and Power Mate.
 The interface between Power Mate and personal computer is
compatible with MMC–IV.
 Ready–made package software enables the basic operation, such as
displaying or entering data to Power Mate, from the personal
computer.

1–2
B–62684EN–1/01 GENERAL 2. CONFIGURATION OF HARDWARE

2 CONFIGURATION OF HARDWARE

Power Mate

Control of CNC
Control of PMC

HSSB Module

When the HSSB module is used, neither a CRT module nor a


HSSB module touch panel connection module is available. So CRT, PDP,
LCD, detachable LCD, Touch panel and Handy operator’s
panel are not available with HSSB.

HSSB control

COMMON RAM
The total edition of Power Mate–H base PCB needs 06F or later.

HSSB adapter Optical fiber cable (max 50meter)

(DPL/MDI)

High Speed Serial Bus

IBM–PC Compatible
personal Computer
Personal HSSB Control
Computer
Function

use of I/O map

ISA BUS

1–3
2. CONFIGURATION OF HARDWARE GENERAL B–62684EN–1/01

2.1 (1) FANUC requires the customer to purchase and maintain the personal
computer itself.
NOTICE ABOUT THE
(2) Every personal computer should be operated by MS–DOS (V6.2 or
SELECTION OF THE later) and Windows3.1.
PERSONAL (3) The interface board for the personal computer is based on the ISA
COMPUTER specification and it can be used in IBM–PC/AT and full compatible
computer.
(Need 386 processor or above. 286 cannot manage HSSB.)
(4) The number of the ISA–BUS expansion slot must be beyond the
number of Power Mate’s and the number of other ISA boards in total.
(5) The interface board for the personal computer uses the I/O space
instead of the ISA memory space. You should arrange the I/O address
with other ISA extended board.
(6) Please examine the connection test including the communication
between the personal computer and Power Mate controller
sufficiently.

NOTE
FANUC is not responsible for the proper working of the
personal computer itself and any troubles caused by using
the personal computer.

2.2 Please use the interface board under the environmental conditions
required for each systems, that is Power Mate control unit or personal
ENVIRONMENTAL computer or Intelligent Terminal, in which the interface boards are
REQUIREMENTS installed.

1–4
B–62684EN–1/01 GENERAL 3. CONFIGURATION OF SOFTWARE

3 CONFIGURATION OF SOFTWARE

Power Mate

Power Mate Control software *1

Direct Command software *2

HSSB Control software *3

HSSB (optical fiber cable)


Personal Computer

MS–DOS and Windows3.1 OS

HSSB Driver software for Windows *4

API Library for Windows *4

Application software for Windows

BOOT/IPL Maintenance,*4 User’s


application Basic *5 Application
software Operation Software
*4 Package

*1 This software can be used by purchasing a Power Mate control device.


*2 This software is provided when a direct command function is
purchased with the Power Mate control unit.
This optional function must be ordered for every Power Mate control
unit.
*3 This software can be used if a HSSB module for Power Mate is ordered
and attached to Power Mate. Following(*4) software is necessary to
connect with the personal computer.
*4 When a customer (Machine Tool Builder or End User) purchases this
software, it can be used with all Power Mate that the above software
(*1,*2,*3) runs. But, when a Maintenance Operation Package is run
or the application software which API Library was used for is run, the
option of direct command function is necessary for every Power Mate
that is connected with the personal computer.
*5 It can be used when Basic Operation Package software is purchased.
This package software cannot run alone.
Use this Basic operation package software with the Maintenance
Operation Package software of the above(*4).
A using condition is equal to the above *4.

NOTE
1 When High Speed Serial Bus is used, C language Executor
function cannot be used at the same time.
2 When you use a Macro Library function, be sure to use the
version of the software which supports the HSSB function.

1–5
3. CONFIGURATION OF SOFTWARE GENERAL B–62684EN–1/01

3.1 The following special software for High Speed Serial Bus is supplied.
SOFTWARE OF HIGH  HSSB Driver software for Windows3.1
Data Input and output is carried out by connecting Power Mate with
SPEED SERIAL BUS a personal computer through HSSB.
At maximum, four Power Mate can be connected by this software.
 API Library for Windows3.1
This is a library of functions to execute data input/output operation and
command to the Power Mate from the application software on the
personal computer.
 Package Software
The following software is available.
1. BOOT Application Software
2. Maintenance Operation Package Software
3. Basic Operation Package Software

3.2 We distribute the software in 3.5″ 1.44MB formatted floppy diskettes.


PRODUCT  Driver and Library Diskette
This distribution includes the Driver which serve data communication
DISTRIBUTION between Power Mate/PMC and personal computer, API Library which
provides the information exchange of the internal data of Power
Mate/PMC.
Also, “BOOT Application Software” and “Maintenance Package” to
provide the maintenance screens is included.
 Basic Operation Package
This distribution is a Basic Operation Package.
You can do the Power Mate/PMC operation from the personal
computer.

1–6
B–62684EN–1/01 GENERAL 3. CONFIGURATION OF SOFTWARE

3.3
SPECIFICATIONS Item Specifications Remarks

OS MS–DOS Ver.6.2 or later Purchase from the market.


Windows Ver.3.1 FANUC cannot provide.

Power Mate Direct Command function A software option should be spe-


Option cified at the time of the purchase
(A02B–0211–J834) of Power Mate.

Driver High Speed Serial Bus Serves the data communication


Driver for Windows3.1 between Power Mate/PMC and
(A08B–9001–J721) PC.

Library API Library for Windows3.1 Provides the Various data ex-
change between Power Mate/
(A08B–9001–J721) PMC and axis moving command

Package BOOT Application The exchange of the system


Software Software for Windows3.1 software and the backup and re-
store of the S–RAM data can be
done.
The clearing the various files of
(A08B–9001–J721) Power Mate can be done.

Maintenance Operation Screens for Power Mate/PMC


Package for Windows3.1 maintenance.
(A08B–9001–J721)

Basic Operation Package Screens for Power Mate opera-


for Windows3.1 tion.
(A08B–9001–J722)

Development Microsoft C/C++ 7.0 Microsoft Corp.


Tools Visual C++ 1.0 or later Microsoft Corp.
Visual Basic 2.0 or later Microsoft Corp.

3.4 This driver software initializes of the HSSB board connected with
ISA–BUS of the personal computer and executes the input and output
HIGH SPEED SERIAL management of the data from API Library.
BUS DRIVER At maximum, four Power Mate can be connected with this driver
SOFTWARE FOR software.
The number of HSSB boards in the file of SYSTEM.INI of Windows
WINDOWS 3.1
must be equal to the real board number.
Refer to the manual of HSSB driver for the detailed specification and
explanation of operation.

1–7
3. CONFIGURATION OF SOFTWARE GENERAL B–62684EN–1/01

3.5 This library reads/writes the various kinds of Power Mate/PMC data via
High Speed Serial Bus.
API LIBRARY FOR For the detail of the functions, refer to “API Library Manual”.
HSSB
(FOR WINDOWS 3.1) Function related to the communication

Function name Brief description

(1) Init_HSSB Initialization for HSSB

(2) Set_HSSB_Port_no Port number estabishment

(3) Get_HSSB_Port_no Port number reading

Function related to the control axis

Function name Brief description

(1) cnc_actf Read actual axis feedrate(F)

(2) cnc_absolute Read absolute axis position

(3) cnc_machine Read machine axis position

(4) cnc_relative Read relative axis position

(5) cnc_distance Read distance to go

(6) cnc_skip Read skip position

(7) cnc_srvdelay Read servo delay value

(8) cnc_accdecdly Read acceleration/deceleration delay value

(9) cnc_rddynamic Read all dynamic data

(10) cnc_wrrelpos Set origin / preset relative axis position

1–8
B–62684EN–1/01 GENERAL 3. CONFIGURATION OF SOFTWARE

Function related to the program

Function name Brief description

(1) cnc_dwnstart Start downloading NC program

(2) cnc_download Download NC program

(3) cnc_dwnend End of downloading NC program

(4) cnc_upstart Start uploading NC program

(5) cnc_upload Upload NC program

(6) cnc_upend End of uploading NC program

(7) cnc_search Search specified program

(8) cnc_delall Delete all programs

(9) cnc_delete Delete specified program

(10) cnc_rdprogdir Read program directory

(11) cnc_rdproginfo Read program information

(12) cnc_rdprgnum Read program number under execution

(13) cnc_rdseqnum Read sequence number under execution

(14) cnc_rdexecprog Read program under execution

(15) cnc_wrmdiprog Write program for MDI operation

(16) cnc_rdmdipntr Read execution pointer for MDI operation

(17) cnc_wrmdipntr Write execution pointer for MDI operation

(18) cnc_seqsrch Search specified sequence number

(19) cnc_rewind Rewind cursor of NC program

1–9
3. CONFIGURATION OF SOFTWARE GENERAL B–62684EN–1/01

Function related to the file data for NC

Function name Brief description

(1) cnc_rdtofs Read tool offset value

(2) cnc_wrtofs Write tool offset value

(3) cnc_rdtofsr Read tool offset value(area specified)

(4) cnc_wrtofsr Write tool offset value(area specified)

(5) cnc_rdtofsinfo Read tool offset information

(6) cnc_rdparam Read parameter

(7) cnc_wrparam Write parameter

(8) cnc_rdparar Read parameter(area specified)

(9) cnc_wrparas Write parameter(area specified)

(10) cnc_rdparainfo Read parameter information

(11) cnc_rdsetr Read setting data(area specified)

(12) cnc_wrsets Write setting data(area specified)

(13) cnc_rdmacro Read custom macro variable

(14) cnc_wrmacro Write custom macro variable

(15) cnc_rdmacror Read custom macro variable(area specified)

(16) cnc_wrmacror Write custom macro variable(area specified)

(17) cnc_rdmacroinfo Read custom macro variable information

(18) cnc_getmactype Get type of custom macro variable

(19) cnc_setmactype Set type of custom macro variable

Function related to operation history data

Function name Brief description

(1) cnc_stopophis Stop logging operation history data

(2) cnc_startophis Restart logging operation history data

(3) cnc_rdophisno Read number of operation history data

(4) cnc_rdophistry Read operation history data

(5) cnc_rdalmhisno Read number of alarm history data

(6) cnc_rdalmhistry Read alarm history data

(7) cnc_clearophis Clear operation history data

(8) cnc_rdhissgnl Read signals related operation history

(9) cnc_wrhissgnl Write signals related operation history

1 – 10
B–62684EN–1/01 GENERAL 3. CONFIGURATION OF SOFTWARE

Function related to the axis movement control

Function name Brief description

(1) cnc_opdi Signal operation command

(2) cnc_refpoint Reference point return

(3) cnc_abspoint Absolute movement

(4) cnc_incpoint Incremental movement

(5) cnc_dwell Dwell

(6) cnc_coordre Coordinate establihment

(7) cnc_exebufstat Reading of the executive buffer condition

(8) cnc_finstate Reading of the complete executive condition

(9) cnc_setfin The release of the complete executive condition

Others

Function name Brief description

(1) cnc_sysinfo Read CNC system information

(2) cnc_sysconfig Read CNC configuration information

(3) cnc_statinfo Read CNC status information

(4) cnc_alarm Read alarm status

(5) cnc_rdalminfo Read alarm information

(6) cnc_modal Read modal data

(7) cnc_diagnoss Read diagnosis data

(8) cnc_diagnosr Read diagnosis data(area specified)

(9) cnc_getfigure Read maximum valid figures, number of decimal


places

(10) cnc_rdcurrent Read real current for servo adjustment

(11) cnc_rdsrvspeed Read real speed for servo adjustment

(12) cnc_rdloopgain Read loop gain for servo adjustment

(13) cnc_rdopmsg Read operator’s message

(14) cnc_rdopnlsgnl Read output signal image of software operator’s


panel

(15) cnc_wropnlsgnl Write output signal of software operator’s panel

(16) cnc_rdopnlgnrl Read general signal image of software opera-


tor’s panel

(17) cnc_wropnlgnrl Write general output signal of software operator’s


panel

(18) cnc_rdopnlgsname Read general signal name of software operator’s


panel

(19) cnc_wropnlgsname Write general signal name of software operator’s


panel

1 – 11
3. CONFIGURATION OF SOFTWARE GENERAL B–62684EN–1/01

Function related to the PMC

Function name Brief description

(1) pmc_rdpmcrng read PMC data(area specified)

(2) pmc_wrpmcrng write PMC data(area specified)

(3) pmc_rdmcinfo read PMC data information

NOTE
1 Please do the exclusive control between tasks and design
so that the function is called only by one task at a time when
you use the function of the API library in the multitask
environment. That is, it is designed so that two or more
functions may not be called at the same time in the multitask
environment.
2 The function of the API library is designed so that the
processing is not influenced by the protection processing in
Power Mate.
Therefore, by using the API library function, data can be
changed or axis can be moved at any time. But this is on the
other hand dangerous.
Please consider the protection or interlock processing on
the application software side.

1 – 12
B–62684EN–1/01 GENERAL 3. CONFIGURATION OF SOFTWARE

3.6
PACKAGE
SOFTWARE

3.6.1 Boot application software executs the following operation for Power
Boot Application Mate.
Software (1) The exchange of the system control software and PMC ladder.
(for Windows 3.1) (2) The backup and restore of the S–RAM data.
(3) The deletion and initialization of the flash ROM file.
(4) The deletion and format of the memory card file.
(5) The initialization of the system file such as the NC program, the NC
parameter, the tool offset, etc.
(6) The diagnosis and maintenance of the HSSB board.

3.6.2 This package software enables the Power Mate/PMC maintenance


Maintenance Package operation from the personal computer.
Here shows the available screens.
 System configuration Screen
Hardware/Software configuration information of Power Mate/ PMC/
Servo.
 Alarm(History) Screen
Shows Power Mate Alarm information.
 Parameter Screen
Show/Set the Power Mate parameter data.
 Diagnosis Screen
 PMC Data Screen
Show/Set PMC data Status, Alarm, Timer, Counter, Keep Relay,
Data_table
 Servo Setting Screen

3.6.3 This package software enables the Power Mate/PMC basic operation
Basic Operation from the personal computer. Various screens for operator are included.
Package Here shows the additional screens to “Maintenance Package”.
 Status
Show Program/Sequence number, Feedrate
 Position
Shows Relative/Absolute/Machine position, Distance to go, Over all
position
 Program
Show program directory, Edit the program
 Data Setting
Setting, Tool offset, Custom Macro variable, Operator’s panel

1 – 13
4. SET UP POWER MATE GENERAL B–62684EN–1/01

4 SET UP POWER MATE

There are the following two modes when Power Mate is connected with
the personal computer through High Speed Serial Bus.

The setting value


The starting of Power Mate
mode of RSW for the CRT
Description
device number

The synchronized Power Mate waits for the com- 0


mode mand of starting a connection by
HSSB from the application soft-
ware of the personal computer.
Therefore, until the command of
starting a connection by HSSB
from the personal computer is
done, Power Mate doesn’t start
Servo control, PMC control and
NC control.

The independent Power Mate starts the control of 1


mode the machine without the starting
command from personal comput-
er. And, even if a PC itself isn’t
connected with Power Mate, the
control of the machine is started
in the same way as mentioning
above.
PC can be connected at anytime
with out turning off the power of
the Power Mate.

1 – 14
II. API LIBRARY
B–62684EN–1/01 API LIBRARY 1. GENERAL

1 

The API library is used for exchanging data and information between the
personal computer and Power Mate.

The main functions of the library are as follows.


1) Related to the communication
initialize, communication establishment, etc
2) Reading of data related to controlled axes
These data include the absolute position, relative position, machine
position, remaining travel distance, actual feedrate, and so forth.
3) Operations related to CNC program
Operations include upload/download, search, and deletion of NC
programs, read NC program directory.
4) Reading/writing of CNC file data
These data include tool offset data, parameters, settings, custom macro
variables, and P–code macro variables.
5) Reading of operation history data
These data include operation history data and alarm history data.
6) Related to the axis movement control
These command include reference point return, positioning
absolute/incremental, dwell, etc.
7) Reading of other data
These data include continuous–state data, diagnostic data, alarm
information, and operator messages.
8) Reading/writing of data related to PMC
These data includes addresses G, F, Y, X, A, R, T, C, and D.

2–1
2. GENERAL DESCRIPTION API LIBRARY B–62684EN–1/01

2 GENERAL DESCRIPTION

(1) Language for development, Memory model, and OS


CNC/PMC data window library is developed/tested by using the
following language.
D Microsoft C/C++7.0
D Visual C++1.0,
D Visual Basic 2.0
The memory model uses large model.
The OS of personal computre uses Windows3.1.
(2) Header file
There are the following header files for ‘definition of return status’,
‘structure’, and ‘prototype of API library function’.
D windows version : “apilib.h”
(3) Return status of CNC data window (API library)
return value meaning explanation and user response

EW_INIERR Error in API library S The initial value file is not found.
(–14) inital valuefile S The mistake is found in set value.
S Necessary information is not de-
scribed.

EW_ITLOW Low temperature Please cut and reactivate the power


(–13) alarm of intelligent supply where the data in the disk
terminal migth be destroyed after a while.

EW_IHIGHT Hight temperature Please cut and reactivate the power


(–12) alarm of intelligent supply where the data in the disk
terminal migth be destroyed after a while.

EW_BUS Bus error. Bus error of Power Mate.


(–11) Ask service/charge post.

EW_SYSTEM2 System error(2). System error of Power Mate.


(–10) Ask service/charge post.

EW_HSSB Communication error Confirm the serial cable of HSSB or


(–9) of HSSB. I/F board.

EW_SYSTEM System error. System error of Power Mate.


(–5) Ask service/charge post.

EW_BUSY Busy. Wait until the completion of Power


(–1) Mate processing, or retry.

EW_OK Normal termination.


(0)

EW_FUNC Error (start operation The user has not started any of the
(1) not executed or start following operations, or attempted to
already executed) start one of the following operations
hile it was
while as already
alread started
started.
S Start downloading NC program.
S Start uploading NC program.

2–2
B–62684EN–1/01 API LIBRARY 2. GENERAL DESCRIPTION

return value meaning explanation and user response

EW_LENGTH Error (data block Check and correct the data block
(2) length error) length or number of data.

EW_NUMBER Error (data number Check and correct the data number.
(3) error)

EW_ATTRIB Error (data attribute Check and correct the data attrib-
(4) error) ute.

EW_DATA Error (data error) Check and correct the data.


(5) For the following operations, this
code indicates that the specified
program cannot be found.
S Delete specified program.
S Search specified program.
S Start uploading NC program.

EW_NOOPT Error (no option) The Power Mate option is not pro-
(6) vided.

EW_PROT Error (write protect) Write operation is prohibited.


(7)

EW_OVRFLOW Error (memory over- The Power Mate memory over-


(8) flow) flowed.

EW_PARAM Error (Power Mate Power Mate parameter is set incor-


(9) parameter error) rectly

EW_BUFFER Error (buffer empty/ The buffer is empty or full.


(10) full) Wait unit completion of Power Mate
processing, or retry.

EW_PATH Error (path number A path number is incorrect.


(11) error)

EW_MODE Error (Power Mate The Power Mate mode is incorrect.


(12) mode error) Correct the Power Mate mode.

CAUTION
1 Please do the exclusive control between tasks and design
so that the function is called only by one task at a time when
you use the function of the API library in the multitask
environment. That is, two functions or more must not be
called at the same time in the multitask environment.
2 The Input/Output the data by the function of the API library
is not influenced by the processing of protecting status in
Power Mate. The change and the movement instruction of
the data are possible at any time.
Therefore, it is necessary to build the protecting processing
and the interlock processing of the data Input/Output in the
application software side.

2–3
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

3 FUNCTION LIST

Related to the communication

Function name Brief description Page

(1) Init_HSSB Initialization for HSSB 2–9


(2) Set_HSSB_Port_no Port number estabishment 2 – 10
(3) Get_HSSB_Port_no Port number reading 2 – 11

Related to the control axis

Function name Brief description Page

(1) cnc_actf Read actual axis feedrate(F) 2 – 13


(2) cnc_absolute Read absolute axis position 2 – 14
(3) cnc_machine Read machine axis position 2 – 16
(4) cnc_relative Read relative axis position 2 – 18
(5) cnc_distance Read distance to go 2 – 20
(6) cnc_skip Read skip position 2 – 22
(7) cnc_srvdelay Read servo delay value 2 – 24
(8) cnc_accdecdly Read acceleration/deceleration delay 2 – 26
value
(9) cnc_rddynamic Read all dynamic data 2 – 28
(10) cnc_wrrelpos Set origin / preset relative axis position 2 – 32

2–4
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Related to the program

Function name Brief description Page


(1) cnc_dwnstart Start downloading NC program 2 – 35
(2) cnc_download Download NC program 2 – 36
(3) cnc_dwnend End of downloading NC program 2 – 39
(4) cnc_upstart Start uploading NC program 2 – 41
(5) cnc_upload Upload NC program 2 – 42
(6) cnc_upend End of uploading NC program 2 – 45
(7) cnc_search Search specified program 2 – 46
(8) cnc_delall Delete all programs 2 – 48
(9) cnc_delete Delete specified program 2 – 50
(10) cnc_rdprogdir Read program directory 2 – 52
(11) cnc_rdproginfo Read program information 2 – 55
(12) cnc_rdprgnum Read program number under execution 2 – 58
(13) cnc_rdseqnum Read sequence number under execution 2 – 60
(14) cnc_rdexecprog Read program under execution 2 – 62
(15) cnc_wrmdiprog Write program for MDI operation 2 – 63
(16) cnc_rdmdipntr Read execution pointer for MDI operation 2 – 65
(17) cnc_wrmdipntr Write execution pointer for MDI operation 2 – 66
(18) cnc_seqsrch Search specified sequence number 2 – 67
(19) cnc_rewind Rewind cursor of NC program 2 – 68

Related to NC data file

Function name Brief description Page


(1) cnc_rdtofs Read tool offset value 2 – 70
(2) cnc_wrtofs Write tool offset value 2 – 72
(3) cnc_rdtofsr Read tool offset value(area specified) 2 – 74
(4) cnc_wrtofsr Write tool offset value(area specified) 2 – 76
(5) cnc_rdtofsinfo Read tool offset information 2 – 78
(6) cnc_rdparam Read parameter 2 – 79
(7) cnc_wrparam Write parameter 2 – 82
(8) cnc_rdparar Read parameter(area specified) 2 – 85
(9) cnc_wrparas Write parameter(area specified) 2 – 90
(10) cnc_rdparainfo Read parameter information 2 – 93
(11) cnc_rdsetr Read setting data(area specified) 2 – 95
(12) cnc_wrsets Write setting data(area specified) 2 – 98
(13) cnc_rdmacro Read custom macro variable 2 – 101
(14) cnc_wrmacro Write custom macro variable 2 – 104
(15) cnc_rdmacror Read custom macro variable(area specified) 2 – 106
(16) cnc_wrmacror Write custom macro variable(area specified) 2 – 109
(17) cnc_rdmacroinfo Read custom macro variable information 2 – 112
(18) cnc_getmactype Get type of custom macro variable 2 – 113
(19) cnc_setmactype Set type of custom macro variable 2 – 114

2–5
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Related to operation history data

Function name Brief description Page

(1) cnc_stopophis Stop logging operation history data 2 – 116


(2) cnc_startophis Restart logging operation history data 2 – 117
(3) cnc_rdophisno Read number of operation history data 2 – 118
(4) cnc_rdophistry Read operation history data 2 – 119
(5) cnc_rdalmhisno Read number of alarm history data 2 – 123
(6) cnc_rdalmhistry Read alarm history data 2 – 124
(7) cnc_clearophis Clear operation history data 2 – 127
(8) cnc_rdhissgnl Read signals related operation history 2 – 128
(9) cnc_wrhissgnl Write signals related operation history 2 – 129

Related to the axis movement control

Function name Brief description Page

(1) cnc_opdi Signal operation command 2 – 132


(2) cnc_refpoint Reference point return 2 – 134
(3) cnc_abspoint Absolute movement 2 – 136
(4) cnc_incpoint Incremental movement 2 – 139
(5) cnc_dwell Dwell 2 – 142
(6) cnc_coordre Coordinate establihment 2 – 144
(7) cnc_exebufstat Reading of the executive buffer condition 2 – 146
(8) cnc_finstate Reading of the complete executive condi- 2 – 148
tion
(9) cnc_setfin The release of the complete executive 2 – 149
condition

2–6
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Others function

Function name Brief description Page

(1) cnc_sysinfo Read CNC system information 2 – 151


(2) cnc_sysconfig Read CNC configuration information 2 – 153
(3) cnc_statinfo Read CNC status information 2 – 157
(4) cnc_alarm Read alarm status 2 – 159
(5) cnc_rdalminfo Read alarm information 2 – 161
(6) cnc_modal Read modal data 2 – 164
(7) cnc_diagnoss Read diagnosis data 2 – 169
(8) cnc_diagnosr Read diagnosis data(area specified) 2 – 172
(9) cnc_getfigure Read maximum valid figures, number of 2 – 175
decimal places
(10) cnc_rdcurrent Read real current for servo adjustment 2 – 177
(11) cnc_rdsrvspeed Read real speed for servo adjustment 2 – 178
(12) cnc_rdloopgain Read loop gain for servo adjustment 2 – 179
(13) cnc_rdopmsg Read operator’s message 2 – 180
(14) cnc_rdopnlsgnl Read output signal image of software 2 – 182
operator’s panel
(15) cnc_wropnlsgnl Write output signal of software opera- 2 – 185
tor’s panel
(16) cnc_rdopnlgnrl Read general signal image of software 2 – 188
operator’s panel
(17) cnc_wropnlgnrl Write general output signal of software 2 – 190
operator’s panel
(18) cnc_rdopnlgsname Read general signal name of software 2 – 192
operator’s panel
(19) cnc_wropnlgsname Write general signal name of software 2 – 194
operator’s panel

Related to the PMC

Function name Brief description Page

(1) pmc_rdpmcrng read PMC data(area specified) 2 – 197


(2) pmc_wrpmcrng write PMC data(area specified) 2 – 200
(3) pmc_rdpmcinfo read PMC data information 2 – 202

2–7
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

3.1
RELATED TO THE Function name Brief description
COMMUNICATION (1) Init_HSSB Initialization for HSSB
(2) Set_HSSB_Port_no Port number estabishment
(3) Get_HSSB_Port_no Port number reading

2–8
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(1) Initialization for


HSSB
Function Name Init_HSSB

Declaration #include “apilib.h”


short FAR PASCAL Init_HSSB(unsigned short FlibHndl);

Description The communication with Power Mate via HSSB is established, and
initialization is done. It is enough to execute this command one time
when the application is started.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_HSSB The communication error of HSSB.


Check serial cable of HSSB or a I/F board.

CNC option CNC option is not reqired for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program establishes communication with Power Mate.


When connectionit fails, error message is indicated.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
if( Init_HSSB( 0 ) != 0 ){
printf( ”System failed in connecting the HSSB line.¥n” ) ;
}else{
.
.
.
.
}
return ;
}

2–9
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(2) Port number


estabishment
Function Name Set_HSSB_Port_no

Declaration #include “apilib.h”


short FAR PASCAL Set_HSSB_Port_no(unsigned short FlinHndl,
unsigned short num);

Description When plural I/F boards are connected, it is set up which board an order
is issued in. “1” must be specified when I/F board is one.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
num A port number is set.(1 – 4)

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_DATA Data number error


Confirm a port number.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program sets up the number set in the argument “num” as
a port number. When a set number is not effective, an error message is
indicated and the procedure is finished.
#include <stdio.h>
#include ”apilib.h”

void example( unsigned short num )


{
if( Set_HSSB_Port_no( 0, num ) != 0 ){
printf( ”Data Number error.(%d)¥n”, num ) ;
printf( ”An effective range is 1 to 4.¥n” ) ;
}
}

2 – 10
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(3) Port number reading

Function Name Get_HSSB_Port_no

Declaration #include “apilib.h”


short FAR PASCAL Get_HSSB_Port_no(unsigned short FlinHndl,
unsigned short *num);

Description When plural I/F board are connected, it can get the information of the port
number which an order can be issued to.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
num A port number is stored.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program shows how to read the port number selected at
present.

#include <stdio.h>
#include ”apilib.h”

void example( unsigned short num )


{
unsigned short port_no ;

Get_HSSB_Port_no( 0, &port_no ) ;
printf( ”A port number is %d.¥n”, port_no ) ;
}

2 – 11
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

3.2
RELATED TO THE Function name Brief description
CONTROL AXES (1) cnc_actf Read actual axis feedrate(F)
(2) cnc_absolute Read absolute axis position
(3) cnc_machine Read machine axis position
(4) cnc_relative Read relative axis position
(5) cnc_distance Read distance to go
(6) cnc_skip Read skip position
(7) cnc_srvdelay Read servo delay value
(8) cnc_accdecdly Read acceleration/deceleration delay value
(9) cnc_rddynamic Read all dynamic data
(10) cnc_wrrelpos Set origin / preset relative axis position

2 – 12
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(1) Read actual axis


feedrate(F)

Function Name cnc_actf

Declaration #include “apilib.h”


short FAR PASCAL cnc_actf(unsigned short FlibHndl,
ODBACT *actualfeed);

Description Reads the actual feed rate of the controlled axes of CNC.
The actual feed rate is stored in “data” of “ODBACT”.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
actualfeed
Pointer to the ODBACT structure including the actual feed rate of
the controlled axes.
The ODBACT structure is as follows.
typedef struct odbact {
short dummy[2]; /* dummy */
long data; /* the actual feed rate(F)*/
} ODBACT ;

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program displays “CURRENT F=1200” while the block
N20:O1234 of the following NC program is being executed.
(in case of “mm input”.)
O1234 ;
N10 G90 F1200 ;
N20 G1 X10. Z200.
N30 ...

#include <stdio.h>
#include ”apilib.h”
void example( void )
{
ODBACT buf ;
cnc_actf( 0, &buf ) ;
printf( ”CURRENT F=%ld¥n”, buf.data ) ;
}

2 – 13
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(2) Read absolute axis


position

Function Name cnc_absolute

Declaration #include “apilib.h”


short FAR PASCAL cnc_absolute(unsigned short FlibHndl,short axis,
short length,ODBAXIS *absolute);

Description Reads the absolute position data of the axis specified with “axis”.
The absolute position is stored in “data[0]” of “ODBAXIS”.
All axes can be read at a time by specifying ALL_AXES for “axis”.
In that case, an absolute position of each axis is stored in the data array
of ODBAXIS.
The decimal point position of the absolute position can be acquired in the
cnc_getfigure() function.
As for Power Mate, amounts of Tool Length Compensation , and amounts
of servo delay and acceleration/deceleration delay is always included in
the read absolute position.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
axis Specify axis number to read.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m : number of controlled axis)
length
Specify the length of the data block (size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0 0
dummy dummy
2 2
type length type length
4 4
data[0] data[0]
8 8

4+4x(n–1)
data[n–1]
4+4xn
n : Current controlled axes

absolute
Pointer to the ODBAXIS structure including the absolute position
data of the controlled axes.
The ODBAXIS structure is as follows.
typedef struct odbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Absolute position
data of controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

2 – 14
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program displays


1: 120005
2: –50119
3: 80
while the absolute position data for each axes is
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 <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBAXIS buf ;
cnc_absolute( 0, –1, 4+4*3, &buf ) ;
printf( ”1:%8ld¥n2:%8ld¥n3:%8ld¥n”, buf.data[0], buf.data[1],
buf.data[2] ) ;
}

2 – 15
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(3) Read machine axis


position

Function Name cnc_machine

Declaration #include “apilib.h”


short FAR PASCAL cnc_machine(unsigned short FlibHndl,short axis,
short length,ODBAXIS *machine);

Description Reads the machine position data of the axis specified with “axis”.
The machine position is stored in “data[0]” of “ODBAXIS”.
All axes can be read at a time by specifying ALL_AXES for “axis”.
In that case, an machine position of each axis is stored in the data array
of ODBAXIS.
The decimal point position of the machine position can be acquired in the
cnc_getfigure() function.
As for Power Mate, amounts of servo delay and acceleration/deceleration
delay is always included in the read machine position.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
axis Specify axis number to read.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m :number of controlled axis)
length
Specify the length of the data block (size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0 0
dummy dummy
2 2
type length type length
4 4
data[0] data[0]
8 8

4+4x(n–1)
data[n–1]
4+4xn
n : Current controlled axes

machine
Pointer to the ODBAXIS structure including the machine position
data of the controlled axes.
The ODBAXIS structure is as follows.
typedef struct odbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Machine position
data of controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

2 – 16
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

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 <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBAXIS buf ;
cnc_machine( 0, 2, 4+4*1, &buf ) ;
printf( ”MACHINE 2:%8ld¥n”, buf.data[0] ) ;
}

2 – 17
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(4) Read relative axis


position

Function Name cnc_relative

Declaration #include “apilib.h”


short FAR PASCAL cnc_relative(unsigned short FlibHndl,short axis,
short length,ODBAXIS *relative);

Description Reads the relative position data of the axis specified with “axis”.
The relative position is stored in “data[0]” of “ODBAXIS”.
All axes can be read at a time by specifying ALL_AXES for “axis”.
In that case, an relative position of each axis is stored in the data array of
ODBAXIS.
The decimal point position of the relative position can be acquired in the
cnc_getfigure() function.
As for Power Mate, amounts of Tool Length Compensation, and amounts
of servo delay and acceleration/deceleration delay is always included in
the read relative position.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
axis Specify axis number to read.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m : number of controlled axis)
length
Specify the length of the data block (size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0 0
dummy dummy
2 2
type length type length
4 4
data[0] data[0]
8 8

4+4x(n–1)
data[n–1]
4+4xn
n : Current controlled axes

relative
Pointer to the ODBAXIS structure including the relative position
data of the controlled axes.
The ODBAXIS structure is as follows.
typedef struct odbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Relative position
data of controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

2 – 18
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program displays “RELATIVE 4: 900051” while the


relative position data of the 4th axis (rotation axis) is 900.051.
(in case of “IS–B”.)

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBAXIS buf ;
cnc_relative( 0, 4, 4+4*1, &buf ) ;
printf( ”RELATIVE 4:%8ld¥n”, buf.data[0] ) ;
}

2 – 19
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(5) Read distance to go

Function Name cnc_distance

Declaration #include “apilib.h”


short FAR PASCAL cnc_distance(unsigned short FlibHndl,short axis,
short length,ODBAXIS *distance);

Description Reads the amount of distance to go of the axis specified with “axis”.
The amount of distance to go is stored in “data[0]” of “ODBAXIS”.
All axes can be read at a time by specifying ALL_AXES for “axis”.
In that case, an amount of distance to go of each axis is stored in the data
array of ODBAXIS.
The decimal point position of the amount of distance to go can be acquired
in the cnc_getfigure() function.
As for Power Mate, the read amount of distance to go is twice as big as
the actual.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
axis Specify axis number to read.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m : number of controlled axis)
length
Specify the length of the data block(size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0 0
dummy dummy
2 2
type length type length
4 4
data[0] data[0]
8 8

4+4x(n–1)
data[n–1]
4+4xn
n : Current controlled axes

distance
Pointer to the ODBAXIS structure including the number of
distance to go of the controlled axes.
The ODBAXIS structure is as follows.
typedef struct odbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* number of distance to go of
controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

2 – 20
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program displays


1: –34600
2: 60018
3: –360
while the amount of distance to go for each axes are
The 1st axis –17.300 (Linear axis)
The 2nd axis 30.009 (linear axis)
The 3rd axis –0.180 (Rotation axis)
in 3–axis system.(in case of “mm input” and “IS–B”.)

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBAXIS buf ;
unsigned int idx ;
cnc_distance( 0, –1, 4+4*4, &buf ) ;
for ( idx = 0 ; idx < 3 ; idx++ )
printf( ”%u:%8ld¥n”, idx, buf.data[idx] ) ;
}

2 – 21
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(6) Read skip position

Function Name cnc_skip

Declaration #include “apilib.h”


short FAR PASCAL cnc_skip(unsigned short FlibHndl,short axis,
short length,ODBAXIS *skip);

Description Reads the skipped position of the axis specified with “axis”.
The skipped position is stored in “data[0]” of “ODBAXIS”.
All axes can be read at a time by specifying ALL_AXES for “axis”.
In that case, an skipped position of each axis is stored in the data array of
ODBAXIS.
The decimal point position of the skipped position can be acquired in the
cnc_getfigure() function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
axis Specify axis number to read.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m : number of controlled axis)
length
Specify the length of the data block (size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0 0
dummy dummy
2 2
type length type length
4 4
data[0] data[0]
8 8

4+4x(n–1)
data[n–1]
4+4xn
n : Current controlled axes

skip Pointer to the ODBAXIS structure including the skipped position


data of the controlled axes.
The ODBAXIS structure is as follows.
typedef struct odbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Skipped position
data of controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

2 – 22
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program displays the skipped position of the 1st and 2nd
axes.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBAXIS buf ;
unsigned int idx ;
cnc_skip( 0, 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] ) ;
}

2 – 23
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(7) Read servo delay


value

Function Name cnc_srvdelay

Declaration #include “apilib.h”


short FAR PASCAL cnc_srvdelay(unsigned short FlibHndl,short axis,
short length,ODBAXIS *srvdelay);

Description Reads the servo delay amount of the axis specified with “axis”.
The servo delay amount is stored in “data[0]” of “ODBAXIS”.
All axes can be read at a time by specifying ALL_AXES for “axis”.
In that case, an servo delay amount of each axis is stored in the data array
of ODBAXIS.
The decimal point position of the servo delay amount can be acquired in
the cnc_getfigure() function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
axis Specify axis number to read.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m : number of controlled axis)
length
Specify the length of the data block (size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0 0
dummy dummy
2 2
type length type length
4 4
data[0] data[0]
8 8

4+4x(n–1)
data[n–1]
4+4xn
n : Current controlled axes

srvdelay
Pointer to the ODBAXIS structure including the servo delay amount
of controlled axis.
The ODBAXIS structure is as follows.
typedef struct odbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Servo delay amount
of controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes.*/

2 – 24
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program displays the servo delay amount of all axes
(number of axes = MAX_AXIS).

#include <stdio.h>
#include ”apilib.h”
void example( void )
{
ODBAXIS buf ;
unsigned int idx ;
cnc_srvdelay( 0, –1, 4+4*MAX_AXIS, &buf ) ;
for ( idx = 0 ; idx < MAX_AXIS ; idx++ )
printf( ”%u:%8ld¥n”, idx, buf.data[idx] ) ;
}

2 – 25
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(8) Read acceleration/


deceleration delay
value
Function Name cnc_accdecdly

Declaration #include “apilib.h”


short FAR PASCAL cnc_accdecdly (unsigned short FlibHndl,short axis,
short length,ODBAXIS *accdecdly);

Description Reads the acceleration/deceleration delay amount of the axis specified


with “axis”.
The acceleration/deceleration delay amount is stored in “data[0]” of
“ODBAXIS”.
All axes can be read at a time by specifying ALL_AXES for “axis”.
In that case, an acceleration/deceleration delay amount of each axis is
stored in the data array of ODBAXIS.
The decimal point position of the acceleration/deceleration delay amount
can be acquired in the cnc_getfigure() function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
axis Specify axis number to read.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m : number of controlled axis)
length
Specify the length of the data block (size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0 0
dummy dummy
2 2
type length type length
4 4
data[0] data[0]
8 8

4+4x(n–1)
data[n–1]
4+4xn
n : Current controlled axes

accdecdly
Pointer to the ODBAXIS structure including the acceleration/
deceleration delay amount of the controlled axes.
The ODBAXIS structure is as follows.
typedef struct odbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Acceleration/deceleration
delay amount of controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes.*/

2 – 26
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program displays the acceleration/deceleration delay


amount of all axes (number of axes = MAX_AXIS).
#include <stdio.h>
#include ”apilib.h”
void example( void )
{
ODBAXIS buf ;
unsigned int idx ;
cnc_accdecdly( 0, –1, 4+4*MAX_AXIS, &buf ) ;
for ( idx = 0 ; idx < MAX_AXIS ; idx++ )
printf( ”%u:%8ld¥n”, idx, buf.data[idx] ) ;
}

2 – 27
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(9) Read all dynamic


data

Function Name cnc_rddynamic

Declaration #include “apilib.h”


short FAR PASCAL cnc_rddynamic(unsigned short FlibHndl,short axis,
short length,ODBDY *rddynamic);

Description Read various data which changes as CNC operating at a time.


The data which can be read is as follows.
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
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

(Last four functions have axis attribute)


The formats of each data are the same as each corresponding “Function”
used for reading each data.
Refer each functions for details.
Reads the data concerning the axis specified with “axis”.
Each data is stored in oaxis structure in ODBDY.
All axes can be read at a time by specifying ALL_AXES for “axis”.
In that case, each data concerning the axis is stored in each array of the
structure “faxis” inside ODBDY.
The decimal point position of each data concerning the axis can be
acquired in the cnc_getfigure() function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
axis Specify axis number to read.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m : number of controlled axis)

2 – 28
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

length
Specify the length of the data block(size of ODBDY structure)

for each axis for all axes


ODBDY 0 0
dummy dummy
2 2
axis axis
4 4
alarm alarm
6 6
prgnum prgnum
8 8
prgmnum length prgmnum length
10 10
seqnum seqnum
14 14
actf actf
18 18
(dummy 4 byte) (dummy 4 byte)
22 22
absolute absolute[0]
26 26
machine
30 22+4x(n–1)
relative absolute[n–1]
34 22+4xn
distance machine[0]
38 22+4x(n+1)

22+4x(2n–1)
machine[n–1]
22+4x2n
relative[0]
22+4x(2n+1)

22+4x(3n–1)
relative[n–1]
22+4x3n
distance[0]
22+4x(3n+1)

22+4x(4n–1)
distance[n–1]
22+4x4n
n : Maximum controlled axes
* The data for current controlled axes are valid.

rddynamic
Pointer to the ODBDY structure including various data.
The ODBDY structure is as follows.
typedef struct odbdy {
short dummy ; /* not used */
short axis ; /* axis number */
short alarm ; /* alarm status */
short prgnum ; /* current program number */
short prgmnum ; /* main program number */
long seqnum ; /* current sequence number */
long actf ; /* actual feed rate */
long acts ; /* not used */
union {
struct {
long absolute[MAX_AXIS] ; /* absolute */

2 – 29
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

long machine[MAX_AXIS] ; /* machine */


long relative[MAX_AXIS] ; /* relative */
long distance[MAX_AXIS] ; /* distance to go */
} faxis ; /* In case of all axes */
struct {
long absolute ; /* absolute */
long machine ; /* machine */
long relative ; /* relative */
long distance ; /* distance to go */
} oaxis ; /* In case of 1 axis */
} pos ;
} ODBDY ; /* MAX_AXIS is the maximum controlled axes. */
dummy Not used
axis Axis number
The axis number to be read is returned.
alarm Alarm status
The meaning of each bit is as follows.
Power Mate
#15:External alarm message
#14:(Not used)
#13:(Not used)
#12:(Not used)
#11:(Not used)
#10:P/S alarm 5000
#09:(Not used)
#08:APC alarm
#07:System alarm
#06:Servo alarm
#05:Overheat alarm
#04:Overtravel alarm
#03:P/S alarm except above
#02:P/S alarm 101
#01:P/S alarm 000
#00:P/S alarm 100
prgnum Program number under execution
(It is the selected program number while automatic
operation stopping)
prgmnum Main program number
seqnum Current sequence number
actf Actual feed rate of the controlled axes
acts dummy 4 byte
absolute Absolute position of the controlled axes
machine Machine position of the controlled axes
relative Relative position of the controlled axes
distance Amount of distance to go of the controlled axes

2 – 30
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBDY structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program reads the dynamic data of all axes
(number of axes = MAX_AXIS) and displays them on the screen.
#include <stdio.h>
#include ”apilib.h”

void example( void )


{
struct odbdy buf ;
unsigned int idx ;
cnc_rddynamic( 0, –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¥n”, buf.actf ) ;
printf( ”Alarm status = %d¥n”, buf.alarm ) ;
printf( ”AXIS Absolute Relative Machine Distance¥n” ) ;
printf( ” ¥n” ) ;
for ( idx = 0 ; idx < MAX_AXIS ; 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] ) ;
}

2 – 31
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(10) Set origin/preset


relative axis position
Function Name cnc_wrrelpos

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrrelpos(unsigned short FlibHndl,
short length,IDBWRR *wrrelpos);

Description Preset relative position against the axis specified with “type”.
Preset data is specified by “data[0]” in “IDBWRR”.
If 0 is specified as preset data, it means origin (0 clear of relative position).
It is possible to make preset to all axes at a time by specifying ALL_AXES
for “type”.
In that case, an preset data of each axis is specified by the data array in
IDBWRR.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
length
Specify the length of the data block(size of IDBWRR structure)

for each axis for all axes


IDBWRR 0 0
datano datano
2 2
type length type length
4 4
data[0] data[0]
8 8

4+4x(n–1)
data[n–1]
4+4xn
n : Current controlled axes

wrrelpos
Pointer to the IDBWRR structure to be set the relative position data
of the controlled axes.
The IDBWRR structure is as follows.
typedef struct idbwrr {
short datano; /* Not used. */
short type; /* Axis number. */
long data[MAX_AXIS]; /* Preset data. */
} IDBWRR ; /* MAX_AXIS is the maximum controlled axes. */
type Specify axis number to make preset.
ALL_AXES : for all axes(ALL_AXES : –1)
1,..,m : for each axis
(m : number of controlled axis)
data Specify value to make preset.
data[0],..,data[m–1] : for all axes
data[0] : for each axis

2 – 32
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ODBWRR structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (type) is improper.
EW_DATA data error
The content of “data” is out of range which can be speci-
fied.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program preset the relative position of the first axis.

#include <stdio.h>
#include ”apilib.h”
#define FIRST_AXIS 1
#define ONE_AXIS_LEN 8

IDBWRR wrrelpos ;
short ret ;

wrrelpos.type = FIRST_AXIS ;
wrrelpos.data[0] = 0 ;
ret = cnc_wrrelpos( 0, ONE_AXIS_LEN, &wrrelpos);

2 – 33
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

3.3
RELATED TO Function name Brief description
PROGRAM (1) cnc_dwnstart Start downloading NC program
(2) cnc_download Download NC program
(3) cnc_dwnend End of downloading NC program
(4) cnc_upstart Start uploading NC program
(5) cnc_upload Upload NC program
(6) cnc_upend End of uploading NC program
(7) cnc_search Search specified program
(8) cnc_delall Delete all programs
(9) cnc_delete Delete specified program
(10) cnc_rdprogdir Read program directory
(11) cnc_rdproginfo Read program information
(12) cnc_rdprgnum Read program number under execution
(13) cnc_rdseqnum Read sequence number under execution
(14) cnc_rdexecprog Read program under execution
(15) cnc_wrmdiprog Write program for MDI operation
(16) cnc_rdmdipntr Read execution pointer for MDI operation
(17) cnc_wrmdipntr Write execution pointer for MDI operation
(18) cnc_seqsrch Search specified sequence number
(19) cnc_rewind Rewind cursor of NC program

2 – 34
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(1) Start downloading


NC program

Function Name cnc_dwnstart

Declaration #include “apilib.h”


short FAR PASCAL cnc_dwnstart(unsigned short FlibHndl);

Description Requests CNC to start downloading NC program.


(This function must be executed before cnc_download.)

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY busy
S cnc_dwnstart function has been executed.
Terminate a downloading(verifying) by using
cnc_dwnend function.
S background edit processing in CNC side
Terminate background edit processing in CNC side.
S alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
S MDI mode
Change CNC mode to any mode except MDI.
EW_PROT write protection in CNC side
S Protection KEY(DI) turns on.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
0000#0 influenced by setting
3201#2,#6
3202#0,#4
3290#7

CNC mode This function relates to the following mode.


It is possible to use in other than MDI mode.

Example See an example of “Download NC program(cnc_download)”.

2 – 35
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(2) Download NC
program
Function Name cnc_download

Declaration #include “apilib.h”


short FAR PASCAL cnc_download(unsigned short FlibHndl,char *data,
short number);

Description Output NC program to be registered(downloading).


When the data processing on the CNC side is delayed and the data cannot
be transferred, this function waits until it can be transferred.
The procedure of downloading is as follows.

cnc_dwnstart() beginning of download (must be done)

cnc_download() output of download data

Yes
Is there data of unoutput?

No

cnc_dwnend() End of download (must be done)

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%”
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_download
functions.

2 – 36
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
data Specify the top address of NC program data.
number
Specify the number of characters of NC program data. (1 – 256)

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_RESET reset or stop request


‘RESET or STOP’ was pushed.
Call the cnc_dwnend function.
EW_FUNC cnc_dwnstart function has not been executed.
EW_LENGTH data block length error
Length of data block(number) exceeds 256 bytes.
EW_DATA data error
S The same program number has already been regis-
tered.
S The same program number is selected on CNC.
S A character which is unavailable for NC program is de-
tected.
S When TV check is effective, a block which includes odd
characters(including ‘LF’ at the end of the block) is de-
tected.
See ‘Description’ about the timing of error.
EW_PROT write protection in CNC side
S CNC parameter is a state of write–protection
(O8000–/O9000– protection, encoding).
See ‘Description’ about the timing of error.
EW_OVRFLOW memory overflow
It is lack of free area in CNC memory.
Make enough free area in CNC memory.
See ‘Description’ about the timing of error.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.

0000#0 influenced by setting


3201#2,#6
3202#0,#4
3290#7

CNC mode This function relates to the following mode.


It is possible to use in other than MDI mode.

2 – 37
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Example The following program registers the following NC program to CNC.

O1234 ;
G0 Z0 ;
G0 X0 Y0 ;
G1 F500 X120. Y–30. ;
M30 ;

#include ”apilib.h”

short example( void )


{
char *prg[] = {
”¥n”,
”O1234¥n”,
”G0 Z0¥n”,
”G0 X0 Y0¥n”,
”G1 F500 X120. Y–30.¥n”,
”M30¥n”,
”%”
} ;
short ret, idx ;
ret = cnc_dwnstart( 0 ) ;
if ( ret ) return ( ret ) ;
for ( idx = 0 ; idx < sizeof(prg)/sizeof(char *) ; idx++ ) {
ret = cnc_download( 0, prg[idx], strlen( prg[idx] ) ) ;
if ( ret ) {
cnc_dwnend( 0 ) ;
return ( ret ) ;
}
}
ret = cnc_dwnend( 0 ) ;
return ( ret ) ;
}

2 – 38
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(3) End of downloading


NC program
Function Name cnc_dwnend

Declaration #include “apilib.h”


short FAR PASCAL cnc_dwnend (unsigned short FlibHndl);

Description Notices the end of downloading NC program to CNC.


(This function must be executed after cnc_download.)
There are cases where errors(EW_DATA, EW_OVRFLOW, etc.) during
execution of downloading NC program are returned by this function.
Further, there is no return from this function until the registration of the
output data by cnc_download is finished.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_FUNC cnc_dwnstart function has not been executed.


EW_DATA data error
S The same program number has already been regis-
tered.
S The same program number is selected on CNC.
S A character which is unavailable for NC program is de-
tected.
S When TV check is effective, a block which includes odd
characters(including ‘LF’ at the end of the block) is de-
tected.
See ‘Description’ about the timing of error.
EW_PROT write protection in CNC side
S CNC parameter is a state of write–protection
(O8000–/O9000– protection, encoding).
See ‘Description’ about the timing of error.
EW_OVRFLOW memory overflow
It is lack of free area in CNC memory.
Make enough free area in CNC memory.
See ‘Description’ about the generation timing.

2 – 39
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
0000#0 influenced by setting
3201#2,#6
3202#0,#4
3290#7

CNC mode This function relates to the following mode.


It is possible to use in other than MDI mode.

Example See example of “Download NC program(cnc_download)”.

2 – 40
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(4) Start uploading NC


program

Function Name cnc_upstart

Declaration #include “apilib.h”


short FAR PASCAL cnc_upstart(unsigned short FlibHndl,short number);

Description Notices the start of uploading NC program to the library.


(This function must be executed before cnc_upload.)

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify program number

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY busy
S cnc_upstart function has been executed.
Terminate an uploading by using cnc_upend function.
S alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
EW_DATA data error
Program number(number) is not found or wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example See example of “Upload NC program(cnc_upload)”.

2 – 41
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(5) Upload NC program

Function Name cnc_upload

Declaration #include “apilib.h”


short FAR PASCAL cnc_upload(unsigned short FlibHndl,
ODBUP *upld,unsigned short *number);

Description Read NC program registered for the tape memory in CNC (program
memory).
The procedure of uploading is as follows.

cnc_upstart() beginning of upload (must be done)

cnc_upload() read NC program

No
the last data=‘%’?

Yes

cnc_upend() End of upload (must be done)

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 ‘%’.
Nothing for Power Mate 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 characters)
2nd and after “” (0 character)

2 – 42
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

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 “” (0 character)

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
upld Pointer to the ODBUP structure including the NC program.
The ODBUP structure is as follows.
typedef struct odbup {
short dummy[2] ; /* Not used. */
char data[MAX_RBUF] ; /* NC program data. */
} ODBUP ; (MAX_RBUF : maximum character number
to read)
The default value of read buffer size (MAX_RBUF) with ODBUP
structure is 256.
In order to read more characters at a time, it is necessary to
customize.

ODBUP 0
dummy[0]
2
dummy[1]
4
data[0]
5

4+MAX_RBUF–1
data[MAX_RBUF–1]
4+MAX_RBUF

number
Specify the address of the variable which shows number of
characters to read.
Set read number of characters by one time to this
variable(*number).
After reading ends, the number of characters actually read is set in
this variable(*number) again.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_FUNC cnc_upstart function has not been executed.


EW_LENGTH data block length error
The read number of characters of NC program (*number)
is 0.

2 – 43
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program reads the specified NC program registered in


CNC, and displays its contents on the screen.

#include <stdio.h>
#include ”apilib.h”
#define BUFSIZE 40

/* number is NC program number to be read. */


short example( short number )
{
char buf[BUFSIZE+4] ;
short ret, number ;
ret = cnc_upstart( 0 ) ;
if ( ret ) return ( ret ) ;
for (;;) {
number = BUFSIZE – 1 ;
ret = cnc_upload( 0, (ODBUP *)(&buf), &number ) ;
if ( ret ) {
cnc_upend( 0 ) ;
return ( ret ) ;
}
buf[4+number] = ’¥x00’ ;
printf( ”%s”, &buf[4] ) ;
if ( buf[4+number–1] == ’%’ ) break ;
}
putchar( ’¥n’ ) ;
ret = cnc_upend( 0 ) ;
return ( ret ) ;
}

2 – 44
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(6) End of uploading NC


program

Function Name cnc_upend

Declaration #include “apilib.h”


short FAR PASCAL cnc_upend(unsigned short FlibHndl);

Description Notices the end of uploading NC program to the library.


(This function must be executed after cnc_upload.)

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_FUNC cnc_upstart function has not been executed.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example See example of “Upload NC program(cnc_upload)”.

2 – 45
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(7) Search specified


program

Function Name cnc_search

Declaration #include “apilib.h”


short FAR PASCAL cnc_search(unsigned short FlibHndl,short number);

Description Searches the number of NC program registered in program memory of


CNC.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify program number.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY busy
S ‘OP’ signal(DO)<F000#7> on
(only EDIT mode or MEMORY mode)
Automatic operation is being executed in CNC.
S downloading
Terminate a downloading by using cnc_dwnend func-
tion.
S alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
EW_DATA data error
Program number(number) is not found or wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode The behavior of this function depends on the CNC mode.
EDIT,MEMORY mode :foreground search
Other mode :background search
(foreground search : set again selecting program.)
(background search : check whether the specified program exists
or not.)

2 – 46
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example The following program searches the program whose program number is
same as specified one, and displays the result.

#include <stdio.h>
#include ”apilib.h”

/* num is program number to be searched. */


void example( short num )
{
short ret ;
ret = cnc_search( 0, num ) ;
switch ( ret ) {
case EW_OK:
printf( ”PROGRAM O%d has been searched.¥n”, num ) ;
case EW_DATA:
printf( ”PROGRAM O%d doesn’t exist.¥n”, num ) ;
case EW_PROT:
printf( ”PROTECTED.¥n” ) ;
case EW_BUSY:
printf( ”REJECTED.¥n” ) ;
}
}

2 – 47
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(8) Delete all programs

Function Name cnc_delall

Declaration #include “apilib.h”


short FAR PASCAL cnc_delall(unsigned short FlibHndl);

Description Deletes all NC programs registered in CNC.


The protected program cannot be deleted.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY busy
S background edit processing in CNC side
Terminate background edit.
S downloading
Terminate a downloading by using cnc_dwnend
function.
S alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
S MEMORY, MDI mode in CNC side
Change CNC mode except MEMORY, MDI mode.
S ‘OP’ signal(DO)<F000#7> on
(only EDIT mode or MEMORY mode)
Automatic operation is being executed in CNC.
EW_PROT write protection in CNC side
S Protection KEY(DI) turns on.
S CNC parameter is a state of write–protection
(O8000–/O9000– protection, encoding).
See ‘Description’ about the timing of error.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function relates to the following mode.


It is possible to use in other than MEM,MDI mode.

2 – 48
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example The following program deletes all programs and displays the result.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
short ret ;
ret = cnc_delall( 0 ) ;
switch ( ret ) {
case EW_OK:
printf( ”ALL PROGRAMS has been deleted.¥n”, num ) ;
case EW_PROT:
printf( ”PROTECTED.¥n” ) ;
case EW_BUSY:
printf( ”REJECTED.¥n” ) ;
}
}

2 – 49
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(9) Delete specified


program

Function Name cnc_delete

Declaration #include “apilib.h”


short FAR PASCAL cnc_delete(unsigned short FlibHndl,short number);

Description Deletes the specified NC program registered in CNC.


The protected program cannot be deleted.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify program number.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY busy
S background edit processing in CNC side
Terminate background edit.
S downloading
Terminate a downloading by using cnc_dwnend
function.
S alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
S MDI mode in CNC side
Change CNC mode except MDI mode.
S ‘OP’ signal(DO)<F000#7> on
(only EDIT mode or MEMORY mode)
Automatic operation is being executed in CNC.
S foreground program selected by CNC
Change selected program in CNC.
EW_PROT write protection in CNC side
S Protection KEY(DI) turns on.
S CNC parameter is a state of write–protection
(O8000–/O9000– protection, encoding).
See ‘Description’ about the timing of error.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function relates to the following mode.


It is possible to use in other than MDI mode.

2 – 50
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example The following program deletes the program whose program number is
same as specified one, and displays the result.

#include <stdio.h>
#include ”apilib.h”

/* num is program number to be deleted. */


void example( short num )
{
short ret ;
ret = cnc_delete( 0, num ) ;
switch ( ret ) {
case EW_OK:
printf( ”PROGRAM O%d has been deleted.¥n”, num ) ;
case EW_DATA:
printf( ”PROGRAM O%d doesn’t exist.¥n”, num ) ;
case EW_PROT:
printf( ”PROTECTED.¥n” ) ;
case EW_BUSY:
printf( ”REJECTED.¥n” ) ;
}
}

2 – 51
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(10) Read program


directory

Function Name cnc_rdprogdir

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdprogdir(unsigned short FlibHndl,short type,
short datano_s,short datano_e,short length,PRGDIR *prgdir);

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”.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
type Specify the form of the read program list.
0 : only the program number
1 : program number and comment
2 : program number, comment, and number of use
characters.
datano_s
Specify the start program number.
datano_e
Specify the end program number.
length
Specify the length of a block(buffer size).
prgdir
Pointer to the PRGDIR structure including program directory.
The PRGDIR structure is as follows.
typedef struct prgdir {
char prg_data[MAX_PBUF] ; /* Directory data. */
} PRGDIR ; (MAX_PBUF : maximum character number
to read)

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’)

2 – 52
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Oxxxxs 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 including 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.
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 not enough for the specified program, the specified size
is read. In case of 15 bytes, the result is as follows.
type Contents to be read

0 “O12O200O201O900”
1 “%¥nO12(TEST)¥nO20”
2 “O12(TEST)420O20”

2 – 53
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Length of the block (length) is illegal.
EW_NUMBER data number error
Start program number (datano_s) or end program number
(datano_e) is illegal.
EW_ATTRIB data attribute error
Output format (type) is illegal.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program reads the registration information of NC program


included specified by the arguments, and displays program number list.

#include <stdio.h>
#include <string.h>
#include ”apilib.h”
#define BUFSIZE 256

/* start/end specify program number range. */


short example( short start, short end )
{
char buf[BUFSIZE] ;
short ret, idx ;
memset( buf, ’¥x00’, BUFSIZE ) ;
ret = cnc_rdprogdir( 0, 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’ ) ;
}

2 – 54
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(11) Read program


information

Function Name cnc_rdproginfo

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdproginfo(unsigned short FlibHndl,short type,
short length,ODBNC *prginfo);

Description Reads the management data of NC programs already registered in CNC.


The management data of NC program are
Amount of registered programs,
Amount of available programs,
Character number of used memory,
Character number of unused memory.
This function returns these data with binary format or ASCII string
format.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
type Specify the output format.
0 : binary
1 : ASCII
length
Specify the length of data block.
12 : binary
31 : ASCII
prginfo
Pointer to the ODBNC structure including the program directory.
The ODBNC structure is as follows.
typedef struct odbnc {
union {
struct {
short reg_prg ;
/* Amount of registered programs. */
short unreg_prg ;
/* Amount of available programs. */
long used_mem ;
/* Character number of used memory. */
long unused_mem ;
/* Character number of unused memory. */
} bin ;
char asc[31] ; /* Buffer for ASCII format */
}u;
} ODBNC ;

2 – 55
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

S type=0
Each data are stored in each members of the structure with
binary format.
prginfo.bin.reg_prg Amount of registered programs.
prginfo.bin.unreg_prg Amount of available programs.
prginfo.bin.used_mem
Character number of used memory.
prginfo.bin.unused_mem
Character number of unused memory.
S type=1
ASCII strings are stored in “prginfo.u.asc” with following
format.
% LF d1 LF d2 LF d3 LF d4 LF %
LF 0x0A(‘¥n’)
d1 Amount of registered programs
d2 Amount of available programs
d3 Character number of used memory
d4 Character number of unused memory
d1 – d4 are ASCII strings without the leading ‘0’.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Length of the block (length) is illegal.
EW_ATTRIB data attribute error
Output format (type) is illegal.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 56
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example The following program reads the management data of NC program, and
displays them.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBNC buf ;
short ret ;
ret = cnc_rdproginfo( 0, 0, 12, &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 ) ;
}
}

2 – 57
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(12) Read program


number under
execution

Function Name cnc_rdprgnum

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdprgnum(unsigned short FlibHndl,
ODBPRO *prgnum);

Description Reads program number of the program which is being currently selected
in CNC.
As for Power Mate, 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 running program
number.
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.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
prgnum
Pointer to the ODBPRO structure including the number of
executing program.
The ODBPRO structure is as follows.
typedef struct odbpro {
short dummy[2] ; /* Not used. */
short data ; /* Running program number. */
short mdata ; /* Main program number. */
} ODBPRO ;

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 58
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example The next program displays “CURRENT(O9876) MAIN(O1234)” while


the block “O9876/N210” of the following NC program is being executed.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
struct odbpro buf ;
cnc_rdprgnum( 0, &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 ;

2 – 59
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(13) Read sequence


number under
execution
Function Name cnc_rdseqnum

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdseqnum(unsigned short FlibHndl,
ODBSEQ *seqnum);

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.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
seqnum
Pointer to the ODBSEQ structure including the sequence number
under execution.
The ODBSEQ structure is as follows.
typedef struct odbseq {
short dummy[2] ; /* Not used. */
long data ; /* Sequence number in executing. */
} ODBSEQ ;

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 60
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example The following program displays “CURRENT N30” while the block
“O1234/N30” of the following NC program is being executed.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
struct odbact buf ;
cnc_rdseqnum( 0, &buf ) ;
printf( ”CURRENT N%ld¥n”, buf.data ) ;
}

O1234 ;
N10 M3 ;
N20 T12 ;
N30 G0 X110. ;
N40 ...

2 – 61
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(14) Read program under


execution

Function Name cnc_rdexecprog

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdexecprog(unsigned short FlibHndl,
unsigned short *length,short *blknum,char *data);

Description Read only the number of specified characters from the executing
program.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
length
Specify the address of the variable which shows the number of
characters to read.
Set the number of characters to read to this variable(*length).
After reading ends, the number of characters actually read is set in
this variable(*length) again.
blknum
Specify the address of the variable to store the block counter.
data Specify the top address of the array to store with the executing NC
program.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Length of the block (*length) is illegal.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 62
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(15) Write program for


MDI operation
Function Name cnc_wrmdiprog

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrmdiprog(unsigned short FlibHndl,
short length,char *data);

Description Outputs NC program for MDI operation to CNC.

Format of NC command NC command data to be executed to CNC is a string composed of ASCII


data to be executed characters as following format.
LF NC command1 LF NC command2 LF ... LF Mxx LF %
LF 0x0A(‘¥n’)
Mxx M code at the end of the DNC operation
(M02,M30,etc.)
‘LF’ must be placed at the top of the whole NC commands, and ‘%’ at the
end.
‘LF’s are added after each NC commands.
For example, to execute commands such as
O1234 ;
G01F0.3W10. ;
M30 ;
%
send a following string using cnc_wrmdiprog function.
cnc_wrmdiprog( 0, 24, “¥nO1234¥nG01F0.3W10.¥nM30¥%”);

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
length
Specify the number of characters of NC program to write.
1 ,.., 199
data Specify the top address of NC program data.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Length of the block (length) is illegal.
EW_DATA data error
S A character which is unavailable for NC program is de-
tected.
S When TV check is effective, a block which includes odd
characters (including ‘LF’ at the end of the block) is de-
tected.
Confirm the above–mentioned point.
EW_MODE CNC mode error
Set CNC mode to MDI.
EW_REJECT CNC execution denied

2 – 63
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function must be used in MDI mode.

2 – 64
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(16) Read execution


pointer for MDI
operation

Function Name cnc_rdmdipntr

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdmdipntr(unsigned short FlibHndl,
ODBMDIP *mdip);

Description Read the execution pointer information for MDI operating program.
The content which can be acquired is the following items.
 program number being executed
It is basically 0 for MDI operation.
When executing program is sub–program, the sub–program number
is return.
 execution block pointer
block pointer which is being currently executed in CNC.
 preread program number
program number read in advance.(displayed in green on the CNC
screen)
For MDI operating, it is basically 0, and for reading sub–program in
advance, it is the number of sub–program.
 preread block pointer
last block pointer in the program read ahead.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
mdip Pointer to the ODBMDIP structure including the execution pointer
information.
The ODBMDIP structure is as follows.
typedef struct odbmdip {
short mdiprog; /* Program number being executed. */
long mdipntr; /* Execution block pointer. */
short crntprog; /* Preread program number.*/
long crntpntr; /* Preread block pointer. */
} ODBMDIP ;

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_MODE CNC mode error


Set CNC mode to MDI.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function must be used in MDI mode.

2 – 65
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(17) Write execution


pointer for MDI
operation

Function Name cnc_wrmdipntr

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrmdipntr(unsigned short FlibHndl,
long crntpntr);

Description Specify the execution starting pointer for MDI operation.


(It is impossible to operate the execution pointer directly)
Register the MDI program previously according to the cnc_wrmdiprog()
function when executing this function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
crntpntr
Specify the block pointer to execute first.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_DATA data error


The specification of the block point to execute
first(crntpntr) is illegal.
EW_MODE CNC mode error
Set CNC mode to MDI.
EW_REJECT CNC execution denied
S Edit processing in the CNC side.
S MDI program is not registered.
Register the MDI program previously according to the
cnc_wrmdiprog() function.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function must be used in MDI mode.

2 – 66
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(18) Search specified


sequence number

Function Name cnc_seqsrch

Declaration #include “apilib.h”


short FAR PASCAL cnc_seqsrch(unsigned short FlibHndl,long seq_no);

Description Searches the specified sequence number of the selected program in CNC.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
seq_no
Specify sequence number.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_DATA data error


The specified sequence number does not exist.
EW_MODE CNC mode error
See the paragraph of CNC mode.
EW_REJECT CNC execution denied

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function must be used in MEM mode.

2 – 67
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(19) Rewind cursor of NC


program

Function Name cnc_rewind

Declaration #include “apilib.h”


short FAR PASCAL cnc_rewind(unsigned short FlibHndl);

Description Sets cursor to the top of selected NC program in CNC.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_MODE CNC mode error


See the paragraph of CNC mode.
EW_REJECT CNC execution denied

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function relates to the following mode.


It is possible to use in other than MDI mode.

2 – 68
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

3.4
RELATED TO NC Function name Brief description
DATA FILE (1) cnc_rdtofs Read tool offset value
(2) cnc_wrtofs Write tool offset value
(3) cnc_rdtofsr Read tool offset value(area specified)
(4) cnc_wrtofsr Write tool offset value(area specified)
(5) cnc_rdtofsinfo Read tool offset information
(6) cnc_rdparam Read parameter
(7) cnc_wrparam Write parameter
(8) cnc_rdparar Read parameter(area specified)
(9) cnc_wrparas Write parameter(area specified)
(10) cnc_rdparainfo Read parameter information
(11) cnc_rdsetr Read setting data(area specified)
(12) cnc_wrsets Write setting data(area specified)
(13) cnc_rdmacro Read custom macro variable
(14) cnc_wrmacro Write custom macro variable
(15) cnc_rdmacror Read custom macro variable(area specified)
(16) cnc_wrmacror Write custom macro variable(area specified)
(17) cnc_rdmacroinfo Read custom macro variable information
(18) cnc_getmactype Get type of custom macro variable
(19) cnc_setmactype Set type of custom macro variable

2 – 69
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(1) Read tool offset


value
Function Name cnc_rdtofs

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdtofs(unsigned short FlibHndl,short number,
short type,short length,ODBTOFS *tofs);

Description Reads the tool offset value specified by “number”, “type”.


The offset value is stored in “data” of “ODBTOFS” with signed binary
format.
The unit of offset value is as follows.
Linear axis
1004#1 Rotation axis
mm input inch input
(ISC) [mm] [inch] [deg]

(IS–B) 0 0.001 0.0001 0.001

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify the tool offset number.
The available number of tool offset can be got by cnc_rdtofsinfo()
function.
type Specify the tool offset type.
A zero is set up at the time of Power Mate.
length
Specify the data block length(size of ODBTOFS structure=8).
tofs Pointer to the ODBTOFS structure including the tool offset value.
The ODBTOFS structure is as follows.
typedef struct odbtofs {
short datano ; /* offset number */
short type ; /* offset type */
long data ; /* offset value */
} ODBTOFS ;

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of ODBTOFS structure(length) is wrong.
EW_NUMBER Data number error
Offset number(number) is wrong.
EW_ATTRIB Data attribute error
Offset type(type) is wrong.

2 – 70
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

CNC option There is need of CNC option for this function.

CNC parameter This function relates to the following CNC parameters.


See the manual of CNC parameter for details.
1004#0,#1

CNC mode This function can be used in any CNC mode.

Example The following program reads the offset value of specified tool number and
displays them.

#include <stdio.h>
#include ”apilib.h”

/* tidx is tool index. */


void example( short tidx )
{
ODBTOFS tofs ;
short ret ;
ret = cnc_rdtofs( 0, tidx, 0, 8, &tofs ) ;
if ( !ret ) printf( ”Z(%d) = %ld¥n”, tidx, tofs.data ) ;
}

2 – 71
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(2) Write tool offset


value

Function Name cnc_wrtofs

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrtofs(unsigned short FlibHndl,short number,
short type,short length,long data);

Description Writes the tool offset value specified by “number”, “type”.


The offset value must be stored in “data” with signed binary format.
The unit of offset value is as follows.
Linear axis
1004#1 Rotation axis
mm input inch input
(ISC) [mm] [inch] [deg]

(IS–B) 0 0.001 0.0001 0.001

The available range of offset value is as follows.


Linear axis
1004#1 Rotation axis
mm input inch input
(ISC) [mm] [inch] [deg]

(IS–B) 0 999.999 99.9999 999.999

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify the tool offset number.
The available number of tool offset can be got by cnc_rdtofsinfo()
function.
type Specify the tool offset type.
A zero is set up at the time of Power Mate.
length
Specify the data block length(size of ODBTOFS structure=8).
data Set the tool offset value.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size(length) is less than 8.
EW_NUMBER Data number error
Offset number(number) is wrong.
EW_ATTRIB Data attribute error
Offset type(type) is wrong.

2 – 72
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameters.


See the manual of CNC parameter for details.
1004#0,#1

CNC mode This function can be used in any CNC mode.

Example The following program writes the offset value of specified offset number.

#include <stdio.h>
#include ”apilib.h”

/* tidx is tool index. */


/* offset is new offset value. */
short example( short tidx, long offset )
{
short ret ;
ret = cnc_wrtofs( 0, tidx, 0, 8, offset ) ;
return ( ret ) ;
}

2 – 73
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(3) Read tool offset


value (area specified)

Function Name cnc_rdtofsr

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdtofsr(unsigned short FlibHndl,
short s_number,short type,short e_number,
short length,IODBTO *tofsr);

Description Reads the tool offset value specified by “s_number”, “e_number”, “type”.
The offset value is stored in “IODBTO” with signed binary format.
The unit of offset value is the same as “Read tool offset
value(cnc_rdtofs)”. See the description of cnc_rdtofs() function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
s_number
Specify the start tool offset number.
The available number of tool offset can be got by cnc_rdtofsinfo()
function.
e_number
Specify the end tool offset number.
type Specify the tool offset type.(see the following table)
length
Specify the data block length.(see the following table)
tofsr Pointer to the IODBTO structure including the tool offset value.
The IODBTO structure is as follows.
typedefstructiodbto {
short datano_s; /* start offset number */
short type; /* offset type */
short datano_e; /* end offset number */
union {
long m_ofs[N]; /* individual */
long m_ofs_a[N]; /* all */
}u;
} IODBTO ; /* N is number of the offset value. */
The combinations of the value specified in “type”, the data block length
“length”, the kind of offset value to be read and the member where the
result is stored in are as follows.
Type Length Attribute Offset type Member to be stored in

0 6+4*N individual Tool offset buf.u.m_ofs[i]


–1 6+4*N all Tool offset buf.u.m_ofs_a[i]

N is number of offset to be read, i = 0,..,(N–1).

2 – 74
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of ODBTOFS structure(length) is wrong.
EW_NUMBER Data number error
Offset number(number) is wrong.
EW_ATTRIB Data attribute error
Offset type(type) is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameters.


See the manual of CNC parameter for details.
1004#0,#1

CNC mode This function can be used in any CNC mode.

Example The following program reads all offset values of 99 sets and displays
them.

#include <stdio.h>
#include <stdlib.h>
#include ”apilib.h”
#define MAXTOOL 99

short example( void )


{
IODBTO *tofsr ;
short ret, idx ;
tofsr = (IODBTO *)malloc( 6+4*MAXTOOL ) ;
ret = cnc_rdtofsr( 0, 1, 0, MAXTOOL, 6+4*MAXTOOL, tofsr ) ;
if ( !ret ) {
printf( ”No Z:offset¥n” ) ;
printf( ” ¥n” ) ;
for ( idx = 0 ; idx < MAXTOOL ; idx++ ) {
printf( ”%02d%8ld¥n”,idx, tofsr–>u.m_ofs[i] ) ;
}
}
free( tofsr ) ;
return ( ret ) ;
}

2 – 75
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(4) Write tool offset


value (area specified)

Function Name cnc_wrtofsr

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrtofsr(unsigned short FlibHndl,short length,
IODBTO *tofsr);

Description Writes the tool offset value specified by “datano_s”, “datano_e”, “type”.
The offset value must be stored in “IODBTO” with signed binary format.
The unit of offset value is the same as “Write tool offset
value(cnc_wrtofs)”. See the description of cnc_wrtofs() function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
length
Specify the data block length.
tofsr Pointer to the IODBTO structure including the tool offset value.
The IODBTO structure is as follows.
typedef struct iodbto {
short datano_s; /* start offset number */
short type; /* offset type */
short datano_e; /* end offset number */
union {
long m_ofs[N]; /* individual */
long m_ofs_a[N]; /* all */
}u;
} IODBTO ; /* N is number of the offset value. */
datano_s Specify the start tool offset number.
The available number of tool offset can be got by
cnc_rdtofsinfo() function.
datano_e Specify the end tool offset number.
type Specify the tool offset type.
The combinations of the value specified in “type”, the data block length
“length”, the kind of offset value to be written and the member where the
offset value must be stored in are the same as “Read tool offset value(area
specified)(cnc_rdtofsr)”. See the description of cnc_rdtofsr() function.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of ODBTOFS structure(length) is wrong.
EW_NUMBER Data number error
Offset number(number) is wrong.
EW_ATTRIB Data attribute error
Offset type(type) is wrong.

2 – 76
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameters.


1004#0,#1

CNC mode This function can be used in any CNC mode.

Example The following program writes all tool offset values of 99 sets.

#include <stdlib.h>
#include <string.h>
#include ”apilib.h”
#define MAXTOOL 99
short example( long *offset )
{
IODBTO *tofsr ;
short ret ;
tofsr = (IODBTO *)malloc( 6+4*MAXTOOL ) ;
tofsr–>datano_s = 1 ;
tofsr–>datano_e = MAXTOOL ;
tofsr–>type = –1 ;
memcpy( &(tofsr–>u.m_ofs_a[0]), offset, 4*MAXTOOL ) ;
ret = cnc_wrtofsr( 0, 6+4*MAXTOOL, tofsr ) ;
free( tofsr ) ;
return ( ret ) ;
}

2 – 77
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(5) Read tool offset


information

Function Name cnc_rdtofsinfo

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdtofsinfo(unsigned short FlibHndl,
ODBTLINF *tlinf);

Description Reads the memory type of tool offset, and the available number of it.
Those are stored in “ofs_type” and “use_no” of “ODBTLINF” with
signed binary format.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
tlinf Pointer to the ODBTLINF structure for the tool offset information.
The ODBTLINF structure is as follows.
typedef struct odbtlinf {
short ofs_type; /* memory type */
short use_no; /* available number */
} ODBTLINF ;
ofs_type Memory type of tool offset
The offset type always becomes 0.
use_no Available number of tool offset

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 78
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(6) Read parameter

Function Name cnc_rdparam

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdparam(unsigned short FlibHndl,
short number,short axis,short length,IODBPSD *param);

Description Reads the parameter specified by “number”,“axis”(only for the parameter


with axis). The data format depends on each parameter. The format of
Byte/Word/2–Word parameter is generally signed binary.
Reads the parameter for all axes once by specifying ‘ALL_AXES’ in
‘axis’. The parameter for each axis is stored in each array of “IODBPSD”.
The attribute of CNC parameter depends on the type and axis, and it is
different for each parameter. It is as follows, and can be got by
cnc_rdparainfo() function.
Parameter type Use Byte size

Bit parameter Every bits have each definition. 1


Bit parameter with axis Every bits have each definition. 1
(each axis)
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

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.
See the “PARAMETER MANUAL” of CNC for details of each
parameter.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify the parameter number.
See the “PARAMETER MANUAL” of CNC about available
parameter number. It can be got by cnc_rdparainfo() function.
axis Specify the axis number.
ALL_AXES : assigns all axes(ALL_AXES=–1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)

2 – 79
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

length
Specify the data block length(size of IODBPSD structure).
(4+(byte size of parameter)*(number of axis))
In case that the size of parameter is 4 byte, the IODBPSD structure
is as follows. In case that its size is 1 or 2 byte, the size of data part
per 1 parameter or 1 axis is 1 or 2 byte.

no axis/1 axis all axes


IODBPSD 0 0
datano datano
2 2
type length type length
4 4
ldata ldatas[0]:1st
8 8

4+2x(n–1)
ldatas[n–1]:n–th
4+2xn
n : Current controlled axes

param
Pointer to the IODBPSD structure including the parameter.
The IODBPSD structure is as follows.
typedef struct iodbpsd {
short datano; /* parameter number */
short type; /* axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2–word parameter */
char cdatas[MAX_AXIS]; /* bit/byte parameter
with axis*/
short idatas[MAX_AXIS]; /* word parameter
with axis */
long ldatas[MAX_AXIS]; /* 2–word parameter
with axis */
}u;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */
datano Parameter number which was read is stored.
type Attribute of parameter which was read is stored.
axis
ALL_AXES : all axes(ALL_AXES=–1)
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)

2 – 80
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of IODBPSD structure(length) is wrong.
EW_NUMBER Data number error
Parameter number(number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program reads axes name of controlled axes (number of
axis=MAX_AXIS), and displays them.

#include <stdio.h>
#include <stdlib.h>
#include ”apilib.h”

void example( void )


{
ODBSYS info ;
IODBPSD param ;
short ret, idx, axno ;
cnc_sysinfo( &info ) ;
axno = atoi( info.axes ) ;
ret = cnc_rdparam( 0, 1020, –1, 4+1*MAX_AXIS, &param ) ;
for ( idx = 0 ; idx < axno ; idx++ ) {
printf( ”#%d”, idx+1 ) ;
if ( param.u.cdatas[idx] == 0 )
printf( ”¥033[7m%c¥033[27m¥n”, idx+’1’ ) ;
else
printf( ”%c¥n”, param.u.cdatas[idx] ) ;
}
}

2 – 81
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(7) Write parameter

Function Name cnc_wrparam

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrparam(unsigned short FlibHndl,short length,
IODBPSD *param);

Description Writes the parameter specified by “datano”,“type”(only for the parameter


with axis). The data format depends on each parameter. The format of
Byte/Word/2–Word parameter is generally signed binary.
Writes the parameter for all axes once by specifying ‘ALL_AXES’ in
‘type’. The parameter for each axis must be stored in each array of
“IODBPSD”.
The attribute of CNC parameter depends on the type and axis, and it is
different for each parameter. It is as follows, and can be got by
cnc_rdparainfo() function.
Parameter type Use Byte size

Bit parameter Every bits have each definition. 1


Bit parameter with axis Every bits have each definition. 1
(each axis)
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

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.
PS000 alarm:“PLEASE TURN OFF POWER” may be issued when some
specific parameters are written.
See the “PARAMETER MANUAL” of CNC for details of each
parameter.

2 – 82
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
length
Specify the data block length(size of IODBPSD structure).
(4+(byte size of parameter)*(number of axis))
In case that the size of parameter is 4 byte, the IODBPSD structure
is as follows. In case that its size is 1 or 2 byte, the size of data part
per 1 parameter or 1 axis is 1 or 2 byte.

no axis/1 axis all axes


IODBPSD 0 0
datano datano
2 2
type length type length
4 4
ldata ldatas[0]:1st
8 8

4+2x(n–1)
ldatas[n–1]:n–th
4+2xn
n : Current controlled axes

param
Pointer to the IODBPSD structure including the parameter.
The IODBPSD structure is as follows.
typedef struct iodbpsd {
short datano; /* parameter number */
short type; /* axis number */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2–word parameter */
char cdatas[MAX_AXIS]; /* bit/byte parameter
with axis*/
short idatas[MAX_AXIS] ; /* word parameter
with axis */
long ldatas[MAX_AXIS]; /* 2–word parameter
with axis */
}u;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */
datano Specify the parameter number.
See the “PARAMETER MANUAL” of CNC about available
parameter number. It can be got by cnc_rdparainfo() function.
type Specify the axis number.
ALL_AXES : assigns all axes(ALL_AXES=–1)
0 : assigns no axis
1,..,m : assigns 1 axis
(m=max. controlled axes)

2 – 83
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of IODBPSD structure(length) is wrong.
EW_NUMBER Data number error
Parameter number(datano) is wrong.
EW_ATTRIB Data attribute error
Axis number(type) is wrong.
EW_NOOPT No option
There is no option required for the specified parameter.
EW_PROT Write operation is prohibited.

CNC option In case of Power Mate, there may be need of CNC option for some specific
parameters.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program writes the parameter of stroke limit check for the
specified axis.

#include ”apilib.h”

/* axis is axis index. */


/* plus and minus are plus and minus position of stroke limit. */
short example( short axis, long plus, long minus)
{
IODBPSD param ;
short ret ;
param.datano = 1320 ;
param.type = axis ;
param.u.ldata = plus ;
ret = cnc_wrparam( 0, 4+4*1, &param ) ;
if ( ret ) return ( ret ) ;
param.datano = 1321 ;
param.type = axis ;
param.u.ldata = minus ;
ret = cnc_wrparam( 0, 4+4*1, &param ) ;
return ( ret ) ;
}

2 – 84
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(8) Read parameter


(area specified)

Function Name cnc_rdparar

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdparar(unsigned short FlibHndl,
(short *)&s_number,short axis,(short *)&e_number,
(short *)&length,(void *)param);

Description Reads the parameter specified by “s_number”, “e_number”, “axis”(only


for the parameter with axis). The data format depends on each parameter.
The format of Byte/Word/2–Word parameter is generally signed binary.
Reads the parameter for all axes specified range by specifying
‘ALL_AXES’ in ‘axis’.
The attribute of CNC parameter depends on the type and axis, and it is
different for each parameter. It is as follows, and can be got by
cnc_rdparainfo() function.
Parameter type Use Byte size

Bit parameter Every bits have each definition. 1


Bit parameter with axis Every bits have each definition. 1
(each axis)
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

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.
See the “PARAMETER MANUAL” of CNC for details of each
parameter.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
s_number
Specify the start parameter number.
The first parameter number to be read is returned.
See the “PARAMETER MANUAL” of CNC about available
parameter number. It can be got by cnc_rdparainfo() function.

2 – 85
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

e_number
Specify the end parameter number.
The last parameter number to be read is returned.
The new parameter may be added according to updating CNC
software, addition of the new function, etc. If the new parameter
is added within reading range, the error(Return: EW_LENGTH)
will be returned or the application program will not work correctly.
In order to avoid these mistakes, specify the continuous numbers
of existing parameters as the reading range.
axis Specify the axis number.
ALL_AXES : assigns all axes(ALL_AXES=–1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)
None axis type parameter can be read even if any value is specified
in “axis”. In case that an axis type parameter exists in the specified
range, the error(Return:EW_ATTRIB) is returned by specifying
“axis=0”.
length
Specify the data block length which is enough to store the specified
parameter.
The structure per 1 parameter is as follows, and each parameter is
lined up in order of number.
[= Sum of (4+(byte size of each parameter)*(number of axis))]
Because the size to be read is returned, it is possible to specify the
length more than the actual size.
In case that the size of parameter is 1 byte, the IODBPSD structure
is as follows.
In case that the size of parameter is 1 byte and the length per 1
parameter is an odd number, ‘dummy’ is necessary in the end of
structure. In case that its size is 2 or 4 byte, the size of data part per
1 parameter or 1 axis is 2 or 4 byte, and so ‘dummy’ is not
necessary.

no axis/1 axis all axes


IODBPSD 0 0
datano datano
2 2
type length/parameter type length/
4 4 param.
cdata cdatas[0]:1st
5 5
dummy
6 4+1x(n–1)
cdatas[n–1]:n–th
4+1xn
dummy (in case of
n=odd num.)

n : Maximum controlled axes

2 – 86
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

param
Pointer to the area to store the parameters.
Each parameter can be referred by using the IODBPSD structure.
typedef struct iodbpsd {
short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2–word parameter */
char cdatas[MAX_AXIS]; /* bit/byte parameter
with axis*/
short idatas[MAX_AXIS]; /* word parameter
with axis */
long ldatas[MAX_AXIS]; /* 2–word parameter
with axis */
}u;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */
datano Parameter number which was read is stored.
type Attribute of parameter which was read is stored.
Upper byte:type
0 : bit type
1 : byte type
2 : word type
3 : 2–word type
Lower byte:axis
ALL_AXES : all axes(ALL_AXES=–1)
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of area to store parameter(length) is wrong.
EW_NUMBER Data number error
Parameter number(s_number,e_number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 87
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Example The following program reads the parameter within the specified number
range and axis, and displays them.

#include <stdio.h>
#include <stdlib.h>
#include ”apilib.h”

/* start/end are start/end number to be read, axis is axis number. */


short example( short start, short end, short axis )
{
ODBSYS info ;
IODBPSD *param, *ptr ;
short ret, idx1, idx2, axno, inc ;
cnc_sysinfo( 0, &info ) ;
axno = atoi( info.axes ) ;
param = (IODBPSD *)calloc( 1, 1000 ) ;
ret = cnc_rdparar( 0, start, axis, end, 1000, param ) ;
ptr = param ;
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 ;
}
}
putchar( ’¥n’ ) ;
ptr = (IODBPSD *)(((char *)ptr)+4+8*inc) ;
break ;

2 – 88
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

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 = (IODBPSD *)(((char *)ptr)+4+inc) ;
break ;
}
}
}
else
printf( ”ERROR!(%d)¥n”, ret ) ;
free( param ) ;
return ( ret ) ;
}

2 – 89
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(9) Write parameter


(area specified)

Function Name cnc_wrparas

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrparas(unsigned short FlibHndl,short length,
(void *)param);

Description Writes all parameters stored in “param”.


The data format depends on each parameter. The format of Byte/Word/
2–Word parameter is generally signed binary.
Writes the parameter for all axes once by specifying ‘ALL_AXES’ in
‘type’. The parameter for each axis must be stored in each array of
“IODBPSD”.
The attribute of CNC parameter depends on the type and axis, and it is
different for each parameter. It is as follows, and can be got by
cnc_rdparainfo() function.
Parameter type Use Byte size

Bit parameter Every bits have each definition. 1


Bit parameter with axis Every bits have each definition. 1
(each axis)
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

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.
PS000 alarm:“PLEASE TURN OFF POWER” may be issued when some
specific parameters are written.
See the “PARAMETER MANUAL” of CNC for details of each
parameter.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
length
Specify the data block length which is enough to store the specified
parameter.
The structure per 1 parameter is as follows, and each parameter
must be lined up in order of number.
[= Sum of (4+(byte size of each parameter)*(number of axis))]

2 – 90
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

In case that the size of parameter is 1 byte, the IODBPSD structure


is as follows.
In case that the size of parameter is 1 byte and the length per 1
parameter is an odd number, ‘dummy’ is necessary in the end of
structure. In case that its size is 2 or 4 byte, the size of data part per
1 parameter or 1 axis is 2 or 4 byte, and so ‘dummy’ is not
necessary.

no axis/1 axis all axes


IODBPSD 0 0
datano datano
2 2
type length/parameter type length/
4 4 param.
cdata cdatas[0]:1st
5 5
dummy
6 4+1x(n–1)
cdatas[n–1]:n–th
4+1xn
dummy (in case of
n=odd num.)
n : Maximum controlled axes

param
Pointer to the area to store the parameters.
Each parameter can be referred by using the IODBPSD structure.
typedef struct iodbpsd {
short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2–word parameter */
char cdatas[MAX_AXIS]; /* bit/byte parameter
with axis*/
short idatas[MAX_AXIS]; /* word parameter with axis */
long ldatas[MAX_AXIS]; /* 2–word parameter
with axis */
}u;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */
datano Specify the parameter number.
See the “PARAMETER MANUAL” of CNC about available
parameter number. It can be got by cnc_rdparainfo() function.
type Specify the attribute of parameter.
Upper byte:type
0 : bit type
1 : byte type
2 : word type
3 : 2–word type
Lower byte:axis
ALL_AXES : assigns all axes(ALL_AXES=–1)
0 : assigns no axis
1,..,m : assigns 1 axis (m=max. controlled axes)

2 – 91
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of area to store parameter(length) is wrong.
EW_NUMBER Data number error
Parameter number(datano) is wrong.
EW_ATTRIB Data attribute error
Axis number(type) is wrong.
EW_NOOPT No option
There is no option required for the specified parameter.
EW_PROT Write operation is prohibited.

CNC option In case of Power Mate, there may be need of CNC option for some specific
parameters.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program writes M codes for macro call in No.6080,..,
No.6089.

#include <stdlib.h>
#include ”apilib.h”
short example( short *mcode )
{
IODBPSD *param, *ptr ;
short ret, idx ;
param = (IODBPSD *)calloc( 1, 100 ) ;
ptr = param ;
for ( idx = 0 ; idx < 10 ; idx++ ) {
ptr–>datano = 6080 + idx ;
ptr–>type = 0 ;
ptr–>cdata = mcode[idx] ;
ptr = (IODBPSD *)(((char *)ptr)+6) ;
}
ret = cnc_wrparar( 0, 6*10, param ) ;
free( param ) ;
return ( ret ) ;
}

2 – 92
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(10) Read parameter


information

Function Name cnc_rdparainfo

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdparainfo(unsigned short FlibHndl,
short s_number,unsigned short read_no,ODBPARAIF *paraif);

Description The information specified by “s_number” and ”read_no” are read.


The CNC parameter is basically non–continuous, and the attribute like the
type and the size, etc. is different in each number.
Use for such as displaying the parameter.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
s_number
Specify the start parameter number.
read_no
Specify the number of the parameter information to read.
paraif
Pointer to the ODBPARAIF structure including the parameter
information. The ODBPARAIF structure is as follows.
typedef struct odbparaif {
unsigned short info_no ;
/* number of parameter information */
short prev_no ;
/* previous parameter number */
short next_no ;
/* next parameter number */
struct {
short prm_no ; /* parameter number */
short prm_type ; /* attribute of parameter */
} info[N] ;/* N is amount of parameter information */
} ODBPARAIF ;
info_no Number of parameter information
Number of parameter information read actually.
prev_no Previous parameter number
Effective number ahead of parameter information read
first.
next_no Next parameter number
Effective number after parameter information read at the
end.
info[N].prm_no
Parameter number
Parameter number which exists actually.

2 – 93
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

info[N].prm_type
Attribute of parameter
The following attributes are set.
bit 0,1 : type attribute
0 : bit type 2 : word type
1 : bite type 3 : 2–word type
bit 2 : axis attribute
0 : without axis
1 : with axis
bit 3 : sign
0 : with sign
1 : without sign
bit 4 : settings input
0 : disable 1 : enable
bit 5 : write protection
0 : enable 1 : disable
bit 6 : power must be off after writing
0 : not necessary
1 : necessary
bit 7 : read protection
0 : enable 1 : disable
bit 8 : spindle parameter
0 : no spindle 1 : spindle
bit 9 – 15:(reserve)

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_NUMBER data number error


Start parameter number(s_number)is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 94
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(11) Read setting data


(area specified)

Function Name cnc_rdsetr

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdsetr(unsigned short FlibHndl,
(short *)&s_number,short axis,(short *)&e_number,
(short *)&length,(void *)set);

Description Reads the setting data specified by “s_number”, “e_number”, “axis”(only


for the setting data with axis). The data format depends on each setting
data. The format of Byte/Word/2–Word setting data is generally signed
binary.
Reads the setting data for all axes specified range by specifying
‘ALL_AXES’ in ‘axis’.
The attribute of setting data depends on the type and axis, and it is
different for each setting data.
Setting data type Use Byte size

Bit setting data Every bits have each definition. 1


Bit setting data with axis Every bits have each definition. 1
(each axis)
Byte setting data 1–byte data is stored. 1
Byte setting data with axis 1–byte data is stored.(each axis) 1
Word setting data 2–byte data is stored. 2
Word setting data with axis 2–byte data is stored.(each axis) 2
2–Word setting data 4–byte data is stored. 4
2–Word setting data with ax. 4–byte data is stored.(each axis) 4

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 “Read parameter(area specified)
(cnc_rdparar)” except that it cannot read the parameter without setting
attribute.
See the “PARAMETER MANUAL” of CNC for details of each setting
data.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
s_number
Specify the start setting data number.
The first setting data number to be read is returned.
See the “PARAMETER MANUAL” of CNC about available
setting data number.

2 – 95
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

e_number
Specify the end setting data number.
The last setting data number to be read is returned.
The new setting data may be added according to updating CNC
software, addition of the new function, etc. If the new setting data
is added within reading range, the error(Return: EW_LENGTH)
will be returned or the application program will not work correctly.
In order to avoid these mistakes, specify the continuous numbers
of existing setting data as the reading range.
axis Specify the axis number.
ALL_AXES : assigns all axes(ALL_AXES=–1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)
None axis type setting data can be read even if any value is specified
in “axis”. In case that an axis type setting data exists in the
specified range, the error(Return:EW_ATTRIB) is returned by
specifying “axis=0”.
length
Specify the data block length which is enough to store the specified
setting data.
The structure per 1 setting data is as follows, and each setting data
is lined up in order of number.
[= Sum of (4+(byte size of each setting data)*(number of axis))]
Because the size to be read is returned, it is possible to specify the
length more than the actual size.
In case that the size of setting data is 1 byte, the IODBPSD structure
is as follows.
In case that the size of setting data is 1 byte and the length per 1
setting data is an odd number, ‘dummy’ is necessary in the end of
structure. In case that its size is 2 or 4 byte, the size of data part per
1 setting data or 1 axis is 2 or 4 byte, and so ‘dummy’ is not
necessary.

no axis/1 axis all axes


IODBPSD 0 0
datano datano
2 2
type length/setting data type length/
4 4 set.data
cdata cdatas[0]:1st
5 5
dummy
6 4+1x(n–1)
cdatas[n–1]:n–th
4+1xn
dummy (in case of
n=odd num.)

n : Maximum controlled axes

2 – 96
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

set Pointer to the area to store the setting data.


Each setting data can be referred by using the IODBPSD structure.
typedef struct iodbpsd {
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 */
char cdatas[MAX_AXIS]; /* bit/byte set. data
with axis*/
short idatas[MAX_AXIS]; /* word setting data
with axis */
long ldatas[MAX_AXIS]; /* 2–word set. data
with axis */
}u;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */
datano Setting data number which was read is stored.
type Attribute of setting data which was read is stored.
Upper byte:type
0 : bit type
1 : byte type
2 : word type
3 : 2–word type
Lower byte:axis
ALL_AXES : all axes(ALL_AXES=–1)
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of area to store setting data(length) is wrong.
EW_NUMBER Data number error
Setting data number(s_number,e_number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 97
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(12) Write setting data


(area specified)

Function Name cnc_wrsets

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrsets(unsigned short FlibHndl,short length,
(void *)set);

Description Writes all setting data stored in “set”.


The data format depends on each setting data. The format of Byte/Word/
2–Word setting data is generally signed binary.
Writes the setting data for all axes once by specifying ‘ALL_AXES’ in
‘type’. The setting data for each axis must be stored in each array of
“IODBPSD”.
The attribute of setting data depends on the type and axis, and it is
different for each setting data.
Setting data type Use Byte size

Bit setting data Every bits have each definition. 1


Bit setting data with axis Every bits have each definition. 1
(each axis)
Byte setting data 1–byte data is stored. 1
Byte setting data with axis 1–byte data is stored.(each axis) 1
Word setting data 2–byte data is stored. 2
Word setting data with axis 2–byte data is stored.(each axis) 2
2–Word setting data 4–byte data is stored. 4
2–Word setting data with ax. 4–byte data is stored.(each axis) 4

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 “Write parameter(area specified)
(cnc_wrparas)” except that it cannot write the parameter without setting
attribute.
See the “PARAMETER MANUAL” of CNC for details of each setting
data.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

2 – 98
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

length
Specify the data block length which is enough to store the specified
setting data.
The structure per 1 setting data is as follows, and each setting data
must be lined up in order of number.
[= Sum of (4+(byte size of each setting data)*(number of axis))]
In case that the size of setting data is 1 byte, the IODBPSD structure
is as follows.
In case that the size of setting data is 1 byte and the length per 1
setting data is an odd number, ‘dummy’ is necessary in the end of
structure. In case that its size is 2 or 4 byte, the size of data part per
1 setting data or 1 axis is 2 or 4 byte, and so ‘dummy’ is not
necessary.

no axis/1 axis all axes


IODBPSD 0 0
datano datano
2 2
type length/setting data type length/
4 4 set.data
cdata cdatas[0]:1st
5 5
dummy
6 4+1x(n–1)
cdatas[n–1]:n–th
4+1xn
dummy (in case of
n=odd num.)
n : Maximum controlled axes

set Pointer to the area to store the setting data.


Each setting data can be referred by using the IODBPSD structure.
typedef struct iodbpsd {
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 */
char cdatas[MAX_AXIS]; /* bit/byte set. data
with axis*/
short idatas[MAX_AXIS]; /* word setting data
with axis */
long ldatas[MAX_AXIS]; /* 2–word set. data
with axis */
}u;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */
datano Specify the setting data number.
See the “PARAMETER MANUAL” of CNC about available
setting data number.

2 – 99
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

type Specify the attribute of setting data.


Upper byte:type
0 : bit type
1 : byte type
2 : word type
3 : 2–word type
Lower byte:axis
ALL_AXES : assigns all axes(ALL_AXES=–1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of area to store setting data(length) is wrong.
EW_NUMBER Data number error
Setting data number(datano) is wrong.
EW_ATTRIB Data attribute error
Axis number(type) is wrong.
EW_NOOPT No option
There is no option required for the specified setting data.

CNC option In case of Power Mate, there may be need of CNC option for some specific
setting data.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 100
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(13) Read custom macro


variable

Function Name cnc_rdmacro

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdmacro(unsigned short FlibHndl,
short number,short length,ODBM *macro);

Description Reads the custom macro variable specified by “number”.


The data is stored in “ODBM” with signed binary format.
The kinds of custom macro variable are as follows.
1) Local variable(#1,..,#33)
The local variables which belong to the macro program just being
executed when the application program calls this function are read.
2) Common variable(#100,..)
See the description of cnc_rdmacroinfo() function about the available
range of common variables.
It is possible to exchange the type of macro variable by cnc_setmactype()
function.
S fixed–point type(data format=M*10**(–E))
mcr_val : value of variable(=M)
4–byte singed binary data
(available range:
Power Mate –99999999,..,99999999)
dec_val : number of places of decimals(=E)
2–byte singed binary data
(available range:
Power Mate –1,0,..,8)
* In case of Power Mate, specify the floating–point type when
the data is beyond above limitation, because ‘mcr_val’ and
‘dec_val’ are invalid(=–1) in such case.
S floating–point type(data format=M*2**(–E))
mcr_val : numerical part of variable(=M)
4–byte singed binary data
(available range:No limitation)
dec_val : exponent part of variable(=E)
2–byte singed binary data
(available range:–128,..,127)
The value of an undefined variable is called “vacant”, and it is as follows
both under fixed–point type and under floating–point type.
mcr_val = 0
dec_val = –1
See “OPERATOR’S MANUAL” of CNC for details of the custom macro
variable.

2 – 101
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify the custom macro variable number.
length
Specify the data block length(size of ODBM structure=10).

ODBM 0
datano
2
dummy
4 length
mcr_val
8
dec_val
10

macro
Pointer to the ODBM structure including the custom macro
variable. The ODBM structure is as follows.
typedef struct odbm {
short datano ; /* custom macro variable number */
short dummy ; /* (not used) */
long mcr_val ; /* value of custom macro variable */
short dec_val ; /* number of places of decimals */
} ODBM ;

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of ODBM structure(length) is wrong.
EW_NUMBER Data number error
Custom macro variable number(number) is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 102
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example The following program reads the custom macro variable data of specified
number and displays it.

#include <stdio.h>
#include <string.h>
#include ”apilib.h”

/* number is variable number to be read. */


short example( short number )
{
ODBM macro ;
char strbuf[11] ;
short ret ;
ret = cnc_rdmacro( 0, number, 10, &macro ) ;
if ( !ret ) {
sprintf( &strbuf[1], ”%09ld”, macro.mcr_val ) ;
if ( strbuf[1] == ’0’ ) strbuf[1] = ’ ’ ;
strncpy( &strbuf[0], &strbuf[1], 9 – macro.dec_val ) ;
strbuf[9–macro.dec_val] = ’.’ ;
printf( ”%s¥n”, strbuf ) ;
}
else
printf( ”**********¥n” ) ;
return ( ret ) ;
}

2 – 103
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(14) Write custom macro


variable

Function Name cnc_wrmacro

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrmacro(unsigned short FlibHndl,
short number,short length,long mcr_val,short dec_val);

Description Writes the custom macro variable specified by “number”.


The data must be stored in “mcr_val”, “dec_val” with signed binary
format.
The kind of custom macro variable is as follows.
The local variable cannot be written.
1) Common variable(#100,..)
See the description of cnc_rdmacroinfo() function about the available
range of common variables.
It is possible to exchange the type of macro variable by cnc_setmactype()
function.
S fixed–point type(data format=M*10**(–E))
mcr_val : value of variable(=M)
4–byte singed binary data
(available range:
Power Mate –99999999,..,99999999)
dec_val : number of places of decimals(=E)
2–byte singed binary data
(available range:
Power Mate –1,0,..,8)
* In case of Power Mate, specify the floating–point type when
the data is beyond above limitation, because the
error(Return:EW_DATA) is returned in such case.
S floating–point type(data format=M*2**(–E))
mcr_val : numerical part of variable(=M)
4–byte singed binary data
(available range:No limitation)
dec_val : exponent part of variable(=E)
2–byte singed binary data
(available range:–128,..,127)
The value of an undefined variable is called “vacant”, and it is as follows
both under fixed–point type and under floating–point type.
mcr_val = 0
dec_val = –1
See “OPERATOR’S MANUAL” of CNC for details of the custom macro
variable.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify the custom macro variable number.
length
Specify the data block length(=10).

2 – 104
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

mcr_val
Specify the value of variable/numerical part of variable.
dec_val
Specify the number of places of decimals/exponent part of
variable.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size(length) is wrong.
EW_NUMBER Data number error
Custom macro variable number(number) is wrong.
EW_DATA Data error
Value of custom macro variable(mcr_val, dec_val) is out of
available range.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program writes the specified value in the specified custom
macro variable.

#include ”apilib.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( 0, number, 10, value, dec ) ;
return ( ret ) ;
}

2 – 105
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(15) Read custom macro


variable
(area specified)

Function Name cnc_rdmacror

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdmacror(unsigned short FlibHndl,
short s_number,short e_number,short length,IODBMR *macror);

Description Reads the custom macro variable specified by “s_number”, “e_number”.


The data is stored in “IODBMR” with signed binary format.
The kinds of custom macro variable are as follows.
1) Local variable(#1,..,#33)
The local variables which belong to the macro program just being
executed when the application program calls this function are read.
2) Common variable(#100,..)
See the description of cnc_rdmacroinfo() function about the available
range of common variables.
It is possible to exchange the type of macro variable by cnc_setmactype()
function.
S fixed–point type(data format=M*10**(–E))
mcr_val : value of variable(=M)
4–byte singed binary data
(available range:
Power Mate –99999999,..,99999999)
dec_val : number of places of decimals(=E)
2–byte singed binary data
(available range:
Power Mate –1,0,..,8)
* In case of Power Mate, specify the floating–point type when
the data is beyond above limitation, because ‘mcr_val’ and
‘dec_val’ are invalid(=–1) in such case.
S floating–point type(data format=M*2**(–E))
mcr_val : numerical part of variable(=M)
4–byte singed binary data
(available range:No limitation)
dec_val : exponent part of variable(=E)
2–byte singed binary data
(available range:–128,..,127)
The value of an undefined variable is called “vacant”, and it is as follows
both under fixed–point type and under floating–point type.
mcr_val = 0
dec_val = –1
See “OPERATOR’S MANUAL” of CNC for details of the custom macro
variable.

2 – 106
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
s_number
Specify the start custom macro variable number.
e_number
Specify the end custom macro variable number.
length
Specify the data block length(size of IODBMR structure).
(6+6*(Number of custom macro variable)

IODBMR 0
datano_s
2
dummy
4
datano_e
6
data[0].mcr_val length
10
data[0].dec_val
12

6+6*(N–1)
data[N–1].mcr_val

data[N–1].dec_val
6+6*N

N : Number of custom macro variable

macror
Pointer to the IODBMR structure including the custom macro
variable. The IODBMR structure is as follows.
typedef struct iodbmr {
short datano_s; /* start custom macro variable number */
short dummy; /* (not used) */
short datano_e; /* end custom macro variable number */
struct {
longmcr_val; /* value of custom macro var. */
short dec_val; /* number of places of decimals*/
} data[N]; /* N : number of variable */
} IODBMR;
datano_s The first custom macro variable number to be read is
returned.
datano_e The last custom macro variable number to be read is
returned.

2 – 107
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of IODBMR structure(length) is wrong.
EW_NUMBER Data number error
Custom macro variable number(s_number, e_number) is
wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program reads the custom macro variables within the
specified range and displays them.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include ”apilib.h”

/* start/end are start/end variable number to be read. */


short example( short start, short end )
{
IODBMR *macror ;
char strbuf[11] ;
short ret, idx ;
macror = (IODBMR *)malloc( 1000 ) ;
ret = cnc_rdmacror( 0, start, end, 1000, macror ) ;
if ( !ret )
for ( idx = 0 ; idx <= end–start ; idx++ ) {
sprintf( &strbuf[1], ”%09ld”,
macror–>data[idx].mcr_val ) ;
if ( strbuf[1] == ’0’ ) strbuf[1] = ’ ’ ;
strncpy( &strbuf[0], &strbuf[1],
9 – macror–>data[idx].dec_val ) ;
strbuf[9–macror–>data[idx].dec_val] = ’.’ ;
printf( ”#%04d %s¥n”, start+idx, strbuf ) ;
}
else
printf( ”ERROR!(%d)¥n”, ret ) ;
free( macror ) ;
return ( ret ) ;
}

2 – 108
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(16) Write custom macro


variable
(area specified)

Function Name cnc_wrmacror

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrmacror(unsigned short FlibHndl,
short length,IODBMR *macror);

Description Writes the custom macro variable specified by “datano_s”, “datano_e”.


The data must be stored in “IODBMR” with signed binary format.
The kind of custom macro variable is as follows.
The local variable cannot be written.
1) Common variable(#100,..)
See the description of cnc_rdmacroinfo() function about the available
range of common variables.
It is possible to exchange the type of macro variable by cnc_setmactype()
function.
S fixed–point type(data format=M*10**(–E))
mcr_val : value of variable(=M)
4–byte singed binary data
(available range:
Power Mate –99999999,..,99999999)
dec_val : number of places of decimals(=E)
2–byte singed binary data
(available range:
Power Mate –1,0,..,8)
* In case of Power Mare, specify the floating–point type when
the data is beyond above limitation, because the error
(Return:EW_DATA) is returned in such case.
S floating–point type(data format=M*2**(–E))
mcr_val : numerical part of variable(=M)
4–byte singed binary data
(available range:No limitation)
dec_val : exponent part of variable(=E)
2–byte singed binary data
(available range:–128,..,127)
The value of an undefined variable is called “vacant”, and it is as follows
both under fixed–point type and under floating–point type.
mcr_val = 0
dec_val = –1
See “OPERATOR’S MANUAL” of CNC for details of the custom macro
variable.

2 – 109
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
length
Specify the data block length(size of IODBMR structure).
(6+6*(Number of custom macro variable)

IODBMR 0
datano_s
2
dummy
4
datano_e
6
data[0].mcr_val length
10
data[0].dec_val
12

6+6*(N–1)
data[N–1].mcr_val

data[N–1].dec_val
6+6*N
N : Number of custom macro variable

macror
Pointer to the IODBMR structure including the custom macro
variable. The IODBMR structure is as follows.
typedef 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; /* value of custom macro var. */
short dec_val; /* number of places of decimals*/
} data[N]; /* N : number of variable */
} IODBMR;
datano_s Specify the start custom macro variable number.
datano_e Specify the end custom macro variable number.
mcr_val Specify the value of variable/numerical part of variable.
dec_val Specify the number of places of decimals/exponent part of
variable.

2 – 110
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of IODBMR structure(length) is wrong.
EW_NUMBER Data number error
Custom macro variable number(datano_s, datano_e) is
wrong.
EW_DATA Data error
Value of custom macro variable(mcr_val, dec_val) is out of
available range.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program writes the specified values into the custom macro
variables within the specified range.

#include <stdlib.h>
#include ”apilib.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 )
{
IODBMR *macror ;
short ret, idx ;
macror = (IODBMR *)malloc( 6+6*number ) ;
macror–>datano_s = start ;
macror–>datano_e = start + number – 1 ;
for ( idx = 0 ; idx < number ; idx++ ) {
macror–>data[idx].mcr_val = value[idx] ;
macror–>data[idx].dec_val = 0 ;
}
ret = cnc_wrmacror( 0, 6+6*number, macror ) ;
free( macror ) ;
return ( ret ) ;
}

2 – 111
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(17) Read custom macro


variable information

Function Name cnc_rdmacroinfo

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdmacroinfo(unsigned short FlibHndl,
ODBMVINF *mvinf);

Description Reads the available number of the local macro variable and the common
macro variable. Those are stored in “use_no1”, “use_no2” of
“ODBMVINF” with signed binary format.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
mvinf
Pointer to the ODBMVINF structure including the custom macro
variable information. The ODBMVINF structure is as follows.
typedef struct odbmvinf {
short use_no1 ; /* number of local variable */
short use_no2 ; /* indicator of common variable */
} ODBMVINF ;
use_no1 Available number of local macro variable(33 sets)
use_no2 Indicator of available common variable
0 : 100,..,149, 500,..,531
1 : 100,..,199, 500,..,999
2 : 100,..,199, 500,..,699

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 112
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(18) Get type of custom


macro variable

Function Name cnc_getmactype

Declaration #include “apilib.h”


short FAR PASCAL cnc_getmactype(unsigned short FlibHndl,
(short *) &macro_type);

Description Gets the type of custom macro variable which is used by cnc_rdmacro,
cnc_wrmacro, cnc_rdmacror, cnc_wrmacror function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
macro_type
Custom macro variable type
0 :Fixed–point type (default)
none 0 :Floating–point type

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 113
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(19) Set type of custom


macro variable

Function Name cnc_setmactype

Declaration #include “apilib.h”


short FAR PASCAL cnc_setmactype(unsigned short FlibHndl,
short macro_type);

Description Changes the type of custom macro variable which is used by


cnc_rdmacro, cnc_wrmacro, cnc_rdmacror, cnc_wrmacror function.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
macro_type
Custom macro variable type
0 :Fixed–point type (default)
none 0 :Floating–point type

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 114
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

3.5
RELATED TO Function name Brief description
OPERATION HISTORY (1) cnc_stopophis Stop logging operation history data
DATA (2) cnc_startophis Restart logging operation history data
(3) cnc_rdophisno Read number of operation history data
(4) cnc_rdophistry Read operation history data
(5) cnc_rdalmhisno Read number of alarm history data
(6) cnc_rdalmhistry Read alarm history data
(7) cnc_clearophis Clear operation history data
(8) cnc_rdhissgnl Read signals related operation history
(9) cnc_wrhissgnl Write signals related operation history

2 – 115
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(1) Stop logging


operation history
data
Function Name cnc_stopophis

Declaration #include “apilib.h”


short FAR PASCAL cnc_stopophis(unsigned short FlibHndl);

Description Stops sampling the operation history data and the alarm history data of
CNC.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 116
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(2) Restart logging


operation history
data

Function Name cnc_startophis

Declaration #include “apilib.h”


short FAR PASCAL cnc_startophis(unsigned short FlibHndl);

Description Restarts sampling the operation history data and the alarm history data of
CNC.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 117
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(3) Read number of


operation history
data

Function Name cnc_rdophisno

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdophisno(unsigned short FlibHndl,
unsigned short *hisno);

Description Reads the number of operation history data.


It is necessary to stop sampling the operation history data by using
cnc_stopophis() function before this function is used.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
hisno
Pointer to the variable by which the number of operation history
data is stored.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_FUNC cnc_stopophis function has not been executed.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 118
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(4) Read operation


history data

Function Name cnc_rdophistry

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdophistry(unsigned short FlibHndl,
unsigned short s_no,unsigned short e_no,unsigned short length,
ODBHIS *his);

Description Reads the operation history data.


The structure of the operation history data is different according to kind
of the record(rec_type).
When the operation history data is accessed, it is necessary to use a
structure corresponding to the kind.
The operation history data and the alarm history data are automatically
recorded on the CNC. When these data are accessed, it is necessary to
temporarily stop sampling on the CNC.
Therefore, it is necessary to execute “Stop logging operation history
data”(cnc_stopophis) before this function is used.
It is necessary to execute “Restart logging operation history data”
(cnc_startophis) to make the sampling stop time of the history data a
minimum as soon as the lead ends.
The record number of the beginning/end is an applied number of each
record of the operation history data.
The record number is effective from the execution of “Stop logging
operation history data” to the execution of “Restart logging operation
history data”.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
s_no Specify the beginning record number.(more than 1)
e_no Specify the end record number.(more than 1)

2 – 119
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

length
Specify the data block length(size of ODBHIS structure).

ODBHIS 0
s_no
2
type
4
e_no
6 length
data[0]
14

6+8*(n–1)
data[n]
6+8*n
data.rec_alm 0
rec_type
2
alm_grp
4
alm_no
6
axis_no
7
dummy
8
data.rec_mdi 0
rec_type
2
key_code
3
pw_flag
4
dummy[0]
5
dummy[1]
6
dummy[2]
7
dummy[3]
8
data.rec_sgn 0
rec_type
2
sig_name
3
sig_old
4
sig_new
5
dummy
6
sig_no
8

2 – 120
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

his Pointer to the ODBHIS structure by which the operation history


data is stored. The ODBHIS structure is as follows.
typedef struct odbhis {
unsigned s_no; /* Start record number */
short type; /* Not used */
unsigned e_no; /* Most recently entered */
/* record number */
union {
struct {
short rec_type; /* Record type */
short alm_grp; /* Alarm type */
short alm_no; /* Alarm number */
char axis_no; /* Axis number */
char dummy; /* Not used */
} rec_alm; /* Structure of alarm */
/* record */
struct {
short rec_type; /* Record type */
char key_code; /* Key code */
char pw_flag; /* Not used */
char dummy[4]; /* Not used */
} rec_mdi; /* Structure of */
/* MDI key record */
struct {
short rec_type; /* Record type */
char sig_name; /* Signal name */
char sig_old; /* Bit pattern before a */
/* transition */
char sig_new; /* Bit pattern after a */
/* transition */
char dummy; /* Not used */
short sig_no; /* Signal number */
} rec_sgn; /* Structure of signal */
/* record */
} data[N]; /* N : Number of record */
} ODBHIS ;
rec_type Record type
0 : MDI key history
1 : Signal history
2 : Alarm history

2 – 121
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

alm_grp Alarm type


Power Mate
bit0 : P/S 100
bit1 : P/S 000
bit2 : P/S 101
bit3 : P/S others
bit4 : Over travel
bit5 : Over heat
bit6 : Servo alarm
bit7 : System alarm
bit8 : APC alarm
bit9 : (Not used)
bit 10 : P/S 5000
bit 11 : (Not used)
bit 12 : (Not used)
bit 13 : (Not used)
bit 14 : (Not used)
bit 15 : External alarm message
alm_no Alarm number
key_code Key code
sig_name Signal name
1:X
2:G
3:Y
4:F
sig_old Bit pattern before a transition
sig_new Bit pattern after a transition
sig_no Signal number
X: From 0 to 127 or from 1000 to 1063
G: From 0 to 255 or from 1000 to 1255
Y: From 0 to 127 or from 1000 to 1063
F : From 0 to 255 or from 1000 to 1255

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_FUNC cnc_stopophis function has not been executed.


EW_LENGTH Data block length error
Size of ODBHIS structure(length) is wrong.
(e_no–s_no+1) * sizeof(data[0]) + 6 < length

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 122
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(5) Read number of


alarm history data

Function Name cnc_rdalmhisno

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdalmhisno(unsigned short FlibHndl,
unsigned short *hisno);

Description Reads the number of alarm history the data.


It is necessary to stop sampling the alarm history data by using
cnc_stopophis() function before this function is used.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
hisno
Pointer to the variable by which the number of alarm history data
is stored.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_FUNC cnc_stopophis function has not been executed.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 123
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(6) Read alarm history


data

Function Name cnc_rdalmhistry

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdalmhistry(unsigned short FlibHndl,
unsigned short s_no,unsigned short e_no,unsigned short length,
ODBAHIS *his);

Description Reads the alarm history data.


The unit of one alarm history data is called a record.
The operation history data and the alarm history data are automatically
recorded on the CNC. When these data are accessed, it is necessary to
temporarily stop sampling on the CNC.
Therefore, it is necessary to execute “Stop logging operation history
data”(cnc_stopophis) before this function is used.
It is necessary to execute “Restart logging operation history data”
(cnc_startophis) to make the sampling stop time of the history data a
minimum as soon as the read ends.
The record number of the beginning/end is an applied number of each
record of the alarm history data.
This record number is effective from the execution of “Stop logging
operation history data” to the execution of “Restart logging operation
history data”.

2 – 124
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
s_no Specify the beginning record number.(more than 1)
e_no Specify the end record number.(more than 1)
length
Specify the data block length(size of ODBHIS structure).

ODBAHIS 0
s_no
2
type
4
e_no
6 length
alm_his[0]
54

6+48*(n–1)
alm_his[n]
6+48*n

alm_his 0
dummy
2
alm_grp
4
alm_no
6
axis_no
7
year
8
month
9
day
10
hour
11
minute
12
second
13
dummy2
14
len_meg
16
alm_msg[0]
17

47
alm_msg[31]
48

2 – 125
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

his Pointer to the ODBAHIS structure by which the alarm history data
is stored. The ODBAHIS structure is as follows.
typedef struct odbahis {
unsigned s_no; /* Start record number */
short type; /* Not used */
unsigned e_no; /* Most recently entered */
/* record number */
struct {
short dummy; /* Not used */
short alm_grp; /* Alarm type */
short alm_no; /* Alarm number */
char axis_no; /* Axis number */
char year; /* Year(Not used) */
char month; /* Month (Not used) */
char day; /* Day (Not used) */
char hour; /* Hour(Not used) */
char minute; /* Minute(Not used) */
char second; /* Second(Not used) */
char dummy2; /* Not used */
short len_msg; /* Length of alarm */
/* messafe */
char alm_msg[32]; /* Alarm messafe */
} alm_his[N]; /* N : Number of record */
} ODBAHIS ;
alm_grp Alarm type
Power Mate Not used
alm_no Alarm number
axis_no Axis number(from 1 to maximum controlled axis)
It is –1 for an unrelated alarm to the axis.
len_msg Length of alarm message (from 0 to 32)
alm_msg Alarm message

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_FUNC cnc_stopophis function has not been executed.


EW_LENGTH Data block length error
Size of ODBAHIS structure(length) is wrong.
(e_no–s_no+1) * sizeof(data[0]) + 6 < length

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 126
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(7) Clear operation


history data

Function Name cnc_clearophis

Declaration #include “apilib.h”


short FAR PASCAL cnc_clearophis(unsigned short FlibHndl,short slct);

Description Clears the opeation history data and the alarm history data.
It is possible to be selected the operation history or the alarm history by
setting “slct” in Power Mate.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
slct Specify the kind of the cleared history data.
0 : the operation history data
1 : the alarm history data

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_ATTRIB Data attribute error


The specification of “kind of the cleared history data” (slct)
is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 127
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(8) Read signals related


operation history

Function Name cnc_rdhissgnl

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdhissgnl(unsigned short FlibHndl,
IODBSIG *sig);

Description Reads the target signal for the operation history.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
sig Pointer to the IODBSIG structure by which the operation history
signal is stored. The IODBSIG structure is as follows.
typedef struct iodbsig {
short datano; /* Not used */
short type; /* Not used */
struct {
short ent_no; /* Registration sequence number */
short sig_no; /* Registered signal number */
char sig_name; /* Registered signal name */
char mask_pat; /* Signal mask pattern */
} data[20];
} IODBSIG ;
ent_no Registration sequence number (from 1 to 20)
sig_no Number of a registered signal
X : from 0 to 127 or from 1000 to 1063
G : from 0 to 255 or from 1000 to 1255
Y : from 0 to 127 or from 1000 to 1063
F : from 0 to 255 or from 1000 to 1255
sig_name Name of a registered signal
0 : Not registered
1 : X
2 : G
3 : Y
4 : F
mask_pat Signal mask pattern

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 128
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(9) Write signals related


operation history

Function Name cnc_wrhissgnl

Declaration #include “apilib.h”


short FAR PASCAL cnc_wrhissgnl(unsigned short FlibHndl,
IODBSIG *sig);

Description Writes the operation history object signal.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
sig Pointer to the IODBSIG structure which the operation history
signal to set to CNC is stored.
The IODBSIG structure is as follows.
typedef struct iodbsig {
short datano; /* Not used */
short type; /* Number of signals*/
struct {
short ent_no; /* Registration sequence number */
short sig_no; /* Registered signal number */
char sig_name; /* Registered signal name */
char mask_pat; /* Signal mask pattern */
} data[20];
} IODBSIG ;
ent_no Registration sequence number (from 1 to 20)
sig_no Number of a registered signal
X : from 0 to 127 or from 1000 to 1063
G : from 0 to 255 or from 1000 to 1255
Y : from 0 to 127 or from 1000 to 1063
F : from 0 to 255 or from 1000 to 1255
sig_name Name of a registered signal
0 : Not registered
1 : X
2 : G
3 : Y
4 : F
mask_pat Signal mask pattern

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_ATTRIB Data attribute error


The specification of “Number of signals”(type) is wrong.
EW_DATA Data error

2 – 129
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 130
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

3.6
RELATED TO THE Function name Brief description
AXIS MOVEMENT (1) cnc_opdi Signal operation command
CONTROL (2) cnc_refpoint Reference point return
(3) cnc_abspoint Absolute movement
(4) cnc_incpoint Incremental movement
(5) cnc_dwell Dwell
(6) cnc_coordre Coordinate establihment
(7) cnc_exebufstat Reading of the executive buffer condition
(8) cnc_finstate Reading of the execution completion condition
(9) cnc_setfin Release of the reading mode of the execution
completion condition

2 – 131
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(1) Signal operation


command
Function Name cnc_opdi

Declaration #include “apilib.h”


short FAR PASCAL cnc_opdi(unsigned short FlibHndl,short number,
ODBOPDI *idb )

Description Switches the condition of the specified G code signal.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
An operation signal number is set.
idb It is pointer to the ODBPOS structure that shows the information
of each axis.
The ODBPOS structure is as follows.
typedef struct odbopdi {
short axis; /* axis number */
union {
char cdata;
short idata;
long ldata;
} u; /* signal data */
} ODBOPDI;
operation operation signal set value
signal name
number

1 Emergency stop signal cdata 0:Emergency state 1:release


2 Feed hold signal cdata 0:Feedhold state 1:release
3 Reset signal cdata 1:Reset status 0:release
4 Servo off signal cdata #7 #6 #5 #4 #3 #2 #1 #0
0 0

#0 1:1st axis servo off


0:1st axis servo on

#5 1:6th axis servo off
0:6th axis servo on
7 Rapid traverse signal cdata 1:set 0:reset
8 Start signal cdata 1:set 0:reset
9 Change mode signal cdata #7 #6 #5 #4 #3 #2 #1 #0
0 0 0 0

#3, #2, #1, #0


0 0 0 0 :MDI
0 0 0 1 :MEM
0 0 1 0 :EDIT
0 0 1 1 :REF
0 1 0 0 :JOG
0 1 0 1 :INC
0 1 1 1 :HNDL

2 – 132
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

operation operation signal set value


signal name
number

10 Feedrate override cdata 00000000 : 0%


signal 00000001 : 1%
00000010 : 2%
...
01100100 : 100%
...
11111110 : 254%
11111111 : 0%
12 Torque limit enable cdata #7 #6 #5 #4 #3 #2 #1 #0
signal
0 0

#0 1:1st axis enable


0:1st axis disable

#5 1:6th axis enable
0:6th axis disable
13 Torque limit signal axis : 0:for all axes
1 – m:for each axis
(m:number of controlled axis)
cdata : 0 – 255
overraide value
= ( cdata / 255 ) * 100%
14 Jog signal axis : 0:for all axes
1 – m:for each axis
(m:number of controlled axis)
cdata #7 #6 #5 #4 #3 #2 #1 #0

0 0 0 0 0 0
#3 move direction
1:–J 0:+J
#0 1:move 0:stop
15 Single block signal cdata 1:effective 0:not effective

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 133
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(2) Reference point


return

Function Name cnc_refpoint

Declaration #include “apilib.h”


short FAR PASCAL cnc_refpoint(unsigned short FlibHndl,
short path_no, short nmod, short axis, ODBEXEC *odb);

Description Moves the axis specified by “path_no” and “axis” to the reference point.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
path_no
PATH number is set.(1 – 6)
nmod
The requirement to send the completion notice flag is set.
1:require
0:not require
axis Axis number is set.(1 – 6)
odb It is pointer to the ODBEXEC structure that shows the information
of executive condition.
The ODBEXEC structure is as follows.
typedef struct odbexec {
short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of*/
/* each PATH. */
cdata The condition of the present command buffer is shown.

#7 #6 #5 #4 #3 #2 #1 #0
cdata[0][x–1] EMNT16 EMNT15 EMNT14 EMNT13 EMNT12 EMNT11

cdata[1][x–1] EMNT26 EMNT25 EMNT24 EMNT23 EMNT22 EMNT21

EMNT2x EMNT1x status

0 0 A buffer is empty
0 1 There is data in the buffer 1.
1 0 There is data in the buffer 2.
1 1 A buffer is full.

x : PATH number

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

2 – 134
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


Refer to the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct command.
8010 The choice of DI/DO group of each axis in the axis control by
PMC.

CNC mode This function can be used in any CNC mode.

Example The following program moves the first axis of first PATH to the reference
point and indicates command buffer condition.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBEXEC odb ;
short ret ;
short i, j ;

ret = cnc_refpoint( 0, 1, 0, 1, &odb ) ;

printf( ”Return value : %d¥n”, ret ) ;


if( ret == 0 ){
for( i = 0 ; i < 2 ; i++ ){
for( j = 0 ; j < 8 ; j++ ){
printf( ”%x ”, odb.cdata[i][j] ) ;
}
printf( ”¥n” ) ;
}
}
}

2 – 135
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(3) Absolute movement

Function Name cnc_abspoint

Declaration #include “apilib.h”


short FAR PASCAL cnc_abspoint(unsigned short FlibHndl,
short path_no, short nmod, short axis, long feed,ODBPOS *idb,
ODBEXEC *odb);

Description Moves the axis specified by “path_no” to the position specified by the
absolute command in “idb.data” by the “feed” speed.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
path_no
PATH number is set.(1 – 6)
nmod
The requirement to send the completion notice flag is set.
1:require
0:not require
axis The number of movement axis is set.(1 – 6)
feed A movement speed is set.
idb It is pointer to the ODBPOS structure that shows the information
of each axis.
The ODBPOS structure is as follows.
typedef struct odbpos {
short idata; /* axis number */
long ldata; /* coordinate value */
} ODBPOS;
idata Axis number is set.(1 – 6)
ldata The coordinate value of movement axis is set.
A movement unit is as the following.
IS–B

linear axis 0.001 [mm]


linear axis 0.0001 [inch]
rotation axis 0.00 [deg]

odb It is pointer to the ODBEXEC structure that shows the information


of executive condition.
The ODBEXEC structure is as follows.
typedef struct odbexec {
short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of*/
/* each PATH. */
cdata The condition of the present command buffer is shown.

2 – 136
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

#7 #6 #5 #4 #3 #2 #1 #0
cdata[0][x–1] EMNT16 EMNT15 EMNT14 EMNT13 EMNT12 EMNT11

cdata[1][x–1] EMNT26 EMNT25 EMNT24 EMNT23 EMNT22 EMNT21

EMNT2x EMNT1x status

0 0 A buffer is empty
0 1 There is data in the buffer 1.
1 0 There is data in the buffer 2.
1 1 A buffer is full.

x : PATH number

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct command.
8010 The choice of DI/DO group of each axis in the axis control by
PMC.

CNC mode This function can be used in any CNC mode.

2 – 137
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Example The 1st axis of 1st PATH is moved to the position of 100 and 2nd axis is
moved to the position of –100 at the speed 500. The following program
requests the reply about the buffer condition.
(mm output. Least incremental unit is IS–B.)

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBPOS idb[2] ;
ODBEXEC odb ;
short ret ;
short i, j ;

idb[0].idata = 1 ;
idb[0].ldata = 100000 ;
idb[1].idata = 2 ;
idb[1].ldata = –100000 ;

ret = cnc_abspoint( 0, 1, 0, 2, 500, idb, &odb ) ;

printf( ”Return value : %d¥n”, ret ) ;


if( ret == 0 ){
for( i = 0 ; i < 2 ; i++ ){
for( j = 0 ; j < 8 ; j++ ){
printf( ”%x ”, odb.cdata[i][j] ) ;
}
printf( ”¥n” ) ;
}
}
}

2 – 138
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(4) Incremental
movement

Function Name cnc_incpoint

Declaration #include “apilib.h”


short FAR PASCAL cnc_incpoint(unsigned short FlibHndl,
short path_no, short nmod, short axis, long feed, ODBPOS *idb,
ODBEXEC *odb);

Description Moves the axis specified by “path_no” to the position specified by the
incremental command in “idb.data” by the “feed” speed.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
path_no
PATH number is set.(1 – 6)
nmod
The requirement to send the completion notice flag is set.
1:require
0:not require
axis The number of movement axis is set.(1 – 6)
feed A movement speed is set.
idb It is pointer to the ODBPOS structure that shows the information
of each axis.
The ODBPOS structure is as follows.
typedef struct odbpos {
short idata; /* axis number */
long ldata; /* movement distance */
} ODBPOS;
idata Axis number is set.(1 – 6)
ldata The distance of movement axis is set.
A movement unit is as the following.
IS–B

linear axis 0.001 [mm]


linear axis 0.0001 [inch]
rotation axis 0.001 [deg]

odb It is pointer to the ODBEXEC structure that shows the information


of executive condition.
The ODBEXEC structure is as follows.
typedef struct odbexec {
short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of*/
/* each PATH. */
cdata The condition of the present command buffer is shown.

2 – 139
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

#7 #6 #5 #4 #3 #2 #1 #0
cdata[0][x–1] EMNT16 EMNT15 EMNT14 EMNT13 EMNT12 EMNT11

cdata[1][x–1] EMNT26 EMNT25 EMNT24 EMNT23 EMNT22 EMNT21

EMNT2x EMNT1x status

0 0 A buffer is empty
0 1 There is data in the buffer 1.
1 0 There is data in the buffer 2.
1 1 A buffer is full.

x : PATH number

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct command.
8010 The choice of DI/DO group of each axis in the axis control by
PMC.

CNC mode This function can be used in any CNC mode.

2 – 140
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example The 1st axis of 1st PATH is moved to the distance of +100 and 2nd axis
is moved to the distance of –100 at the speed 500. The following program
requests the reply about the buffer condition.
(mm output. Least incremental unit is IS–B.)

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
ODBPOS idb[2] ;
ODBEXEC odb ;
short ret ;
short i, j ;

idb[0].idata = 1 ;
idb[0].ldata = 100000 ;
idb[1].idata = 2 ;
idb[1].ldata = –100000 ;

ret = cnc_incpoint( 0, 1, 0, 2, 500, idb, &odb ) ;

printf( ”Return value : %d¥n”, ret ) ;


if( ret == 0 ){
for( i = 0 ; i < 2 ; i++ ){
for( j = 0 ; j < 8 ; j++ ){
printf( ”%x ”, odb.cdata[i][j] ) ;
}
printf( ”¥n” ) ;
}
}
}

2 – 141
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(5) Dwell

Function Name cnc_dwell

Declaration #include “apilib.h”


short FAR PASCAL cnc_dwell(unsigned short FlibHndl, short path_no,
short nmod,short axis, ODBPOS *idb, ODBEXEC *odb);

Description Pause the operation of the path specified “path_no” for the time (sec)
specified by “data”.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
path_no
PATH number is set.(1 – 6)
nmod
The requirement to send the completion notice flag is set.
1:require
0:not require
axis The number of stop axis is set.(1 – 6)
idb It is pointer to the ODBPOS structure that shows the information
of each axis.
The ODBPOS structure is as follows.
typedef struct odbpos {
short idata; /* axis number */
long ldata; /* stop time(sec) */
} ODBPOS;
idata Axis number is set.(1 – 6)
ldata Time(sec) is set.(0.001 – 99999.999)
odb It is pointer to the ODBEXEC structure that shows the information
of executive condition.
The ODBEXEC structure is as follows.
typedef struct odbexec {
short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of*/
/* each PATH. */
cdata The condition of the present command buffer is shown.

#7 #6 #5 #4 #3 #2 #1 #0
cdata[0][x–1] EMNT16 EMNT15 EMNT14 EMNT13 EMNT12 EMNT11

cdata[1][x–1] EMNT26 EMNT25 EMNT24 EMNT23 EMNT22 EMNT21

EMNT2x EMNT1x status

0 0 A buffer is empty
0 1 There is data in the buffer 1.
1 0 There is data in the buffer 2.
1 1 A buffer is full.

x : PATH number

2 – 142
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct command.
8010 The choice of DI/DO group of each axis in the axis control by
PMC.

CNC mode This function can be used in any CNC mode.

2 – 143
3. FUNCTION LIST API LIBRARY B–62684EN–1/0
1

(6) Coordinate
establishment

Function Name cnc_coordre

Declaration #include ”apilib.h”


short FAR PASCAL cnc_coordre(unsigned short FlibHndl,
short path_no, short nmod, short axis, ODBPOS *idb, ODBEXEC *odb);

Description Preset the coordinate of the axis specified by “path_no” and “idb.idata”
to the value specified by “idb.ldata”.

Arguments FlibHndl
Because it isn ’t used at present, this a rgument must be set up a zero.
path_no
PATH number is set.(1 – 6)
nmod
The requirement to send the completion notice flag is set.
1:require
0:not require
axis A number of the axis to set up is set.(1 – 6)
idb It is pointer to the ODBPOS structure that shows the information
of each axis.
The ODBPOS structure is as follows.
typedef struct odbpos {
short idata; /* axis number */
long ldata; /* stop time(sec) */
} ODBPOS;
idata Axis number is set.(1 – 6)
ldata Coordinate value is set.
A movement unit is as the following.
IS–B

linear axis 0.001 [mm]


linear axis 0.0001 [inch]
rotation axis 0.001 [deg]

odb It is pointer to the ODBEXEC structure that shows the information


of executive condition.
The ODBEXEC structure is as follows.
typedef struct odbexec {
short dummy; /* none */
char cdata[2][8] ; /* The infomation of th e */
} ODBEXEC; /* executive condition o f*/
/* each PATH. */
cdat a The condition of the present command bu ffer is shown.

2 – 144
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

#7 #6 #5 #4 #3 #2 #1 #0
cdata[0][x–1] EMNT16 EMNT15 EMNT14 EMNT13 EMNT12 EMNT11

cdata[1][x–1] EMNT26 EMNT25 EMNT24 EMNT23 EMNT22 EMNT21

EMNT2x EMNT1x status

0 0 A buffer is empty
0 1 There is data in the buffer 1.
1 0 There is data in the buffer 2.
1 1 A buffer is full.

x : PATH number

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct command.
8010 The choice of DI/DO group of each axis in the axis control by
PMC.

CNC mode This function can be used in any CNC mode.

2 – 145
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(7) Reading of the


executive buffer
condition

Function Name cnc_exebufstat

Declaration #include “apilib.h”


short FAR PASCAL cnc_exebufstat(unsigned short FlibHndl,
ODBEXEC *odb);

Description Request the information of the buffer condition of the block that is
commanded by cnc_refpoint, cnc_abspoint, cnc_incpoint, cnc_dwell or
cnc_coordre.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
odb It is pointer to the ODBEXEC structure that information of
executive condition is shown.
ODBEXEC structure is as the next.
typedef struct odbexec {
short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of*/
/* each PATH. */
cdata The condition of the present command buffer is shown.

#7 #6 #5 #4 #3 #2 #1 #0
cdata[0][x–1] EMNT16 EMNT15 EMNT14 EMNT13 EMNT12 EMNT11

cdata[1][x–1] EMNT26 EMNT25 EMNT24 EMNT23 EMNT22 EMNT21

EMNT2x EMNT1x status

0 0 A buffer is empty
0 1 There is data in the buffer 1.
1 0 There is data in the buffer 2.
1 1 A buffer is full.

x : PATH number

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

2 – 146
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct command.
8010 The choice of DI/DO group of each axis in the axis control by
PMC.

CNC mode This function can be used in any CNC mode.

2 – 147
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(8) Reading of the


execution completion
condition

Function Name cnc_finstate

Declaration #include “apilib.h”


short FAR PASCAL cnc_finstate(unsigned short FlibHndl, ODBFIN *odb);

Description Request the completion notice flag of the block that is commanded by
cnc_refpoint, cnc_abspoint, cnc_incpoint, cnc_dwell or cnc_coordre for
each path.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
odb It is pointer to the ODBFIN structure that the condition of the
completion notice flag is returned.
The ODBFIN structure is as follows.
typedef struct odbfin {
short dummy; /* none */
char cdata[8]; /* The infomation of the */
} ODBFIN; /* complete notice flag */
/* condition of each PATH. */
cdata The present condition of the completion notice flag is
shown.

#7 #6 #5 #4 #3 #2 #1 #0
cdata[x–1] EMNT63 EMNT15 EMNT14 EMNT13 EMNT12 EMNT11

EMNT1x 0 : un–completion
1 : completion
x : PATH number

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct command.
8010 The choice of DI/DO group of each axis in the axis control by
PMC.

CNC mode This function can be used in any CNC mode.

2 – 148
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(9) The release of the


reading mode of the
execution completion
condition

Function Name cnc_setfin

Declaration #include “apilib.h”


short FAR PASCAL cnc_setfin(unsigned short FlibHndl, ODBFIN *idb);

Description A completion notice flag is reset.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
odb It is pointer to the ODBFIN structure that the condition of the
completion notice flag is returned.
The ODBFIN structure is as follows.
typedef struct odbfin {
short dummy; /* none */
char cdata[8]; /* The infomation of the */
} ODBFIN; /* complete notice flag */
/* condition of each PATH. */
cdata A complete notice flag to reset is specified.

#7 #6 #5 #4 #3 #2 #1 #0
cdata[x–1] EMNT63 EMNT15 EMNT14 EMNT13 EMNT12 EMNT11

EMNT1x A bit to reset made 1.


x : PATH number

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_BUSY Busy
Try it again or wait until the procedure of CNC is finished.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct command.
8010 The choice of DI/DO group of each axis in the axis control by
PMC.

CNC mode This function can be used in any CNC mode.

2 – 149
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

3.7
OTHER FUNCTIONS Function name Brief description

(1) cnc_sysinfo Read CNC system information


(2) cnc_sysconfig Read CNC configuration information
(3) cnc_statinfo Read CNC status information
(4) cnc_alarm Read alarm status
(5) cnc_rdalminfo Read alarm information
(6) cnc_modal Read modal data
(7) cnc_diagnoss Read diagnosis data
(8) cnc_diagnosr Read diagnosis data(area specified)
(9) cnc_getfigure Read maximum valid figures, number of decimal
places
(10) cnc_rdcurrent Read real current for servo adjustment
(11) cnc_rdsrvspeed Read real speed for servo adjustment
(12) cnc_rdloopgain Read loop gain for servo adjustment
(13) cnc_rdopmsg Read operator’s message
(14) cnc_rdopnlsgnl Read output signal image of software operator’s
panel
(15) cnc_wropnlsgnl Write output signal of software operator’s panel
(16) cnc_rdopnlgnrl Read general signal image of software opera-
tor’s panel
(17) cnc_wropnlgnrl Write general output signal of software operator’s
panel
(18) cnc_rdopnlgsname Read general signal name of software operator’s
panel
(19) cnc_wropnlgsname Write general signal name of software operator’s
panel

2 – 150
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(1) Read CNC system


information

Function Name cnc_sysinfo

Declaration #include “apilib.h”


short FAR PASCAL cnc_sysinfo(unsigned short FlibHndl,
ODBSYS *sysinfo);

Description Reads system information such as 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 position.
Note that a null character (‘¥x00’) is not added at the end of each strings.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
sysinfo
Pointer to the ODBSYS structure including CNC system
information.
The ODBSYS structure for Power Mate is as follows.
typedef struct odbsys {
short dummy[2] ; /* dummy */
char cnc_type[2] ; /* not used */
char mt_type[2] ; /* not used */
char series[4] ; /* Series number (ASCII) */
char version[4] ; /* Version number (ASCII) */
char axes[2] ; /* Current controlled axes(ASCII)*/
} ODBSYS ;
series Series number of CNC(ASCII)
The character string of 4 digits is stored.
version Version number of CNC(ASCII)
The character string of 4 digits is stored.
axes Amount of controlled axes(ASCII)
The character string of 2 digits is stored.
In case of 4 axes, ‘4’ is set.

ODBSYS 0
dummy
4
cnc_type
6
mt_type
8
series
12
version
16
axes
18

2 – 151
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the details, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following information are gotten by execution of this function on


Power Mate (8880–10) system with 4 servo axes.
sysinfo.series = “8880”
sysinfo.version = “0010”
sysinfo.axes = “4”

2 – 152
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(2) cnc_sysconfig Read


CNC configuration
information

Function Name cnc_sysconfig

Declaration #include “apilib.h”


short FAR PASCAL cnc_sysconfig(unsigned short FlibHndl,
ODBSYSC *sysinfo);

Description Read the CNC system configuration information.


Various information is stored in each member of ODBSYSC.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
sysinfo
Pointer to the ODBSYSC structure includingthe CNC
configuration information.
S The ODBSYSC structure for Power Mate is as follows.
typedef struct odbsysc {
char slot_no_p[16]; /*Physical slot number(Not used)*/
char slot_no_l[16]; /* Logical slot number(Not used)*/
short mod_id[16]; /* Module ID */
short soft_id[16]; /* Software ID */
char s_series[16][5]; /* Software series */
char s_version[16][5];/* Software version */
char dummy[16]; /* Not used */

short m_rom; /* Main–CPU CNC software


installation status */
short s_rom; /* Sub–CPU CNC software
installation status */
char svo_soft[8]; /* Series and version
of servo software */
char pmc_soft[6]; /* Series and version of PMC
management software */
char lad_soft[6]; /* Series and version of
Ladder software */
char mcr_soft[8]; /* Series and version of
a macro executor/order–made macro */
char spl1_soft[6]; /* Series and version of
a spindle software (first spindle) (Not used)*/
char spl2_soft[6]; /* Series and version of
a spindle software (second spindle) (Not used)*/
short frmmin; /* Capacity of FROM module (MAIN) */
short drmmin; /* Capacity of DRAM module (MAIN)*/
short srmmin; /* Capacity of added SRAM module
(MAIN) */
short pmcmin; /* Type of PMC module (MAIN) */
short sv1min; /* Presence or absence of
a servo module (axis 1, 2) (MAIN) */

2 – 153
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

short sv3min; /* Presence or absence of


a servo module (axis 3, 4) (MAIN) */
short sv5min; /* Presence or absence of
a servo module (axis 5, 6) (MAIN) */
short sicmin; /* Presence or absence of SIC (MAIN) */
short posmin; /* Presence or absence of
a position LSI (MAIN) */
short submin; /* Information of sub–board */
short hdiio; /* Presence or absence of an LSI for
high–speed skip(I/O card) */
short dummy[32];
} ODBSYSC ;
slot_no_p Not used.
slot_no_l Not used.
mod_id Not used.
soft_id Software ID
The software IDs of the modules which are built in the slots
are stored in binary in order of their position.
This array is terminated with FFH. The data subsequent to
FFH are invalid.
40H : CNC
s_series Software series
Software series information is stored in ASCII code in
order of slot numbers, first four bytes being used for each
slot number, and next one byte is NULL.
s_version Software version
Software version information is stored in ASCII code in
order of slot numbers, four bytes being used for each slot
number, and next one byte is NULL.
m_rom Not used.
s_rom Not used.
svo_soft Series and version of servo software
This information item is stored in ASCII code. The first
four bytes indicate the series, and the remaining four bytes
indicate the version.
It is impossible that this software is absent.
pmc_soft Series and version of PMC management software
This information item is stored in ASCII code. The first
four bytes indicate the series, and the remaining two bytes
indicate the version.
It is impossible that this software is absent.
lad_soft Series and version of Ladder software
This information item is stored in ASCII code. The first
four bytes indicate the series, and the remaining two bytes
indicate the version.
If this software does not exist, all of the 6 bytes are
space(20H).

2 – 154
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

mcr_soft Series and version of a macro


executor/order–made macro
This information item is stored in ASCII. The first byte is
not used. The subsequent four bytes indicate the series, and
the remaining two bytes indicate the version.
If this software does not exist, the first byte is FFH (in some
cases, that is excluding FFH). The last byte is not used.
spl1_soft Not ussed.
spl2_soft Not used.
frmmin Capacity of FROM module (MAIN)
–1 : Not existence
0 : 2 (MB)
1 : reserve
2 : 4 (MB)
drmmin Capacity of DRAM module (MAIN)
–1 : Not existence
0 : 2 (MB)
1 : 2.5 (MB)
2 : reserve
3 : 3 (MB)
srmmin Capacity of added SRAM module (MAIN)
–1 : Not existence 1 : 1 (MB)
0 : 256 (KB)
Series 210
Presence or absence of MATRIX DI/DO (MAIN)
0 : Not existence 1 : Existence
pmcmin Type of PMC module (MAIN)
–1 : Not existence 2 : reserve
0 : PMP2+SL 3 : reserve
1 : reserve 4 : reserve
sv1min Presence or absence of a servo module
(axis 1, 2) (MAIN)
–1 : Not existence 0 : Existence
sv3min Presence or absence of a servo module
(axis 3, 4) (MAIN)
–1 : Not existence 0 : Existence
sv5min Presence or absence of a servo module
(axis 5, 6) (MAIN)
–1 : Not existence 0 : Existence
sicmin Presence or absence of SIC (MAIN)
–1 : Not existence 0 : Existence
posmin Presence or absence of a position LSI (MAIN)
–1 : Not existence 0 : Existence
submin Information of sub–board
–1 : Not existence
1 : RS485
2 : Built–in I/O board
3 : M–NET board
7 : I/O link2 board

2 – 155
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

hdiio Presence or absence of an LSI


for high–speed skip (I/O card)
–1 : Not existence 0 : Existence

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 156
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(3) Read CNC status


information

Function Name cnc_statinfo

Declaration #include “apilib.h”


short FAR PASCAL cnc_statinfo(unsigned short FlibHndl,
ODBST *statinfo);

Description Read the status information of CNC.


The various information is stored in each member of “ODBST”.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
statinfo
Pointer to the ODBST structure including the status information of
CNC.
The ODBST structure for Power Mate is as follows.
typedef struct odbst {
short dummy[2]; /* Not used */
short aut ; /* AUTOMATIC/MANUAL 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 */
short alarm ; /* Status of alarm */
short edit ; /* Status of program editing */
} ODBST ;
aut AUTOMATIC/MANUAL mode selection
0 : MDI 1 : MEMory
2 : **** 3 : EDIT
4 : HaNDle 5 : JOG
6 : Teach in JOG 7 : Teach in HND
8 : INC– feed 9 : REFerence
10 : ReMoTe
run Status of automatic operation
0 : **** (reset) 1 : STOP
2 : HOLD 4 : STaRT
motion
Status of axis movement,dwell
0 : *** 1 : MoTioN
3 : DWeLl
mstb Status of M,S,T,B function
0 : *** (Others) 1 : FIN
emergency
Status of emergency
0 : (Not emergency) 1 : EMerGency
2 : ReSET

2 – 157
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

alarm Status of alarm


0 : *** (Others) 1 : ALarM
2 : BATtery low
edit Status of program editing
0 : **** (Not editing) 1: EDIT
2 : SeaRCH 3: OUTPUT
4 : INPUT 5: COMPARE
6 : Label SKip 7: OFfSeT
8 : Work ShiFT 9: ReSTaRt

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the details, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 158
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(4) Read alarm status

Function Name cnc_alarm

Declaration #include “apilib.h”


short FAR PASCAL cnc_alarm(unsigned short FlibHndl,
ODBALM *alarm);

Description Reads the alarm status of CNC.


Various information is stored in “data” of ODBALM.
This function is used for watching CNC’s alarm status, displaying the
maintenance information or guidance of how to reset the alarm, etc.
When CNC becomes system alarm, it is completely impossible to
communicate data between PC and CNC, and the alarm status cannot be
acquired.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
alarm
Pointer to the ODBALM structure including the alarm status
information.
The ODBALM structure is as follows.
typedef struct odbalm {
short dummy[2] ; /* Not used. */
short data ; /* Alarm status */
} ODBALM ;
dummy Not used.
data Alarm status
The meaning of each bit is as follows.
#00 : P/S alarm 100
#01 : P/S alarm 000
#02 : P/S alarm 101
#03 : P/S alarm except above
#04 : Overtravel alarm
#05 : Overheat alarm
#06 : Servo alarm
#07 : (Not used)
#08 : APC alarm
#09 : (Not used)
#10 : P/S alarms (No.5000 –)
#11 : (Not used)
#12 : (Not used)
#13 : (Not used)
#14 : (Not used)
#15 : External alarm message

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

2 – 159
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program displays the kinds of alarms currently arising.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
char *almmsg[] = {
”P/S 100 ALARM”,”P/S 000 ALARM”,
”P/S 101 ALARM”,”P/S ALARM (1–255)”,
”OT ALARM”, ”OH ALARM”,
”SERVO ALARM”, ”unknown ALARM”,
”APC ALARM”, ”SPINDLE ALARM”,
”P/S ALARM (5000–)”
} ;
ODBALM buf ;
unsigned short idx ;
cnc_alarm( 0, &buf ) ;
if ( buf.data == 0 )
printf( ”NO ALARM¥n” ) ;
else
for ( idx = 0 ; idx < 11 ; idx++ ) {
if ( buf.data & 0x0001 )
printf( ”%s¥n”, almmsg[idx] ) ;
buf.data >>= 1 ;
}
}

2 – 160
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(5) Read alarm


information

Function Name cnc_rdalminfo

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdalminfo(unsigned short FlibHndl,short type,
short alm_type,short length,ALMINFO *alarminfo);

Description Reads the detail information of currently arising CNC alarms.


Various information is stored in “data” of ALMINFO.
This function is used for displaying the alarm numbers or messages of the
currently arising alarms by the application program, etc.
When CNC becomes system alarm, it is completely impossible to
communicate data between PC and CNC, and the alarm information
cannot be acquired.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
type Specify the type of output format.
0 : Alarm information 1 (without message)
1 : Alarm information 2 (with message)
alm_type
Specify the type of alarm.
The meaning of each bit is as follows.
#00 : P/S alarm 100
#01 : P/S alarm 000
#02 : P/S alarm 101
#03 : P/S alarm except above
#04 : Overtravel alarm
#05 : Overheat alarm
#06 : Servo alarm
#07 : (Not used)
#08 : APC alarm
#09 : (Not used)
#10 : P/S alarm (No.5000 – )
#11 : (Not used)
#12 : (Not used)
#13 : (Not used)
#14 : (Not used)
#15 : External alarm message

2 – 161
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

length
Specify the length of the data block(size of ALMINFO structure)

u.alm1 0
alm[0]
4

4*(N–1) length
alm[N–1]
4*N
data_end
4*N+2

u.alm1.alm 0
axis
2
alm_no
4

u.alm2 0
alm[0]
38

38*(N–1) length
alm[N–1]
38*N
data_end
38*N+2

u.alm2.alm 0
axis
2
alm_no
4
msg_len
6
alm_msg[0]
7

37
alm_msg[31]
38

N is number of messages to be read.

alarminfo
Pointer to the ALMINFO structure including the alarm
information.
The ALMINFO structure is as follows.
typedef struct alminfo {
union {
struct {
struct {
short axis ; ;/* Axis information.*/
short alm_no ; ;/* Alarm number. */
} alm[N] ;
short data_end ; ;/* data end */
} alm1 ;
struct {
struct {
short axis ; ;/* Axis information.*/

2 – 162
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

short alm_no ; ;/* Alarm number. */


short msg_len ; ;/* Message length. */
char alm_msg[32] ; ;/* Alarm message. */
} alm[N] ;
short data_end ; ;/* data end */
}alm2 ;
}u;
} ALMINFO ; /*N : number of messages to be read. */
axis Axis information is stored.
0 : assigns no axis
1,..,m : assigns 1 axis
(m=max. controlled axes)
alarm_no Alarm number(binary) is stored.
msg_len Message length(binary) is stored.
(1 to 32)
alm_msg Alarm message character string(ASCII) is stored.
data_end Data end is stored.
Always 0FFFFH is set.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of ALMINFO structure(length) is illegal.
EW_NUMBER data number error
The type of output format(type) is improper.
EW_ATTRIB data attribute error
The specification of alarm type(alm_type) is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 163
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(6) Read modal data

Function Name cnc_modal

Declaration #include “apilib.h”


short FAR PASCAL cnc_modal(unsigned short FlibHndl,short type,
short block,ODBMDL *modal);

Description Reads the modal information of CNC.


Various information is stored in each member of ODBMDL.
The readable modal data are modal G code, M code or commanded data
such as F.
The union type which stores the data depends on the type of modal
data(type). therefore in case of accessing data, use the union
corresponding to the type.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
type Type of data is stored.(refer to below)
–3 : Read the all data concerning axis other than G code at
a time.
–2 : Read the all data other than G code at a time.
–1 : Read the all data of G code at a time.
0 to 20 : Read the data of G code one by one.
100 to 126 : Read the data other than G code one by one.
200 to 205 : Read the data concerning axis other than G
code one by one.
block
Assigned block in stored.
0 : active block
1 : next block
2 : block after next block

2 – 164
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

modal
Pointer to the ODBMDL structure including the modal data.
The ODBMDL structure is as follows.
typedef struct odbmdl {
short datano; /* Kind of modal data. */
short type; /* Objective block. */
union {
char g_data; /* Modal data of G code. */
char g_rdata[21]; /* Modal data of G code */
struct {
long aux_data;
/* Modal data other than G code */
char flag1; /* Flag 1 */
char flag2; /* Flag 2 */
}aux;
struct {
long aux_data;
/* Modal data other than G code */
char flag1; /* Flag 1 */
char flag2; /* Flag 2 */
}raux1[27];
struct {
long aux_data;
/* Modal data other than G code */
char flag1; /* Flag 1 */
char flag2; /* Flag 2 */
}raux2[MAX_AXIS];
}modal; /* MAX_AXIS : max. controlled axes. */
} ODBMDL ;
datano Kind of modal data is stored.
type Objected block is stored.
g_data Use for an individual reading G code.
Modal G code in the corresponding G code group is
stored.
g_rdata Use for reading G code at a time.
Modal G code in the all G code group is stored.
aux Use for an individual reading other than G code
(include axis data).
raux1 Use for reading other than G code at a time.
raux2 Use for reading concerning axis other than G code at a
time.
aux_data Modal data other than G code is stored.
flag1 Supplementary information is stored.
flag2 Supplementary information is stored.

2 – 165
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

1) Reading modal G code.


Specify 0,..,20 of G code group number in “type”.
type g_data G code

0 0 G00
1 G01
2 G02
3 G03
1 0 G17
4 G19
8 G18
2 0 G90
1 G91
4 0 G94
1 G95
5 0 G20
1 G21
7 0 G49
1 G43
2 G44
11 0 G67
1 G66
20 0 G13.1
1 G12.1

The numerical value of “g_data” mentioned in the above table is stored


in the bit 0,..,bit 6 of “g_data” with binary format.
Whether this G code is commanded in the objective block specified by
“block” or not is stored in the bit 7 of “g_data”.

7 6 5 4 3 2 1 0

* Code in each group : 1 byte

0 : Not under command in the present block


1 : Under command in the present block

For example, the following result is gotten by calling this function during
executing N100’s block of the next machining program.
N090 G18 ;
N100 G1 Z100. ;
N110 G17 G2 X10. Y–20. R12. ;
type block g_data[0] Modal status

0 0 0x81 G1 is commanded.
0 1 0x82 G2 is commanded.
1 0 0x08 G18 mode. (not commanded)
1 1 0x80 G17 is commanded.

To read all “type” concerning G code at a time, –1 is specified.


The array of g_data is stored in g_rdata.

2 – 166
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

2) Reading modal data other than G code.


type Address

100 B
101 D
102 E
103 F
104 H
105 L
106 M
107 S
108 T
109 R
110 P
111 Q
112 A
113 C
114 I
115 J
116 K
117 N
118 O
119 U
120 V
121 W
122 X
123 Y
124 Z
125 M2
126 M3
200 1st axis
201 2nd axis
202 3rd axis
203 4th axis
204 5th axis
205 6th axis

To read “type” concerning 100’s at a time, –2 is specified.


The data is stored in the array of raux1.
To read “type” concerning 200’s at a time, –3 is specified.
The data is stored in the array of raux2.

2 – 167
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

Data : 4 byte

FLAG1 : 1 byte

FLAG2 : 1 byte

7 6 5 4 3 2 1 0
Number of input place

0 : Positive
1 : Negative
0 : There is no command of a decimal point.
1 : There is a command of a decimal point.
0 : There is no command in the present block.
1 : There is a command in the present block.

Number of places of decimals

* The command of a decimal point in ‘FLAG1’ and the number of places of


decimals in ‘FLAG2’ are valid in the case of ‘F code’.
Sometimes the number of places of decimals is ‘not zero’ without the
command of a decimal point.
* The number of input place of M is digits granted by NC parameter.
M code : parameter No.3030

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_NUMBER data number error


The specification of modal data(type) is improper.
EW_ATTRIB data attribute error
The specification of block(block)is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 168
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(7) Read diagnosis data

Function Name cnc_diagnoss

Declaration #include “apilib.h”


short FAR PASCAL cnc_diagnoss(unsigned short FlibHndl,
short number,short axis,short length,ODBDGN *diag);

Description Reads the diagnosis specified by “number”,“axis”(only for the diagnosis


with axis). The data format depends on each diagnosis. The format of
Byte/Word/2–Word diagnosis is generally signed binary.
Reads the diagnosis for all axes once by specifying ‘ALL_AXES’ in
‘axis’. The diagnosis for each axis is stored in each array of “ODBDGN”.
The attribute of diagnosis depends on the type and axis, and it is different
for each diagnosis.
Diagnosis type Use Byte size

Bit diagnosis Every bits have each definition. 1


Bit diagnosis with axis Every bits have each definition. 1
(each axis)
Byte diagnosis 1–byte data is stored. 1
Byte diagnosis with axis 1–byte data is stored. (each axis) 1
Word diagnosis 2–byte data is stored. 2
Word diagnosis with axis 2–byte data is stored. (each axis) 2
2–Word diagnosis 4–byte data is stored. 4
2–Word diagnosis with axis 4–byte data is stored. (each axis) 4

It is impossible to read any bit diagnosis bit by bit.


8 bits(i.e. 1 byte) which belong to the same diagnosis number are read at
the same time.
See the “MAINTENANCE MANUAL” of CNC for details of each
diagnosis.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
number
Specify the diagnosis number.
See the “MAINTENANCE MANUAL” of CNC about available
diagnosis number.
axis Specify the axis number.
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)
ALL_AXES : assigns all axes(ALL_AXES=–1)

2 – 169
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

length
Specify the data block length(size of ODBDGN structure).
(4+(byte size of diagnosis)*(number of axis))
In case that the size of diagnosis is 4 byte, the ODBDGN structure
is as follows. In case that its size is 1 or 2 byte, the size of data part
per 1 diagnosis or 1 axis is 1 or 2 byte.

no axis/1 axis all axes


ODBDGN 0 0
datano datano
2 2
type length type length
4 4
ldata ldatas[0]:1st
8 8

4+2x(n–1)
ldatas[n–1]:n–th
4+2xn
n : Current controlled axes

diag Pointer to the ODBDGN structure including the diagnosis.


The ODBDGN structure is as follows.
typedef struct iodbpsd {
short datano; /* diagnosis number */
short type; /* Axis */
union {
char cdata; /* bit/byte diagnosis */
short idata; /* word diagnosis */
long ldata; /* 2–word diagnosis */
char cdatas[MAX_AXIS]; /* bit/byte diagnosis with
axis*/
short idatas[MAX_AXIS]; /* word diagnosis with axis */
long ldatas[MAX_AXIS]; /* 2–word diagnosis with
axis */
}u;
} ODBDGN ; /* MAX_AXIS : max. controlled axes */
datano Diagnosis number which was read is stored.
type Attribute of diagnosis which was read is stored.
Axis
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)
ALL_AXES : all axes(ALL_AXES=–1)

2 – 170
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of ODBDGN structure(length) is wrong.
EW_NUMBER Data number error
Diagnosis number(number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 171
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(8) Read diagnosis data


(area specified)
Function Name cnc_diagnosr

Declaration #include “apilib.h”


short FAR PASCAL cnc_diagnosr (unsigned short FlibHndl,
(short *) &s_number, short axis, (short *)&e_number,
(short *) &length, (void *) diag);

Description Reads the diagnosis specified by “s_number”,“e_number”,“axis”(only


for the diagnosis with axis). The data format depends on each diagnosis.
The format of Byte/Word/2–Word diagnosis is generally signed binary.
Reads the diagnosis for all axes specified range by specifying
‘ALL_AXES’ in ‘axis’.
The attribute of CNC diagnosis depends on the type and axis, and it is
different for each diagnosis.
Diagnosis type Use Byte size

Bit diagnosis Every bits have each definition. 1


Bit diagnosis with axis Every bits have each definition. 1
(each axis)
Byte diagnosis 1–byte data is stored. 1
Byte diagnosis with axis 1–byte data is stored.(each axis) 1
Word diagnosis 2–byte data is stored. 2
Word diagnosis with axis 2–byte data is stored.(each axis) 2
2–Word diagnosis 4–byte data is stored. 4
2–Word diagnosis with axis 4–byte data is stored.(each axis) 4

It is impossible to read any bit diagnosis bit by bit.


8 bits(i.e. 1 byte) which belong to the same diagnosis number are read at
the same time.
See the “MAINTENANCE MANUAL” of CNC for details of each
parameter.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
s_number
Specify the start diagnosis number.
The first diagnosis number to be read is returned.
See the “MAINTENANCE MANUAL” of CNC about available
diagnosis number.
e_number
Specify the end diagnosis number.
The last diagnosis number to be read is returned.
The new diagnosis may be added according to updating CNC
software, addition of the new function, etc. If the new diagnosis
is added within reading range, the error(Return:EW_LENGTH)
will be returned or the application program will not work correctly.
In order to avoid these mistakes, specify the continuous numbers
of existing diagnoses as the reading range.

2 – 172
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

axis Specify the axis number.


0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)
ALL_AXES : assigns all axes(ALL_AXES=–1)
None axis type diagnosis can be read even if any value is specified
in “axis”. In case that an axis type diagnosis exists in the specified
range, the error(Retuen:EW_ATTRIB) is returned by specifying
“axis=0”.
length
Specify the data block length which is enough to store the specified
diagnosis.
The structure per 1 diagnosis is as follows, and each diagnosis is
lined up in order of number.
[= Sum of (4+(byte size of each diagnosis)*(number of axis))]
Because the size to be read is returned, it is possible to specify the
length more than the actual size.
In case that the size of diagnosis is 1 byte, the ODBDGN structure
is as follows.
In case that the size of diagnosis is 1 byte and the length per 1
diagnosis is an odd number, ‘dummy’ is necessary in the end of
structure. In case that its size is 2 or 4 byte, the size of data part per
1 diagnosis or 1 axis is 2 or 4 byte, and so ‘dummy’ is not necessary.

no axis/1 axis all axes


ODBDGN 0 0
datano datano
2 2
type length/diagnosis type length
4 4 /diag.
cdata cdatas[0]:1st
5 5
dummy
6 4+1x(n–1)
cdatas[n–1]:n–th
4+1xn
dummy (in case of
n : Maximum controlled axes n=odd num.)

diag Pointer to the area to store the diagnoses.


Each diagnosis can be referred by using the ODBDGN structure.
typedef struct iodbpsd {
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[MAX_AXIS]; /* bit/byte diagnosis with
axis*/
short idatas[MAX_AXIS]; /* word diagnosis with axis */
long ldatas[MAX_AXIS]; /* 2–word diagnosis with
axis */
}u;
} ODBDGN ; /* MAX_AXIS : max. controlled axes */

2 – 173
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

datano Diagnosis number which was read is stored.


type Attribute of diagnosis which was read is stored.
Lower byte:axis
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)
ALL_AXES : all axes(ALL_AXES=–1)

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH Data block length error


Size of area to store diagnosis(length) is wrong.
EW_NUMBER Data number error
Diagnosis number(s_number,e_number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 174
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(9) Read maximum valid


figures, number of
decimal places
Function Name cnc_getfigure

Declaration #include “apilib.h”


short FAR PASCAL cnc_getfigure(unsigned short FlibHndl,
short data_type, short *valid_fig,
short *dec_fig_in, short *dec_fig_out);

Description Reads the maximum valid figures, number of digits below decimal point
by unit of input and output, which is related to various data of CNC.
The value which can be read in the window library is binary data by set
unit of the CNC side. Therefore, it is nesessary to display decimal point
position etc. in consideration of set unit.
It is valid when using the following functions.
S axis type data S tool offset S custum 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
The value which returns from the function is as follows.
D maximum valid figures
Power Mate

axis type data 8


tool offset 7
custum macro 8
(unit [digit])
D number of digits below decimal point by unit of input and output
1) axis type data
Both of the number of digits below the decimal point at each I/O
inside of the controlled axes are valid.
Linear axis Rotary axis
[mm] [inch] [deg]
IS–B 3 4 3
* ‘Metric/Inch” of linear axis depends on the following NC parameter.
In case of the input unit –––Input unit(0000#2)
In case of the output unit–––Machine linear axis detection unit
(1001#0)
2) tool offset
The number of digits below the decimal point under the input unit
only at the first axis part is valid, and it under the output unit is invalid.
[mm] [inch]
IS–B 3 4

2 – 175
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

3) custom macro
The number of digits below the decimal point under the input unit
only at the first axis part is valid, and it under the output unit is
invalid.
[mm] [inch]

IS–B 3 4

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
data_type
Specify the kind of the data.
0 : axis type dat
1 : tool offset
2 : custom macro
valid_fig
Specify the address of the variable to store with the maximum valid
figures.
dec_fig_in
Specify the address of the array to store with the number of digits
below decimal point under the input unit.
The number of array must be equal to the number of maximum
controlled axis.
(In the case except axis type data, only the top of array is valid.)
dec_fig_out
Specify the address of the array to store with the number of digits
below decimal point under the output unit.
The number of array must be equal to the number of maximum
controlled axis.
(In the case except axis type data, only the top of array is valid.)

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_ATTRIB data attribute error


Kind of data(data_type)is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
0000#2, 1001#0 influenced by setting
1004#0,#1

CNC mode This function can be used in any CNC mode.

2 – 176
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(10) Read real current for


servo adjustment

Function Name cnc_rdcurrent

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdcurrent(unsigned short FlibHndl,
short *crrnt);

Description Reads “The servo adjustment real current”.


When the following parameter is 0, the real current become 0.
Power Mate 2086

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
crrnt Specify the address of the array to store with the real current for
servo adjustment.
The number of array must be equal to the number of maximum
controlled axis.
Actually the object within the number of controlled axis is valid.
long gain[MAX_AXIS] ;/* MAX_AXIS : max. controlled axes */

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function relates to the following CNC parameter.


See description and the manual of CNC parameter for details.
Power mate 2086 ––– influenced by setting

CNC mode This function can be used in any CNC mode.

2 – 177
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(11) Read real speed for


servo adjustment

Function Name cnc_rdsrvspeed

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdsrvspeed(unsigned short FlibHndl,
long *speed);

Description Reads “The servo adjustment real speed”.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
speed
Specify the address of the array to store with the real speed for servo
adjustment.
The number of array must be equal to the number of maximum
controlled axis.
Actually the object within the number of controlled axis is valid.
long gain[MAX_AXIS] ;/* MAX_AXIS : max. controlled axes */

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 178
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(12) Read loop gain for


servo adjustment

Function Name cnc_rdloopgain

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdloopgain(unsigned short FlibHndl,
long *gain);

Description Reads “The servo adjustment loop gain”.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
gain Specify the address of the array to store with the loop gain for servo
adjustment.
The number of array must be equal to the number of maximum
controlled axis.
Actually the object within the number of controlled axis is valid.
long gain[MAX_AXIS] ;/* MAX_AXIS : max. controlled axes */

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 179
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(13) Read operator’s


message
Function Name cnc_rdopmsg

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdopmsg(unsigned short FlibHndl,short type,
short length,OPMSG *opmsg);

Description Reads the contents of the operator’s message in CNC.


The operator’s message is stored in “data” of “OPMSG”.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
type Specify the kind of operator’s message.
0 : 1st message
length
Specify the length of the data block(size of OPMSG structure)

0
datano
2
type
4
char_num
6 length
data[0]
7

6+255
data[255]
6+256

opmsg
Pointer to the OPMSG structure including the operator’s message.
The OPMSG structure is as follows.
typedef struct msg {
short datano ; /* Number of operator’s message */
short type ; /* Kind of operator’s message */
short char_num ; /* Message length */
char data[MSG_SIZE] ;/* Operator’s message strings */
} OPMSG ; /* MSG_SIZE : Message length */
datano The Number of operator’s message is stored.
message exists
100 to999
2000 to 2099
message does not exist
–1
type Kind of operator’s message is stored.
0 : 1st message
char_num The operator’s message length is stored.
1 to 256 : operator’s message
data The operator’s message strings are stored.
ASCII strings are set.
‘¥0’ is set at the end of strings.

2 – 180
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_LENGTH data block length error


Size of OPMSG structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of the kind of operator’s message(type)
is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

Example The following program reads the operator’s message and displays it.

#include <stdio.h>
#include ”apilib.h”

void example( void )


{
OPMSG buf ;
cnc_rdopmsg( 0, 0, 6+256, &buf ) ;
if ( buf.datano != –1 )
printf( ”#04d %s¥n”, buf.datano. buf.data ) ;
else
printf( ”No operator message.¥n” ) ;
}

2 – 181
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(14) Read output signal


image of software
operator’s panel

Function Name cnc_rdopnlsgnl

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdopnlsgnl(unsigned short FlibHndl,
short slct_data,IODBSGNL *sgnl);

Description Read the output signal image of software operator’s panel.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
slct_data
Specify the data select flag.
bit 0 : Mode signal
bit 1 : (Not used)
bit 2 : (Not used)
bit 3 : Rapid traverse override signal
bit 4 : Manual feedrate override signal
bit 5 : Feedrate override signal
bit 6 : (Not used)
bit 7 : Optional block skip signal
bit 8 : Single block signal
bit 9 : Machine lock signal
bit 10 : Dry run signal
bit 11 : Memory protection signal
bit 12 : Automatic operation halt signal
bit 13 : (Not used)
bit 14 : (Not used)
bit 15 : (Not used)
* When the bit corresponding to a signal is set to 0, that signal is not
applied.
To apply a signal, set the corresponding bit to 1.
sgnl Pointer to the IODBSGNL structure including the output signal
image of software operator’s panel.
The IODBSGNL structure is as follows.
typedef struct iodbsgnl {
short datano; /* (Not used) */
short type; /* Data select flag */
short mode; /* Mode signal */
short hndl_ax; /* (Not used)*/
short hndl_mv; /* (Not used)*/
short rpd_ovrd; /* Rapid traverse override signal */
short jog_ovrd; /* Manual feedrate override signal */
short feed_ovrd; /* Feedrate override signal */
short spdl_ovrd; /* (Not used) */
short blck_del; /* Optional block skip signal(0/1) */
short sngl_blck; /* Single block signal(0/1) */

2 – 182
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

short machn_lock; /* Machine lock signal(0/1) */


short dry_run; /* Dry run signal(0/1) */
short mem_prtct; /* Memory protection signal(0/1) */
short feed_hold; /* Automatic operation halt
signal(0/1) */
} IODBSGNL ;
datano Not used
type Data select flag is stored.
mode Mode signal is stored.
0 : MDI
1 : MEM
2 : EDIT
3 : HNDL or INC
4 : JOG
5 : REF
hndl_ax Not used.
hndl_mv Not used.
rpd_ovrd Rapid traverse override signal is stored.
0 : 100%
1 : 50%
2 : 25%
3 : F0
jog_ovrd Manual feedrate override signal is stored.
0 : 0% 10 : 2.0% 20 : 52.0%
1 : 0.1% 11 : 2.7% 21 : 72.0%
2 : 0.14% 12 : 3.7% 22 : 100%
3 : 0.2% 13 : 5.2% 23 : 140%
4 : 0.27% 14 : 7.2% 24 : 200%
5 : 0.37% 15 : 10.0%
6 : 0.52% 16 : 14.0%
7 : 0.72% 17 : 20.0%
8 : 1.0% 18 : 27.0%
9 : 1.4% 19 : 37.0%
feed_ovrd Feedrate override signal is stored.
0 : 0% 10 : 100% 20 : 200%
1 : 10% 11 : 110%
2 : 20% 12 : 120%
3 : 30% 13 : 130%
4 : 40% 14 : 140%
5 : 50% 15 : 150%
6 : 60% 16 : 160%
7 : 70% 17 : 170%
8 : 80% 18 : 180%
9 : 90% 19 : 190%
spdl_ovrd Not used.
blck_del Optional block skip signal(0/1) is stored.
sngl_blck Single block signal(0/1) is stored.
machn_lock
Machine lock signal(0/1) is stored.
dry_run Dry run signal(0/1) is stored.

2 – 183
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

mem_prtct
Memory protection signal(0/1) is stored.
feed_hold Automatic operation halt signal(0/1) is stored.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 184
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(15) Write output signal


of software
operator’s panel

Function Name cnc_wropnlsgnl

Declaration #include “apilib.h”


short FAR PASCAL cnc_wropnlsgnl(unsigned short FlibHndl,
IODBSGNL *sgnl);

Description Write the output signal of software operator’s panel.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
sgnl Pointer to the IODBSGNL structure to be set the output signal of
software operator’s panel.
The IODBSGNL structure is as follows.
typedef struct iodbsgnl {
short datano; /* (Not used) */
short type; /* Data select flag */
short mode; /* Mode signal */
short hndl_ax; /* (Not used)
short hndl_mv; /* (Not used)
short rpd_ovrd; /* Rapid traverse override signal */
short jog_ovrd; /* Manual feedrate override signal */
short feed_ovrd; /* Feedrate override signal */
short spdl_ovrd; /* (Not used) */
short blck_del; /* Optional block skip signal(0/1) */
short sngl_blck; /* Single block signal(0/1) */
short machn_lock; /* Machine lock signal(0/1) */
short dry_run; /* Dry run signal(0/1) */
short mem_prtct; /* Memory protection signal(0/1) */
short feed_hold; /* Automatic operation halt
signal(0/1) */
} IODBSGNL ;
datano Not used

2 – 185
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

type Specify the data select flag.


bit 0 : Mode signal
bit 1 : (Not used)
bit 2 : (Not used)
bit 3 : Rapid traverse override signal
bit 4 : Manual feedrate override signal
bit 5 : Feedrate override signal
bit 6 : (Not used)
bit 7 : Optional block skip signal
bit 8 : Single block signal
bit 9 : Machine lock signal
bit 10 : Dry run signal
bit 11 : Memory protection signal
bit 12 : Automatic operation halt signal
bit 13 : (Not used)
bit 14 : (Not used)
bit 15 : (Not used)
* When the bit corresponding to a signal is set to 0, that signal is not
written.
To write a signal, set the corresponding bit to 1.
mode Specify the mode signal.
0 : MDI
1 : MEM
2 : EDIT
3 : HNDL or INC
4 : JOG
5 : REF
hndl_ax Not used.
hndl_mv Not used.
rpd_ovrd Specify the rapid traverse override signal.
0 : 100%
1 : 50%
2 : 25%
3 : F0
jog_ovrd Specify the manual feedrate override signal.
0 : 0% 10 : 2.0% 20 : 52.0%
1 : 0.1% 11 : 2.7% 21 : 72.0%
2 : 0.14% 12 : 3.7% 22 : 100%
3 : 0.2% 13 : 5.2% 23 : 140%
4 : 0.27% 14 : 7.2% 24 : 200%
5 : 0.37% 15 : 10.0%
6 : 0.52% 16 : 14.0%
7 : 0.72% 17 : 20.0%
8 : 1.0% 18 : 27.0%
9 : 1.4% 19 : 37.0%

2 – 186
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

feed_ovrd Specify the feedrate override signal.


0 : 0% 10 : 100% 20 : 200%
1 : 10% 11 : 110%
2 : 20% 12 : 120%
3 : 30% 13 : 130%
4 : 40% 14 : 140%
5 : 50% 15 : 150%
6 : 60% 16 : 160%
7 : 70% 17 : 170%
8 : 80% 18 : 180%
9 : 90% 19 : 190%
spdl_ovrd Not used.
blck_del Specify the optional block skip signal(0/1).
sngl_blck Specify the single block signal(0/1).
machn_lock
Specify the machine lock signal(0/1).
dry_run Specify the dry run signal(0/1).
mem_prtct
Specify the memory protection signal(0/1).
feed_hold
Specify the automatic operation halt signal(0/1).

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_DATA data error


Some value of member in IODBSGNL is improper.

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 187
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(16) Read general signal


image of software
operator’s panel

Function Name cnc_rdopnlgnrl

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdopnlgnrl(unsigned short FlibHndl,
short slct_data,IODBGNRL *opnlgnrl);

Description Read the general output signal image of software operator’s panel.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
slct_data
Specify the data select flag.
bit 0 : General–purpose signal 1
bit 1 : General–purpose signal 2
bit 2 : General–purpose signal 3
bit 3 : General–purpose signal 4
bit 4 : General–purpose signal 5
bit 5 : General–purpose signal 6
bit 6 : General–purpose signal 7
bit 7 : General–purpose signal 8
* Bit 8 to 15 is not used.
* When the bit corresponding to a signal is set to 0, that signal is not
applied.
To apply a signal, set the corresponding bit to 1.
opnlgnrl
Pointer to the IODBGNRL structure including the general output
signal image of software operator’s panel.
The IODBGNRL structure is as follows.
typedef struct iodbgnrl {
short datano; /* Not used */
short type; /* Data select flag */
char sgnal; /* General–purpose signal 1 to 8 */
} IODBGNRL ;
datano Not used.
type Data select flag is stored.
sgnal General–purpose signal is stored.
bit 0 : General–purpose signal 1
bit 1 : General–purpose signal 2
bit 2 : General–purpose signal 3
bit 3 : General–purpose signal 4
bit 4 : General–purpose signal 5
bit 5 : General–purpose signal 6
bit 6 : General–purpose signal 7
bit 7 : General–purpose signal 8

2 – 188
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 189
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(17) Write general output


signal of software
operator’s panel

Function Name cnc_wropnlgnrl

Declaration #include “apilib.h”


short FAR PASCAL cnc_wropnlgnrl(unsigned short FlibHndl,
IODBGNRL *opnlgnrl);

Description Write the general output signal of software operator’s panel.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
opnlgnrl
Pointer to the IODBGNRL structure to be set the general output
signal of software operator’s panel.
The IODBGNRL structure is as follows.
typedef struct iodbgnrl {
short datano; /* Not used */
short type; /* Data select flag */
char sgnal; /* General–purpose signal 1 to 8 */
} IODBGNRL ;
datano Not used.
type Specify the data select flag.
bit 0 : General–purpose signal 1
bit 1 : General–purpose signal 2
bit 2 : General–purpose signal 3
bit 3 : General–purpose signal 4
bit 4 : General–purpose signal 5
bit 5 : General–purpose signal 6
bit 6 : General–purpose signal 7
bit 7 : General–purpose signal 8
* Bit 8 to 15 is not used.
* When the bit corresponding to a signal is set to 0, that signal is not
written.
To write a signal, set the corresponding bit to 1.
sgnal Specify the General–purpose signal.
bit 0 : General–purpose signal 1
bit 1 : General–purpose signal 2
bit 2 : General–purpose signal 3
bit 3 : General–purpose signal 4
bit 4 : General–purpose signal 5
bit 5 : General–purpose signal 6
bit 6 : General–purpose signal 7
bit 7 : General–purpose signal 8

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

2 – 190
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 191
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(18) Read general signal


name of software
operator’s panel

Function Name cnc_rdopnlgsname

Declaration #include “apilib.h”


short FAR PASCAL cnc_rdopnlgsname(unsigned short FlibHndl,
short slct_data,IODBRDNA *brdna);

Description Read the general signal name of software operator’s panel.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
slct_data
Specify the data select flag.
bit 0 : General–purpose signal 1
bit 1 : General–purpose signal 2
bit 2 : General–purpose signal 3
bit 3 : General–purpose signal 4
bit 4 : General–purpose signal 5
bit 5 : General–purpose signal 6
bit 6 : General–purpose signal 7
bit 7 : General–purpose signal 8
* Bit 8 to 15 is not used.
* When the bit corresponding to a signal is set to 0, that signal is not
applied.
To apply a signal, set the corresponding bit to 1.
brdna
Pointer to the IODBRDNA structure including the general signal
name of software operator’s panel.
The IODBRDNA structure is as follows.
typedef struct iodbrdna {
short datano; /* Not used */
short type; /* Data select flag */
char sgnl1_name[9]; /* General signal name 1 (ASCII) */
char sgnl2_name[9]; /* General signal name 2 (ASCII) */
char sgnl3_name[9]; /* General signal name 3 (ASCII) */
char sgnl4_name[9]; /* General signal name 4 (ASCII) */
char sgnl5_name[9]; /* General signal name 5 (ASCII) */
char sgnl6_name[9]; /* General signal name 6 (ASCII) */
char sgnl7_name[9]; /* General signal name 7 (ASCII) */
char sgnl8_name[9]; /* General signal name 8 (ASCII) */
} IODBRDNA ;
datano Not used.
type Data select flag is stored.

2 – 192
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

sgnl1_name General signal name 1 (ASCII)


sgnl2_name General signal name 2 (ASCII)
sgnl3_name General signal name 3 (ASCII)
sgnl4_name General signal name 4 (ASCII)
sgnl5_name General signal name 5 (ASCII)
sgnl6_name General signal name 6 (ASCII)
sgnl7_name General signal name 7 (ASCII)
sgnl8_name General signal name 8 (ASCII)
The specified name is set.
For the end of name(sgnl?_name[8]),
NULL character(‘¥0’) is set.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 193
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(19) Write general signal


name of software
operator’s panel

Function Name cnc_wropnlgsname

Declaration #include “apilib.h”


short FAR PASCAL cnc_wropnlgsname(unsigned short FlibHndl,
IODBRDNA *brdna);

Description Write the general signal name of software operator’s panel.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
brdna
Pointer to the IODBRDNA structure to be set the general signal
name of software operator’s panel.
The IODBRDNA structure is as follows.
typedef struct iodbrdna {
short datano; /* Not used */
short type; /* Data select flag */
char sgnl1_name[9]; /* General signal name 1 (ASCII) */
char sgnl2_name[9]; /* General signal name 2 (ASCII) */
char sgnl3_name[9]; /* General signal name 3 (ASCII) */
char sgnl4_name[9]; /* General signal name 4 (ASCII) */
char sgnl5_name[9]; /* General signal name 5 (ASCII) */
char sgnl6_name[9]; /* General signal name 6 (ASCII) */
char sgnl7_name[9]; /* General signal name 7 (ASCII) */
char sgnl8_name[9]; /* General signal name 8 (ASCII) */
} IODBRDNA ;
datano Not used.
type Specify the select flag.
bit 0 : General–purpose signal 1
bit 1 : General–purpose signal 2
bit 2 : General–purpose signal 3
bit 3 : General–purpose signal 4
bit 4 : General–purpose signal 5
bit 5 : General–purpose signal 6
bit 6 : General–purpose signal 7
bit 7 : General–purpose signal 8
* Bit 8 to 15 is not used.
* When the bit corresponding to a signal is set to 0, that signal is not
written.
To write a signal, set the corresponding bit to 1.

2 – 194
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

sgnl1_name General signal name 1 (ASCII)


sgnl2_name General signal name 2 (ASCII)
sgnl3_name General signal name 3 (ASCII)
sgnl4_name General signal name 4 (ASCII)
sgnl5_name General signal name 5 (ASCII)
sgnl6_name General signal name 6 (ASCII)
sgnl7_name General signal name 7 (ASCII)
sgnl8_name General signal name 8 (ASCII)
Specify the general signal name.
Eight characters from the top of each name
(sgnl?_name[0] – sgnl?_name[7])
is set in CNC.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 195
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

3.8
RELATED TO THE Function name Brief description
PMC (1) pmc_rdpmcrng read PMC data(area specified)
(2) pmc_wrpmcrng write PMC data(area specified)
(3) pmc_rdpmcinfo read PMC data information

2 – 196
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

(1) Read PMC data


(area specified)

Function Name pmc_rdpmcrng

Declaration #include “apilib.h”


short FAR PASCAL pmc_rdpmcrng(unsigned short FlibHndl,
short adr_type,short data_type,short s_number,
short e_number,short length,IODBPMC *buf);

Description Reads the PMC data of the specified PMC address/range.


This function is used to exchange the data between the application of PC
and LADDER soft of PMC.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
adr_type
Specify the identification code corresponding to the kind of the
PMC address.
<The referenceable range of PMC data of Power Mate>
ID code Kind of PMC address Referenceable range

0 G (Signal to PMC³CNC) 0000–0255, 1000–1255


1 F (Signal to CNC³PMC) 0000–0255, 1000–1255
2 Y (Signal to PMC³machine) 0000–0127, 1000–1063
3 X (Signal to machine³PMC) 0000–0127, 1000–1063
4 A (Message demand) 0000–0024
5 R (Internal relay) 0000–0999, 9000–9117
6 T (Changeable timer) 0000–0079
7 K (Keep relay) 0000–0019
8 C (Counter) 0000–0079
9 D (Data table) 0000–1859

(*) It is not possible to write to all areas of address ‘F’ and ‘X’, and
“R9000”,... Moreover, “K0017”,..,“K0019”.
(*) See the “PROGRAMMING MANUAL” of PMC about CNC
which each PMC can correspond.
data_type
Specify the type of the PMC data.
It must be the same one as the type of data of the PMC side.
0 : Byte type
1 : Word type
2 : Long type
s_number
Specify the start PMC address number.
e_number
Specify the end PMC address number.

2 – 197
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

length
Specify the data block length.
data_type is 0 (byte type) : length = 8 + N
data_type is 1 (word type) : length = 8 + N * 2
data_type is 2 (long type) : length = 8 + N * 4
* N is a number of read data.
buf Pointer to the IODBPMC structure.
The IODBPMC structure is as follows.
typedef struct iodbpmc {
short type_a ; /* Kind of PMC address */
short type_d ; /* Type of the PMC data */
short datano_s ; /* Start PMC address number */
short datano_e ; /* End PMC address number */
union {
char cdata[N] ; /* The PMC data(byte type) */
short idata[N] ; /* (word type) */
long ldata[N] ; /* (long type) */
}u; /* N is a number of read data */
} IODBPMC ;

Example of specifying 1) D0100(It is assumed the word type) is read.


argument adr_type 9
data_type 1
s_number 100
e_number 101
length 8+2*1 (=10)
buf.u.idata[0] The content of D0100 is stored.
2) R0200,..,R0209(It is assumed the byte type) is read.
adr_type 5
data_type 0
s_number 200
e_number 209
length 8+1*10 (=18)
buf.u.cdata[0] The contents of R0200,..,R0209 are stored.
,..,buf.u.cdata[9]

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of PMC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_NOPMC There is no PMC.


EW_LENGTH Data block length error
Size of IODBPMC structure(length) is wrong.
EW_NUMBER Data number error
PMC address number(s_number,e_number) is wrong.
EW_ATTRIB Data attribute error
Kind of PMC address(adr_type) or type of PMC data
(data_type) is wrong.

2 – 198
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 199
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(2) Write PMC data


(area specified)

Function Name pmc_wrpmcrng

Declaration #include “apilib.h”


short FAR PASCAL pmc_wrpmcrng(unsigned short FlibHndl,
short length,IODBPMC *buf);

Description Writes the PMC data of the specified PMC address/range.


This function is used to exchange the data between the application of PC
and LADDER soft of PMC.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
length
Specify the data block length.
data_type is 0 (byte type) : length = 8 + N
data_type is 1 (word type) : length = 8 + N * 2
data_type is 2 (long type) : length = 8 + N * 4
* N is a number of written data.
buf Pointer to the IODBPMC structure.
The IODBPMC structure is as follows.
typedef struct iodbpmc {
short type_a ; /* Kind of PMC address */
short type_d ; /* Type of the PMC data */
short datano_s ; /* Start PMC address number */
short datano_e ; /* End PMC address number */
union {
char cdata[N] ; /* The PMC data(byte type) */
short idata[N] ; /* (word type) */
long ldata[N] ; /* (long type) */
}u; /* N is a number of written data */
} IODBPMC ;
type_a Specify the identification code corresponding to the
kind of the PMC address.
type_d Specify the type of the PMC data.
It must be the same one as the type of data of the PMC
side.
0 : Byte type
1 : Word type
2 : Long type
datano_s Specify the start PMC address number.
datano_e Specify the end PMC address number.
See “The referenceable range of PMC data” of “Read PMC data(area
specified)(pmc_rdpmcrng)” about the kind of the PMC address, the start
address, and the end address.

2 – 200
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

Example of specifying 1) 250 is written in D0100(It is assumed the word type)


argument buf.type_a 9
buf.type_d 1
buf.datano_s 100
buf.datano_e 101
length 8+2*1 (=10)
buf.u.idata[0] 250
2) 0 is written all of R0200,..,R0209(It is assumed byte type)
buf.type_a 5
buf.type_d 0
buf.datano_s 200
buf.datano_e 209
length 8+1*10 (=18)
buf.u.cdata[0] 0 all
,..,buf.u.cdata[9]

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of PMC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_NOPMC There is no PMC.


EW_LENGTH Data block length error
Size of IODBPMC structure(length) is wrong.
EW_NUMBER Data number error
PMC address number(datano_s,datano_e) is wrong.
EW_ATTRIB Data attribute error
Kind of PMC address(type_a) or type of PMC data
(type_d) is wrong.

CNC option There is no need of CNC option for this function.

CNC parameter This function doesn’t relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 201
3. FUNCTION LIST API LIBRARY B–62684EN–1/01

(3) Read PMC data


information

Function Name pmc_rdpmcinfo

Declaration #include “apilib.h”


short FAR PASCAL pmc_rdpmcinfo(unsigned short FlibHndl,
short adr_type,ODBPMCINF *pmcif);

Description Read the data information about the attribute of each kind of PMC, the
effective range of address, etc.

Arguments FlibHndl
Because it isn’t used at present, this argument must be set up a zero.
adr_type
Specify the kind of PMC address.
0 <––> : refer to the table pmc_rdpmcrng() function
–1 : all address information
pmcif
Pointer to the ODBPMCINF structure including the PMC data
information.
The ODBPMCINF structure is as follows.
typedef struct odbpmcinf {
short datano ; /* number of PMC data information */
struct {
char pmc_adr ; /* kind of PMC address */
char adr_attr ; /* attribute of PMC address */
unsigned short top_num ; /* top number of PMC address */
unsigned short last_num ; /* end number of PMC address */
} info[64] ;
} ODBPMCINF ;
datano Number of PMC data information (1 – 64)
* Some PMC address may be devided into several
parts.
pmc_adr Type of PMC address (ASCII CODE)
adr_attr Attribute of PMC address
bit 7 : Write protection
0 : enable 1 : disable
bit 0<––>6 : (Not used)
top_num Top number of PMC address
last_num Last number of PMC address
* Refer to the table of cnc_rdpmcrng() function.

Return EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see “Return status of CNC data window” in “General
Description”.)
Return code Meaning/Error handling

EW_ATTRIB data attribute error


Kind of data(adr_type)is improper.

2 – 202
B–62684EN–1/01 API LIBRARY 3. FUNCTION LIST

CNC option There is no need of CNC option for this function.

CNC parameter This function does not relate to CNC parameter.

CNC mode This function can be used in any CNC mode.

2 – 203
III. BOOT APPLICATION SOFTWARE
B–62684EN–1/01 BOOT APPLICATION SOFTWARE 1. FUNCTION OUTLINE

1 FUNCTION OUTLINE

Boot application software executes the following operation for Power


Mate.
(1) The load of the system control software and PMC ladder.
(2) The backup and restore of the S–RAM data.
(3) The deletion and initialization of the flash ROM file.
(4) The deletion and format of the memory card file.
(5) The initialization of the system file such as the NC program, the NC
parameter, the tool offset, etc.
(6) The diagnosis and maintenance of the HSSB board.

NOTE
This function is equivalent to the Boot function and the
memory clearing function on the CRT/MDI. The operation
by Boot application is for maintenance.
Careful operation is required because it is a special
operation of the system such as starting up.

3–1
2. INSTALL BOOT APPLICATION SOFTWARE B–62684EN–1/01

2 INSTALL

There is a directory of “BOOT” in API library(FOR HSSB) floppy disk.


There is a file of the executive form of “PMBOOT.EXE” in this directory.
Copy this file to the hard disk of the personal computer. The installation
of “PMBOOT” is just completed in this operation.

3–2
B–62684EN–1/01 BOOT APPLICATION SOFTWARE 3. OPERATION EXPLANATION

3 OPERATION EXPLANATION

Please set the value of “0” to rotary switch(RSW) for setting the CRT
device number in Power Mate.
(0 : Power Mate synchronizes with the personal computer)

After “Windows3.1” of the personal computer which “PMBOOT.EXE”


is installed is made to start, HSSB driver can be possible. (Refer to the
manual for the way of installing HSSB driver.)
Click the MS–DOS prompt icon in main icon group of Program Manager.
Then a DOS prompt screen appears. Change the directory so that
PMBOOT can be recognized and type the following command.
How to start PMBOOT (option designation)
Option –Z: Loading and saving of the Boot function are
done to the hard disk drive of the personal
computer.
When this option is not designated those are
done to the memory card in Power Mate.
–T: The maintenance operation function menu
of HSSB is displayed.
Input example C:¥BOOT>PMBOOT –Z –T<Enter>
PMBOOT is better to be registered in the suitable program group in
Program Manager of Windows as a MS–DOS application. When a
environment is set up by PIF Editer, input operation such as option
designation and change directory command can be omitted. Choose “full
screen display” by the setting of PIF.

3–3
4. OPERATION SCREEN BOOT APPLICATION SOFTWARE B–62684EN–1/01

4 OPERATION SCREEN

3–4
B–62684EN–1/01 BOOT APPLICATION SOFTWARE 4. OPERATION SCREEN

4.1
MACHINE SELECT
SCREEN **** MACHINE SELECT ****
ADDRESS:MACHINE NAME
300H:Machine1
310H:Machine2
END

**** MESSAGE ****


SELECT MACHINE AND HIT [Enter] KEY.
FANUC Power Mate BOOT Application Version 1.00 [I/O]
Copyright(C) FANUC LTD. 1996 All right reserved.

Fig.4.1 Machine select screen

The above screen is the top menu when PMBOOT is started. The
following items set up in the SYSTEM.INI file for Windows is displayed.
 I/O Port Address
 Machine name
 Number of HSSB boards
A machine to connect is chosen by this menu screen. The reversed
machine name is just selected. This reversal display position can be
moved up and down by the cursor key. After a cursor is moved to the
target machine and Enter key is pushed, the following confirmation
message is displayed at the MESSAGE display line. Confirm the
machine name, and type “Y” or “N”.
ARE YOU SURE?
[Y]es OR [N]o.

When [Y] is selected, if the following is checked and there is no problem,


the screen proceeds Fig. 4.2 Processing select screen.
1. The communication of HSSB is checked.
The time limit of the check is 180 seconds. The power supply of
the machine must be turned on in this time. A time out error occurs
if communication is not established. When an error occurs, the
message of “NO RESPONSE FROM CNC.” is indicated, and then
this application software is finished. 180 seconds countdown can
be stopped by pushing [Esc] key in the midst.
2. The initialization of common–RAM for HSSB is finished.

3–5
4. OPERATION SCREEN BOOT APPLICATION SOFTWARE B–62684EN–1/01

4.2
PROCESSING
SELECT SCREEN **** MENU ****
BOOT
IPL
BOOT&IPL
ALARM MESSAGE
HSSB BOARD I/O TEST
HSSB REGISTERS
COMMON RAM DUMP
END

**** MESSAGE ****


SELECT MENU AND HIT [Enter] KEY.
FANUC Power Mate BOOT Application Version 1.00 [I/O]
Copyright(C) FANUC LTD. 1996 All right reserved.

Fig.4.2 Processing select screen

Operation to the selected machine can be chosen by this sub menu screen.
Top three items in the menu are always displayed but if the machine is
already started up, they appears as follows showing that they cannot be
chosen.
BOOT (THIS FUNCTION CAN’T BE CHOSEN.)
IPL (THIS FUNCTION CAN’T BE CHOSEN.)
BOOT&IPL (THIS FUNCTION CAN’T BE CHOSEN.)
Above is displayed when “1” is set in rotary switch(RSW) for setting the
CRT device number in Power Mate.
When system alarm occurs in Power Mate, “ALARM MESSAGE” is
displayed automatically.
When PMBOOT is started with “–T” option, three other items from
“HSSB BOARD I/O TEST” appears. These items are used at the time of
the maintenance of HSSB.
When “END” is chosen, machine can be started.

Introductory remarks
*1:This is basic function when PMBOOT is started.
S Set “0” on the rotary switch(RSW) for setting the CRT device
number in Power Mate, and turn on the power of Power Mate
to do this function.
S This function cannot be chosen when system alarm occurs in
Power Mate.
*2:This is displayed automatically according to the state of Power
Mate.
*3:This is displayed when PMBOOT is started with “–T” option, or
when the system alarm occurs.

3–6
B–62684EN–1/01 BOOT APPLICATION SOFTWARE 4. OPERATION SCREEN

Explanation of the function in sub menu screen


BOOT(*1)
The following operation is available in this function.
(1) The exchange of the system control software and PMC ladder.
(2) The backup and restore of the S–RAM data.
(3) The deletion and initialization of the flash ROM file.
(4) The deletion and format of the memory card file.
IPL(*1)
In case of using CRT/MDI on Power Mate, the initialization of the
various files can be done when the power is turned on with a MDI
key pushed. This system function is realized with the dialog form
the personal computer. Because only one system file can be
initialized at a time, the power of the Power Mate have to be cycled
once for each initialization, if multiple files are to be initialized.
It takes some time before a dialog form screen is displayed because
the system control software is to be loaded.
BOOT&IPL(*1)
This function executes two above functions continuously. It takes
some time from the end of the BOOT function to the beginning of
the IPL dialogue screen as the system control software is loaded.
ALARM MESSAGE(*2)
The alarm message is displayed when system alarm occurs in
Power Mate.
It disappears when the power of Power Mate is turned off.
Record display contents when this message occurs. Then, contact
with FANUC.
HSSB BOARD I/O TEST(*3)
The reliability of the communication to connect the personal
computer with Power Mate through HSSB can be diagnosed.
HSSB REGISTERS(*3)
This function displays the hardware information of the HSSB
board.
This screen is sometimes displayed automatically when an error
occurs in the communication. The contents displayed in the screen
should be recorded, because it is useful for the investigation of the
communication problem.
COMMON RAM DUMP(*3)
This function displays the memory contents of common–RAM for
HSSB in Power Mate. It is used at the time of the diagnosis of
HSSB API library.

3–7
4. OPERATION SCREEN BOOT APPLICATION SOFTWARE B–62684EN–1/01

4.3
BOOT PROCESSING
SCREEN BOOT MENU 881A – 06
PMBOOT V1.00
SYSTEM DATA LOADING
SYSTEM DATA CHECK
SYSTEM DATA DELETE
SYSTEM DATA SAVE
SRAM DATA BACKUP
MEMORY CARD FILE DELETE
MEMORY CARD FORMAT
END

**** MESSAGE ****


SELECT MENU AND HIT [Enter] KEY.
FANUC Power Mate BOOT Application Version 1.00 [I/O]
Copyright(C) FANUC LTD. 1996 All right reserved.

Fig.4.3 Boot processing screen

When “BOOT” is chosen, the above “BOOT MENU” screen appears.


As for the key input operation after this, the operation is the same as the
key input operation for the CRT/MDI.

NOTE
The file name for “SRAM DATA BACKUP” is fixed to be
“SRAM256A.FDB”.
Therefore, the object of input and output is only
“SRAM256A.FDB”.
“SRAM256K.000” or other file name cannot be handled.
The ROM series and ROM number of only [NC BASIC] and
[DG SERVO] can be displayed properly. As for other file
name, the ROM series can not be displayed properly
because file structure is different.
(Example: The data of [PMC–PA],[PCD 128K],[CEX 1.0M]
can not be displayed. )

3–8
B–62684EN–1/01 BOOT APPLICATION SOFTWARE 4. OPERATION SCREEN

4.4
IPL PROCESSING
SCREEN IPL MENU
(MENU)
0. EXIT
1. MEMORY CLEAR
2. SETTING

9. OTHERS

SELECT NO. : 1

Fig.4.4 (a) IPL processing screen (1)

When “IPL” is chosen, the above “IPL MENU” screen appears. To select
the function from the menu, type the number of the items displayed on the
screen and type Enter key. When a wrong number is typed, it can be
corrected with Back Space key.

NOTE
When a DPL/MDI unit is attached to Power Mate, the
presponse of the key input from the personal computer
become slow. Operate it after you remove DPL/MDI when
DPL/MDI unit is not necessary.

When the item of “1. MEMORY CLEAR” is chosen, the sub menu screen
example like the following Fig.4.4 (b) appears.

3–9
4. OPERATION SCREEN BOOT APPLICATION SOFTWARE B–62684EN–1/01

IPL MENU
(MENU) MEMORY CLEAR
0. CANCEL
1. ALL MEMORY
2. PARAMETER AND OFFSET
3. PROGRAM
4. PMC

SELECT NO. : 1

Fig.4.4 (b) IPL processing screen (2)

In the above screen select an item by typing item number and Enter key.
Then next menu appears.
0. CANCEL
1. EXEC
The following message appears when “1. EXIT” is selected.
SURE ?:
(NO=0,YES=1)
Judge “yes” or “no” and type “1” or “0” accordingly.
After the file initialization processing is done, series and edition number
of system software are displayed. Then IPL processing is finished.

Then, PMBOOT software is returned to the function choice sub screen


(Fig.4.2).

3 – 10
B–62684EN–1/01 BOOT APPLICATION SOFTWARE 4. OPERATION SCREEN

4.5
SYSTEM ALARM
SCREEN SYSTEM ALARM 8880–12

915 SRAM PARITY : (LOW)

FFFF 0A70 0440 0A88 0A66 06D8 0000 00E0


0B08 0000 3FFD 0000 FFFF 0000 000C 0000
000C 0000 0000 0000 FFEE 0000 FFFF 0ADB
0418 3046 0257 2A48 03C0 32F4 0000

NMIC 00010000 00000000 00000101 11000000

Fig.4.5 System alarm screen

The system alarm screen is displayed on the personal computer. Record


the displayed screen contents. Be careful that this alarm disappears and
it cannot be seen again when the power of Power Mate is turned off.

3 – 11
4. OPERATION SCREEN BOOT APPLICATION SOFTWARE B–62684EN–1/01

4.6
HSSB BOARD TEST
SCREEN HSSB BOARD I/O TEST
2W––W–B–
ACCESS TIMES/DATA ... 001000 / 12345678H
BYTE DATA W/R TEST PC(I.T.) PM
W/R ERROR TIMES.... 0 –––––– *Good *
BIT ERROR RATE ....0.001% 0.000% *Good *
WORD DATA W/R TEST
W/R ERROR TIMES.... 2 –––––– *No Good*
BIT ERROR RATE ....0.002% 0.003% *Good *
2WORD DATA W/R TEST
W/R ERROR TIMES.... 123 –––––– *No Good*
BIT ERROR RATE ....0.000% 12.3% *Warning*

**** MESSAGE ****


ACCESS TIMES ³ 001000
ACCESS DATA ³ 00000000H
FANUC Power Mate BOOT Application Version 1.00 [I/O]
Copyright(C) FANUC LTD. 1996 All right reserved.

Fig.4.6 HSSB board test screen

By this function, the reliability of the communication between the


personal computer and Power Mate through HSSB can be diagnosed.
The data of different length(byte,word,2word) are written in
common–RAM, and then this function checks whether the same data can
be read. The test is started after the number of times and the data value are
inputted.
“W/R ERROR TIMES” shows the number of times when difference is
detected in W/R(Write/Read) test. “*No Good*” is indicated when
different value is detected more than once.
“BIT ERROR RATE” indicates a ratio between the number of
times(molecule) of the bit transmission error and the number of
times(denominator) of the repetition test shown in the HSSB register in
the per cent.
The bit transmission error counter is placed on both of the personal
computer and Power Mate. A calculation is done by using the value of
each counter, and the ratio is indicated. There is nothing to do with in the
software because hardware detects this bit transmission error
automatically and retransmits the data again. But, when the bit
transmission error occurs frequently, the countermeasure is necessary.
This function is provided for this diagnosis.
“*Warning*” is indicated when an error ratio goes over 1%.

3 – 12
B–62684EN–1/01 BOOT APPLICATION SOFTWARE 4. OPERATION SCREEN

4.7
HSSB REGISTERS
SCREEN HSSB REGISTERS
I/O PORT REGISTERS
DATA ADDRESS S1 S2
12345678 12345678 12 12 FFFF FFFFFFFF
PERSONAL COMPUTER(I.T.) SIDE
BIT C 8 4 0 HEX
R0 1111 0000 1111 0000 (F0F0)
R2 0000 1111 0000 1111 (0F0F)
R4 1111 0000 1111 0000 (F0F0)
R6 0000 1111 0000 1111 (0F0F)
POWER MATE SIDE
BIT C 8 4 0 HEX
R0 0001 0010 0011 0100 (1234)
R2 0101 0110 0111 1000 (5678)
R4 1001 1010 1011 1100 (9ABC)
R6 1101 1110 1111 0000 (DEF0)

**** MESSAGE ****


HIT [Enter] KEY.
FANUC Power Mate BOOT Application Version 1.00 [I/O]
Copyright(C) FANUC LTD. 1996 All right reserved.

Fig.4.7 HSSB registers screen

The above screen indicates the condition of I/O port 16 byte, HSSB
register 8 byte of personal computer, and HSSB register 8 byte of Power
Mate.
The meaning of the register is the following.

R0.00 BUSRDY

When the link of HSSB is established and it can access remote space after
the power is turned on, it becomes “1”.

R0.02

It becomes “1” at the time of the condition that the signal of the receiving line
is not changed electrically.

R0.04–R0.03 The communication condition of HSSB is shown

0 0 : Close state
0 1 : Openstate
1 1 : Error state

3 – 13
4. OPERATION SCREEN BOOT APPLICATION SOFTWARE B–62684EN–1/01

R0.08–R0.05 The factor is shown when “FATAL ERROR” occurs while


communication opens.

R0.12–R0.09 The factor on the partner side is shown when “ERROR NO-
TICE” is taken from the partner side while communication
opens.

0001: This error occurs when the hardware of the partner side HSSB is re-
set.
0010: This error occurs when “ERROR NOTICE” from the partner side HSSB
is received.
0100: It occurs when a bus cycle to HSSB is finished abnormally.
0101: It occurs when an OPEN requirement was received in BUSRDY.
0110: It occurs when the data of packet–ID that is send again from the part-
ner side HSSB did not exist any longer in the buffer.
0111: It occurs when SYNC–code cannot be detected more than 256 bit.
(disconnection condition)

R0.13 Power Mate side

When parity error of common–RAM occurs, it becomes “1”.

R0.14

When “FATAL ERROR” except for the hardware resetting error occurs, it be-
comes “1”.

R2.07–R2.00 Bit transmission error counter

This is binary counter added by 1 when bit transmission error ocurs.

R2.08

When bit transmission error counter causes overflow, it becomes “1”.

R4.04–R4.03 Temperature alarm of intelligent terminal(PC side)

R4.07–R4.06 Temperature alarm of intelligent terminal(Power Mate side)

01: High temperature alarm


10: Low temperature alarm
11: normal condition

R6.12–R6.15 Revision number

Revision number on each side is shown by these four bits.

3 – 14
B–62684EN–1/01 BOOT APPLICATION SOFTWARE 4. OPERATION SCREEN

4.8
CONTENT C–RAM
SCREEN CONTENT
ADDRESS
OF
+0
COMMON RAM
+1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
00000 12 34 56 78–9A BC DE F0–00 00 00 00–00 00 00 00
00010 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
00020 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
00030 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
00040 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
00050 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
00060 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
00070 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
00080 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
00090 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
000A0 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
000B0 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
000C0 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
000D0 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
000E0 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00
000F0 00 00 00 00–00 00 00 00–00 00 00 00–00 00 00 00

**** MESSAGE ****


B:BYTE W:WORD L:2WORD PAGE–UP: PAGE–DOWN:
ESC:EXIT A:ADDRESS INPUT CURSOR:
FANUC Power Mate BOOT Application Version 1.00 [I/O]
Copyright(C) FANUC LTD. 1996 All right reserved.

Fig.4.8 (a) Content C–RAM screen (1)

This screen displays the memory content of HSSB common–RAM in


Power Mate. This is provided as a maintenance tool to investigate the
problem of HSSB protocol or Direct Command function.
The example of the display in the word size is shown in Fig.4.8 (b).
The example of the display in the double word size is shown in Fig.4.8
(c).

CONTENT OF COMMON RAM


ADDRESS +0 +2 +4 +6 +8 +A +C +E
00000 3412 7856–BC9A F0DE–0000 0000–0000 0000
00010 0000 0000–0000 0000–0000 0000–0000 0000
00020 0000 0000–0000 0000–0000 0000–0000 0000
00030 0000 0000–0000 0000–0000 0000–0000 0000
00040 0000 0000–0000 0000–0000 0000–0000 0000
00050 0000 0000–0000 0000–0000 0000–0000 0000
00060 0000 0000–0000 0000–0000 0000–0000 0000
00070 0000 0000–0000 0000–0000 0000–0000 0000
00080 0000 0000–0000 0000–0000 0000–0000 0000
00090 0000 0000–0000 0000–0000 0000–0000 0000
000A0 0000 0000–0000 0000–0000 0000–0000 0000
000B0 0000 0000–0000 0000–0000 0000–0000 0000
000C0 0000 0000–0000 0000–0000 0000–0000 0000
000D0 0000 0000–0000 0000–0000 0000–0000 0000
000E0 0000 0000–0000 0000–0000 0000–0000 0000
000F0 0000 0000–0000 0000–0000 0000–0000 0000

**** MESSAGE ****


B:BYTE W:WORD L:2WORD PAGE–UP: PAGE–DOWN:
ESC:EXIT A:ADDRESS INPUT CURSOR:
FANUC Power Mate BOOT Application Version 1.00 [I/O]
Copyright(C) FANUC LTD. 1996 All right reserved.

Fig.4.8 (b) Content C–RAM screen (2)

3 – 15
4. OPERATION SCREEN BOOT APPLICATION SOFTWARE B–62684EN–1/01

CONTENT OF COMMON RAM


ADDRESS +0 +4 +8 +C
00000 78563412–F0DEBC9A–00000000–00000000
00010 00000000–00000000–00000000–00000000
00020 00000000–00000000–00000000–00000000
00030 00000000–00000000–00000000–00000000
00040 00000000–00000000–00000000–00000000
00050 00000000–00000000–00000000–00000000
00060 00000000–00000000–00000000–00000000
00070 00000000–00000000–00000000–00000000
00080 00000000–00000000–00000000–00000000
00090 00000000–00000000–00000000–00000000
000A0 00000000–00000000–00000000–00000000
000B0 00000000–00000000–00000000–00000000
000C0 00000000–00000000–00000000–00000000
000D0 00000000–00000000–00000000–00000000
000E0 00000000–00000000–00000000–00000000
000F0 00000000–00000000–00000000–00000000
* The display was omitted from 19 to 24 lines of this screen.

Fig.4.8 (c) Content C–RAM screen (3)

3 – 16
B–62684EN–1/01 Index
ƠAơ IPL processing screen, 3 – 9

API library for HSSB (for Windows 3.1), 1 – 8

ƠM ơ
ƠBơ
Machine select screen, 3 – 5
Maintenance package, 1 – 13
Basic operation package, 1 – 13
Boot application software (for Windows 3.1), 1 – 13
Boot processing screen, 3 – 8 ƠNơ
Notice about the selection of the personal computer, 1 – 4

ƠCơ
Configuration of hardware, 1 – 3 ƠOơ
Configuration of software, 1 – 5 Operation explanation, 3 – 3
Content C–RAM screen, 3 – 15 Operation screen, 3 – 4
Others function, 2 – 150

ƠE ơ
Environmental requirements, 1 – 4
ƠP ơ
Package software, 1 – 13
Processing select screen, 3 – 6

ƠF ơ Product distribution, 1 – 6

Function list, 2 – 4
Function outline, 3 – 1
ƠRơ
Related to NC data file, 2 – 69
Related to operation history data, 2 – 115
ƠGơ Related to program, 2 – 34
General description, 2 – 2 Related to the axis movement control, 2 – 131
Related to the communication, 2 – 8
Related to the control axes, 2 – 12

ƠHơ Related to the PMC, 2 – 196

High speed serial bus driver software for Windows 3.1, 1 – 7


HSSB board test screen, 3 – 12
HSSB registers screen, 3 – 13
ƠS ơ
Set up Power Mate, 1 – 14
Software of high speed serial bus, 1 – 6

ƠI ơ
Specifications, 1 – 7
System alarm screen, 3 – 11
Install, 3 – 2

i–1
Revision Record

FANUCĄPower Mate-MODEL H High Speed Serial Bus function OPERATOR’S MANUAL (B–62684EN–1)

01 Jan., ’97

Edition Date Contents Edition Date Contents


Addendum

This addendum to GFZ-62684EN-1 contains the HSSB


library functions for communicating with the Power Mate
Model D and Power Mate Model H in the 32-bit Windows 95
and Windows NT4.0 environment. When developing in the
32-bit programming environment, please use the reference
information provided in this addendum.
GE Fanuc Automation

PowerMotion™ Products

Power Mate D and H Motion Controllers


HSSB Library Functions for 32-Bit Environment

Addendum to HSSB Operator's Manual

GFZ-62684EN-1/01 January 1997


(with Supplementary Information)
GFL-001
Warnings, Cautions, and Notes
as Used in this Publication

Warning
Warning notices are used in this publication to emphasize that hazardous voltages, currents,
temperatures, or other conditions that could cause personal injury exist in this equipment or
may be associated with its use.
In situations where inattention could cause either personal injury or damage to equipment, a
Warning notice is used.

Caution
Caution notices are used where equipment might be damaged if care is not taken.

Note
Notes merely call attention to information that is especially significant to understanding and
operating the equipment.

This document is based on information available at the time of its publication. While efforts
have been made to be accurate, the information contained herein does not purport to cover all
details or variations in hardware or software, nor to provide for every possible contingency in
connection with installation, operation, or maintenance. Features may be described herein
which are not present in all hardware and software systems. GE Fanuc Automation assumes
no obligation of notice to holders of this document with respect to changes subsequently made.

GE Fanuc Automation makes no representation or warranty, expressed, implied, or statutory


with respect to, and assumes no responsibility for the accuracy, completeness, sufficiency, or
usefulness of the information contained herein. No warranties of merchantability or fitness for
purpose shall apply.

PowerMotion is a trademark of GE Fanuc Automation North America, Inc.

©Copyright 1997-1998 GE Fanuc Automation North America, Inc.


All Rights Reserved.
Preface

Content of this Addendum


This addendum to GFZ-62684EN-1 contains the HSSB library functions for communicating with
the Power Mate Model D and Power Mate Model H in the 32-bit Windows 95 and Windows
NT4.0 environment. When developing in the 32-bit programming environment, please use the
reference information provided in this addendum.

GFZ-62684EN-1/01 iii
Introduction ______________________________________________________________________ 4
1. Extended Libraries_______________________________________________________________ 5
1.1 CNC/PMC Data Window Library for Windows 95 ____________________________________ 5
1.1.1 Outline ___________________________________________________________________________5
1.1.2 General Description_________________________________________________________________6
1.1.3 Library Handle ____________________________________________________________________7
(1) Library Handle Description. ___________________________________________________________________ 7
(2) Library Handle Cautions. _____________________________________________________________________ 8
1.1.4 Return Status of Data Window Function________________________________________________9
1.1.5 Function List _____________________________________________________________________11
Multi-Connection of HSSB ______________________________________________________________________ 11
Functions Related to Controlled Axis ______________________________________________________________ 11
Functions Related to CNC Program _______________________________________________________________ 11
Functions Related to CNC File Data_______________________________________________________________ 12
Functions Related to History Data ________________________________________________________________ 12
Functions Related to the axis movement control _____________________________________________________ 12
Functions Related to Others _____________________________________________________________________ 13
Functions Related to PMC ______________________________________________________________________ 13
1.1.6 Multi-Connection of HSSB __________________________________________________________14
Structure of library for multi-connection ___________________________________________________________ 14
(1) Allocate the Library Handle (for Multi-Connection) _______________________________________________ 15
(2) Allocate library handle 2(for Multi-Connection) __________________________________________________ 16
(3) Free library handle(for Multi-Connection) _______________________________________________________ 17
1.1.7 Function Reference Related to Controlled Axes _________________________________________18
(1) Read Actual Axis Feedrate (F) ________________________________________________________________ 18
(2) Read absolute axis position ___________________________________________________________________ 19
(3) Read machine axis position___________________________________________________________________ 21
(4) Read relative axis position____________________________________________________________________ 23
(5) Read distance to go _________________________________________________________________________ 25
(6) Read skip position __________________________________________________________________________ 27
(7) Read servo delay value ______________________________________________________________________ 29
(8) Read acceleration/deceleration delay value_______________________________________________________ 31
(9) Read all dynamic data _______________________________________________________________________ 33
(10) Set origin / preset relative axis position ________________________________________________________ 37
1.1.8 Function Reference Related to Program _______________________________________________39
(1) Start Downloading NC Program _______________________________________________________________ 39
(2) Download NC program ______________________________________________________________________ 40
(3) End of downloading NC program ______________________________________________________________ 43
(4) Start uploading NC program __________________________________________________________________ 44
(5) Upload NC program ________________________________________________________________________ 45
(6) End of uploading NC program ________________________________________________________________ 48
(7) Search specified program ____________________________________________________________________ 49
(8) Delete all programs _________________________________________________________________________ 51
(9) Delete specified program_____________________________________________________________________ 53
(10) Read program directory _____________________________________________________________________ 55
(11) Read program information __________________________________________________________________ 58
(12) Read program number under execution ________________________________________________________ 60
(13) Read sequence number under execution ________________________________________________________ 61
(14) Read program under execution _______________________________________________________________ 62
(15) Write program for MDI operation_____________________________________________________________ 63

1
(16) Read execution pointer for MDI operation ______________________________________________________ 64
(17) Write execution pointer for MDI operation______________________________________________________ 65
(18) Search specified sequence number ____________________________________________________________ 66
(19) Rewind cursor of NC program _______________________________________________________________ 67
1.1.9 Function Reference Related to NC File Data____________________________________________68
(1) Read Tool Offset Value ______________________________________________________________________ 68
(2) Write tool offset value _______________________________________________________________________ 70
(3) Read tool offset value(area specified) ___________________________________________________________ 72
(4) Write tool offset value(area specified)___________________________________________________________ 74
(5) Read tool offset information __________________________________________________________________ 76
(6) Read parameter ____________________________________________________________________________ 77
(7) Write parameter____________________________________________________________________________ 80
(8) Read parameter(area specified) ________________________________________________________________ 83
(9) Write parameter(area specified) _______________________________________________________________ 87
(10) Read parameter information _________________________________________________________________ 90
(11) Read setting data(area specified)______________________________________________________________ 92
(12) Write setting data(area specified) _____________________________________________________________ 95
(13) Read custom macro variable _________________________________________________________________ 98
(14) Write custom macro variable________________________________________________________________ 100
(15) Read custom macro variable(area specified) ____________________________________________________ 102
(16) Write custom macro variable(area specified) ___________________________________________________ 105
(17) Read custom macro variable information ______________________________________________________ 108
(18) Get type of custom macro variable ___________________________________________________________ 109
(19) Set type of custom macro variable____________________________________________________________ 110
1.1.10 Function Reference Related to History Data__________________________________________111
(1) Stop Logging Operation History Data__________________________________________________________ 111
(2) Restart logging operation history data _________________________________________________________ 112
(3) Read number of operation history data _________________________________________________________ 113
(4) Read operation history data __________________________________________________________________ 114
(5) Read number of alarm history data ____________________________________________________________ 118
(6) Read alarm history data_____________________________________________________________________ 119
(7) Clear operation history data _________________________________________________________________ 122
(8) Read signals related operation history__________________________________________________________ 123
(9) Write signals related operation history _________________________________________________________ 124
1.1.11 Functions Related to the axis movement control _______________________________________125
(1) Signal operation command (Cannot be used on Power Mate-D) _____________________________________ 125
(2) Reference point return (Cannot be used on Power Mate-D) _________________________________________ 128
(3) Absolute movement (Cannot be used on Power Mate-D) ___________________________________________ 130
(4) Incremental movement (Cannot be used on Power Mate-D) ________________________________________ 133
(5) Dwell (Cannot be used on Power Mate-D) ______________________________________________________ 136
(6) Coordinate establishment (Cannot be used on Power Mate-D) ______________________________________ 138
(7) Reading of the executive buffer condition (Cannot be used on Power Mate-D)__________________________ 140
(8) Reading of the execution completion condition (Cannot be used on Power Mate-D) _____________________ 142
(9) The release of the reading mode of the execution completion condition (Cannot be used on Power Mate-D) __ 143
1.1.12 Function Reference of Others ______________________________________________________144
(1) Read CNC System Information _______________________________________________________________ 144
(2)Read CNC configuration information __________________________________________________________ 146
(3)Read CNC status information_________________________________________________________________ 149
(4) Read alarm status__________________________________________________________________________ 151
(5) Read alarm information_____________________________________________________________________ 153
(6) Read modal data __________________________________________________________________________ 156
(7) Read diagnosis data ________________________________________________________________________ 161
(8) Read diagnosis data(area specified) ___________________________________________________________ 163
(9) Read maximum valid figures, number of decimal places ___________________________________________ 166
(10) Read real current for servo adjustment ________________________________________________________ 168

2
(11) Read real speed for servo adjustment _________________________________________________________ 169
(12) Read loop gain for servo adjustment __________________________________________________________ 170
(13) Read operator's message ___________________________________________________________________ 171
(14) Read output signal image of software operator's panel ____________________________________________ 173
(15) Write output signal of software operator's panel_________________________________________________ 175
(16) Read general signal image of software operator's panel ___________________________________________ 177
(17) Write general output signal of software operator's panel __________________________________________ 178
(18) Read general signal name of software operator's panel ___________________________________________ 179
(19) Write general signal name of software operator's panel ___________________________________________ 181
1.1.13 Function Reference Related to PMC ________________________________________________183
(1) Read PMC data(area specified) _______________________________________________________________ 183
(2) Write PMC data(area specified) ______________________________________________________________ 185
(3) Read PMC data information _________________________________________________________________ 187

3
Introduction
This manual describes the information necessary for developing the
application software of the Power Mate CNCs in the 32 bit Windows 95
and Windows NT4.0 environment.

Use this manual together with the operator's manual for the Power Mate CNCs.

NOTE:
The Power Mate CNC is supported in Version 1.4 and newer
of the HSSB software only.

COPYRIGHT, OTHERS

* The copyright of MS-DOS and other software provided with the control is
owned by Microsoft Corporation(U.S.A.), Phoenix Technologies
Limited(U.S.A.), Cirrus Logic Inc.(U.S.A.), Fujitsu Limited, and FANUC
Limited.

* No part of the software described above, or its manuals, may be used or


reproduced without permission.

* No part of the software described above, or its manuals, may be sold


independently of the control.

* Basically, one set of the software described above must be purchased for
each control.

* The software described above, and its manual, must be used under the
conditions described in the attached license agreement.

* The use of the CNC incorporating HSSB shall imply that the user agrees
to the conditions of the license agreement described above.
+---------------------------------------------------------------------------+
| * Microsoft, MS, MS-DOS, Windows, Visual Basic are registered trademark of|
| Microsoft corporation, U.S.A. |
| * Visual C++ is trademark of Microsoft corporation, U.S.A. |
| * Company name and product name mentioned in this manual are registered |
| trademark or trademark of each company. |
+---------------------------------------------------------------------------+

4
1. Extended Libraries

1.1 CNC/PMC Data Window Library for Windows 95

1.1.1 Outline
The CNC/PMC data window library is used for exchanging data and information
between the Intelligent terminal or personal computer through HSSB and
the CNC/PMC.

The main functions of the library are as follows.

(1) Reading of data related to controlled axes

This data includes the absolute position, relative position, machine


position, remaining travel distance, actual feedrate, and so forth.

(2) Operations related to CNC program

Operations include upload/download, verification, search, and deletion of


CNC programs, read CNC program directory, and DNC operation from the MMC.

(3) Reading/writing of CNC file data

This data includes tool offset data, workpiece reference point offset
data, parameters, settings, custom macro variables, P-code macro
variables, and pitch error compensation data.

(4) Reading of history data

This data includes operation history data and alarm history data.

(5) Functions Related to the axis movement control

This data includes manual control of the servos, separate from the CNC
control or part program control.

(6) Reading of other data

This data includes continuous-state data, diagnostic data, A/D conversion


data, alarm information, and operator messages.

(7) Reading/writing of data related to PMC

This data includes addresses G, F, Y, X, A, R, T, C, and D, extended


backup memory, and information to be exchanged between the CNC and PMC.

5
1.1.2 General Description
(1) Library files

FWLIB32.DLL : the DLL library


FWLIB32.LIB : the import library
FWLIB32.H : the header file for 'prototype of function', 'structure'
and 'definition of return status'

(2) Language for development and Memory model

CNC/PMC data window library is developed/tested by using the following


language.

- Visual C++ 4.0,4.1

(3) Number of axes

Maximum controlled axes : maximum number of axes for data window interface
Current controlled axes : number of axes controlled by CNC system currently

Maximum controlled axes is defined as 'MAX_AXIS' in the header file.


It is different for each Power Mate CNC system, and so define the following
constant by using the '-D' option which is specified on compiling.

'Current controlled axis' can be got by 'Read CNC system information


(cnc_sysinfo())' function.

System Option(-D)
----------------------------------
Power Mate-H #define MAX_AXIS 6
Power Mate-D #define MAX_AXIS 2

6
1.1.3 Library Handle

(1) Library Handle Description.

The library handle number has to be obtained by using the 'cnc_allclibhndl()'


or 'cnc_allclibhndl2()' function until the CNC/PMC data window function is called
for the first time after the start of an application program.

It has to be held until an application program terminates, and it has to


be released by using the 'cnc_freelibhndl()' function when an application
program terminates.

The outline of sequence of an application program is as follows.

+------------------------------+
| Start of application program |
+------------------------------+
|
v
+---------------------------+
| Get library handle number |
+---------------------------+
|
v
+----------------------------------------------+
| Set library handle number to global variable |
+----------------------------------------------+
|
v
+------------------------+
| Call library function | * Pass library handle number as argument
+------------------------+
|
v
+-------------------------------+
| Release library handle number |
+-------------------------------+
|
v
+------------------------------------+
| Termination of application program |
+------------------------------------+

NOTE
If an application program terminates without releasing the library
handle number, the area for it remains and accumulates. If this repeats,
to much memory will be used and the library handle number will
eventually not be able to be obtained.

7
(2) Library Handle Cautions.

Cautions, which have to be considered when the power supply on the NC side
connected with PC via HSSB is turned off, are shown below.

(1) When the power supply on the NC side is turned off while the library
function is running

When the power supply on the NC side is turned off while the library
function is running, the result of the operation under execution is not
guaranteed. Therefore, the power supply should be turned off after confirming
that no library functions are running.
When the power supply on the NC side is turned off while the library is not
running, the library function becomes executable by acquiring the library
handle again after NC is started up.

(2) Specification of cnc_allclibhndl() and cnc_allclibhndl2()

If cnc_allclibhndl() or cnc_allclibhndl2() is executed while the power


supply on the NC side is off, EW_HSSB is returned as the completion status.
And, if cnc_allclibhndl() or cnc_allclibhndl2() is executed immediately after
the NC starting up, the completion status EW_BUSY may be returned. This
shows that the initialization of the interface between NC and PC is not
finished.
Retry calling the function until the initialization completes when the
completion status is EW_BUSY.

(3) Validity of the library handle when power supply on the NC side is
turned off

When the power supply of NC is turned off after the library handle is
acquired, the acquired library handles become invalid.
(When multiple NC's are connected via HSSB interface, only the library handle
of the NC whose power supply is turned off becomes invalid. The library
handle of the NC whose power supply is not off remains valid.)
If the library function is executed with the invalid library handle while the
power supply of the NC is OFF, the completion status of EW_HSSB is returned.
Moreover, when the library function is executed with the invalid library
handle after starting up the NC again, the completion status of EW_HANDLE
is returned.
The library handle which became invalid must be released by the function
cnc_freelibhndl().

8
1.1.4 Return Status of Data Window Function
(1) CNC/PMC data window

+------------+---------------------------+-----------------------------------+
|return value| meaning | explanation and user response |
+------------+---------------------------+-----------------------------------+
| EW_ITLOW | Low temperature alarm of | Please cut and reactivate the |
| (-13) | intelligent terminal | power supply where the data in the|
| | | disk might be destroyed after a |
| | | while. |
+------------+---------------------------+-----------------------------------+
| EW_IHIGHT | High temperature alarm of | Please cut and reactivate the |
| (-12) | intelligent terminal | power supply where the data in the|
| | | disk might be destroyed after a |
| | | while. |
+------------+---------------------------+-----------------------------------+
| EW_BUS | Bus error. | Bus error of Power Mate. |
| (-11) | | Ask service/charge post. |
+------------+---------------------------+-----------------------------------+
| EW_SYSTEM2| System error(2). | System error of Power Mate. |
| (-10) | | Ask service/charge post. |
+------------+---------------------------+-----------------------------------+
| EW_HSSB | Communication error of | Confirm the serial cable of HSSB |
| (- 9) | HSSB. | or I/F board. |
+------------+---------------------------+-----------------------------------+
| EW_SYSTEM | System error. | System error of Power Mate. |
| (- 5) | | Ask service/charge post. |
+------------+---------------------------+-----------------------------------+
| EW_BUSY | Busy. | Wait until the completion of Power|
| (- 1) | | Mate processing, or retry. |
+------------+---------------------------+-----------------------------------+
| EW_OK | Normal termination. | |
| ( 0) | | |
+------------+---------------------------+-----------------------------------+
| EW_FUNC | Error(start operation not | The user has not started any of |
| ( 1) | executed or start | the following operations, or |
| | already executed) | attempted to start one of the |
| | | following operations while it was |
| | | already started. |
| | | - Start downloading NC program. |
| | | - Start uploading NC program. |
+------------+---------------------------+-----------------------------------+
| EW_LENGTH | Error(data block length | Check and correct the data block |
| ( 2) | error) | length or number of data. |
+------------+---------------------------+-----------------------------------+
| EW_NUMBER | Error(data number error) | Check and correct the data number.|
| ( 3) | | |
+------------+---------------------------+-----------------------------------+
| EW_ATTRIB | Error(data attribute | Check and correct the data |
| ( 4) | error) | attribute. |
+------------+---------------------------+-----------------------------------+
| | | Check and correct the data. |
| | | For the following operations, this|
| EW_DATA | Error(data error) | code indicates that the specified |
| ( 5) | | program cannot be found. |
| | | - Delete specified program. |
| | | - Search specified program. |
| | | - Start uploading NC program. |
+------------+---------------------------+-----------------------------------+

9
+------------+---------------------------+-----------------------------------+
| EW_NOOPT | Error(no option) | The Power Mate option is not |
| ( 6) | | provided. |
+------------+---------------------------+-----------------------------------+
| EW_PROT | Error(write protect) | Write operation is prohibited. |
| ( 7) | | |
+------------+---------------------------+-----------------------------------+
| EW_OVRFLOW| Error(memory overflow) | The Power Mate memory overflowed. |
| ( 8) | | |
+------------+---------------------------+-----------------------------------+
| EW_PARAM | Error(Power Mate parameter| Power Mate parameter is set |
| ( 9) | error) | incorrectly |
+------------+---------------------------+-----------------------------------+
| | | The buffer is empty or full. |
| EW_BUFFER | Error(buffer empty/full) | Wait unit completion of Power Mate|
| ( 10) | | processing, or retry. |
+------------+---------------------------+-----------------------------------+
| EW_PATH | Error(path number error) |A path number is incorrect. |
| ( 11) | | |
+------------+---------------------------+-----------------------------------+
| EW_MODE | Error(Power Mate mode | The Power Mate mode is incorrect. |
| ( 12) | error) | Correct the Power Mate mode. |
+------------+---------------------------+-----------------------------------+
| EW_REJECT | Error(execution refusal of| The execution of the processing |
| ( 13) | CNC side processing) | was refused by Power Mate. |
| | | Please confirm the execution |
| | | condition. |
+------------+---------------------------+-----------------------------------+

10
1.1.5 Function List

Multi-Connection of HSSB
-------------------------------------------------------------------------------
1.1.6 Function name Brief description
-------------------------------------------------------------------------------
( 1) cnc_allclibhndl Allocate library handle
( 2) cnc_allclibhndl2 Allocate library handle2
( 3) cnc_freelibhndl Free library handle
-------------------------------------------------------------------------------

Functions Related to Controlled Axis


--------------------------------------------------------------------------------
1.1.7 Function name Brief description
--------------------------------------------------------------------------------
( 1) cnc_actf Read actual axis feedrate(F)
( 2) cnc_absolute Read absolute axis position
( 3) cnc_machine Read machine axis position
( 4) cnc_relative Read relative axis position
( 5) cnc_distance Read distance to go
( 6) cnc_skip Read skip position
( 7) cnc_srvdelay Read servo delay value
( 8) cnc_accdecdly Read acceleration/deceleration delay value
( 9) cnc_rddynamic Read all dynamic data
(10) cnc_wrrelpos Set origin / preset relative axis position
-------------------------------------------------------------------------------

Functions Related to CNC Program


--------------------------------------------------------------------------------
1.1.8 Function name Brief description
--------------------------------------------------------------------------------
( 1) cnc_dwnstart Start downloading NC program
( 2) cnc_download Download NC program
( 3) cnc_dwnend End of downloading NC program
( 4) cnc_upstart Start uploading NC program
( 5) cnc_upload Upload NC program
( 6) cnc_upend End of uploading NC program
( 7) cnc_search Search specified program
( 8) cnc_delall Delete all programs
( 9) cnc_delete Delete specified program
(10) cnc_rdprogdir Read program directory
(11) cnc_rdproginfo Read program information
(12) cnc_rdprgnum Read program number under execution
(13) cnc_rdseqnum Read sequence number under execution
(14) cnc_rdexecprog Read program under execution
(15) cnc_wrmdiprog Write program for MDI operation
(16) cnc_rdmdipntr Read execution pointer for MDI operation
(17) cnc_wrmdipntr Write execution pointer for MDI operation
(18) cnc_seqsrch Search specified sequence number
(19) cnc_rewind Rewind cursor of NC program
-------------------------------------------------------------------------------

11
Functions Related to CNC File Data
--------------------------------------------------------------------------------
1.1.9 Function name Brief description
--------------------------------------------------------------------------------
( 1) cnc_rdtofs Read tool offset value
( 2) cnc_wrtofs Write tool offset value
( 3) cnc_rdtofsr Read tool offset value(area specified)
( 4) cnc_wrtofsr Write tool offset value(area specified)
( 5) cnc_rdtofsinfo Read tool offset information
( 6) cnc_rdparam Read parameter
( 7) cnc_wrparam Write parameter
( 8) cnc_rdparar Read parameter(area specified)
( 9) cnc_wrparas Write parameter(area specified)
(10) cnc_rdparainfo Read parameter information
(11) cnc_rdsetr Read setting data(area specified)
(12) cnc_wrsets Write setting data(area specified)
(13) cnc_rdmacro Read custom macro variable
(14) cnc_wrmacro Write custom macro variable
(15) cnc_rdmacror Read custom macro variable(area specified)
(16) cnc_wrmacror Write custom macro variable(area specified)
(17) cnc_rdmacroinfo Read custom macro variable information
(18) cnc_getmactype Get type of custom macro variable
(19) cnc_setmactype Set type of custom macro variable
-------------------------------------------------------------------------------

Functions Related to History Data


--------------------------------------------------------------------------------
1.1.10 Function name Brief description
--------------------------------------------------------------------------------
( 1) cnc_stopophis Stop logging operation history data
( 2) cnc_startophis Restart logging operation history data
( 3) cnc_rdophisno Read number of operation history data
( 4) cnc_rdophistry Read operation history data
( 5) cnc_rdalmhisno Read number of alarm history data
( 6) cnc_rdalmhistry Read alarm history data
( 7) cnc_clearophis Clear operation history data
( 8) cnc_rdhissgnl Read signals related operation history
( 9) cnc_wrhissgnl Write signals related operation history
-------------------------------------------------------------------------------

Functions Related to the axis movement control


--------------------------------------------------------------------------------
1.1.11 Function name Brief description
--------------------------------------------------------------------------------
*( 1) cnc_opdi Signal operation command
*( 2) cnc_refpoint Reference point return
*( 3) cnc_abspoint Absolute movement
*( 4) cnc_incpoint Incremental movement
*( 5) cnc_dwell Dwell
*( 6) cnc_coordre Coordinate establishment
*( 7) cnc_exebufstat Reading of the executive buffer condition
*( 8) cnc_finstate Reading of the complete executive condition
*( 9) cnc_setfin The release of the complete executive condition
-------------------------------------------------------------------------------
* This function cannot be used with Power Mate-D.

12
Functions Related to Others
--------------------------------------------------------------------------------
1.1.12 Function name Brief description
--------------------------------------------------------------------------------
( 1) cnc_sysinfo Read CNC system information
( 2) cnc_sysconfig Read CNC configuration information
( 3) cnc_statinfo Read CNC status information
( 4) cnc_alarm Read alarm status
( 5) cnc_rdalminfo Read alarm information
( 6) cnc_modal Read modal data
( 7) cnc_diagnoss Read diagnosis data
( 8) cnc_diagnosr Read diagnosis data(area specified)
( 9) cnc_getfigure Read maximum valid figures, number of decimal places
(10) cnc_rdcurrent Read real current for servo adjustment
(11) cnc_rdsrvspeed Read real speed for servo adjustment
(12) cnc_rdloopgain Read loop gain for servo adjustment
(13) cnc_rdopmsg Read operator's message
(14) cnc_rdopnlsgnl Read output signal image of software operator's panel
(15) cnc_wropnlsgnl Write output signal of software operator's panel
(16) cnc_rdopnlgnrl Read general signal image of software operator's panel
(17) cnc_wropnlgnrl Write general output signal of software operator's panel
(18) cnc_rdopnlgsname Read general signal name of software operator's panel
(19) cnc_wropnlgsname Write general signal name of software operator's panel
-------------------------------------------------------------------------------

Functions Related to PMC


--------------------------------------------------------------------------------
1.1.13 Function name Brief description
--------------------------------------------------------------------------------
( 1) pmc_rdpmcrng read PMC data(area specified)
( 2) pmc_wrpmcrng write PMC data(area specified)
( 3) pmc_rdmcinfo read PMC data information
-------------------------------------------------------------------------------

13
1.1.6 Multi-Connection of HSSB

Structure of library for multi-connection

+---------------------------+
| Application |
+-------------+-------------+
|
+-------------+-------------+
| FWLIB32.DLL: Control DLL |
+-----------+---+---+-------+
| | |
+--------------+ | +--------------+
| | |
+-------+-------+ +-------+-------+ +-------+-------+
| FWLIB150.DLL: | | FWLIB160.DLL: | | FWLIBPM.DLL: |
| DLL for 150 | | DLL for | | DLL for |
| | | 160/180/210 | | Power Mate |
+---------------+ +---------------+ +---------------+

- All function must be called through the control DLL after the handle
number of specified node has been got by using the cnc_allclibhndl2()
function.

- The cnc_allclibhndl() is allocated to the default node (number 0).

14
(1) Allocate the Library Handle (for Multi-Connection)

Function Name: cnc_allclibhndl

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_allclibhndl(unsigned short *FlibHndl);

Description: Allocates the library handle which is used by the Windows


version library.

Arguments:
FlibHndl Identify the process which uses the library.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

15
(2) Allocate library handle 2(for Multi-Connection)

Function Name: cnc_allclibhndl2

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_allclibhndl2(long node,
unsigned short *FlibHndl);

Description: Allocates the library handle which is used by the Windows


version library.

Arguments:
FlibHndl Identify the process which uses the library.

node The node number of the device is specified. (0•`7)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

16
(3) Free library handle(for Multi-Connection)

Function Name: cnc_freelibhndl

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_freelibhndl(unsigned short FlibHndl);

Description: Frees the library handle which is used by the Windows version
library.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

17
1.1.7 Function Reference Related to Controlled Axes

(1) Read Actual Axis Feedrate (F)

Function Name: cnc_actf

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_actf(unsigned short FlibHndl,
ODBACT *actualfeed);

Description: Reads the actual feed rate of the controlled axes of CNC.
The actual feed rate is stored in "data" of "ODBACT".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Actualfeed Pointer to the ODBACT structure including the actual feed


rate of the controlled axes.

The ODBACT structure is as follows.

typedef struct odbact {


short dummy[2]; /* dummy */
long data; /* the actual feed rate(F)*/
} ODBACT ;

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program displays "CURRENT F=1200" while the block
N20:O1234 of the following NC program is being executed.
(in case of "mm input".)
O1234 ;
N10 G90 F1200 ;
N20 G1 X10. Z200.
N30 ...

#include <stdio.h>
#include "apilib.h"
void example( void )
{
ODBACT buf ;
cnc_actf( 0, &buf ) ;
printf( "CURRENT F=%ld\n", buf.data ) ;
}

18
(2) Read absolute axis position

Function Name: cnc_absolute

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_absolute(unsigned short FlibHndl, short axis,
short length, ODBAXIS *absolute);

Description: Reads the absolute position data of the axis specified with
"axis".
The absolute position is stored in "data[0]" of "ODBAXIS".

All axes can be read at a time by specifying ALL_AXES for


"axis".
In that case, an absolute position of each axis is stored in the
data array of ODBAXIS.

The decimal point position of the absolute position can be


acquired in the cnc_getfigure() function.

As for Power Mate, amounts of Tool Length Compensation , and


amounts of servo delay and acceleration/deceleration delay is
always included in the read absolute position.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

axis Specify axis number to read.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m : number of controlled axis)

length Specify the length of the data block(size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0+-------+ -- 0+-------+ --
| dummy | ^ | dummy | ^
2+-------+ | 2+-------+ |
| type | length | type | length
4+-------+-------+ | 4+-------+-------+ |
| data[0] | v | data[0] | |
8+---------------+ -- 8+---------------+ |
== ==|
4+4x(n-1)+---------------+ |
| data[n-1] | v
4+4xn+---------------+ --
n : Current controlled axes

absolute Pointer to the ODBAXIS structure including the absolute position


data of the controlled axes.

The ODBAXIS structure is as follows.

typedef struct odbaxis {


short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Absolute position data of
controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

19
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program displays
1: 120005
2: -50119
3: 80
while the absolute position data for each axes is
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 <stdio.h>
#include "apilib.h"

void example( void )


{
ODBAXIS buf ;
cnc_absolute( 0, -1, 4+4*3, &buf ) ;
printf( "1:%8ld\n2:%8ld\n3:%8ld\n", buf.data[0], buf.data[1],
buf.data[2] ) ;
}

20
(3) Read machine axis position

Function Name: cnc_machine

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_machine(unsigned short FlibHndl, short axis,
short length, ODBAXIS *machine);

Description: Reads the machine position data of the axis specified with
"axis".
The machine position is stored in "data[0]" of "ODBAXIS".

All axes can be read at a time by specifying ALL_AXES for axis".


In that case, an machine position of each axis is stored in the
data array of ODBAXIS.

The decimal point position of the machine position can be


acquired in the cnc_getfigure() function.

As for Power Mate, amounts of servo delay and acceleration/


deceleration delay is always included in the read machine
position.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

axis Specify axis number to read.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m :number of controlled axis)

length Specify the length of the data block(size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0+-------+ -- 0+-------+ --
| dummy | ^ | dummy | ^
2+-------+ | 2+-------+ |
| type | length | type | length
4+-------+-------+ | 4+-------+-------+ |
| data[0] | v | data[0] | |
8+---------------+ -- 8+---------------+ |
== ==|
4+4x(n-1)+---------------+ |
| data[n-1] | v
4+4xn+---------------+ --
n : Current controlled axes

machine Pointer to the ODBAXIS structure including the machine position


data of the controlled axes.

The ODBAXIS structure is as follows.

typedef struct odbaxis {


short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Machine position data of
controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

21
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

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 <stdio.h>
#include "apilib.h"

void example( void )


{
ODBAXIS buf ;
cnc_machine( 0, 2, 4+4*1, &buf ) ;
printf( "MACHINE 2:%8ld\n", buf.data[0] ) ;
}

22
(4) Read relative axis position

Function Name: cnc_relative

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_relative(unsigned short FlibHndl, short axis,
short length, ODBAXIS *relative);

Description: Reads the relative position data of the axis specified with
"axis".
The relative position is stored in "data[0]" of "ODBAXIS".

All axes can be read at a time by specifying ALL_AXES for


"axis".
In that case, an relative position of each axis is stored in the
data array of ODBAXIS.

The decimal point position of the relative position can be


acquired in the cnc_getfigure() function.

As for Power Mate, amounts of Tool Length Compensation, and


amounts of servo delay and acceleration/deceleration delay is
always included in the read relative position.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

axis Specify axis number to read.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m : number of controlled axis)

length Specify the length of the data block(size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0+-------+ -- 0+-------+ --
| dummy | ^ | dummy | ^
2+-------+ | 2+-------+ |
| type | length | type | length
4+-------+-------+ | 4+-------+-------+ |
| data[0] | v | data[0] | |
8+---------------+ -- 8+---------------+ |
== ==|
4+4x(n-1)+---------------+ |
| data[n-1] | v
4+4xn+---------------+ --
n : Current controlled axes

relative Pointer to the ODBAXIS structure including the relative position


data of the controlled axes.

The ODBAXIS structure is as follows.

typedef struct odbaxis {


short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Relative position data of
controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

23
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program displays "RELATIVE 4: 900051" while the relative
position data of the 4th axis(rotation axis) is 900.051 .
(in case of "IS-B".)

#include <stdio.h>
#include "apilib.h"

void example( void )


{
ODBAXIS buf ;
cnc_relative( 0, 4, 4+4*1, &buf ) ;
printf( "RELATIVE 4:%8ld\n", buf.data[0] ) ;
}

24
(5) Read distance to go

Function Name: cnc_distance

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_distance(unsigned short FlibHndl, short axis,
short length, ODBAXIS *distance);

Description: Reads the amount of distance to go of the axis specified with


"axis".
The amount of distance to go is stored in "data[0]" of
"ODBAXIS".

All axes can be read at a time by specifying ALL_AXES for


"axis".
In that case, an amount of distance to go of each axis is stored
in the data array of ODBAXIS.

The decimal point position of the amount of distance to go can


be acquired in the cnc_getfigure() function.

As for Power Mate, the read amount of distance to go is twice as


big as the actual.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

axis Specify axis number to read.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m : number of controlled axis)

length Specify the length of the data block(size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0+-------+ -- 0+-------+ --
| dummy | ^ | dummy | ^
2+-------+ | 2+-------+ |
| type | length | type | length
4+-------+-------+ | 4+-------+-------+ |
| data[0] | v | data[0] | |
8+---------------+ -- 8+---------------+ |
== ==|
4+4x(n-1)+---------------+ |
| data[n-1] | v
4+4xn+---------------+ --
n : Current controlled axes

distance Pointer to the ODBAXIS structure including the number of


distance to go of the controlled axes.

The ODBAXIS structure is as follows.


typedef struct odbaxis {
short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* number of distance to go of
controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

25
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program displays
1: -34600
2: 60018
3: -360
while the amount of distance to go for each axes are
The 1st axis -17.300 (Linear axis)
The 2nd axis 30.009 (linear axis)
The 3rd axis -0.180 (Rotation axis)
in 3-axis system.(in case of "mm input" and "IS-B".)

#include <stdio.h>
#include "apilib.h"

void example( void )


{
ODBAXIS buf ;
unsigned int idx ;
cnc_distance( 0, -1, 4+4*4, &buf ) ;
for ( idx = 0 ; idx < 3 ; idx++ )
printf( "%u:%8ld\n", idx, buf.data[idx] ) ;
}

26
(6) Read skip position

Function Name: cnc_skip

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_skip(unsigned short FlibHndl, short axis,
short length, ODBAXIS *skip);

Description: Reads the skipped position of the axis specified with "axis".
The skipped position is stored in "data[0]" of "ODBAXIS".

All axes can be read at a time by specifying ALL_AXES for


"axis".
In that case, an skipped position of each axis is stored in the
data array of ODBAXIS.

The decimal point position of the skipped position can be


acquired in the cnc_getfigure() function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

axis Specify axis number to read.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m : number of controlled axis)

length Specify the length of the data block(size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0+-------+ -- 0+-------+ --
| dummy | ^ | dummy | ^
2+-------+ | 2+-------+ |
| type | length | type | length
4+-------+-------+ | 4+-------+-------+ |
| data[0] | v | data[0] | |
8+---------------+ -- 8+---------------+ |
== ==|
4+4x(n-1)+---------------+ |
| data[n-1] | v
4+4xn+---------------+ --
n : Current controlled axes

skip Pointer to the ODBAXIS structure including the skipped


position data of the controlled axes.

The ODBAXIS structure is as follows.

typedef struct odbaxis {


short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Skipped position data of
controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

27
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program displays the skipped position of the 1st and 2nd
axes.

#include <stdio.h>
#include "apilib.h"

void example( void )


{
ODBAXIS buf ;
unsigned int idx ;
cnc_skip( 0, 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] ) ;
}

28
(7) Read servo delay value

Function Name: cnc_srvdelay

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_srvdelay(unsigned short FlibHndl, short axis,
short length, ODBAXIS *srvdelay);

Description: Reads the servo delay amount of the axis specified with "axis".
The servo delay amount is stored in "data[0]" of "ODBAXIS".

All axes can be read at a time by specifying ALL_AXES for


"axis".
In that case, an servo delay amount of each axis is stored in
the data array of ODBAXIS.

The decimal point position of the servo delay amount can be


required in the cnc_getfigure() function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

axis Specify axis number to read.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m : number of controlled axis)

length Specify the length of the data block(size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0+-------+ -- 0+-------+ --
| dummy | ^ | dummy | ^
2+-------+ | 2+-------+ |
| type | length | type | length
4+-------+-------+ | 4+-------+-------+ |
| data[0] | v | data[0] | |
8+---------------+ -- 8+---------------+ |
== ==|
4+4x(n-1)+---------------+ |
| data[n-1] | v
4+4xn+---------------+ --
n : Current controlled axes

srvdelay Pointer to the ODBAXIS structure including the servo delay


amount of controlled axis.

The ODBAXIS structure is as follows.

typedef struct odbaxis {


short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Servo delay amount of controlled
axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

29
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program displays the servo delay amount of all axes
(number of axes = MAX_AXIS).

#include <stdio.h>
#include "apilib.h"
void example( void )
{
ODBAXIS buf ;
unsigned int idx ;
cnc_srvdelay( 0, -1, 4+4*MAX_AXIS, &buf ) ;
for ( idx = 0 ; idx < MAX_AXIS ; idx++ )
printf( "%u:%8ld\n", idx, buf.data[idx] ) ;
}

30
(8) Read acceleration/deceleration delay value

Function Name: cnc_accdecdly

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_accdecdly(unsigned short FlibHndl,
short axis, short length, ODBAXIS *accdecdly);

Description: Reads the acceleration/deceleration delay amount of the axis


specified with "axis".
The acceleration/deceleration delay amount is stored in
"data[0]" of "ODBAXIS".

All axes can be read at a time by specifying ALL_AXES for


"axis".
In that case, an acceleration/deceleration delay amount of each
axis is stored in the data array of ODBAXIS.

The decimal point position of the acceleration/deceleration


delay amount can be acquired in the cnc_getfigure() function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

axis Specify axis number to read.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m : number of controlled axis)

length Specify the length of the data block(size of ODBAXIS structure)

for each axis for all axes


ODBAXIS 0+-------+ -- 0+-------+ --
| dummy | ^ | dummy | ^
2+-------+ | 2+-------+ |
| type | length | type | length
4+-------+-------+ | 4+-------+-------+ |
| data[0] | v | data[0] | |
8+---------------+ -- 8+---------------+ |
== ==|
4+4x(n-1)+---------------+ |
| data[n-1] | v
4+4xn+---------------+ --
n : Current controlled axes

accdecdly Pointer to the ODBAXIS structure including the


acceleration/deceleration delay amount of the controlled axes.

The ODBAXIS structure is as follows.

typedef struct odbaxis {


short dummy ; /* Not used. */
short type ; /* Axis number. */
long data[MAX_AXIS] ; /* Acceleration/deceleration delay
amount of controlled axis. */
} ODBAXIS ; /* MAX_AXIS is the maximum controlled axes. */

31
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBAXIS structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program displays the acceleration/deceleration delay
amount of all axes (number of axes = MAX_AXIS).

#include <stdio.h>
#include "apilib.h"
void example( void )
{
ODBAXIS buf ;
unsigned int idx ;
cnc_accdecdly( 0, -1, 4+4*MAX_AXIS, &buf ) ;
for ( idx = 0 ; idx < MAX_AXIS ; idx++ )
printf( "%u:%8ld\n", idx, buf.data[idx] ) ;
}

32
(9) Read all dynamic data

Function Name: cnc_rddynamic

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rddynamic(unsigned short FlibHndl,
short axis, short length, ODBDY *rddynamic);

Description: Read various data which changes as CNC driving at a time.


The data which can be read is as follows.

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
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

(Last four functions have axis attribute)

The formats of each data are the same as each corresponding "Function"
used for reading each data.
Refer each functions for details.

Reads the data concerning the axis specified with "axis".


Each data is stored in oaxis structure in ODBDY.

All axes can be read at a time by specifying ALL_AXES for "axis".


In that case, each data concerning the axis is stored in each array
of the structure "faxis" inside ODBDY.

The decimal point position of each data concerning the axis


can be acquired in the cnc_getfigure() function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

axis Specify axis number to read.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m : number of controlled axis)

33
length Specify the length of the data block(size of ODBDY structure)

for each axis for all axes


ODBDY 0+-------+ -- 0+-------+ --
| dummy | ^ | dummy | ^
2+-------+ | 2+-------+ |
| axis | | | axis | |
4+-------+ | 4+-------+ |
| alarm | | | alarm | |
6+-------+ | 6+-------+ |
| prgnum| | | prgnum| |
8+-------+ | 8+-------+ |
| prgmnum length | prgmnum length
10+-------+-------+ | 10+-------+-------+ |
| seqnum | | | seqnum | |
14+---------------+ | 14+---------------+ |
| actf | | | actf | |
18+---------------+ | 18+---------------+ |
| (dummy 4 byte)| | | (dummy 4 byte)| |
22+---------------+ | 22+---------------+ |
| absolute | | | absolute[0] | |
26+---------------+ | 26+---------------+ |
| machine | | == ==|
30+---------------+ | 22+4x(n-1)+---------------+ |
| relative | | | absolute[n-1]| |
34+---------------+ | 22+4xn+---------------+ |
| distance | v | machine[0] | |
38+---------------+ -- 22+4x(n+1)+---------------+ |
== ==|
22+4x(2n-1)+---------------+ |
| machine[n-1] | |
22+4x2n+---------------+ |
| relative[0] | |
22+4x(2n+1)+---------------+ |
== ==|
22+4x(3n-1)+---------------+ |
| relative[n-1]| |
22+4x3n+---------------+ |
| distance[0] | |
22+4x(3n+1)+---------------+ |
== ==|
22+4x(4n-1)+---------------+ |
| distance[n-1]| v
22+4x4n+---------------+ --
n : Maximum controlled axes

* The data for current controlled axes are valid.

rddynamic Pointer to the ODBDY structure including various data.

The ODBDY structure is as follows.

typedef struct odbdy {


short dummy ; /* not used */
short axis ; /* axis number */
short alarm ; /* alarm status */
short prgnum ; /* current program number */
short prgmnum ; /* main program number */
long seqnum ; /* current sequence number */
long actf ; /* actual feed rate */
long acts ; /* not used */
union {
struct {
long absolute[MAX_AXIS] ; /* absolute */

34
long machine[MAX_AXIS] ; /* machine */
long relative[MAX_AXIS] ; /* relative */
long distance[MAX_AXIS] ; /* distance to go*/
} faxis ; /* In case of all axes */
struct {
long absolute ; /* absolute */
long machine ; /* machine */
long relative ; /* relative */
long distance ; /* distance to go */
} oaxis ; /* In case of 1 axis */
} pos ;
} ODBDY ; /* MAX_AXIS is the maximum controlled axes. */

dummy Not used

axis Axis number


The axis number to be read is returned.

alarm Alarm status


The meaning of each bit is as follows.

Power Mate
#15:External alarm message
#14:(Not used)
#13:(Not used)
#12:(Not used)
#11:(Not used)
#10:P/S alarm 5000
#09:(Not used)
#08:APC alarm
#07:System alarm
#06:Servo alarm
#05:Overheat alarm
#04:Overtravel alarm
#03:P/S alarm except above
#02:P/S alarm 101
#01:P/S alarm 000
#00:P/S alarm 100

prgnum Program number under execution


(It is the selected program number while
automatic operation stopping)

prgmnum Main program number


seqnum Current sequence number

actf Actual feed rate of the controlled axes

acts dummy 4 byte

absolute Absolute position of the controlled axes

machine Machine position of the controlled axes

relative Relative position of the controlled axes

distance Amount of distance to go of the controlled axes

35
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBDY structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (axis) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program reads the dynamic data of all axes
(number of axes = MAX_AXIS) and displays them on the screen.

#include <stdio.h>
#include "apilib.h"

void example( void )


{
struct odbdy buf ;
unsigned int idx ;
cnc_rddynamic( 0, -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\n", buf.actf ) ;
printf( "Alarm status = %d\n", buf.alarm ) ;
printf( "AXIS Absolute Relative Machine Distance\n" ) ;
printf( "----+---------+---------+---------+--------\n" ) ;
for ( idx = 0 ; idx < MAX_AXIS ; 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] ) ;
}

36
(10) Set origin / preset relative axis position

Function Name: cnc_wrrelpos

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrrelpos(unsigned short FlibHndl,
short length, IDBWRR *wrrelpos);

Description: Preset relative position against the axis specified with "type".
Preset data is specified by "data[0]" in "IDBWRR".

If 0 is specified as preset data, it means origin(0 clear of


relative position).

It is possible to make preset to all axes at a time by


specifying ALL_AXES for "type".
In that case, an preset data of each axis is specified by the
data array in IDBWRR.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the length of the data block(size of IDBWRR structure)

for each axis for all axes


IDBWRR 0+-------+ -- 0+-------+ --
| datano| ^ | datano| ^
2+-------+ | 2+-------+ |
| type | length | type | length
4+-------+-------+ | 4+-------+-------+ |
| data[0] | v | data[0] | |
8+---------------+ -- 8+---------------+ |
== ==|
4+4x(n-1)+---------------+ |
| data[n-1] | v
4+4xn+---------------+ --
n : Current controlled axes

wrrelpos Pointer to the IDBWRR structure to be set the relative position


data of the controlled axes.

The IDBWRR structure is as follows.

typedef struct idbwrr {


short datano; /* Not used. */
short type; /* Axis number. */
long data[MAX_AXIS]; /* Preset data. */
} IDBWRR ; /* MAX_AXIS is the maximum controlled axes. */

type Specify axis number to make preset.


ALL_AXES : for all axes(ALL_AXES : -1)
1,..,m : for each axis
(m : number of controlled axis)

data Specify value to make preset.


data[0],..,data[m-1] : for all axes
data[0] : for each axis

37
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ODBWRR structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of axis number (type) is
improper.
EW_DATA data error
The content of "data" is out of range which
can be specified.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program preset the relative position of the first axis.

#include <stdio.h>
#include "apilib.h"
#define FIRST_AXIS 1
#define ONE_AXIS_LEN 8

IDBWRR wrrelpos ;
short ret ;

wrrelpos.type = FIRST_AXIS ;
wrrelpos.data[0] = 0 ;
ret = cnc_wrrelpos( 0, ONE_AXIS_LEN, &wrrelpos);

38
1.1.8 Function Reference Related to Program

(1) Start Downloading NC Program

Function Name: cnc_dwnstart

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_dwnstart(unsigned short FlibHndl);

Description: Requests CNC to start downloading NC program.


(This function must be executed before cnc_download
/cnc_cdownload.)

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY busy
- cnc_dwnstart function has been executed.
Terminate a downloading by using cnc_dwnend
function.
- background edit processing in CNC side
Terminate background edit processing in CNC
side.
- alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
- MDI mode
Change CNC mode to any mode except MDI.
EW_PROT write protection in CNC side
- Protection KEY(DI) turns on.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
0000#0 -+- influenced by setting
3201#2,#6 -+
3202#0,#4 -+
3290#7 -+

CNC mode: This function relates to the following mode.


It is possible to use in other than MDI mode.

Example: See an example of "Download NC program(cnc_download)".

39
(2) Download NC program

Function Name: cnc_download

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_download(unsigned short FlibHndl, char *data,
short number);

Description: Output NC program to be registered(downloading).

When the data processing on the CNC side is delayed and the data
cannot be transferred, this function waits until it can be
transferred.

The procedure of downloading is as follows.

+-------------------+
| cnc_dwnstart() | beginning of download
+---------+---------+ (must be done)
+-------------->|
| +---------+---------+
| | cnc_download() | output of download data
| +---------+---------+
| |
| Yes +---------+----------------+
+-----+Is there data of unoutput?|
+---------+----------------+
| No
+---------+---------+
| cnc_dwnend() | End of download
+-------------------+ (must be done)

Because importance is attached to the speed of data transfer to


the CNC, in general, errors(EW_DATA,EW_OVRFLOW, etc.) are
returned with a delay.
Namely, in actual practice, an error at a certain time is for
data which was transferred several times previously. Further,
an error for an amount of data for several times before finish
is returned by "End of downloading NC program".

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 ;

40
%

send a following string using cnc_download function.

"\nO1234\nG1F0.3W10.\nM30\n%"

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_download functions.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

data Specify the top address of NC program data.

number Specify the number of characters of NC program data. (1 - 256)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_RESET reset or stop request
'RESET or STOP' was pushed.
Call the cnc_dwnend function.
EW_FUNC cnc_dwnstart function has not been executed.

EW_LENGTH data block length error


Length of data block(number) exceeds 256
bytes.
EW_DATA data error
- The same program number has already been
registered.
- The same program number is selected on CNC.
- 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.
See 'Description' about the timing of error.
EW_PROT write protection in CNC side
- CNC parameter is a state of write-protection
(O8000-/O9000- protection, encoding).
See 'Description' about the timing of error.
EW_OVRFLOW memory overflow
It is lack of free area in CNC memory.
Make enough free area in CNC memory.
See 'Description' about the timing of error.

41
CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
0000#0 -+- influenced by setting
3201#2,#6 -+
3202#0,#4 -+
3290#7 -+

CNC mode: This function relates to the following mode.


It is possible to use in other than MDI mode.

Example:
The following program registers the following NC program to CNC.

O1234 ;
G0 Z0 ;
G0 X0 Y0 ;
G1 F500 X120. Y-30. ;
M30 ;

#include "apilib.h"

short example( void )


{
char *prg[] = {
"\n",
"O1234\n",
"G0 Z0\n",
"G0 X0 Y0\n",
"G1 F500 X120. Y-30.\n",
"M30\n",
"%"
} ;
short ret, idx ;
ret = cnc_dwnstart( 0 ) ;
if ( ret ) return ( ret ) ;
for ( idx = 0 ; idx < sizeof(prg)/sizeof(char *) ; idx++ ) {
ret = cnc_download( 0, prg[idx], strlen( prg[idx] ) ) ;
if ( ret ) {
cnc_dwnend( 0 ) ;
return ( ret ) ;
}
}
ret = cnc_dwnend( 0 ) ;
return ( ret ) ;
}

42
(3) End of downloading NC program

Function Name: cnc_dwnend

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_dwnend(unsigned short FlibHndl);

Description: Notices the end of downloading NC program to CNC.


(This function must be executed after
cnc_download/cnc_cdownload.)
There are cases where errors(EW_DATA,EW_OVRFLOW, etc.) during
execution of downloading NC program are returned by this
function.
Further, there is no return from this function until the
registration of the output data by cnc_download(cnc_cdownload)
is finished.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_FUNC cnc_dwnstart function has not been executed.
EW_DATA data error
- The same program number has already been
registered.
- The same program number is selected on CNC.
- 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.
See 'Description' about the timing of error.
EW_PROT write protection in CNC side
- CNC parameter is a state of write-protection
(O8000-/O9000- protection, encoding).
See 'Description' about the timing of error.
EW_OVRFLOW memory overflow
It is lack of free area in CNC memory.
Make enough free area in CNC memory.
See 'Description' about the generation timing.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
0000#0 -+- influenced by setting
3201#2,#6 -+
3202#0,#4 -+
3290#7 -+

CNC mode: This function relates to the following mode.


It is possible to use in other than MDI mode.

Example: See example of "Download NC program(cnc_download)".

43
(4) Start uploading NC program

Function Name: cnc_upstart

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_upstart(unsigned short FlibHndl,
short number);

Description: Notices the start of uploading NC program to the library.


(This function must be executed before cnc_upload/cnc_cupload.)

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify program number

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY busy
- cnc_upstart function has been executed.
Terminate an uploading by using cnc_upend
function.
- alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
EW_DATA data error
Program number(number) is not found or wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example: See example of "Upload NC program(cnc_upload)".

44
(5) Upload NC program

Function Name: cnc_upload

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_upload(unsigned short FlibHndl,
ODBUP *upld, unsigned short *number);

Description: Read NC program registered for the tape memory in CNC (program
memory).

The procedure of uploading is as follows.

+-------------------+
| cnc_upstart() | beginning of upload
+---------+---------+ (must be done)
+-------------->|
| +---------+---------+
| | cnc_upload() | read NC program
| +---------+---------+
| |
| No +---------+---------+
+-----+ the last data='%'?|
+---------+---------+
| Yes
+---------+---------+
| cnc_upend() | End of upload
+-------------------+ (must be done)

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
'%'.
Nothing for Power Mate 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 characters)
2nd and after "" (0 character)

And in case that the buffer size is less than 24 bytes, you will
get the following strings.

45
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 "" (0 character)

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

upld Pointer to the ODBUP structure including the NC program.

The ODBUP structure is as follows.

typedef struct odbup {


short dummy[2] ; /* Not used. */
char data[MAX_RBUF] ; /* NC program data. */
} ODBUP ; (MAX_RBUF : maximum character number to read)

The default value of read buffer size (MAX_RBUF) with ODBUP


structure is 256.
In order to read more characters at a time, it is necessary to
customize.

ODBUP 0+-----------------------------------+
| dummy[0] |
2+-----------------------------------+
| dummy[1] |
4+-----------------+-----------------+
| data[0] |
5+-----------------+
= =
4+MAX_RBUF-1+-----------------+
| data[MAX_RBUF-1]|
4+MAX_RBUF +-----------------+

number Specify the address of the variable which shows number of


characters to read.
Set read number of characters by one time to this
variable(*number).
After reading ends,the number of characters actually read is
set in this variable(*number) again.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_FUNC cnc_upstart function has not been executed.
EW_LENGTH data block length error
The read number of characters of NC program
(*number) is 0.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

46
Example:
The following program reads the specified NC program registered in CNC,
and displays its contents on the screen.

#include <stdio.h>
#include "apilib.h"
#define BUFSIZE 40

/* number is NC program number to be read. */


short example( short number )
{
char buf[BUFSIZE+4] ;
short ret, number ;
ret = cnc_upstart( 0 ) ;
if ( ret ) return ( ret ) ;
for (;;) {
number = BUFSIZE - 1 ;
ret = cnc_upload( 0, (ODBUP *)(&buf), &number ) ;
if ( ret ) {
cnc_upend( 0 ) ;
return ( ret ) ;
}
buf[4+number] = '\x00' ;
printf( "%s", &buf[4] ) ;
if ( buf[4+number-1] == '%' ) break ;
}
putchar( '\n' ) ;
ret = cnc_upend( 0 ) ;
return ( ret ) ;
}

47
(6) End of uploading NC program

Function Name: cnc_upend

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_upend(unsigned short FlibHndl);

Description: Notices the end of uploading NC program to the library.


(This function must be executed after cnc_upload/cnc_cupload.)

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_FUNC cnc_upstart function has not been executed.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example: See example of "Upload NC program(cnc_upload)".

48
(7) Search specified program

Function Name: cnc_search

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_search(unsigned short FlibHndl,
short number);

Description: Searches the number of NC program registered in program memory


of CNC.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify program number.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY busy
- 'OP' signal(DO)<F000#7> on
(only EDIT mode or MEMORY mode)
Automatic operation is being executed in
CNC.
- downloading
Terminate a downloading by using cnc_dwnend
function.
- alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
EW_DATA data error
Program number(number) is not found or wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: The behavior of this function depends on the CNC mode.
EDIT,MEMORY mode :foreground search
Other mode :background search
(foreground search : set again selecting program.)
(background search : check whether the specified program exists
or not.)

49
Example:
The following program searches the program whose program number is same
as specified one, and displays the result.

#include <stdio.h>
#include "apilib.h"

/* num is program number to be searched. */


void example( short num )
{
short ret ;
ret = cnc_search( 0, num ) ;
switch ( ret ) {
case EW_OK:
printf( "PROGRAM O%d has been searched.\n", num ) ;
case EW_DATA:
printf( "PROGRAM O%d doesn't exist.\n", num ) ;
case EW_PROT:
printf( "PROTECTED.\n" ) ;
case EW_BUSY:
printf( "REJECTED.\n" ) ;
}
}

50
(8) Delete all programs

Function Name: cnc_delall

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_delall(unsigned short FlibHndl);

Description: Deletes all NC programs registered in CNC.


The protected program cannot be deleted.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY busy
- background edit processing in CNC side
Terminate background edit.
- downloading
Terminate a downloading by using cnc_dwnend
function.
- alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
- MEMORY, MDI mode in CNC side
Change CNC mode except MEMORY, MDI mode.
- 'OP' signal(DO)<F000#7> on
(only EDIT mode or MEMORY mode)
Automatic operation is being executed in
CNC.
EW_PROT write protection in CNC side
- Protection KEY(DI) turns on.
- CNC parameter is a state of write-protection
(O8000-/O9000- protection, encoding).
See 'Description' about the timing of error.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function relates to the following mode.


It is possible to use in other than MEM,MDI mode.

51
Example:
The following program deletes all programs and displays the result.

#include <stdio.h>
#include "apilib.h"

void example( void )


{
short ret ;
ret = cnc_delall( 0 ) ;
switch ( ret ) {
case EW_OK:
printf( "ALL PROGRAMS has been deleted.\n", num ) ;
case EW_PROT:
printf( "PROTECTED.\n" ) ;
case EW_BUSY:
printf( "REJECTED.\n" ) ;
}
}

52
(9) Delete specified program

Function Name: cnc_delete

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_delete(unsigned short FlibHndl,
short number);

Description: Deletes the specified NC program registered in CNC.


The protected program cannot be deleted.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify program number.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY busy
- background edit processing in CNC side
Terminate background edit.
- downloading
Terminate a downloading by using cnc_dwnend
function.
- alarm (PS000, PS101) in CNC side
Reset the alarm on CNC.
- MDI mode in CNC side
Change CNC mode except MDI mode.
- 'OP' signal(DO)<F000#7> on
(only EDIT mode or MEMORY mode)
Automatic operation is being executed in
CNC.
- foreground program selected by CNC
Change selected program in CNC.
EW_PROT write protection in CNC side
- Protection KEY(DI) turns on.
- CNC parameter is a state of write-protection
(O8000-/O9000- protection, encoding).
See 'Description' about the timing of error.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function relates to the following mode.


It is possible to use in other than MDI mode.

53
Example:
The following program deletes the program whose program number is same
as specified one, and displays the result.

#include <stdio.h>
#include "apilib.h"

/* num is program number to be deleted. */


void example( short num )
{
short ret ;
ret = cnc_delete( 0, num ) ;
switch ( ret ) {
case EW_OK:
printf( "PROGRAM O%d has been deleted.\n", num ) ;
case EW_DATA:
printf( "PROGRAM O%d doesn't exist.\n", num ) ;
case EW_PROT:
printf( "PROTECTED.\n" ) ;
case EW_BUSY:
printf( "REJECTED.\n" ) ;
}
}

54
(10) Read program directory

Function Name: cnc_rdprogdir

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdprogdir(unsigned short FlibHndl,
short type, short datano_s, short datano_e, short length,
PRGDIR *prgdir);

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".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

type Specify the form of the read program list.


0 : only the program number
1 : program number and comment
2 : program number, comment, and number of use
characters.

datano_s Specify the start program number.

datano_e Specify the end program number.

length Specify the length of a block(buffer size).

prgdir Pointer to the PRGDIR structure including program directory.

The PRGDIR structure is as follows.

typedef struct prgdir {


char prg_data[MAX_PBUF] ; /* Directory data. */
} PRGDIR ; (MAX_PBUF : maximum character number to read)

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")

55
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 including 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.

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 not enough for the specified program, the
specified size is read. In case of 15 bytes, the result is as
follows.
type Contents to be read
-------+-------------------------------------------------------
0 "O12O200O201O900"
1 "%\nO12(TEST)\nO20"
2 "O12(TEST)420O20"

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Length of the block (length) is illegal.
EW_NUMBER data number error
Start program number (datano_s) or end program
number (datano_e) is illegal.
EW_ATTRIB data attribute error
Output format (type) is illegal.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

56
Example:
The following program reads the registration information of NC program
included specified by the arguments, and displays program number list.

#include <stdio.h>
#include <string.h>
#include "apilib.h"
#define BUFSIZE 256

/* start/end specify program number range. */


short example( short start, short end )
{
char buf[BUFSIZE] ;
short ret, idx ;
memset( buf, '\x00', BUFSIZE ) ;
ret = cnc_rdprogdir( 0, 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' ) ;
}

57
(11) Read program information

Function Name: cnc_rdproginfo

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdproginfo(unsigned short FlibHndl,
short type, short length, ODBNC *prginfo);

Description: Reads the management data of programs already registered in CNC.

The management data of NC program are


Amount of registered programs,
Amount of available programs,
Character number of used memory,
Character number of unused memory.

This function returns these data with binary format or ASCII


string format.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

type Specify the output format.


0 : binary
1 : ASCII

length Specify the length of data block.


12 : binary
31 : ASCII

prginfo Pointer to the ODBNC structure including the program directory.

The ODBNC structure is as follows.

typedef struct odbnc {


union {
struct {
short reg_prg ;/* Amount of registered
programs. */
short unreg_prg ;/* Amount of available
programs. */
long used_mem ;/* Character number of used
memory. */
long unused_mem ;/* Character number of
unused memory. */
} bin ;
char asc[31] ; /* Buffer for ASCII format */
}u ;
}ODBNC ;

- type=0
Each data are stored in each members of the structure with
binary format.
prginfo.bin.reg_prg Amount of registered programs.
prginfo.bin.unreg_prg Amount of available programs.
prginfo.bin.used_mem Character number of used memory.
prginfo.bin.unused_mem Character number of unused memory.
- type=1
ASCII strings are stored in "prginfo.u.asc" with following

58
format.

% LF d1 LF d2 LF d3 LF d4 LF %

LF 0x0A('\n')
d1 Amount of registered programs
d2 Amount of available programs
d3 Character number of used memory
d4 Character number of unused memory
d1 - d4 are ASCII strings without the leading '0'.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Length of the block (length) is illegal.
EW_ATTRIB data attribute error
Output format (type) is illegal.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program reads the management data of NC program,
and displays them.

#include <stdio.h>
#include "apilib.h"

void example( void )


{
ODBNC buf ;
short ret ;
ret = cnc_rdproginfo( 0, 0, 12, &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 ) ;
}
}

59
(12) Read program number under execution
Function Name: cnc_rdprgnum

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdprgnum(unsigned short FlibHndl,ODBPRO *prgnum);

Description: Reads program number of the program which is being currently


selected in CNC.

As for Power Mate, 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 running program number.

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.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

prgnum Pointer to the ODBPRO structure including the number of


executing program.

The ODBPRO structure is as follows.

typedef struct odbpro {


short dummy[2] ; /* Not used. */
short data ; /* Running program number. */
short mdata ; /* Main program number. */
} ODBPRO ;

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The next program displays "CURRENT(O9876) MAIN(O1234)" while
the block "O9876/N210" of the following NC program is being executed.
#include <stdio.h>
#include "apilib.h"
void example( void )
{
struct odbpro buf ;
cnc_rdprgnum( 0, &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 ;

60
(13) Read sequence number under execution
Function Name: cnc_rdseqnum

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdseqnum(unsigned short FlibHndl,
ODBSEQ *seqnum);

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.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

seqnum Pointer to the ODBSEQ structure including the sequence number


under execution.
The ODBSEQ structure is as follows.
typedef struct odbseq {
short dummy[2] ; /* Not used. */
long data ; /* Sequence number in executing. */
} ODBSEQ ;

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.


Example:
The following program displays "CURRENT N30" while
the block "O1234/N30" of the following NC program is being executed.

#include <stdio.h>
#include "apilib.h"

void example( void )


{
struct odbact buf ;
cnc_rdseqnum( 0, &buf ) ;
printf( "CURRENT N%ld\n", buf.data ) ;
}
O1234 ;
N10 M3 ;
N20 T12 ;
N30 G0 X110. ;
N40 ...

61
(14) Read program under execution

Function Name: cnc_rdexecprog

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdexecprog(unsigned short FlibHndl,
unsigned short *length, short *blknum, char *data);

Description: Read only the number of specified characters from the executing
program.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the address of the variable which shows the number of
characters to read.
Set the number of characters to read to this variable(*length).
After reading ends, the number of characters actually read is
set in this variable(*length) again.

blknum Specify the address of the variable to store the block counter.

data Specify the top address of the array to store with


the executing NC program.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Length of the block (*length) is illegal.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

62
(15) Write program for MDI operation
Function Name: cnc_wrmdiprog

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrmdiprog(unsigned short FlibHndl,
short length, char *data);

Description: Outputs NC program for MDI operation to CNC.

Format of NC command data to be executed


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NC command data to be executed to CNC is a string composed of
ASCII characters as following format.
LF NC command1 LF NC command2 LF ... LF Mxx LF %
LF 0x0A('\n')
Mxx M code at the end of the DNC operation
(M02,M30,etc.)

'LF' must be placed at the top of the whole NC commands, and '%'
at the end.
'LF's are added after each NC commands.
For example, to execute commands such as
O1234 ;
G01F0.3W10. ;
M30 ;
send a following string using cnc_wrmdiprog function.
cnc_wrmdiprog( 0, 24, "\nO1234\nG01F0.3W10.\nM30\n%" ) ;

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the number of characters of NC program to write.


1 ,.., 199

data Specify the top address of NC program data.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error.
Length of the block (length) is illegal.
EW_DATA data error
- 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.
Confirm the above-mentioned point.
EW_MODE CNC mode error. Set CNC mode to MDI.
EW_REJECT CNC execution denied

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function must be used in MDI mode.

63
(16) Read execution pointer for MDI operation

Function Name: cnc_rdmdipntr

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdmdipntr(unsigned short FlibHndl,
ODBMDIP *mdip);

Description: Read the execution pointer information for MDI operating


program.
The content which can be acquired is the following items.
- program number being executed
It is basically 0 for MDI operation.
When executing program is sub-program, the sub-program number
is return.
- execution block pointer
block pointer which is being currently executed in CNC.
- preread program number
program number read in advance.(displayed in green on the CNC
screen)
For MDI operating, it is basically 0, and for reading sub-
program in advance, it is the number of sub-program.
- preread block pointer
last block pointer in the program read ahead.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

mdip Pointer to the ODBMDIP structure including the execution


pointer information.

The ODBMDIP structure is as follows.


typedef struct odbmdip {
short mdiprog; /* Program number being executed. */
long mdipntr; /* Execution block pointer. */
short crntprog; /* Preread program number. */
long crntpntr; /* Preread block pointer. */
} ODBMDIP ;

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_MODE CNC mode error
Set CNC mode to MDI.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function must be used in MDI mode.

64
(17) Write execution pointer for MDI operation

Function Name: cnc_wrmdipntr

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrmdipntr(unsigned short FlibHndl,long crntpntr);

Description: Specify the execution starting pointer for MDI operation.


(It is impossible to operate the execution pointer directly)

Register the MDI program previously according to the


cnc_wrmdiprog() function when executing this function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

crntpntr Specify the block pointer to execute first.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_DATA data error
The specification of the block point to
execute first(crntpntr) is illegal.
EW_MODE CNC mode error
Set CNC mode to MDI.
EW_REJECT CNC execution denied
- Edit processing in the CNC side.
- MDI program is not registered.
Register the MDI program previously
according to the cnc_wrmdiprog() function.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function must be used in MDI mode.

65
(18) Search specified sequence number

Function Name: cnc_seqsrch

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_seqsrch(unsigned short FlibHndl,
long seq_no);

Description: Searches the specified sequence number of the selected program


in CNC.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

seq_no Specify sequence number.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_DATA data error
The specified sequence number does not exist.
EW_MODE CNC mode error
See the paragraph of CNC mode.
EW_REJECT CNC execution denied

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function must be used in MEM mode.

66
(19) Rewind cursor of NC program

Function Name: cnc_rewind

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rewind(unsigned short FlibHndl);

Description: Sets cursor to the top of selected NC program in CNC.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_MODE CNC mode error
See the paragraph of CNC mode.
EW_REJECT CNC execution denied

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function relates to the following mode.


It is possible to use in other than MDI mode.

67
1.1.9 Function Reference Related to NC File Data

(1) Read Tool Offset Value

Function Name: cnc_rdtofs

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdtofs(unsigned short FlibHndl, short number,
short type, short length, ODBTOFS *tofs);

Description: Reads the tool offset value specified by "number", "type".


The offset value is stored in "data" of "ODBTOFS" with signed
binary format.

The unit of offset value is as follows.


| Linear axis |Rotation axis
1004#1 | mm input |inch input|
(ISC) | [mm] | [inch] | [deg]
---------------------------+----------+----------+-------------
(IS-B) 0 0.001 0.0001 0.001

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify the tool offset number.


The available number of tool offset can be got by
cnc_rdtofsinfo() function.

type Specify the tool offset type.


A zero is set up at the time of Power Mate.

length Specify the data block length(size of ODBTOFS structure=8).

tofs Pointer to the ODBTOFS structure including the tool offset


value.

The ODBTOFS structure is as follows.

typedef struct odbtofs {


short datano ; /* offset number */
short type ; /* offset type */
long data ; /* offset value */
} ODBTOFS ;

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of ODBTOFS structure(length) is wrong.
EW_NUMBER Data number error
Offset number(number) is wrong.
EW_ATTRIB Data attribute error
Offset type(type) is wrong.

68
CNC option: There is need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameters.


See the manual of CNC parameter for details.
1004#0,#1

CNC mode: This function can be used in any CNC mode.

Example:
The following program reads the offset value of specified tool
number and displays them.

#include <stdio.h>
#include "apilib.h"

/* tidx is tool index. */


void example( short tidx )
{
ODBTOFS tofs ;
short ret ;
ret = cnc_rdtofs( 0, tidx, 0, 8, &tofs ) ;
if ( !ret ) printf( "Z(%d) = %ld\n", tidx, tofs.data ) ;
}

69
(2) Write tool offset value

Function Name: cnc_wrtofs

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrtofs(unsigned short FlibHndl, short number,
short type, short length, long data);

Description: Writes the tool offset value specified by "number", "type".


The offset value must be stored in "data" with signed binary
format.

The unit of offset value is as follows.


| Linear axis |Rotation axis
1004#1 | mm input |inch input|
(ISC) | [mm] | [inch] | [deg]
---------------------------+----------+----------+-------------
(IS-B) 0 0.001 0.0001 0.001

The available range of offset value is as follows.


| Linear axis |Rotation axis
1004#1 | mm input | inch input |
(ISC) | [mm] | [inch] | [deg]
------------------------+-----------+------------+-------------
(IS-B) 0 +- 999.999 +- 99.9999 +- 999.999

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify the tool offset number.


The available number of tool offset can be got by
cnc_rdtofsinfo() function.

type Specify the tool offset type.


A zero is set up at the time of Power Mate.

length Specify the data block length(size of ODBTOFS structure=8).

data Set the tool offset value.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size(length) is less than 8.
EW_NUMBER Data number error
Offset number(number) is wrong.
EW_ATTRIB Data attribute error
Offset type(type) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameters.


See the manual of CNC parameter for details.
1004#0,#1

70
CNC mode: This function can be used in any CNC mode.

Example:
The following program writes the offset value of specified offset
number.

#include <stdio.h>
#include "apilib.h"

/* tidx is tool index. */


/* offset is new offset value. */
short example( short tidx, long offset )
{
short ret ;
ret = cnc_wrtofs( 0, tidx, 0, 8, offset ) ;
return ( ret ) ;
}

71
(3) Read tool offset value(area specified)

Function Name: cnc_rdtofsr

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdtofsr(unsigned short FlibHndl,
short s_number, short type, short e_number, short length,
IODBTO *tofsr);

Description: Reads the tool offset value specified by "s_number",


"e_number","type".
The offset value is stored in "IODBTO" with signed binary
format.

The unit of offset value is the same as "Read tool offset


value(cnc_rdtofs)". See the description of cnc_rdtofs()
function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

s_number Specify the start tool offset number.


The available number of tool offset can be got by
cnc_rdtofsinfo() function.

e_number Specify the end tool offset number.

type Specify the tool offset type.(see the following table)

length Specify the data block length.(see the following table)

tofsr Pointer to the IODBTO structure including the tool offset


value.

The IODBTO structure is as follows.

typedef struct iodbto {


short datano_s; /* start offset number */
short type; /* offset type */
short datano_e; /* end offset number */
union {
long m_ofs[N]; /* individual */
long m_ofs_a[N]; /* Memory all */
} u ;
} IODBTO ; /* N is number of the offset value. */

The combinations of the value specified in "type", the data


block length "length", the kind of offset value to be read and
the member where the result is stored in are as follows.

Type Length Attribute Offset type Member to be stored in


----+--------+----------+-------------+------------------------
0 6+4*N individual Tool offset buf.u.m_ofs[i]
----+--------+----------+-------------+------------------------
-1 6+4*N all Tool offset buf.u.m_ofs_a[i]

N is number of offset to be read, i = 0,..,(N-1).

72
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of ODBTOFS structure(length) is wrong.
EW_NUMBER Data number error
Offset number(number) is wrong.
EW_ATTRIB Data attribute error
Offset type(type) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameters.


See the manual of CNC parameter for details.
1004#0,#1

CNC mode: This function can be used in any CNC mode.

Example:
The following program reads all offset values of 99 sets and displays
them.

#include <stdio.h>
#include <stdlib.h>
#include "apilib.h"
#define MAXTOOL 99

short example( void )


{
IODBTO *tofsr ;
short ret, idx ;
tofsr = (IODBTO *)malloc( 6+4*MAXTOOL ) ;
ret = cnc_rdtofsr( 0, 1, 0, MAXTOOL, 6+4*MAXTOOL, tofsr ) ;
if ( !ret ) {
printf( "No Z:offset\n" ) ;
printf( "---+-------+\n" ) ;
for ( idx = 0 ; idx < MAXTOOL ; idx++ ) {
printf( "%02d%8ld\n",idx, tofsr->u.m_ofs[i] ) ;
}
}
free( tofsr ) ;
return ( ret ) ;
}

73
(4) Write tool offset value(area specified)

Function Name: cnc_wrtofsr

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrtofsr(unsigned short FlibHndl,
short length, IODBTO *tofsr);

Description: Writes the tool offset value specified by datano_s",


"datano_e","type".
The offset value must be stored in "IODBTO" with signed binary
format.

The unit of offset value is the same as "Write tool offset


value(cnc_wrtofs)". See the description of cnc_wrtofs()
function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the data block length.

tofsr Pointer to the IODBTO structure including the tool offset


value.

The IODBTO structure is as follows.

typedef struct iodbto {


short datano_s; /* start offset number */
short type; /* offset type */
short datano_e; /* end offset number */
union {
long m_ofs[N]; /* individual */
long m_ofs_a[N]; /* all */
} u ;
} IODBTO ; /* N is number of the offset value. */

datano_s Specify the start tool offset number.


The available number of tool offset can be got by
cnc_rdtofsinfo() function.

datano_e Specify the end tool offset number.

type Specify the tool offset type.

The combinations of the value specified in "type", the data


block length "length", the kind of offset value to be written
and the member where the offset value must be stored in are the
same as "Read tool offset value(area specified)(cnc_rdtofsr)".
See the description of cnc_rdtofsr() function.

74
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of ODBTOFS structure(length) is wrong.
EW_NUMBER Data number error
Offset number(number) is wrong.
EW_ATTRIB Data attribute error
Offset type(type) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameters.


1004#0,#1

CNC mode: This function can be used in any CNC mode.

Example:
The following program writes all tool offset values of 99 sets.

#include <stdlib.h>
#include <string.h>
#include "apilib.h"
#define MAXTOOL 99
short example( long *offset )
{
IODBTO *tofsr ;
short ret ;
tofsr = (IODBTO *)malloc( 6+4*MAXTOOL ) ;
tofsr->datano_s = 1 ;
tofsr->datano_e = MAXTOOL ;
tofsr->type = -1 ;
memcpy( &(tofsr->u.m_ofs_a[0]), offset, 4*MAXTOOL ) ;
ret = cnc_wrtofsr( 0, 6+4*MAXTOOL, tofsr ) ;
free( tofsr ) ;
return ( ret ) ;
}

75
(5) Read tool offset information

Function Name: cnc_rdtofsinfo

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdtofsinfo(unsigned short FlibHndl,
ODBTLINF *tlinf);

Description: Reads the memory type of tool offset, and the available number
of it.
Those are stored in "ofs_type" and "use_no" of "ODBTLINF" with
signed binary format.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

tlinf Pointer to the ODBTLINF structure for the tool offset


information.

The ODBTLINF structure is as follows.

typedef struct odbtlinf {


short ofs_type; /* memory type */
short use_no; /* available number */
} ODBTLINF ;

ofs_type Memory type of tool offset


The offset type always becomes 0.

use_no Available number of tool offset

Number of offset 99

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

76
(6) Read parameter

Function Name: cnc_rdparam

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdparam(unsigned short FlibHndl,
short number, short axis, short length, IODBPSD *param);

Description: Reads the parameter specified by "number","axis"(only for the


parameter with axis). The data format depends on each
parameter. The format of Byte/Word/2-Word parameter is generally
signed binary.
Reads the parameter for all axes once by specifying 'ALL_AXES'
in 'axis'. The parameter for each axis is stored in each array
of "IODBPSD".

The attribute of CNC parameter depends on the type and axis, and
it is different for each parameter. It is as follows, and can
be got by cnc_rdparainfo() function.

Parameter type Use Byte size


--------------------------+---------------------------------+---------
Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. 1
(each axis)
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

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.

See the "PARAMETER MANUAL" of CNC for details of each parameter.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify the parameter number.


See the "PARAMETER MANUAL" of CNC about available parameter
number. It can be got by cnc_rdparainfo() function.

axis Specify the axis number.


ALL_AXES : assigns all axes(ALL_AXES=-1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)

length Specify the data block length(size of IODBPSD structure).


(4+(byte size of parameter)*(number of axis))

In case that the size of parameter is 4 byte, the IODBPSD


structure is as follows. In case that its size is 1 or 2 byte,
the size of data part per 1 parameter or 1 axis is 1 or 2 byte.

77
no axis/1 axis all axes
IODBPSD 0 +-------+ --- 0 +-------+ ---
|datano | ^ |datano | ^
2 +-------+ | 2 +-------+ |
|type | length |type | length
4 +-------+-------+ | 4 +-------+-------+ |
| ldata | v |ldatas[0] :1st| |
8 +---------------+--- 8 +---------------+ |
= = |
4+2x(n-1) +---------------+ |
|ldatas[n-1]:n-th v
4+2xn +---------------+---
n : Current controlled axes

param Pointer to the IODBPSD structure including the parameter.

The IODBPSD structure is as follows.

typedef struct iodbpsd {


short datano; /* parameter number */
short type; /* axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2word parameter */
char cdatas[MAX_AXIS]; /*bit/byte parameter with
axis*/
short idatas[MAX_AXIS];/*word parameter with axis */
long ldatas[MAX_AXIS]; /*2word parameter with axis*/
} u ;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */

datano Parameter number which was read is stored.

type Attribute of parameter which was read is stored.


axis
ALL_AXES : all axes(ALL_AXES=-1)
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of IODBPSD structure(length) is wrong.
EW_NUMBER Data number error
Parameter number(number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

78
Example:
The following program reads axes name of controlled axes(number of axis
=MAX_AXIS), and displays them.

#include <stdio.h>
#include <stdlib.h>
#include "apilib.h"

void example( void )


{
ODBSYS info ;
IODBPSD param ;
short ret, idx, axno ;
cnc_sysinfo( &info ) ;
axno = atoi( info.axes ) ;
ret = cnc_rdparam( 0, 1020, -1, 4+1*MAX_AXIS, &param ) ;
for ( idx = 0 ; idx < axno ; idx++ ) {
printf( "#%d", idx+1 ) ;
if ( param.u.cdatas[idx] == 0 )
printf( "\033[7m%c\033[27m\n", idx+'1' ) ;
else
printf( "%c\n", param.u.cdatas[idx] ) ;
}
}

79
(7) Write parameter

Function Name: cnc_wrparam

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrparam(unsigned short FlibHndl,
short length, IODBPSD *param);

Description: Writes the parameter specified by "datano","type"(only for the


parameter with axis). The data format depends on each
parameter. The format of Byte/Word/2-Word parameter is generally
signed binary.

Writes the parameter for all axes once by specifying 'ALL_AXES'


in 'type'. The parameter for each axis must be stored in each
array of "IODBPSD".

The attribute of CNC parameter depends on the type and axis, and
it is different for each parameter. It is as follows, and can
be got by cnc_rdparainfo() function.

Parameter type Use Byte size


--------------------------+---------------------------------+---------
Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. 1
(each axis)
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

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.

PS000 alarm:"PLEASE TURN OFF POWER" may be issued when some


specific parameters are written.

See the "PARAMETER MANUAL" of CNC for details of each parameter.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the data block length(size of IODBPSD structure).


(4+(byte size of parameter)*(number of axis))
In case that the size of parameter is 4 byte, the IODBPSD
structure is as follows. In case that its size is 1 or 2 byte,
the size of data part per 1 parameter or 1 axis is 1 or 2 byte.

80
no axis/1 axis all axes
IODBPSD 0 +-------+ --- 0 +-------+ ---
|datano | ^ |datano | ^
2 +-------+ | 2 +-------+ |
|type | length |type | length
4 +-------+-------+ | 4 +-------+-------+ |
| ldata | v |ldatas[0] :1st| |
8 +---------------+--- 8 +---------------+ |
= = |
4+2x(n-1) +---------------+ |
|ldatas[n-1]:n-th v
4+2xn +---------------+---
n : Current controlled axes

param Pointer to the IODBPSD structure including the parameter.

The IODBPSD structure is as follows.

typedef struct iodbpsd {


short datano; /* parameter number */
short type; /* axis number */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2-word parameter */
char cdatas[MAX_AXIS]; /* bit/byte parameter with
axis*/
short idatas[MAX_AXIS];/*word parameter with axis */
long ldatas[MAX_AXIS]; /*2word parameter with axis*/
} u ;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */

datano Specify the parameter number.


See the "PARAMETER MANUAL" of CNC about available parameter
number. It can be got by cnc_rdparainfo()function.

type Specify the axis number.


ALL_AXES : assigns all axes(ALL_AXES=-1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of IODBPSD structure(length) is wrong.
EW_NUMBER Data number error
Parameter number(datano) is wrong.
EW_ATTRIB Data attribute error
Axis number(type) is wrong.
EW_NOOPT No option
There is no option required for the specified
parameter.
EW_PROT Write operation is prohibited.

CNC option: In case of Power Mate, there may be need of CNC option
for some specific parameters.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

81
Example:
The following program writes the parameter of stroke limit check for
the specified axis.

#include "apilib.h"

/* axis is axis index. */


/* plus and minus are plus and minus position of stroke limit. */
short example( short axis, long plus, long minus )
{
IODBPSD param ;
short ret ;
param.datano = 1320 ;
param.type = axis ;
param.u.ldata = plus ;
ret = cnc_wrparam( 0, 4+4*1, &param ) ;
if ( ret ) return ( ret ) ;
param.datano = 1321 ;
param.type = axis ;
param.u.ldata = minus ;
ret = cnc_wrparam( 0, 4+4*1, &param ) ;
return ( ret ) ;
}

82
(8) Read parameter(area specified)

Function Name: cnc_rdparar

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdparar(unsigned short FlibHndl,
(short *)&s_number, short axis, (short *)&e_number,
(short *)&length, (void *)param);

Description: Reads the parameter specified by "s_number", "e_number",


"axis"(only for the parameter with axis). The data format
depends on each parameter.
The format of Byte/Word/2-Word parameter is generally signed
binary.

Reads the parameter for all axes specified range by specifying


'ALL_AXES' in 'axis'.

The attribute of CNC parameter depends on the type and axis, and
it is different for each parameter. It is as follows, and can
be got by cnc_rdparainfo() function.

Parameter type Use Byte size


--------------------------+---------------------------------+---------
Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. 1
(each axis)
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

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.

See the "PARAMETER MANUAL" of CNC for details of each parameter.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

s_number Specify the start parameter number.


The first parameter number to be read is returned.

See the "PARAMETER MANUAL" of CNC about available parameter


number. It can be got by cnc_rdparainfo() function.

e_number Specify the end parameter number.


The last parameter number to be read is returned.

The new parameter may be added according to updating CNC


software, addition of the new function, etc. If the new
parameter is added within reading range, the error(Return:
EW_LENGTH) will be returned or the application program will not
work correctly. In order to avoid these mistakes, specify the
continuous numbers of existing parameters as the reading range.

83
axis Specify the axis number.
ALL_AXES : assigns all axes(ALL_AXES=-1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)

None axis type parameter can be read even if any value is


specified in "axis". In case that an axis type parameter
exists in the specified range, the error(Return:EW_ATTRIB) is
returned by specifying "axis=0".

length Specify the data block length which is enough to store the
specified parameter.
The structure per 1 parameter is as follows, and each parameter
is lined up in order of number.
[= Sum of (4+(byte size of each parameter)*(number of axis))]

Because the size to be read is returned, it is possible to


specify the length more than the actual size.

In case that the size of parameter is 1 byte, the IODBPSD


structure is as follows.
In case that the size of parameter is 1 byte and the length per
1 parameter is an odd number, 'dummy' is necessary in the end of
structure. In case that its size is 2 or 4 byte, the size of
data part per 1 parameter or 1 axis is 2 or 4 byte, and so
'dummy' is not necessary.

no axis/1 axis all axes


IODBPSD 0 +-------+ --- 0 +-------+ ---
|datano | ^ |datano | ^
2 +-------+ | 2 +-------+ |
|type |length/parameter |type | length
4 +---+---+ | 4 +---+---+ /param.
|cdata | |cdatas[0] :1st |
5 +---+ | 5 +---+ |
|dummy v = = |
6 +---+ --- 4+1x(n-1) +---+ |
|cdatas[n-1]:n-th |
4+1xn +---+ |
|dummy(in case of v
+---+ n=odd num.)---
n : Maximum controlled axes

param Pointer to the area to store the parameters.

Each parameter can be referred by using the IODBPSD structure.

typedef struct iodbpsd {


short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2-word parameter */
char cdatas[MAX_AXIS]; /* bit/byte parameter with
axis*/
short idatas[MAX_AXIS];/*word parameter with axis */
long ldatas[MAX_AXIS]; /*2word parameter with axis*/
} u ;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */

84
datano Parameter number which was read is stored.

type Attribute of parameter which was read is stored.

Upper byte:type
0 : bit type
1 : byte type
2 : word type
3 : 2-word type

Lower byte:axis
ALL_AXES : all axes(ALL_AXES=-1)
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of area to store parameter(length) is
wrong.
EW_NUMBER Data number error
Parameter number(s_number,e_number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program reads the parameter within the specified number
range and axis, and displays them.

#include <stdio.h>
#include <stdlib.h>
#include "apilib.h"

/* start/end are start/end number to be read, axis is axis number. */


short example( short start, short end, short axis )
{
ODBSYS info ;
IODBPSD *param, *ptr ;
short ret, idx1, idx2, axno, inc ;
cnc_sysinfo( 0, &info ) ;
axno = atoi( info.axes ) ;
param = (IODBPSD *)calloc( 1, 1000 ) ;
ret = cnc_rdparar( 0, start, axis, end, 1000, param ) ;
ptr = param ;
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 ;
}

85
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 ;
}
}
putchar( '\n' ) ;
ptr = (IODBPSD *)(((char *)ptr)+4+8*inc) ;
break ;
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 = (IODBPSD *)(((char *)ptr)+4+inc) ;
break ;
}
}
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( param ) ;
return ( ret ) ;
}

86
(9) Write parameter(area specified)

Function Name: cnc_wrparas

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrparas(unsigned short FlibHndl,
short length, (void *)param);

Description: Writes all parameters stored in "param".


The data format depends on each parameter. The format of
Byte/Word/2-Word parameter is generally signed binary.

Writes the parameter for all axes once by specifying 'ALL_AXES'


in 'type'. The parameter for each axis must be stored in each
array of "IODBPSD".

The attribute of CNC parameter depends on the type and axis, and
it is different for each parameter. It is as follows, and can
be got by cnc_rdparainfo() function.

Parameter type Use Byte size


--------------------------+---------------------------------+---------
Bit parameter Every bits have each definition. 1
Bit parameter with axis Every bits have each definition. 1
(each axis)
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

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.

PS000 alarm:"PLEASE TURN OFF POWER" may be issued when some specific
parameters are written.

See the "PARAMETER MANUAL" of CNC for details of each parameter.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the data block length which is enough to store the
specified parameter.
The structure per 1 parameter is as follows, and each parameter
must be lined up in order of number.

[= Sum of (4+(byte size of each parameter)*(number of axis))]

In case that the size of parameter is 1 byte, the IODBPSD


structure is as follows.
In case that the size of parameter is 1 byte and the length per
1 parameter is an odd number, 'dummy' is necessary in the end of
structure. In case that its size is 2 or 4 byte, the size of
data part per 1 parameter or 1 axis is 2 or 4 byte, and so
'dummy' is not necessary.

87
no axis/1 axis all axes
IODBPSD 0 +-------+ --- 0 +-------+ ---
|datano | ^ |datano | ^
2 +-------+ | 2 +-------+ |
|type |length/parameter |type | length
4 +---+---+ | 4 +---+---+ /param.
|cdata | |cdatas[0] :1st |
5 +---+ | 5 +---+ |
|dummy v = = |
6 +---+ --- 4+1x(n-1) +---+ |
|cdatas[n-1]:n-th |
4+1xn +---+ |
|dummy(in case of v
+---+ n=odd num.)---
n : Maximum controlled axes

param Pointer to the area to store the parameters.

Each parameter can be referred by using the IODBPSD structure.

typedef struct iodbpsd {


short datano; /* parameter number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte parameter */
short idata; /* word parameter */
long ldata; /* 2-word parameter */
char cdatas[MAX_AXIS]; /* bit/byte parameter with
axis*/
short idatas[MAX_AXIS];/*word parameter with axis */
long ldatas[MAX_AXIS]; /*2word parameter with axis*/
} u ;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */

datano Specify the parameter number.


See the "PARAMETER MANUAL" of CNC about available
parameter number. It can be got by cnc_rdparainfo()
function.

type Specify the attribute of parameter.


Upper byte:type
0 : bit type
1 : byte type
2 : word type
3 : 2-word type

Lower byte:axis
ALL_AXES : assigns all axes(ALL_AXES=-1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)

88
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of area to store parameter(length) is
wrong.
EW_NUMBER Data number error
Parameter number(datano) is wrong.
EW_ATTRIB Data attribute error
Axis number(type) is wrong.
EW_NOOPT No option
There is no option required for the specified
parameter.
EW_PROT Write operation is prohibited.

CNC option: In case of Power Mate, there may be need of CNC option
for some specific parameters.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program writes M codes for macro call in No.6080,..,
No.6089.
#include <stdlib.h>
#include "apilib.h"
short example( short *mcode )
{
IODBPSD *param, *ptr ;
short ret, idx ;
param = (IODBPSD *)calloc( 1, 100 ) ;
ptr = param ;
for ( idx = 0 ; idx < 10 ; idx++ ) {
ptr->datano = 6080 + idx ;
ptr->type = 0 ;
ptr->cdata = mcode[idx] ;
ptr = (IODBPSD *)(((char *)ptr)+6) ;
}
ret = cnc_wrparar( 0, 6*10, param ) ;
free( param ) ;
return ( ret ) ;
}

89
(10) Read parameter information

Function Name: cnc_rdparainfo

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdparainfo(unsigned short FlibHndl,
short s_number, unsigned short read_no, ODBPARAIF *paraif);

Description: The information specified by "s_number" and "read_no" are read.

The CNC parameter is basically non-continuous, and the attribute


like the type and the size, etc. is different in each number.
Use for such as displaying the parameter.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

s_number Specify the start parameter number.

read_no Specify the number of the parameter information to read.

paraif Pointer to the ODBPARAIF structure including the parameter


information.

The ODBPARAIF structure is as follows.

typedef struct odbparaif {


unsigned short info_no ; /* number of parameter
information */
short prev_no ; /* previous parameter number */
short next_no ; /* next parameter number */
struct {
short prm_no ; /* parameter number */
short prm_type ; /* attribute of parameter */
} info[N] ; /* N is amount of parameter information */
} ODBPARAIF ;

info_no Number of parameter information


Number of parameter information read actually.

prev_no Previous parameter number


Effective number ahead of parameter information
read first.

next_no Next parameter number


Effective number after parameter information
read at the end.

info[N].prm_no Parameter number


Parameter number which exists actually.

90
info[N].prm_type Attribute of parameter
The following attributes are set.
bit 0,1 : type attribute
0 : bit type 2 : word type
1 : bite type 3 : 2-word type
bit 2 : axis attribute
0 : without axis
1 : with axis
bit 3 : sign (Only Series160/180/210)
0 : with sign
1 : without sign
bit 4 : settings input
0 : disable 1 : enable
bit 5 : write protection
0 : enable 1 : disable
bit 6 : power must be off after writing
0 : not necessary
1 : necessary
bit 7 : read protection
0 : enable 1 : disable
bit 8 : spindle parameter
0 : no spindle 1 : spindle
bit 9 - 15:(reserve)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_NUMBER data number error
Start parameter number(s_number)is improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

91
(11) Read setting data(area specified)

Function Name: cnc_rdsetr

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdsetr(unsigned short FlibHndl,(short *)&s_number,
short axis, (short *)&e_number,
(short *)&length, (void *)set);

Description: Reads the setting data specified by "s_number", "e_number",


"axis"(only for the setting data with axis). The data format
depends on each setting data. The format of Byte/Word/2-Word
setting data is generally signed binary.

Reads the setting data for all axes specified range by


specifying 'ALL_AXES' in 'axis'.

The attribute of setting data depends on the type and axis, and
it is different for each setting data.

Setting data type Use Byte size


-----------------------------+---------------------------------+---------
Bit setting data Every bits have each definition. 1
Bit setting data with axis Every bits have each definition. 1
(each axis)
Byte setting data 1-byte data is stored. 1
Byte setting data with axis 1-byte data is stored.(each axis) 1
Word setting data 2-byte data is stored. 2
Word setting data with axis 2-byte data is stored.(each axis) 2
2-Word setting data 4-byte data is stored. 4
2-Word setting data with ax. 4-byte data is stored.(each axis) 4

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 "Read parameter(area


specified)(cnc_rdparar)" except that it cannot read the
parameter without setting attribute.
See the "PARAMETER MANUAL" of CNC for details of each setting
data.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

s_number Specify the start setting data number.


The first setting data number to be read is returned.
See the "PARAMETER MANUAL" of CNC about available setting data
number.

e_number Specify the end setting data number.


The last setting data number to be read is returned.

The new setting data may be added according to updating CNC


software, addition of the new function, etc. If the new
setting data is added within reading range, the error(Return:
EW_LENGTH) will be returned or the application program will not
work correctly. In order to avoid these mistakes, specify the
continuous numbers of existing setting data as the reading

92
range.

axis Specify the axis number.


ALL_AXES : assigns all axes(ALL_AXES=-1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)

None axis type setting data can be read even if any value is
specified in "axis". In case that an axis type setting data
exists in the specified range, the error(Return:EW_ATTRIB) is
returned by specifying "axis=0".

length Specify the data block length which is enough to store the
specified setting data.
The structure per 1 setting data is as follows, and each
setting data is lined up in order of number.
[= Sum of (4+(byte size of each setting data)*(number of axis))]

Because the size to be read is returned, it is possible to


specify the length more than the actual size.

In case that the size of setting data is 1 byte, the IODBPSD


structure is as follows.
In case that the size of setting data is 1 byte and the length
per 1 setting data is an odd number, 'dummy' is necessary in
the end of structure. In case that its size is 2 or 4 byte,
the size of data part per 1 setting data or 1 axis is 2 or 4
byte, and so 'dummy' is not necessary.

no axis/1 axis all axes


IODBPSD 0 +-------+ --- 0 +-------+ ---
|datano | ^ |datano | ^
2 +-------+ | 2 +-------+ |
|type |length/set data |type | length
4 +---+---+ | 4 +---+---+ /set.data
|cdata | |cdatas[0] :1st |
5 +---+ | 5 +---+ |
|dummy v = = |
6 +---+ --- 4+1x(n-1) +---+ |
|cdatas[n-1]:n-th |
4+1xn +---+ |
|dummy(in case of v
+---+ n=odd num)---
n : Maximum controlled axes

set Pointer to the area to store the setting data.

Each setting data can be referred by using the IODBPSD


structure.

typedef struct iodbpsd {


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 */
char cdatas[MAX_AXIS]; /* bit/byte set. data
with axis*/
short idatas[MAX_AXIS];/* word setting data
with axis */
long ldatas[MAX_AXIS]; /* 2-word set. data
with axis */

93
} u ;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */

datano Setting data number which was read is stored.

type Attribute of setting data which was read is stored.


Upper byte:type
0 : bit type
1 : byte type
2 : word type
3 : 2-word type

Lower byte:axis
ALL_AXES : all axes(ALL_AXES=-1)
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of area to store setting data(length) is
wrong.
EW_NUMBER Data number error
Setting data number(s_number,e_number) is
wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

94
(12) Write setting data(area specified)

Function Name: cnc_wrsets

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrsets(unsigned short FlibHndl, short length,
(void *)set);

Description: Writes all setting data stored in "set".


The data format depends on each setting data. The format of
Byte/Word/2-Word setting data is generally signed binary.

Writes the setting data for all axes once by specifying


'ALL_AXES' in 'type'. The setting data for each axis must be
stored in each array of "IODBPSD".

The attribute of setting data depends on the type and axis, and
it is different for each setting data.

Setting data type Use Byte size


-----------------------------+--------------------------------+---------
Bit setting data Every bits have each definition. 1
Bit setting data with axis Every bits have each definition. 1
(each axis)
Byte setting data 1-byte data is stored. 1
Byte setting data with axis 1-byte data is stored.(each axis) 1
Word setting data 2-byte data is stored. 2
Word setting data with axis 2-byte data is stored.(each axis) 2
2-Word setting data 4-byte data is stored. 4
2-Word setting data with ax. 4-byte data is stored.(each axis) 4

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 "Write parameter(area


specified)(cnc_wrparas)" except that it cannot write the
parameter without setting attribute.

See the "PARAMETER MANUAL" of CNC for details of each setting


data.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the data block length which is enough to store the
specified setting data.
The structure per 1 setting data is as follows, and each
setting data must be lined up in order of number.
[= Sum of (4+(byte size of each setting data)*(number of axis))]

In case that the size of setting data is 1 byte, the IODBPSD


structure is as follows.
In case that the size of setting data is 1 byte and the length
per 1 setting data is an odd number, 'dummy' is necessary in
the end of structure. In case that its size is 2 or 4 byte,
the size of data part per 1 setting data or 1 axis is 2 or 4
byte, and so 'dummy' is not necessary.

95
no axis/1 axis all axes
IODBPSD 0 +-------+ --- 0 +-------+ ---
|datano | ^ |datano | ^
2 +-------+ | 2 +-------+ |
|type |length/set data |type | length
4 +---+---+ | 4 +---+---+ /set.data
|cdata | |cdatas[0] :1st |
5 +---+ | 5 +---+ |
|dummy v = = |
6 +---+ --- 4+1x(n-1) +---+ |
|cdatas[n-1]:n-th |
4+1xn +---+ |
|dummy(in case of v
+---+ n=odd num.)---
n : Maximum controlled axes

set Pointer to the area to store the setting data.

Each setting data can be referred by using the IODBPSD


structure.

typedef struct iodbpsd {


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 */
char cdatas[MAX_AXIS]; /* bit/byte set. data with
axis*/
short idatas[MAX_AXIS]; /* word setting data with
axis */
long ldatas[MAX_AXIS]; /* 2-word set. data with
axis */
} u ;
} IODBPSD ; /* MAX_AXIS : max. controlled axes */

datano Specify the setting data number.


See the "PARAMETER MANUAL" of CNC about available
setting data number.

type Specify the attribute of setting data.


Upper byte:type
0 : bit type
1 : byte type
2 : word type
3 : 2-word type
Lower byte:axis
ALL_AXES : assigns all axes(ALL_AXES=-1)
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)

96
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of area to store setting data(length) is
wrong.
EW_NUMBER Data number error
Setting data number(datano) is wrong.
EW_ATTRIB Data attribute error
Axis number(type) is wrong.
EW_NOOPT No option
There is no option required for the specified
setting data.

CNC option: In case of Power Mate, there may be need of CNC option
for some specific setting data.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

97
(13) Read custom macro variable

Function Name: cnc_rdmacro

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdmacro(unsigned short FlibHndl,
short number, short length, ODBM *macro);

Description: Reads the custom macro variable specified by "number".


The data is stored in "ODBM" with signed binary format.

The kinds of custom macro variable are as follows.


(1) Local variable(#1,..,#33)
The local variables which belong to the macro program just
being executed when the application program calls this
function are read.
(2) Common variable(#100,..)
See the description of cnc_rdmacroinfo() function about
the available range of common variables.

It is possible to exchange the type of macro variable by


cnc_setmactype() function.

- fixed-point type(data format=M*10**(-E))


mcr_val : value of variable(=M)
4-byte singed binary data
(available range: Power Mate -99999999,..,99999999)
dec_val : number of places of decimals(=E)
2-byte singed binary data
(available range: Power Mate -1,0,..,8)

* In case of Power Mate, specify the floating-point


type when the data is beyond above limitation,
because 'mcr_val' and 'dec_val' are invalid(=-1) in
such case.

- floating-point type(data format=M*2**(-E))


mcr_val : numerical part of variable(=M)
4-byte singed binary data
(available range:No limitation)
dec_val : exponent part of variable(=E)
2-byte singed binary data
(available range:-128,..,127)

The value of an undefined variable is called "vacant", and it is


as follows both under fixed-point type and under floating-point
type.
mcr_val = 0
dec_val = -1

See "OPERATOR'S MANUAL" of CNC for details of the custom macro


variable.

Arguments:

FlibHndl Identify the process which uses the library.


The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify the custom macro variable number.

98
length Specify the data block length(size of ODBM structure=10).

ODBM 0 +-----------+ ---


|datano | ^
2 +-----------+ |
|dummy | |
4 +-----------+---------+ length
|mcr_val | |
8 +-----------+---------+ |
|dec_val | v
10+-----------+ ---

macro Pointer to the ODBM structure including the custom macro


variable.

The ODBM structure is as follows.

typedef struct odbm {


short datano ; /* custom macro variable number */
short dummy ; /* (not used) */
long mcr_val ; /* value of custom macro variable */
short dec_val ; /* number of places of decimals */
} ODBM ;

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of ODBM structure(length) is wrong.
EW_NUMBER Data number error
Custom macro variable number(number) is wrong.

CNC option: There is no need of CNC option for this function.


CNC parameter: This function does not relate to CNC parameter.
CNC mode: This function can be used in any CNC mode.
Example:
The following program reads the custom macro variable data of specified
number and displays it.

#include <stdio.h>
#include <string.h>
#include "apilib.h"
/* number is variable number to be read. */
short example( short number )
{
ODBM macro ;
char strbuf[11] ;
short ret ;
ret = cnc_rdmacro( 0, number, 10, &macro ) ;
if ( !ret ) {
sprintf( &strbuf[1], "%09ld", macro.mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1], 9 - macro.dec_val ) ;
strbuf[9-macro.dec_val] = '.' ;
printf( "%s\n", strbuf ) ;
}
else
printf( "**********\n" ) ;
return ( ret ) ;
}

99
(14) Write custom macro variable

Function Name: cnc_wrmacro

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrmacro(unsigned short FlibHndl,
short number, short length, long mcr_val, short dec_val);

Description: Writes the custom macro variable specified by "number".


The data must be stored in "mcr_val", "dec_val" with signed
binary format.

The kind of custom macro variable is as follows.


The local variable cannot be written.

(1) Common variable(#100,..)


See the description of cnc_rdmacroinfo() function about
the available range of common variables.

It is possible to exchange the type of macro variable by


cnc_setmactype() function.

- fixed-point type(data format=M*10**(-E))


mcr_val : value of variable(=M)
4-byte singed binary data
(available range: Power Mate -99999999,..,99999999)
dec_val : number of places of decimals(=E)
2-byte singed binary data
(available range: Power Mate -1,0,..,8)

* In case of Power Mate, specify the floating-point


type when the data is beyond above limitation,
because the error(Return:EW_DATA) is returned in such
case.

- floating-point type(data format=M*2**(-E))


mcr_val : numerical part of variable(=M)
4-byte singed binary data
(available range:No limitation)
dec_val : exponent part of variable(=E)
2-byte singed binary data
(available range:-128,..,127)

The value of an undefined variable is called "vacant", and it is


as follows both under fixed-point type and under floating-point
type.
mcr_val = 0
dec_val = -1

See "OPERATOR'S MANUAL" of CNC for details of the custom macro


variable.

Arguments:

FlibHndl Identify the process which uses the library.


The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify the custom macro variable number.

length Specify the data block length(=10).

100
mcr_val Specify the value of variable/numerical part of variable.

dec_val Specify the number of places of decimals/exponent part of


variable.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size(length) is wrong.
EW_NUMBER Data number error
Custom macro variable number(number) is wrong.
EW_DATA Data error
Value of custom macro variable(mcr_val,
dec_val) is out of available range.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program writes the specified value in the specified
custom macro variable.

#include "apilib.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( 0, number, 10, value, dec ) ;
return ( ret ) ;
}

101
(15) Read custom macro variable(area specified)

Function Name: cnc_rdmacror

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdmacror(unsigned short FlibHndl,short s_number,
short e_number, short length,
IODBMR *macror);

Description: Reads the custom macro variable specified by "s_number",


"e_number".
The data is stored in "IODBMR" with signed binary format.

The kinds of custom macro variable are as follows.


(1) Local variable(#1,..,#33)
The local variables which belong to the macro program just
being executed when the application program calls this
function are read.
(2) Common variable(#100,..)
See the description of cnc_rdmacroinfo() function about
the available range of common variables.

It is possible to exchange the type of macro variable by


cnc_setmactype() function.

- fixed-point type(data format=M*10**(-E))


mcr_val : value of variable(=M)
4-byte singed binary data
(available range: Power Mate -99999999,..,99999999)
dec_val : number of places of decimals(=E)
2-byte singed binary data
(available range: Power Mate -1,0,..,8)

* In case of Power Mate, specify the floating-point


type when the data is beyond above limitation,
because 'mcr_val' and 'dec_val' are invalid(=-1) in
such case.

- floating-point type(data format=M*2**(-E))


mcr_val : numerical part of variable(=M)
4-byte singed binary data
(available range:No limitation)
dec_val : exponent part of variable(=E)
2-byte singed binary data
(available range:-128,..,127)

The value of an undefined variable is called "vacant", and it is


as follows both under fixed-point type and under floating-point
type.
mcr_val = 0
dec_val = -1

See "OPERATOR'S MANUAL" of CNC for details of the custom macro


variable.

Arguments:

FlibHndl Identify the process which uses the library.


The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

102
s_number Specify the start custom macro variable number.

e_number Specify the end custom macro variable number.

length Specify the data block length(size of IODBMR structure).


(6+6*(Number of custom macro variable)

IODBMR 0 +-----------+ ---


|datano_s | ^
2 +-----------+ |
|dummy | |
4 +-----------+ |
|datano_e | |
6 +-----------+---------+ |
|data[0].mcr_val | length
10+-----------+---------+ |
|data[0].dec_val |
12+-----------+---------+ |
= = |
6+6*(N-1) +-----------+---------+ |
|data[N-1].mcr_val | |
+-----------+---------+ |
|data[N-1].dec_val v
6+6*N +-----------+ ---
N : Number of custom macro variable

macror Pointer to the IODBMR structure including the custom macro


variable.

The IODBMR structure is as follows.

typedef 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; /* value of custom macro var. */
short dec_val; /* number of places of decimals*/
} data[N]; /* N : number of variable */
} IODBMR;

datano_s The first custom macro variable number to be read is


returned.

datano_e The last custom macro variable number to be read is


returned.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of IODBMR structure(length) is wrong.
EW_NUMBER Data number error
Custom macro variable number(s_number,
e_number) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

103
CNC mode: This function can be used in any CNC mode.

Example:
The following program reads the custom macro variables within the
specified range and displays them.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "apilib.h"

/* start/end are start/end variable number to be read. */


short example( short start, short end )
{
IODBMR *macror ;
char strbuf[11] ;
short ret, idx ;
macror = (IODBMR *)malloc( 1000 ) ;
ret = cnc_rdmacror( 0, start, end, 1000, macror ) ;
if ( !ret )
for ( idx = 0 ; idx <= end-start ; idx++ ) {
sprintf( &strbuf[1], "%09ld",
macror->data[idx].mcr_val ) ;
if ( strbuf[1] == '0' ) strbuf[1] = ' ' ;
strncpy( &strbuf[0], &strbuf[1],
9 - macror->data[idx].dec_val ) ;
strbuf[9-macror->data[idx].dec_val] = '.' ;
printf( "#%04d %s\n", start+idx, strbuf ) ;
}
else
printf( "ERROR!(%d)\n", ret ) ;
free( macror ) ;
return ( ret ) ;
}

104
(16) Write custom macro variable(area specified)

Function Name: cnc_wrmacror

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrmacror(unsigned short FlibHndl,
short length, IODBMR *macror);

Description: Writes the custom macro variable specified by "datano_s",


"datano_e".
The data must be stored in "IODBMR" with signed binary format.

The kind of custom macro variable is as follows.


The local variable cannot be written.

(1) Common variable(#100,..)


See the description of cnc_rdmacroinfo() function about
the available range of common variables.

It is possible to exchange the type of macro variable by


cnc_setmactype() function.

- fixed-point type(data format=M*10**(-E))


mcr_val : value of variable(=M)
4-byte singed binary data
(available range: Power Mate -99999999,..,99999999)
dec_val : number of places of decimals(=E)
2-byte singed binary data
(available range: Power Mate -1,0,..,8)

* In case of Power Mare, specify the floating-point


type when the data is beyond above limitation,
because the error(Return:EW_DATA) is returned in such
case.

- floating-point type(data format=M*2**(-E))


mcr_val : numerical part of variable(=M)
4-byte singed binary data
(available range:No limitation)
dec_val : exponent part of variable(=E)
2-byte singed binary data
(available range:-128,..,127)

The value of an undefined variable is called "vacant", and it is


as follows both under fixed-point type and under floating-point
type.
mcr_val = 0
dec_val = -1

See "OPERATOR'S MANUAL" of CNC for details of the custom macro


variable.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the data block length(size of IODBMR structure).


(6+6*(Number of custom macro variable)

105
IODBMR 0 +-----------+ ---
|datano_s | ^
2 +-----------+ |
|dummy | |
4 +-----------+ |
|datano_e | |
6 +-----------+---------+ |
|data[0].mcr_val | length
10+-----------+---------+ |
|data[0].dec_val |
12+-----------+---------+ |
= = |
6+6*(N-1) +-----------+---------+ |
|data[N-1].mcr_val | |
+-----------+---------+ |
|data[N-1].dec_val v
6+6*N +-----------+ ---
N : Number of custom macro variable

macror Pointer to the IODBMR structure including the custom macro


variable.

The IODBMR structure is as follows.

typedef 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; /* value of custom macro var. */
short dec_val; /* number of places of decimals*/
} data[N]; /* N : number of variable */
} IODBMR;

datano_s Specify the start custom macro variable number.

datano_e Specify the end custom macro variable number.

mcr_val Specify the value of variable/numerical part of


variable.

dec_val Specify the number of places of decimals/exponent part


of variable.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of IODBMR structure(length) is wrong.
EW_NUMBER Data number error
Custom macro variable number(datano_s,
datano_e) is wrong.
EW_DATA Data error
Value of custom macro variable(mcr_val,
dec_val) is out of available range.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

106
CNC mode: This function can be used in any CNC mode.

Example:
The following program writes the specified values into the custom macro
variables within the specified range.

#include <stdlib.h>
#include "apilib.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 )
{
IODBMR *macror ;
short ret, idx ;
macror = (IODBMR *)malloc( 6+6*number ) ;
macror->datano_s = start ;
macror->datano_e = start + number - 1 ;
for ( idx = 0 ; idx < number ; idx++ ) {
macror->data[idx].mcr_val = value[idx] ;
macror->data[idx].dec_val = 0 ;
}
ret = cnc_wrmacror( 0, 6+6*number, macror ) ;
free( macror ) ;
return ( ret ) ;
}

107
(17) Read custom macro variable information

Function Name: cnc_rdmacroinfo

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdmacroinfo(unsigned short FlibHndl,
ODBMVINF *mvinf);

Description: Reads the available number of the local macro variable and the
common macro variable. Those are stored in "use_no1", "use_no2"
of "ODBMVINF" with signed binary format.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

mvinf Pointer to the ODBMVINF structure including the custom macro


variable information.

The ODBMVINF structure is as follows.

typedef struct odbmvinf {


short use_no1 ; /* number of local variable */
short use_no2 ; /* indicator of common variable */
} ODBMVINF ;

use_no1 Available number of local macro variable(33 sets)

use_no2 Indicator of available common variable


0 : 100,..,149, 500,..,531
1 : 100,..,199, 500,..,999
2 : 100,..,199, 500,..,699

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

108
(18) Get type of custom macro variable

Function Name: cnc_getmactype

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_getmactype(unsigned short FlibHndl,
(short *)&macro_type);

Description: Gets the type of custom macro variable which is used by


cnc_rdmacro,cnc_wrmacro, cnc_rdmacror, cnc_wrmacror function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

macro_type Custom macro variable type


0 :Fixed-point type (default)
none 0 :Floating-point type

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

109
(19) Set type of custom macro variable

Function Name: cnc_setmactype

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_setmactype(unsigned short FlibHndl,
short macro_type);

Description: Changes the type of custom macro variable which is used by


cnc_rdmacro,cnc_wrmacro, cnc_rdmacror, cnc_wrmacror function.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

macro_type Custom macro variable type


0 :Fixed-point type (default)
none 0 :Floating-point type

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

110
1.1.10 Function Reference Related to History Data

(1) Stop Logging Operation History Data

Function Name: cnc_stopophis

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_stopophis(unsigned short FlibHndl);

Description: Stops sampling the operation history data and the alarm history
data of CNC.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

111
(2) Restart logging operation history data

Function Name: cnc_startophis

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_startophis(unsigned short FlibHndl);

Description: Restarts sampling the operation history data and the alarm
history data of CNC.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

Return: E W_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

112
(3) Read number of operation history data

Function Name: cnc_rdophisno

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdophisno(unsigned short FlibHndl,
unsigned short *hisno);

Description: Reads the number of operation history data.


It is necessary to stop sampling the operation history data by using
cnc_stopophis() function before this function is used.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

hisno Pointer to the variable by which the number of operation


history data is stored.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_FUNC cnc_stopophis function has not been executed.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

113
(4) Read operation history data

Function Name: cnc_rdophistry

Declaration:
#include "Fwlib32.h
FWLIBAPI short WINAPI cnc_rdophistry(unsigned short FlibHndl,unsigned short
s_no, unsigned short e_no,unsigned short
length, ODBHIS *his);

Description: Reads the operation history data.


The structure of the operation history data is different
according to kind of the record(rec_type).
When the operation history data is accessed, it is necessary to
use a structure corresponding to the kind.

The operation history data and the alarm history data are
automatically recorded on the CNC. When these data are
accessed, it is necessary to temporarily stop sampling on the
CNC.
Therefore, it is necessary to execute "Stop logging operation
history data"(cnc_stopophis) before this function is used.

It is necessary to execute "Restart logging operation history


data" (cnc_startophis) to make the sampling stop time of the
history data a minimum as soon as the lead ends.

The record number of the beginning/end is an applied number of


each record of the operation history data.
The record number is effective from the execution of "Stop
logging operation history data" to the execution of "Restart
logging operation history data".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

s_no Specify the beginning record number.(more than 1)

e_no Specify the end record number.(more than 1)

length Specify the data block length(size of ODBHIS structure).

ODBHIS 0 +---------+ -+-


| s_no | |
2 +---------+ |
| type | |
4 +---------+ |
| e_no | |
6 +---------+---------+ length
| data[0] | |
14+-------------------+ |
= = |
6+8*(n-1) +-------------------+ |
| data[n] | |
6+8*n +-------------------+ -+-

114
data.rec_alm 0 +-----------------------+
| rec_type |
2 +-----------------------+
| alm_grp |
4 +-----------------------+
| alm_no |
6 +-----------+-----------+
| axis_no |
7 +-----------+
| dummy |
8 +-----------+

data.rec_mdi 0 +-----------------------+
| rec_type |
2 +-----------+-----------+
| key_code |
3 +-----------+
| pw_flag |
4 +-----------+
| dummy[0] |
5 +-----------+
| dummy[1] |
6 +-----------+
| dummy[2] |
7 +-----------+
| dummy[3] |
8 +-----------+

data.rec_sgn 0 +-----------------------+
| rec_type |
2 +-----------+-----------+
| sig_name |
3 +-----------+
| sig_old |
4 +-----------+
| sig_new |
5 +-----------+
| dummy |
6 +-----------+-----------+
| sig_no |
8 +-----------------------+

his Pointer to the ODBHIS structure by which the operation history


data is stored.

115
The ODBHIS structure is as follows.

typedef struct odbhis {


unsigned s_no; /* Start record number */
short type; /* Not used */
unsigned e_no; /* Most recently entered */
/* record number */
union {
struct {
short rec_type; /* Record type */
short alm_grp; /* Alarm type */
short alm_no; /* Alarm number */
char axis_no; /* Axis number */
char dummy; /* Not used */
} rec_alm; /* Structure of alarm record*/
struct {
short rec_type; /* Record type */
char key_code; /* Key code */
char pw_flag; /* Power-on flag */
char dummy[4]; /* Not used */
} rec_mdi; /* Structure of MDI key record*/
struct {
short rec_type;
/* Record type */
char sig_name;
/* Signal name */
char sig_old;/* Bit pattern before a */
/* transition */
char sig_new; /* Bit pattern after a */
/* transition */
char dummy; /* Not used */
short sig_no; /* Signal number */
} rec_sgn; /* Structure of signal record */
} data[N]; /* N : Number of record */
} ODBHIS ;

rec_type Record type


0 : MDI key history
1 : Signal history
2 : Alarm history

alm_grp Alarm type


Power Mate
bit 0 : P/S 100
bit 1 : P/S 000
bit 2 : P/S 101
bit 3 : P/S others
bit 4 : Over travel
bit 5 : Over heat
bit 6 : Servo alarm
bit 7 : System alarm
bit 8 : APC alarm
bit 9 : (Not used)
bit 10 : P/S 5000
bit 11 : (Not used)
bit 12 : (Not used)
bit 13 : (Not used)
bit 14 : (Not used)
bit 15 : External alarm message

alm_no Alarm number

axis_no (Not used)

key_code Key code

116
sig_name Signal name
1 : X
2 : G
3 : Y
4 : F

sig_old Bit pattern before a transition

sig_new Bit pattern after a transition

sig_no Signal number


X : From 0 to 127 or from 1000 to 1063
G : From 0 to 255 or from 1000 to 1255
Y : From 0 to 127 or from 1000 to 1063
F : From 0 to 255 or from 1000 to 1255

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_FUNC cnc_stopophis function has not been executed.
EW_LENGTH Data block length error
Size of ODBHIS structure(length) is wrong.
(e_no-s_no+1) * sizeof(data[0]) + 6 < length

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

117
(5) Read number of alarm history data

Function Name: cnc_rdalmhisno

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdalmhisno(unsigned short FlibHndl,unsigned short
*hisno);

Description: Reads the number of alarm history the data.


It is necessary to stop sampling the alarm history data by using
cnc_stopophis() function before this function is used.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

hisno Pointer to the variable by which the number of alarm history


data is stored.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_FUNC cnc_stopophis function has not been executed.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

118
(6) Read alarm history data

Function Name: cnc_rdalmhistry

Declaration:
#include "Fwlib32.h
FWLIBAPI short WINAPI cnc_rdalmhistry(unsigned short FlibHndl,unsigned short
s_no, unsigned short e_no,unsigned
short length, ODBAHIS *his);

Description: Reads the alarm history data.


The unit of one alarm history data is called a record.

The operation history data and the alarm history data are
automatically recorded on the CNC. When these data are
accessed, it is necessary to temporarily stop sampling on the
CNC.
Therefore, it is necessary to execute "Stop logging operation
history data"(cnc_stopophis) before this function is used.

It is necessary to execute "Restart logging operation history


data" (cnc_startophis) to make the sampling stop time of the
history data a minimum as soon as the read ends.

The record number of the beginning/end is an applied number of


each record of the alarm history data.
This record number is effective from the execution of "Stop
logging operation history data" to the execution of "Restart
logging operation history data".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

s_no Specify the beginning record number.(more than 1)

e_no Specify the end record number.(more than 1)

length Specify the data block length(size of ODBHIS structure).

ODBAHIS 0 +---------+ -+-


| s_no | |
2 +---------+ |
| type | |
4 +---------+ |
| e_no | |
6 +---------+---------+ length
| alm_his[0] | |
54+-------------------+ |
= = |
6+48*(n-1) +-------------------+ |
| alm_his[n] | |
6+48*n +-------------------+ -+-

119
alm_his 0 +---------------------------+
| dummy |
2 +---------------------------+
| alm_grp |
4 +---------------------------+
| alm_no |
6 +-------------+-------------+
| axis_no |
7 +-------------+
| year |
8 +-------------+
| month |
9 +-------------+
| day |
10 +-------------+
| hour |
11 +-------------+
| minute |
12 +-------------+
| second |
13 +-------------+
| dummy2 |
14 +-------------+-------------+
| len_meg |
16 +-------------+-------------+
| alm_msg[0] |
17 +-------------+
= =
47 +-------------+
| alm_msg[31]|
48 +-------------+

his Pointer to the ODBAHIS structure by which the alarm history


data is stored.

The ODBAHIS structure is as follows.

typedef struct odbahis {


unsigned s_no; /* Start record number */
short type; /* Not used */
unsigned e_no; /* Most recently entered record number*/
struct {
short dummy; /* Not used */
short alm_grp; /* Alarm type */
short alm_no; /* Alarm number */
char axis_no; /* Axis number */
char year; /* Year (Not used) */
char month; /* Month (Not used) */
char day; /* Day (Not used) */
char hour; /* Hour (Not used) */
char minute; /* Minute(Not used) */
char second; /* Second(Not used) */
char dummy2; /* Not used */
short len_msg; /* Length of alarm message */
char alm_msg[32];/* Alarm message */
} alm_his[N]; /* N : Number of record */
} ODBAHIS ;

120
alm_grp Alarm type Power Mate Not used

alm_no Alarm number

axis_no Axis number(from 1 to maximum controlled axis)


It is -1 for an unrelated alarm to the axis.

len_msg Length of alarm message (from 0 to 32)

alm_msg Alarm message

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_FUNC cnc_stopophis function has not been executed.
EW_LENGTH Data block length error
Size of ODBAHIS structure(length) is wrong.
(e_no-s_no+1) * sizeof(data[0]) + 6 < length

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

121
(7) Clear operation history data

Function Name: cnc_clearophis

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_clearophis(unsigned short FlibHndl,short slct);

Description: Clears the operation history data and the alarm history data.
It is possible to be selected the operation history or the alarm
history by setting "slct" in Power Mate.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

slct Specify the kind of the cleared history data.


0 : the operation history data
1 : the alarm history data

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_ATTRIB Data attribute error
The specification of "kind of the cleared
history data" (slct) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

122
(8) Read signals related operation history

Function Name: cnc_rdhissgnl

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdhissgnl(unsigned short FlibHndl,IODBSIG *sig);

Description: Reads the target signal for the operation history.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

sig Pointer to the IODBSIG structure by which the operation history


signal is stored. The IODBSIG structure is as follows.

typedef struct iodbsig {


short datano; /* Not used */
short type; /* Not used */
struct {
short ent_no; /* Registration sequence number */
short sig_no; /* Registered signal number */
char sig_name; /* Registered signal name */
char mask_pat; /* Signal mask pattern */
} data[20];
} IODBSIG ;

ent_no Registration sequence number (from 1 to 20)

sig_no Number of a registered signal


X : from 0 to 127 or from 1000 to 1063
G : from 0 to 255 or from 1000 to 1255
Y : from 0 to 127 or from 1000 to 1063
F : from 0 to 255 or from 1000 to 1255

sig_name Name of a registered signal


0 : Not registered
1 : X
2 : G
3 : Y
4 : F

mask_pat Signal mask pattern

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

123
(9) Write signals related operation history
Function Name: cnc_wrhissgnl

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wrhissgnl(unsigned short FlibHndl,IODBSIG *sig);

Description: Writes the operation history object signal.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

sig Pointer to the IODBSIG structure which the operation history


signal to set to CNC is stored.
The IODBSIG structure is as follows.

typedef struct iodbsig {


short datano; /* Not used */
short type; /* Number of signals */
struct {
short ent_no; /* Registration sequence number */
short sig_no; /* Registered signal number */
char sig_name; /* Registered signal name */
char mask_pat; /* Signal mask pattern */
} data[20];
} IODBSIG ;

ent_no Registration sequence number (from 1 to 20)

sig_no Number of a registered signal


X : from 0 to 127 or from 1000 to 1063
G : from 0 to 255 or from 1000 to 1255
Y : from 0 to 127 or from 1000 to 1063
F : from 0 to 255 or from 1000 to 1255

sig_name Name of a registered signal


0 : Not registered
1 : X
2 : G
3 : Y
4 : F

mask_pat Signal mask pattern

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_ATTRIB Data attribute error
The specification of "Number of signals"(type)
is wrong.
EW_DATA Data error

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

124
1.1.11 Functions Related to the axis movement control

(1) Signal operation command (Cannot be used on Power Mate-D)

Function Name: cnc_opdi

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_opdi(unsigned short FlibHndl, short number,ODBOPDI
*idb );

Description: Switches the condition of the specified G code signal.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number An operation signal number is set.

idb It is pointer to the ODBPOS structure that shows the


information of each axis.

The ODBPOS structure is as follows.

typedef struct odbopdi {


short axis; /* axis number */
union {
char cdata;
short idata;
long ldata;
} u; /* signal data */
} ODBOPDI;

+---------+-------------------------+---------------------------------------+
|operation| operation signal name | set value |
| signal | | |
| number | | |
+---------+-------------------------+---------------------------------------+
| 1 | Emergency stop signal | cdata 0:Emergency state 1:release |
+---------+-------------------------+---------------------------------------+
| 2 | Feed hold signal | cdata 0:Feedhold state 1:release |
+---------+-------------------------+---------------------------------------+
| 3 | Reset signal | cdata 1:Reset status 0:release |
+---------+-------------------------+---------------------------------------+
| 4 | Servo off signal | cdata #7 #6 #5 #4 #3 #2 #1 #0 |
| | | +---+---+---+---+---+---+---+---+ |
| | | | 0 | 0 | | | | | | | |
| | | +---+---+---+---+---+---+---+---+ |
| | | #0 1:1st axis servo off |
| | | 0:1st axis servo on |
| | | ~ |
| | | #5 1:6th axis servo off |
| | | 0:6th axis servo on |
+---------+-------------------------+---------------------------------------+

125
+---------+-------------------------+---------------------------------------+
|operation| operation signal name | set value |
| signal | | |
| number | | |
+---------+-------------------------+---------------------------------------+
| 7 | Rapid traverse signal | cdata 1:set 0:reset |
+---------+-------------------------+---------------------------------------+
| 8 | Start signal | cdata 1:set 0:reset |
+---------+-------------------------+---------------------------------------+
| 9 | Change mode signal | cdata #7 #6 #5 #4 #3 #2 #1 #0 |
| | | +---+---+---+---+---+---+---+---+ |
| | | | 0 | 0 | 0 | 0 | | | | | |
| | | +---+---+---+---+---+---+---+---+ |
| | | #3,#2,#1,#0 |
| | | 0 0 0 0 :MDI |
| | | 0 0 0 1 :MEM |
| | | 0 0 1 0 :EDIT |
| | | 0 0 1 1 :REF |
| | | 0 1 0 0 :JOG |
| | | 0 1 0 1 :INC |
| | | 0 1 1 1 :HNDL |
+---------+-------------------------+---------------------------------------+
| 10 | Feedrate override signal| cdata 00000000 : 0% |
| | | 00000001 : 1% |
| | | 00000010 : 2% |
| | | ... |
| | | 01100100 :100% |
| | | ... |
| | | 11111110 :254% |
| | | 11111111 : 0% |
+---------+-------------------------+---------------------------------------+
| 12 | Torque limit enable | cdata #7 #6 #5 #4 #3 #2 #1 #0 |
| | signal | +---+---+---+---+---+---+---+---+ |
| | | | 0 | 0 | | | | | | | |
| | | +---+---+---+---+---+---+---+---+ |
| | | #0 1:1st axis enable |
| | | 0:1st axis disable |
| | | ~ |
| | | #5 1:6th axis enable |
| | | 0:6th axis disable |
+---------+-------------------------+---------------------------------------+
| 13 | Torque limit signal | axis : 0:for all axes |
| | | 1 - m:for each axis |
| | | (m:number of controlled axis)|
| | | cdata :0 - 255 |
| | | override value |
| | | = ( cdata / 255 ) * 100% |
+---------+-------------------------+---------------------------------------+
| 14 | Jog signal | axis : 0:for all axes |
| | | 1 - m:for each axis |
| | | (m:number of controlled axis)|
| | | cdata #7 #6 #5 #4 #3 #2 #1 #0 |
| | | +---+---+---+---+---+---+---+---+ |
| | | | 0 | 0 | 0 | 0 | | 0 | 0 | | |
| | | +---+---+---+---+---+---+---+---+ |
| | | #3 move direction |
| | | 1:-J 0:+J |
| | | #0 1:move 0:stop |
+---------+-------------------------+---------------------------------------+
| 15 | Single block signal | cdata 1:effective 0:not effective |
+---------+-------------------------+---------------------------------------+

126
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

127
(2) Reference point return (Cannot be used on Power Mate-D)

Function Name: cnc_refpoint

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_refpoint(unsigned short FlibHndl, short path_no,
short nmod, short axis, ODBEXEC *odb);

Description: Moves the axis specified by "path_no" and "axis" to the


reference point.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

path_no PATH number is set.(1 - 6)

nmod The requirement to send the completion notice flag is set.


1:require
0:not require

axis Axis number is set.(1 - 6)

odb It is pointer to the ODBEXEC structure that shows the


information of executive condition.

The ODBEXEC structure is as follows.

typedef struct odbexec {


short dummy; /* none */
char cdata[2][8]; /* The information of the */
} ODBEXEC; /* executive condition of */
/* each PATH. */

cdata The condition of the present command buffer is shown.

7 6 5 4 3 2 1 0 bit
+------+------+------+------+------+------+------+------+
cdata[0][x-1] | | |EMNT16|EMNT15|EMNT14|EMNT13|EMNT12|EMNT11|
+------+------+------+------+------+------+------+------+
cdata[1][x-1] | | |EMNT26|EMNT25|EMNT24|EMNT23|EMNT22|EMNT21|
+------+------+------+------+------+------+------+------ +

+------+------+---------------------------------------+
|EMNT2x|EMNT1x| status |
+------+------+---------------------------------------+
| 0 | 0 | A buffer is empty |
| 0 | 1 | There is data in the buffer 1. |
| 1 | 0 | There is data in the buffer 2. |
| 1 | 1 | A buffer is full. |
+------+------+---------------------------------------+
x : PATH number

128
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


Refer to the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct
command.
8010 The choice of DI/DO group of each axis in the axis
control by PMC.

CNC mode: This function can be used in any CNC mode.

Example:
The following program moves the first axis of first PATH to the
reference point and indicates command buffer condition.

#include <stdio.h>
#include "apilib.h"

void example( void )


{
ODBEXEC odb ;
short ret ;
short i, j ;
ret = cnc_refpoint( 0, 1, 0, 1, &odb ) ;
printf( "Return value : %d\n", ret ) ;
if( ret == 0 ){
for( i = 0 ; i < 2 ; i++ ){
for( j = 0 ; j < 8 ; j++ ){
printf( "%x ", odb.cdata[i][j] ) ;
}
printf( "\n" ) ;
}
}
}

129
(3) Absolute movement (Cannot be used on Power Mate-D)

Function Name: cnc_abspoint

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_abspoint(unsigned short FlibHndl,short path_no,
short nmod, short axis, long feed,
ODBPOS *idb, ODBEXEC *odb);

Description: Moves the axis specified by "path_no" to the position specified


by the absolute command in "idb.data" by the "feed" speed.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

path_no PATH number is set.(1 - 6)

nmod The requirement to send the completion notice flag is set.


1:require
0:not require

axis The number of movement axis is set.(1 - 6)

feed A movement speed is set.

idb It is pointer to the ODBPOS structure that shows the


information of each axis.

The ODBPOS structure is as follows.

typedef struct odbpos {


short idata; /* axis number */
long ldata; /* coordinate value */
} ODBPOS;

idata Axis number is set.(1 - 6)

ldata The coordinate value of movement axis is set.


A movement unit is as the following.

+--------------+---------------+
| | IS-B |
+--------------+---------------+
| linear axis | 0.001 [mm] |
+--------------+---------------+
| linear axis | 0.0001 [inch] |
+--------------+---------------+
| rotation axis| 0.001 [deg] |
+--------------+---------------+

odb It is pointer to the ODBEXEC structure that shows the


information of executive condition.

The ODBEXEC structure is as follows.

typedef struct odbexec {


short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of */

130
/* each PATH. */

cdata The condition of the present command buffer is shown.

7 6 5 4 3 2 1 0 bit
+------+------+------+------+------+------+------+------+
cdata[0][x-1] | | |EMNT16|EMNT15|EMNT14|EMNT13|EMNT12|EMNT11|
+------+------+------+------+------+------+------+------+
cdata[1][x-1] | | |EMNT26|EMNT25|EMNT24|EMNT23|EMNT22|EMNT21|
+------+------+------+------+------+------+------+------+

+------+------+---------------------------------------+
|EMNT2x|EMNT1x| status |
+------+------+---------------------------------------+
| 0 | 0 | A buffer is empty |
| 0 | 1 | There is data in the buffer 1. |
| 1 | 0 | There is data in the buffer 2. |
| 1 | 1 | A buffer is full. |
+------+------+---------------------------------------+
x : PATH number

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct
command.
8010 The choice of DI/DO group of each axis in the axis
control by PMC.

CNC mode: This function can be used in any CNC mode.

131
Example:
The 1st axis of 1st PATH is moved to the position of 100 and 2nd axis
is moved to the position of -100 at the speed 500. The following
program requests the reply about the buffer condition.
(mm output. Least incremental unit is IS-B.)

#include <stdio.h>
#include "apilib.h"

void example( void )


{
ODBPOS idb[2] ;
ODBEXEC odb ;
short ret ;
short i, j ;
idb[0].idata = 1 ;
idb[0].ldata = 100000 ;
idb[1].idata = 2 ;
idb[1].ldata = -100000 ;
ret = cnc_abspoint( 0, 1, 0, 2, 500, idb, &odb ) ;
printf( "Return value : %d\n", ret ) ;
if( ret == 0 ){
for( i = 0 ; i < 2 ; i++ ){
for( j = 0 ; j < 8 ; j++ ){
printf( "%x ", odb.cdata[i][j] ) ;
}
printf( "\n" ) ;
}
}
}

132
(4) Incremental movement (Cannot be used on Power Mate-D)

Function Name: cnc_incpoint

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_incpoint(unsigned short FlibHndl,short path_no,
short nmod, short axis, long feed,
ODBPOS *idb, ODBEXEC *odb);

Description: Moves the axis specified by "path_no" to the position specified


by the incremental command in "idb.data" by the "feed" speed.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

path_no PATH number is set.(1 - 6)

nmod The requirement to send the completion notice flag is set.


1:require
0:not require

axis The number of movement axis is set.(1 - 6)

feed A movement speed is set.

idb It is pointer to the ODBPOS structure that shows the information


of each axis.

The ODBPOS structure is as follows.

typedef struct odbpos {


short idata; /* axis number */
long ldata; /* movement distance */
} ODBPOS;

idata Axis number is set.(1 - 6)

ldata The distance of movement axis is set.


A movement unit is as the following.

+--------------+---------------+
| | IS-B |
+--------------+---------------+
| linear axis | 0.001 [mm] |
+--------------+---------------+
| linear axis | 0.0001 [inch] |
+--------------+---------------+
| rotation axis| 0.001 [deg] |
+--------------+---------------+

odb It is pointer to the ODBEXEC structure that shows the


information of executive condition.
The ODBEXEC structure is as follows.

typedef struct odbexec {


short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of */

133
/* each PATH. */

cdata The condition of the present command buffer is shown.

7 6 5 4 3 2 1 0 bit
+------+------+------+------+------+------+------+------+
cdata[0][x-1] | | |EMNT16|EMNT15|EMNT14|EMNT13|EMNT12|EMNT11|
+------+------+------+------+------+------+------+------+
cdata[1][x-1] | | |EMNT26|EMNT25|EMNT24|EMNT23|EMNT22|EMNT21|
+------+------+------+------+------+------+------+------+

+------+------+---------------------------------------+
|EMNT2x|EMNT1x| status |
+------+------+---------------------------------------+
| 0 | 0 | A buffer is empty |
| 0 | 1 | There is data in the buffer 1. |
| 1 | 0 | There is data in the buffer 2. |
| 1 | 1 | A buffer is full. |
+------+------+---------------------------------------+
x : PATH number

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct
command.
8010 The choice of DI/DO group of each axis in the axis
control by PMC.

CNC mode: This function can be used in any CNC mode.

134
Example:
The 1st axis of 1st PATH is moved to the distance of +100 and 2nd axis
is moved to the distance of -100 at the speed 500. The following
program requests the reply about the buffer condition.
(mm output. Least incremental unit is IS-B.)

#include <stdio.h>
#include "apilib.h"

void example( void )


{
ODBPOS idb[2] ;
ODBEXEC odb ;
short ret ;
short i, j ;
idb[0].idata = 1 ;
idb[0].ldata = 100000 ;
idb[1].idata = 2 ;
idb[1].ldata = -100000 ;
ret = cnc_incpoint( 0, 1, 0, 2, 500, idb, &odb ) ;
printf( "Return value : %d\n", ret ) ;
if( ret == 0 ){
for( i = 0 ; i < 2 ; i++ ){
for( j = 0 ; j < 8 ; j++ ){
printf( "%x ", odb.cdata[i][j] ) ;
}
printf( "\n" ) ;
}
}
}

135
(5) Dwell (Cannot be used on Power Mate-D)

Function Name: cnc_dwell

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_dwell(unsigned short FlibHndl, short path_no,
short nmod, short axis, ODBPOS *idb,
ODBEXEC *odb);

Description: Pause the operation of the path specified "path_no" for the time
(sec) specified by "data".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

path_no PATH number is set.(1 - 6)

nmod The requirement to send the completion notice flag is set.


1:require
0:not require

axis The number of stop axis is set.(1 - 6)

idb It is pointer to the ODBPOS structure that shows the


information of each axis.

The ODBPOS structure is as follows.

typedef struct odbpos {


short idata; /* axis number */
long ldata; /* stop time(sec) */
} ODBPOS;

idata Axis number is set.(1 - 6)

ldata Time(sec) is set.(0.001 - 99999.999)

odb It is pointer to the ODBEXEC structure that shows the


information of executive condition.

The ODBEXEC structure is as follows.

typedef struct odbexec {


short dummy; /* none */
char cdata[2][8]; /* The information of the */
} ODBEXEC; /* executive condition of */
/* each PATH. */

136
cdata The condition of the present command buffer is shown.

7 6 5 4 3 2 1 0 bit
+------+------+------+------+------+------+------+------+
cdata[0][x-1] | | |EMNT16|EMNT15|EMNT14|EMNT13|EMNT12|EMNT11|
+------+------+------+------+------+------+------+------+
cdata[1][x-1] | | |EMNT26|EMNT25|EMNT24|EMNT23|EMNT22|EMNT21|
+------+------+------+------+------+------+------+------+

+------+------+---------------------------------------+
|EMNT2x|EMNT1x| status |
+------+------+---------------------------------------+
| 0 | 0 | A buffer is empty |
| 0 | 1 | There is data in the buffer 1. |
| 1 | 0 | There is data in the buffer 2. |
| 1 | 1 | A buffer is full. |
+------+------+---------------------------------------+
x : PATH number

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct
command.
8010 The choice of DI/DO group of each axis in the axis
control by PMC.

CNC mode: This function can be used in any CNC mode.

137
(6) Coordinate establishment (Cannot be used on Power Mate-D)

Function Name: cnc_coordre

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_coordre(unsigned short FlibHndl, short path_no,
short nmod, short axis, ODBPOS *idb,
ODBEXEC *odb);

Description: Preset the coordinate of the axis specified by "path_no" and


"idb.idata" to the value specified by "idb.ldata".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

path_no PATH number is set.(1 - 6)

nmod The requirement to send the completion notice flag is set.


1:require
0:not require

axis A number of the axis to set up is set.(1 - 6)

idb It is pointer to the ODBPOS structure that shows the


information of each axis.

The ODBPOS structure is as follows.

typedef struct odbpos {


short idata; /* axis number */
long ldata; /* stop time(sec) */
} ODBPOS;

idata Axis number is set.(1 - 6)

ldata Coordinate value is set.


A movement unit is as the following.

+--------------+---------------+
| | IS-B |
+--------------+---------------+
| linear axis | 0.001 [mm] |
+--------------+---------------+
| linear axis | 0.0001 [inch] |
+--------------+---------------+
| rotation axis| 0.001 [deg] |
+--------------+---------------+

odb It is pointer to the ODBEXEC structure that shows the


information of executive condition.
The ODBEXEC structure is as follows.

typedef struct odbexec {


short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of */
/* each PATH. */

138
cdata The condition of the present command buffer is shown.

7 6 5 4 3 2 1 0 bit
+------+------+------+------+------+------+------+------+
cdata[0][x-1] | | |EMNT16|EMNT15|EMNT14|EMNT13|EMNT12|EMNT11|
+------+------+------+------+------+------+------+------+
cdata[1][x-1] | | |EMNT26|EMNT25|EMNT24|EMNT23|EMNT22|EMNT21|
+------+------+------+------+------+------+------+------+

+------+------+---------------------------------------+
|EMNT2x|EMNT1x| status |
+------+------+---------------------------------------+
| 0 | 0 | A buffer is empty |
| 0 | 1 | There is data in the buffer 1. |
| 1 | 0 | There is data in the buffer 2. |
| 1 | 1 | A buffer is full. |
+------+------+---------------------------------------+
x : PATH number

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct
command.
8010 The choice of DI/DO group of each axis in the axis
control by PMC.

CNC mode: This function can be used in any CNC mode.

139
(7) Reading of the executive buffer condition (Cannot be used on Power Mate-D)

Function Name: cnc_exebufstat

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_exebufstat(unsigned short FlibHndl,ODBEXEC *odb);

Description: Request the information of the buffer condition of the block


that is commanded by cnc_refpoint, cnc_abspoint, cnc_incpoint,
cnc_dwell or cnc_coordpre.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

odb It is pointer to the ODBEXEC structure that information of


executive condition is shown.

The ODBEXEC structure is as follows.

typedef struct odbexec {


short dummy; /* none */
char cdata[2][8]; /* The infomation of the */
} ODBEXEC; /* executive condition of */
/* each PATH. */

cdata The condition of the present command buffer is shown.

7 6 5 4 3 2 1 0 bit
+------+------+------+------+------+------+------+------+
cdata[0][x-1] | | |EMNT16|EMNT15|EMNT14|EMNT13|EMNT12|EMNT11|
+------+------+------+------+------+------+------+------+
cdata[1][x-1] | | |EMNT26|EMNT25|EMNT24|EMNT23|EMNT22|EMNT21|
+------+------+------+------+------+------+------+------+

+------+------+---------------------------------------+
|EMNT2x|EMNT1x| status |
+------+------+---------------------------------------+
| 0 | 0 | A buffer is empty |
| 0 | 1 | There is data in the buffer 1. |
| 1 | 0 | There is data in the buffer 2. |
| 1 | 1 | A buffer is full. |
+------+------+---------------------------------------+
x : PATH number

140
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.

8003#7 Select the validity of the motion command by direct


command.
8010 The choice of DI/DO group of each axis in the axis
control by PMC.

CNC mode: This function can be used in any CNC mode.

141
(8) Reading of the execution completion condition (Cannot be used on Power Mate-D)

Function Name: cnc_finstate

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_finstate(unsigned short FlibHndl,ODBFIN *odb);

Description: Request the completion notice flag of the block that is


commanded by cnc_refpoint, cnc_abspoint, cnc_incpoint, cnc_dwell
or cnc_coordpre for each path.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

odb It is pointer to the ODBFIN structure that the condition of the


completion notice flag is returned.

The ODBFIN structure is as follows.

typedef struct odbfin {


short dummy; /* none */
char cdata[8]; /* The infomation of the */
} ODBFIN; /* complete notice flag */
/* condition of each PATH.*/

cdata The present condition of the completion notice flag is


shown.

7 6 5 4 3 2 1 0 bit
+------+------+------+------+------+------+------+------+
cdata[x-1] | | |EMNT63|EMNT15|EMNT14|EMNT13|EMNT12|EMNT11|
+------+------+------+------+------+------+------+------+
EMNT1x: 0 : un-completion
1 : completion
x : PATH number

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct
command.
8010 The choice of DI/DO group of each axis in the axis
control by PMC.

CNC mode: This function can be used in any CNC mode.

142
(9) The release of the reading mode of the execution completion condition (Cannot be
used on Power Mate-D)

Function Name: cnc_setfin

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_setfin(unsigned short FlibHndl, ODBFIN *idb);

Description: A completion notice flag is reset.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

odb It is pointer to the ODBFIN structure that the condition of the


completion notice flag is returned.

The ODBFIN structure is as follows.

typedef struct odbfin {


short dummy; /* none */
char cdata[8]; /* The infomation of the */
} ODBFIN; /* complete notice flag */
/* condition of each PATH.*/

cdata A complete notice flag to reset is specified.

7 6 5 4 3 2 1 0 bit
+------+------+------+------+------+------+------+------+
cdata[x-1] | | |EMNT63|EMNT15|EMNT14|EMNT13|EMNT12|EMNT11|
+------+------+------+------+------+------+------+------+
EMNT1x: A bit to reset made 1.
x : PATH number

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_BUSY Busy
Try it again or wait until the procedure of
CNC is finished.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
8003#7 Select the validity of the motion command by direct
command.
8010 The choice of DI/DO group of each axis in the axis
control by PMC.

CNC mode: This function can be used in any CNC mode.

143
1.1.12 Function Reference of Others

(1) Read CNC System Information

Function Name: cnc_sysinfo

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_sysinfo(unsigned short FlibHndl,ODBSYS *sysinfo);

Description: Reads system information such as 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 position.

Note that a null character ('\x00') is not added at the end of


each string.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

sysinfo Pointer to the ODBSYS structure for the CNC system information.

The ODBSYS structure for Power Mate is as follows.

typedef struct odbsys {


short dummy[2] ; /* dummy */
char cnc_type[2]; /* not used */
char mt_type[2] ; /* not used */
char series[4] ; /* Series number (ASCII) */
char version[4] ; /* Version number (ASCII) */
char axes[2] ; /* Current controlled axes(ASCII)*/
} ODBSYS ;

series Series number of CNC(ASCII)


The character string of 4 digits is stored.

version Version number of CNC(ASCII)


The character string of 4 digits is stored.

axes Amount of controlled axes(ASCII)


The character string of 2 digits is stored.
In case of 4 axes, ' 4' is set.

ODBSYS 0+---------+
| dummy |
4+---------+
| cnc_type|
6+---------+
| mt_type |
8+---------+-------+
| series |
12+-----------------+
| version |
16+---------+-------+
| axes |

144
18+---------+

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the details, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following information are gotten by execution of this function
on Power Mate (8880-10) system with 4 servo axes.

sysinfo.series = "8880"
sysinfo.version = "0010"
sysinfo.axes = " 4"

145
(2)Read CNC configuration information

Function Name: cnc_sysconfig

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_sysconfig(unsigned short FlibHndl,
ODBSYSC *sysinfo);

Description: Read the CNC system configuration information.


Various information is stored in each member of ODBSYSC.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

sysinfo Pointer to the ODBSYSC structure including the CNC configuration


information.
The ODBSYSC structure for Power Mate is as follows.
typedef struct odbsysc {
char slot_no_p[16]; /* Physical slot number */
char slot_no_l[16]; /* Logical slot number */
short mod_id[16]; /* Module ID */
short soft_id[16]; /* Software ID */
char s_series[16][5]; /* Software series */
char s_version[16][5]; /* Software version */
char dummy[16]; /* Not used */
short m_rom; /* Main-CPU CNC software
installation status */
short s_rom; /* Sub-CPU CNC software
installation status */
char svo_soft[8]; /* Series and version
of servo software */
char pmc_soft[6]; /* Series and version of PMC
management software */
char lad_soft[6]; /* Series and version of
Ladder software */
char mcr_soft[8]; /* Series and version of a macro
executor/order-made macro */
char spl1_soft[6]; /* Series and version of a spindle
software (first spindle) */
char spl2_soft[6]; /* Series and version of a spindle
software (second spindle) */
short frmmin; /*Capacity of FROM module(MAIN) */
short drmmin; /*Capacity of DRAM module (MAIN)*/
short srmmin; /*Capacity of SRAM module (MAIN)*/
short pmcmin; /* Type of PMC module (MAIN) */
short sv1min; /* Presence or absence of a servo
module (axis 1, 2) (MAIN) */
short sv3min; /* Presence or absence of a servo
module (axis 3, 4) (MAIN) */
short sv5min; /* Presence or absence of a servo
module (axis 5, 6) (MAIN) */
short sicmin; /* Presence or absence of SIC
(MAIN)*/
short posmin; /* Presence or absence of a
position LSI (MAIN) */
short submin; /* Information of sub-board */
short hdiio; /* Presence or absence of an LSI
for high-speed skip(I/O card)*/
short dummy[32];

146
} ODBSYSC ;

slot_no_p Not used.

slot_no_l Not used.

mod_id Not used.

soft_id Software ID
The software IDs of the modules which are built in the slots are
stored in binary in order of their position.
This array is terminated with FFH. The data subsequent to FFH
are invalid.
40H : CNC

s_series Software series


Software series information is stored in ASCII code in order of
slot numbers, first four bytes being used for each slot number,
and next one byte is NULL.

s_version Software version


Software version information is stored in ASCII code in order of
slot numbers, four bytes being used for each slot number, and
next one byte is NULL.

m_rom Not used.

s_rom Not used.

svo_soft Series and version of servo software


This information item is stored in ASCII code. The first four
bytes indicate the series, and the remaining four bytes indicate
the version.
It is impossible that this software is absent.

pmc_soft Series and version of PMC management software


This information item is stored in ASCII code. The first four
bytes indicate the series, and the remaining two bytes indicate
the version.
It is impossible that this software is absent.

lad_soft Series and version of Ladder software


This information item is stored in ASCII code. The first four
bytes indicate the series, and the remaining two bytes indicate
the version.
If this software does not exist, all of the 6 bytes are
space(20H).

mcr_soft Series and version of a macro executor/order-made macro


This information item is stored in ASCII. The first byte is not
used. The subsequent four bytes indicate the series, and the
remaining two bytes indicate the version.
If this software does not exist, the first byte is FFH (in some
cases, that is excluding FFH). The last byte is not used.

spl1_soft Not used.

spl2_soft Not used.

frmmin Capacity of FROM module (MAIN)


-1 : Not existence
0 : 2 (MB)
1 : reserve
2 : 4 (MB)
147
drmmin Capacity of DRAM module (MAIN)
-1 : Not existence
0 : 2 (MB)
1 : 2.5 (MB)
2 : reserve
3 : 3 (MB)

srmmin Capacity of added SRAM module (MAIN)


-1 : Not existence
0 : 256 (KB)
1 : 1 (MB)

pmcmin Type of PMC module (MAIN)


-1 : Not existence
0 : PMP2+SL
1 : reserve
2 : reserve
3 : reserve
4 : reserve

sv1min Presence or absence of a servo module


(axis 1, 2) (MAIN)
0 : Existence
-1 : Not existence

sv3min Presence or absence of a servo module


(axis 3, 4) (MAIN)
0 : Existence
-1 : Not existence

sv5min Presence or absence of a servo module


(axis 5, 6) (MAIN)
0 : Existence
-1 : Not existence

sicmin Presence or absence of SIC (MAIN)


-1 : Not existence
0 : Existence

posmin Presence or absence of a position LSI (MAIN)


-1 : Not existence
0 : Existence

submin Information of sub-board


-1 : Not existence
1 : RS485
2 : Built-in I/O board
3 : M-NET board
7 : I/O link2 board

hdiio Presence or absence of an LSI for high-speed skip(I/O card)


0 : Existence
-1 : Not existence

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.


CNC mode: This function can be used in any CNC mode.

148
(3)Read CNC status information

Function Name: cnc_statinfo

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_statinfo(unsigned short FlibHndl,ODBST *statinfo);

Description: Read the status information of CNC.


The various information is stored in each member of "ODBST".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

statinfo Pointer to the ODBST structure including the status


information of CNC.

The ODBST structure for Power Mate is as follows.

typedef struct odbst {


short dummy[2] ; /* Not used */
short aut ; /* AUTOMATIC/MANUAL 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 */
short alarm ; /* Status of alarm */
short edit ; /* Status of program editing */
} ODBST ;

aut AUTOMATIC/MANUAL mode selection


0 : MDI
1 : MEMory
2 : ****
3 : EDIT
4 : HaNDle
5 : JOG
6 : Teach in JOG
7 : Teach in HND
8 : INC- feed
9 : REFerence
10 : ReMoTe

run Status of automatic operation


0 : **** (reset)
1 : STOP
2 : HOLD
4 : STaRT

motion Status of axis movement,dwell


0 : ***
1 : MoTioN
3 : DWeLl

mstb Status of M,S,T,B function


0 : *** (Others)
1 : FIN

149
emergency Status of emergency
0 : (Not emergency)
1 : EMerGency
2 : ReSET

alarm Status of alarm


0 : *** (Others)
1 : ALarM
2 : BATtery low
edit Status of program editing
0 : **** (Not editing)
1 : EDIT
2 : SeaRCH
3 : OUTPUT
4 : INPUT
5 : COMPARE
6 : Label Skip
7 : OFfSeT
8 : Work ShiFT
9 : ReSTaRt

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the details, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

150
(4) Read alarm status

Function Name: cnc_alarm

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_alarm(unsigned short FlibHndl,ODBALM *alarm);

Description: Reads the alarm status of CNC.


Various information is stored in "data" of ODBALM.

This function is used for watching CNC's alarm status,


displaying the maintenance information or guidance of how to
reset the alarm, etc.

When CNC becomes system alarm, it is completely impossible to


communicate data between PC and CNC, and the alarm status cannot
be acquired.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

alarm Pointer to the ODBALM structure including the alarm status


information.

The ODBALM structure is as follows.

typedef struct odbalm {


short dummy[2] ; /* Not used. */
short data ; /* Alarm status */
} ODBALM ;

dummy Not used.

data Alarm status


The meaning of each bit is as follows.
#00 : P/S alarm 100
#01 : P/S alarm 000
#02 : P/S alarm 101
#03 : P/S alarm except above
#04 : Overtravel alarm
#05 : Overheat alarm
#06 : Servo alarm
#07 : (Not used)
#08 : APC alarm
#09 : (Not used)
#10 : P/S alarms (No.5000 -)
#11 : (Not used)
#12 : (Not used)
#13 : (Not used)
#14 : (Not used)
#15 : External alarm message

151
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program displays the kinds of alarms currently arising.

#include <stdio.h>
#include "apilib.h"

void example( void )


{
char *almmsg[] = {
"P/S 100 ALARM","P/S 000 ALARM",
"P/S 101 ALARM","P/S ALARM (1-255)",
"OT ALARM", "OH ALARM",
"SERVO ALARM", "unknown ALARM",
"APC ALARM", "SPINDLE ALARM",
"P/S ALARM (5000-)"
} ;
ODBALM buf ;
unsigned short idx ;
cnc_alarm( 0, &buf ) ;
if ( buf.data == 0 )
printf( "NO ALARM\n" ) ;
else
for ( idx = 0 ; idx < 11 ; idx++ ) {
if ( buf.data & 0x0001 )
printf( "%s\n", almmsg[idx] ) ;
buf.data >>= 1 ;
}
}

152
(5) Read alarm information

Function Name: cnc_rdalminfo

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdalminfo(unsigned short FlibHndl,short type,
short alm_type, short length,
ALMINFO *alarminfo);

Description: Reads the detail information of currently arising CNC alarms.


Various information is stored in "data" of ALMINFO.

This function is used for displaying the alarm numbers or


messages of the currently arising alarms by the application
program, etc.

When CNC becomes system alarm, it is completely impossible to


communicate data between PC and CNC, and the alarm information
cannot be acquired.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

type Specify the type of output format.


0 : Alarm information 1 (without message)
1 : Alarm information 2 (with message)

alm_type Specify the type of alarm.


The meaning of each bit is as follows.
#00 : P/S alarm 100
#01 : P/S alarm 000
#02 : P/S alarm 101
#03 : P/S alarm except above
#04 : Overtravel alarm
#05 : Overheat alarm
#06 : Servo alarm
#07 : (Not used)
#08 : APC alarm
#09 : (Not used)
#10 : P/S alarm (No.5000 - )
#11 : (Not used)
#12 : (Not used)
#13 : (Not used)
#14 : (Not used)
#15 : External alarm message

153
length Specify the length of the data block(size of ALMINFO structure)

u.alm1 0+-----------------------+ ---


| alm[0] | ^
4+-----------------------+ |
== == |
4*(N-1)+-----------------------+length
| alm[N-1] | |
4*N+-----------------------+ |
| data_end | v
4*N+2+-----------------------+ ---

u.alm1.alm 0+-----------------------+
| axis |
2+-----------------------+
| alm_no |
4+-----------------------+

u.alm2 0+-----------------------+ ---


| alm[0] | ^
38+-----------------------+ |
== == |
38*(N-1)+-----------------------+length
| alm[N-1] | |
38*N+-----------------------+ |
| data_end | v
38*N+2+-----------------------+ ---

u.alm2.alm 0+-----------------------+
| axis |
2+-----------------------+
| alm_no |
4+-----------------------+
| msg_len |
6+-----------+-----------+
| alm_msg[0]|
7+-----------+
== ==
37+-----------+
| alm_msg[31]
38+-----------+

N is number of messages to be read.

154
alarminfo Pointer to the ALMINFO structure including the alarm
information.

The ALMINFO structure is as follows.

typedef struct alminfo {


union {
struct {
struct {
short axis ; /* Axis information.*/
short alm_no ; /* Alarm number. */
} alm[N] ;
short data_end ; ;/* data end */
} alm1 ;
struct {
struct {
short axis ; /* Axis information.*/
short alm_no ; /* Alarm number. */
short msg_len ; /* Message length. */
char alm_msg[32] ;/* Alarm message. */
} alm[N] ;
short data_end ; ;/* data end */
}alm2 ;
} u ;
} ALMINFO ; /* N : number of messages to be read. */

axis Axis information is stored.


0 : assigns no axis
1,..,m : assigns 1 axis
(m=max. controlled axes)

alarm_no Alarm number(binary) is stored.

msg_len Message length(binary) is stored.


( 1 to 32 )

alm_msg Alarm message character string(ASCII) is


stored.

data_end Data end is stored.


Always 0FFFFH is set.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of ALMINFO structure(length) is illegal.
EW_NUMBER data number error
The type of output format(type) is improper.
EW_ATTRIB data attribute error
The specification of alarm type(alm_type) is
improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

155
(6) Read modal data

Function Name: cnc_modal

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_modal(unsigned short FlibHndl, short type,
short block, ODBMDL *modal);

Description: Reads the modal information of CNC.


Various information is stored in each member of ODBMDL.

The readable modal data are modal G code, M code or commanded


data such as F.

The union type which stores the data depends on the type of
modal data(type). therefore in case of accessing data, use the
union corresponding to the type.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

type Type of data is stored.(refer to below)


-3 : Read the all data concerning axis, except G code,
at one time.
-2 : Read the all data, except G code, at one time.
-1 : Read the all data of G code at one time.

0 to 20 : Read the data of G code one by one.


100 to 126 : Read the data, except G code, one by one.
200 to 205 : Read the data concerning axis, except G code,
one by one.

block Assigned block in stored.


0 : active block
1 : next block
2 : block after next block

modal Pointer to the ODBMDL structure including the modal data.

156
The ODBMDL structure is as follows.

typedef struct odbmdl {


short datano; /* Kind of modal data. */
short type; /* Objective block. */
union {
char g_data; /* Modal data of G code. */
char g_rdata[21];/* Modal data of G code */
struct {
long aux_data;/*Modal data except G code*/
char flag1; /* Flag 1 */
char flag2; /* Flag 2 */
}aux;
struct {
long aux_data;/* Modal data except G code */
char flag1; /* Flag 1 */
char flag2; /* Flag 2 */
}raux1[27];
struct {
long aux_data;/* Modal data except G code */
char flag1; /* Flag 1 */
char flag2; /* Flag 2 */
}raux2[MAX_AXIS];
}modal; /* MAX_AXIS : max. controlled axes. */
} ODBMDL ;

datano Kind of modal data is stored.

type Objected block is stored.

g_data Use for an individual reading G code.


Modal G code in the corresponding G code group is stored.

g_rdata Use for reading G code at a time.


Modal G code in the all G code group is stored.

aux Use for an individual reading other than


G code(include axis data).

raux1 Use for reading other than G code at a time.

raux2 Use for reading concerning axis other than G


code at a time.

aux_data Modal data other than G code is stored.

flag1 Supplementary information is stored.

flag2 Supplementary information is stored.

157
(1) Reading modal G code.

Specify 0,..,20 of G code group number in "type".

type g_data G code


----------+-------+---------------+
0 0 G00
1 G01
2 G02
3 G03
----------+-------+---------------+
1 0 G17
4 G19
8 G18
-------+-------+---------------+
2 0 G90
1 G91
-------+-------+---------------+
4 0 G94
1 G95
-------+-------+---------------+
5 0 G20
1 G21
-------+-------+---------------+
7 0 G49
1 G43
2 G44
-------+-------+---------------+
11 0 G67
1 G66
-------+-------+---------------+
20 0 G13.1
1 G12.1
-------+-------+---------------+

The numerical value of "g_data" mentioned in the above table is


stored in the bit 0,..,bit 6 of "g_data" with binary format.
Whether this G code is commanded in the objective block
specified by "block" or not is stored in the bit 7 of "g_data".

7 6 5 4 3 2 1 0
+---+---+---+---+---+---+---+---+
+-- * | Code in each group | : 1 byte
| +---+---+---+---+---+---+---+---+
+----+-----> 0 : Not under command in the present block
+-----> 1 : Under command in the present block

For example, the following result is gotten by calling this


function during executing N100's block of the next machining
program.

N090 G18 ;
N100 G1 Z100. ;
N110 G17 G2 X10. Y-20. R12. ;

type block g_data[0] Modal status


----------+-------+---------------+---------------------
0 0 0x81 G1 is commanded.
0 1 0x82 G2 is commanded.
1 0 0x08 G18 mode. (not commanded)
1 1 0x80 G17 is commanded.

To read all "type" concerning G code at a time, -1 is specified.


The array of g_data is stored in g_rdata.

158
(2) Reading modal data other than G code.

type Address
-------+------------------------
100 B (2nd auxiliary function)
101 D
102 E
103 F
104 H
105 L
106 M
107 S
108 T
109 R
110 P
111 Q
112 A
113 C
114 I
115 J
116 K
117 N
118 O
119 U
120 V
121 W
122 X
123 Y
124 Z
125 M2
126 M3
-------+------------------------
200 1st axis
201 2nd axis
202 3rd axis
203 4th axis
204 5th axis
205 6th axis
-------+------------------------

To read "type" concerning 100's at a time, -2 is specified.


The data is stored in the array of raux1.
To read "type" concerning 200's at a time, -3 is specified.
The data is stored in the array of raux2.

159
+-------------------------------+-
| Data | : 4 byte
+-------------------------------+
+---| FLAG1 | : 1 byte
| +-------------------------------+
+-+---| FLAG2 | : 1 byte
| | +-------------------------------+
| | 7 6 5 4 3 2 1 0
| | +---+---+---+---+---+---+---+---+
| +-->| | | |---|Number of input place
| +---+---+---+---+---+---+---+---+
| | | +----> 0 : Positive
| | | +----> 1 : Negative
| | +--------> 0 : There is no command of a decimal point.
| | +--------> 1 : There is a command of a decimal point.
| +------------> 0 : There is no command in the present block.
| +------------> 1 : There is a command in the present block.
| +---+---+---+---+---+---+---+---+
+---->|---|---|---|---|---|Number of places of decimals
+---+---+---+---+---+---+---+---+

* The command of a decimal point in 'FLAG1' and the number of places


of decimals in 'FLAG2' are valid in the case of 'F code'.
Sometimes the number of places of decimals is 'not zero' without the
command of a decimal point.

* The number of input place of M is digits granted by NC parameter.


M code : parameter No.3030

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_NUMBER data number error
The specification of modal data(type) is
improper.
EW_ATTRIB data attribute error
The specification of block(block)is improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

160
(7) Read diagnosis data

Function Name: cnc_diagnoss

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_diagnoss(unsigned short FlibHndl,short number,
short axis, short length, ODBDGN *diag);

Description: Reads the diagnosis specified by "number","axis"(only for the


diagnosis with axis). The data format depends on each
diagnosis. The format of Byte/Word/2-Word diagnosis is generally
signed binary.
Reads the diagnosis for all axes once by specifying 'ALL_AXES'
in 'axis'. The diagnosis for each axis is stored in each array
of "ODBDGN".

The attribute of diagnosis depends on the type and axis, and it


is different for each diagnosis.

Diagnosis type Use Byte size


--------------------------+-----------------------------------+---------
Bit diagnosis Every bits have each definition. 1
Bit diagnosis with axis Every bits have each definition. 1
(each axis)
Byte diagnosis 1-byte data is stored. 1
Byte diagnosis with axis 1-byte data is stored.(each axis) 1
Word diagnosis 2-byte data is stored. 2
Word diagnosis with axis 2-byte data is stored.(each axis) 2
2-Word diagnosis 4-byte data is stored. 4
2-Word diagnosis with axis 4-byte data is stored.(each axis) 4

It is impossible to read any bit diagnosis bit by bit.


8 bits(i.e. 1 byte) which belong to the same diagnosis number
are read at the same time.

See the "MAINTENANCE MANUAL" of CNC for details of each


diagnosis.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

number Specify the diagnosis number.


See the "MAINTENANCE MANUAL" of CNC about available diagnosis
number.

axis Specify the axis number.


0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)
ALL_AXES : assigns all axes(ALL_AXES=-1)

length Specify the data block length(size of ODBDGN structure).


(4+(byte size of diagnosis)*(number of axis))

In case that the size of diagnosis is 4 byte, the ODBDGN


structure is as follows. In case that its size is 1 or 2 byte,
the size of data part per 1 diagnosis or 1 axis is 1 or 2 byte.

161
no axis/1 axis all axes
ODBDGN 0 +-------+ --- 0 +-------+ ---
|datano | ^ |datano | ^
2 +-------+ | 2 +-------+ |
|type | length |type | length
4 +-------+-------+ | 4 +-------+-------+ |
| ldata | v |ldatas[0] :1st| |
8 +---------------+--- 8 +---------------+ |
= = |
4+2x(n-1) +---------------+ |
|ldatas[n-1]:n-th v
4+2xn +---------------+---
n : Current controlled axes

diag Pointer to the ODBDGN structure including the diagnosis.

The ODBDGN structure is as follows.

typedef struct iodbpsd {


short datano; /* diagnosis number */
short type; /* axis */
union {
char cdata; /* bit/byte diagnosis */
short idata; /* word diagnosis */
long ldata; /* 2-word diagnosis */
char cdatas[MAX_AXIS]; /*bit/byte diagnosis with
axis*/
short idatas[MAX_AXIS];/*word diagnosis with axis */
long ldatas[MAX_AXIS]; /*2word diagnosis with axis*/
} u ;
} ODBDGN ; /* MAX_AXIS : max. controlled axes */

datano Diagnosis number which was read is stored.

type Attribute of diagnosis which was read is stored.


axis
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)
ALL_AXES : all axes(ALL_AXES=-1)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of ODBDGN structure(length) is wrong.
EW_NUMBER Data number error
Diagnosis number(number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

162
(8) Read diagnosis data(area specified)

Function Name: cnc_diagnosr

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_diagnosr(unsigned short FlibHndl,
(short *)&s_number, short axis,
(short *)&e_number,(short *)&length,
(void *)diag);

Description: Reads the diagnosis specified by "s_number", "e_number",


"axis"(only for the diagnosis with axis). The data format
depends on each diagnosis.
The format of Byte/Word/2-Word diagnosis is generally signed
binary.

Reads the diagnosis for all axes specified range by specifying


'ALL_AXES' in 'axis'.

The attribute of CNC diagnosis depends on the type and axis, and
it is different for each diagnosis.

Diagnosis type Use Byte size


----------------------------+----------------------------------+------
Bit diagnosis Every bits have each definition. 1
Bit diagnosis with axis Every bits have each definition. 1
(each axis)
Byte diagnosis 1-byte data is stored. 1
Byte diagnosis with axis 1-byte data is stored.(each axis) 1
Word diagnosis 2-byte data is stored. 2
Word diagnosis with axis 2-byte data is stored.(each axis) 2
2-Word diagnosis 4-byte data is stored. 4
2-Word diagnosis with axis 4-byte data is stored.(each axis) 4

It is impossible to read any bit diagnosis bit by bit.


8 bits(i.e. 1 byte) which belong to the same diagnosis number
are read at the same time.

See the "MAINTENANCE MANUAL" of CNC for details of each


parameter.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

s_number Specify the start diagnosis number.


The first diagnosis number to be read is returned.

See the "MAINTENANCE MANUAL" of CNC about available diagnosis


number.

e_number Specify the end diagnosis number.


The last diagnosis number to be read is returned.

The new diagnosis may be added according to updating CNC


software, addition of the new function, etc. If the new
diagnosis is added within reading range, the error(Return:
EW_LENGTH) will be returned or the application program will not
work correctly. In order to avoid these mistakes, specify the
continuous numbers of existing diagnoses as the reading range.

163
axis Specify the axis number.
0 : assigns no axis
1,..,m : assigns 1 axis(m=max. controlled axes)
ALL_AXES : assigns all axes(ALL_AXES=-1)

None axis type diagnosis can be read even if any value is


specified in "axis". In case that an axis type diagnosis
exists in the specified range, the error(Retuen:EW_ATTRIB) is
returned by specifying "axis=0".

length Specify the data block length which is enough to store the
specified diagnosis.
The structure per 1 diagnosis is as follows, and each diagnosis
is lined up in order of number.
[= Sum of (4+(byte size of each diagnosis)*(number of axis))]

Because the size to be read is returned, it is possible to


specify the length more than the actual size.

In case that the size of diagnosis is 1 byte, the ODBDGN


structure is as follows.
In case that the size of diagnosis is 1 byte and the length per
1 diagnosis is an odd number, 'dummy' is necessary in the end
of structure. In case that its size is 2 or 4 byte, the size
of data part per 1 diagnosis or 1 axis is 2 or 4 byte, and so
'dummy' is not necessary.

no axis/1 axis all axes


ODBDGN 0 +-------+ --- 0 +-------+ ---
|datano | ^ |datano | ^
2 +-------+ | 2 +-------+ |
|type |length/diagnosis |type | length
4 +---+---+ | 4 +---+---+ /diag.
|cdata | |cdatas[0] :1st |
5 +---+ | 5 +---+ |
|dummy v = = |
6 +---+ --- 4+1x(n-1) +---+ |
|cdatas[n-1]:n-th |
4+1xn +---+ |
|dummy(in case of v
+---+ n=odd num.)---
n : Maximum controlled axes

diag Pointer to the area to store the diagnoses.

Each diagnosis can be referred by using the ODBDGN structure.

typedef struct iodbpsd {


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[MAX_AXIS]; /* bit/byte diagnosis with
axis*/
short idatas[MAX_AXIS];/*word diagnosis with axis */
long ldatas[MAX_AXIS]; /*2word diagnosis with axis*/
} u ;
} ODBDGN ; /*MAX_AXIS : max. controlled axes*/

164
datano Diagnosis number which was read is stored.

type Attribute of diagnosis which was read is stored.


Lower byte:axis
0 : no axis
1,..,m : 1 axis(m=max. controlled axes)
ALL_AXES : all axes(ALL_AXES=-1)

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH Data block length error
Size of area to store diagnosis(length) is
wrong.
EW_NUMBER Data number error
Diagnosis number(s_number,e_number) is wrong.
EW_ATTRIB Data attribute error
Axis number(axis) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

165
(9) Read maximum valid figures, number of decimal places

Function Name: cnc_getfigure

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_getfigure(unsigned short FlibHndl,short data_type,
short *valid_fig, short *dec_fig_in,
short *dec_fig_out);

Description: Reads the maximum valid figures, number of digits below decimal
point by unit of input and output, which is related to various
data of CNC.

The value which can be read in the window library is binary data
by set unit of the CNC side. Therefore, it is necessary to
display decimal point position etc. in consideration of set
unit.

It is valid when using the following functions.

- axis type data - tool offset - custum 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

The value which returns from the function is as follows.

- maximum valid figures


Power Mate
-----------------------+---------------+
axis type data 8
tool offset 7
custum macro 8
(unit [digit])

- number of digits below decimal point by unit of input and


output

1) axis type data


Both of the number of digits below the decimal point
at each I/O inside of the controlled axes are valid.

Linear axis Rotary axis


----------------+------------------------
[mm] [inch] [deg]
--------+-------+------------------------
3 4 3 IS-B

* "Metric/Inch" of linear axis depends on the following NC


parameter.

In case of the input unit ---- Input unit(0000#2)


In case of the output unit --- Machine linear axis
detection unit (1001#0)

166
2) tool offset
The number of digits below the decimal point under the
input unit only at the first axis part is valid, and it
under the output unit is invalid.

[mm] [inch]
--------+--------
3 4 IS-B

3) custom macro
The number of digits below the decimal point under the
input unit only at the first axis part is valid, and it
under the output unit is invalid.

[mm] [inch]
--------+--------
3 4 IS-B

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

data_type Specify the kind of the data.


0 : axis type dat
1 : tool offset
2 : custom macro

valid_fig Specify the address of the variable to store with the maximum
valid figures.

dec_fig_in Specify the address of the array to store with the number of
digits below decimal point under the input unit.
The number of array must be equal to the number of maximum
controlled axis.
(In the case except axis type data, only the top of array is
valid.)

dec_fig_out Specify the address of the array to store with the number of
digits below decimal point under the output unit.
The number of array must be equal to the number of maximum
controlled axis.
(In the case except axis type data, only the top of array is
valid.)

Return : EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_ATTRIB data attribute error
Kind of data(data_type)is improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See the manual of CNC parameter for details.
0000#2, 1001#0 -+- influenced by setting
1004#0,#1 -+-

CNC mode: This function can be used in any CNC mode.

167
(10) Read real current for servo adjustment

Function Name: cnc_rdcurrent

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdcurrent(unsigned short FlibHndl,short *crrnt);

Description: Reads "The servo adjustment real current".

When the following parameter is 0, the real current become 0.


Power Mate #2086

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

crrnt Specify the address of the array to store with the real current
for servo adjustment.
The number of array must be equal to the number of maximum
controlled axis.
Actually the object within the number of controlled axis is
valid.
short crrnt[MAX_AXIS] ; /* MAX_AXIS : max. controlled axes */

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function relates to the following CNC parameter.


See description and the manual of CNC parameter for details.
#2086 -+- influenced by setting

CNC mode: This function can be used in any CNC mode.

168
(11) Read real speed for servo adjustment

Function Name: cnc_rdsrvspeed

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdsrvspeed(unsigned short FlibHndl,long *speed);

Description: Reads "The servo adjustment real speed".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

speed Specify the address of the array to store with the real speed
for servo adjustment.
The number of array must be equal to the number of maximum
controlled axis.
Actually the object within the number of controlled axis is
valid.
long speed[MAX_AXIS] ; /* MAX_AXIS : max. controlled axes */

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

169
(12) Read loop gain for servo adjustment

Function Name: cnc_rdloopgain

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdloopgain(unsigned short FlibHndl,long *gain);

Description: Reads "The servo adjustment loop gain".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

gain Specify the address of the array to store with the loop gain
for servo adjustment.
The number of array must be equal to the number of maximum
controlled axis.
Actually the object within the number of controlled axis is
valid.
long gain[MAX_AXIS] ; /* MAX_AXIS : max. controlled axes */

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

170
(13) Read operator's message

Function Name: cnc_rdopmsg

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdopmsg(unsigned short FlibHndl, short type,
short length, OPMSG *opmsg);

Description: Reads the contents of the operator's message in CNC.


The operator's message is stored in "data" of "OPMSG".

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

type Specify the kind of operator's message.


0 : 1st message

length Specify the length of the data block(size of OPMSG structure)

0+-----------------------+ ----
| datano | ^
2+-----------------------+ |
| type | |
4+-----------------------+ |
| char_num | |
6+-----------+-----------+ length
| data[0] | |
7+-----------+ |
== == |
6+255+-----------+ |
| data[255]| v
6+256+-----------+ ----

opmsg Pointer to the OPMSG structure including the operator's message.

The OPMSG structure is as follows.

typedef struct msg {


short datano ; /* Number of operator's message */
short type ; /* Kind of operator's message */
short char_num ; /* Message length */
char data[MSG_SIZE] ; /* Operator's message strings */
} OPMSG ; /* MSG_SIZE : Message length */

datano The Number of operator's message is stored.


message exists
100 to 999
2000 to 2099
message does not exist
-1

type Kind of operator's message is stored.


0 : 1st message

char_num The operator's message length is stored.


1 to 256 : operator's message

data The operator's message strings are stored.


ASCII strings are set.

171
'\0' is set at the end of strings.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_LENGTH data block length error
Size of OPMSG structure(length) is illegal.
EW_ATTRIB data attribute error
The specification of the kind of operator's
message(type) is improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

Example:
The following program reads the operator's message and displays it.

#include <stdio.h>
#include "apilib.h"

void example( void )


{
OPMSG buf ;
cnc_rdopmsg( 0, 0, 6+256, &buf ) ;
if ( buf.datano != -1 )
printf( "#04d %s\n", buf.datano. buf.data ) ;
else
printf( "No operator message.\n" ) ;
}

172
(14) Read output signal image of software operator's panel
Function Name: cnc_rdopnlsgnl

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdopnlsgnl(unsigned short FlibHndl,
short slct_data, IODBSGNL *sgnl);

Description: Read the output signal image of software operator's panel.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

slct_data Specify the data select flag.


bit 0 : Mode signal
bit 1 : (Not used)
bit 2 : (Not used)
bit 3 : Rapid traverse override signal
bit 4 : Manual feedrate override signal
bit 5 : Feedrate override signal
bit 6 : (Not used)
bit 7 : Optional block skip signal
bit 8 : Single block signal
bit 9 : Machine lock signal
bit 10 : Dry run signal
bit 11 : Memory protection signal
bit 12 : Automatic operation halt signal
bit 13 : (Not used)
bit 14 : (Not used)
bit 15 : (Not used)

* When the bit corresponding to a signal is set to 0,


that signal is not applied.
To apply a signal, set the corresponding bit to 1.

sgnl Pointer to the IODBSGNL structure including the output signal


image of software operator's panel.

The IODBSGNL structure is as follows.

typedef struct iodbsgnl {


short datano; /* (Not used) */
short type; /* Data select flag */
short mode; /* Mode signal */
short hndl_ax; /* (Not used) */
short hndl_mv; /* (Not used) */
short rpd_ovrd; /* Rapid traverse override signal */
short jog_ovrd; /* Manual feedrate override
signal */
short feed_ovrd; /* Feedrate override signal */
short spdl_ovrd; /* (Not used) */
short blck_del; /* Optional block skip
signal(0/1) */
short sngl_blck; /* Single block signal(0/1) */
short machn_lock; /* Machine lock signal(0/1) */
short dry_run; /* Dry run signal(0/1) */
short mem_prtct; /* Memory protection signal(0/1) */
short feed_hold; /* Automatic operation halt
signal(0/1) */
} IODBSGNL ;

173
datano Not used

type Data select flag is stored.

mode Mode signal is stored.


0 : MDI 3 : HNDL or INC
1 : MEM 4 : JOG
2 : EDIT 5 : REF

hndl_ax Not used.

hndl_mv Not used.

rpd_ovrd Rapid traverse override signal is stored.


0 : 100% 2 : 25%
1 : 50% 3 : F0

jog_ovrd Manual feedrate override signal is stored.


0 : 0 % 8 : 1.0 % 16 : 14.0%
1 : 0.1 % 9 : 1.4 % 17 : 20.0%
2 : 0.14% 10 : 2.0% 18 : 27.0%
3 : 0.2 % 11 : 2.7% 19 : 37.0%
4 : 0.27% 12 : 3.7% 20 : 52.0%
5 : 0.37% 13 : 5.2% 21 : 72.0%
6 : 0.52% 14 : 7.2% 22 : 100 %
7 : 0.72% 15 : 10.0% 23 : 140 %
24 : 200 %

feed_ovrd Feedrate override signal is stored.


0 : 0% 10 : 100% 20 : 200%
1 : 10% 11 : 110%
2 : 20% 12 : 120%
3 : 30% 13 : 130%
4 : 40% 14 : 140%
5 : 50% 15 : 150%
6 : 60% 16 : 160%
7 : 70% 17 : 170%
8 : 80% 18 : 180%
9 : 90% 19 : 190%

spdl_ovrd Not used.

blck_del Optional block skip signal(0/1) is stored.

sngl_blck Single block signal(0/1) is stored.

machn_lock Machine lock signal(0/1) is stored.

dry_run Dry run signal(0/1) is stored.

mem_prtct Memory protection signal(0/1) is stored.

feed_hold Automatic operation halt signal(0/1) is stored.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

174
(15) Write output signal of software operator's panel

Function Name: cnc_wropnlsgnl

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wropnlsgnl(unsigned short FlibHndl,
IODBSGNL *sgnl);

Description: Write the output signal of software operator's panel.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

sgnl Pointer to the IODBSGNL structure to be set the output signal


of software operator's panel.

The IODBSGNL structure is as follows.

typedef struct iodbsgnl {


short datano; /* (Not used) */
short type; /* Data select flag */
short mode; /* Mode signal */
short hndl_ax; /* (Not used)
short hndl_mv; /* (Not used)
short rpd_ovrd; /* Rapid traverse override signal */
short jog_ovrd; /* Manual feedrate override signal */
short feed_ovrd; /* Feedrate override signal */
short spdl_ovrd; /* (Not used) */
short blck_del; /* Optional block skip signal(0/1) */
short sngl_blck; /* Single block signal(0/1) */
short machn_lock; /* Machine lock signal(0/1) */
short dry_run; /* Dry run signal(0/1) */
short mem_prtct; /* Memory protection signal(0/1) */
short feed_hold; /* Automatic operation halt
signal(0/1) */
} IODBSGNL ;

datano Not used

type Specify the data select flag.


bit 0 : Mode signal
bit 1 : (Not used)
bit 2 : (Not used)
bit 3 : Rapid traverse override signal
bit 4 : Manual feedrate override signal
bit 5 : Feedrate override signal
bit 6 : (Not used)
bit 7 : Optional block skip signal
bit 8 : Single block signal
bit 9 : Machine lock signal
bit 10 : Dry run signal
bit 11 : Memory protection signal
bit 12 : Automatic operation halt signal
bit 13 : (Not used)
bit 14 : (Not used)
bit 15 : (Not used)
* When the bit corresponding to a signal is set to 0,
that signal is not written.
To write a signal, set the corresponding bit to 1.

175
mode Specify the mode signal.
0 : MDI 3 : HNDL or INC
1 : MEM 4 : JOG
2 : EDIT 5 : REF

hndl_ax Not used.

hndl_mv Not used.

rpd_ovrd Specify the rapid traverse override signal.


0 : 100% 2 : 25%
1 : 50% 3 : F0

jog_ovrd Specify the manual feedrate override signal.


0 : 0 % 8 : 1.0 % 16 : 14.0%
1 : 0.1 % 9 : 1.4 % 17 : 20.0%
2 : 0.14% 10 : 2.0% 18 : 27.0%
3 : 0.2 % 11 : 2.7% 19 : 37.0%
4 : 0.27% 12 : 3.7% 20 : 52.0%
5 : 0.37% 13 : 5.2% 21 : 72.0%
6 : 0.52% 14 : 7.2% 22 : 100 %
7 : 0.72% 15 : 10.0% 23 : 140 %
24 : 200 %

feed_ovrd Specify the feedrate override signal.


0 : 0% 10 : 100% 20 : 200%
1 : 10% 11 : 110%
2 : 20% 12 : 120%
3 : 30% 13 : 130%
4 : 40% 14 : 140%
5 : 50% 15 : 150%
6 : 60% 16 : 160%
7 : 70% 17 : 170%
8 : 80% 18 : 180%
9 : 90% 19 : 190%

spdl_ovrd Not used.

blck_del Specify the optional block skip signal(0/1).

sngl_blck Specify the single block signal(0/1).

machn_lock Specify the machine lock signal(0/1).

dry_run Specify the dry run signal(0/1).

mem_prtct Specify the memory protection signal(0/1).

feed_hold Specify the automatic operation halt


signal(0/1).

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_DATA data error
Some value of member in IODBSGNL is improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.


CNC mode: This function can be used in any CNC mode.

176
(16) Read general signal image of software operator's panel

Function Name: cnc_rdopnlgnrl

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdopnlgnrl(unsigned short FlibHndl,
short slct_data, IODBGNRL *opnlgnrl);

Description: Read the general output signal image of software operator's


panel.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

slct_data Specify the data select flag.


bit 0 : General-purpose signal 1
bit 1 : General-purpose signal 2
bit 2 : General-purpose signal 3
bit 3 : General-purpose signal 4
bit 4 : General-purpose signal 5
bit 5 : General-purpose signal 6
bit 6 : General-purpose signal 7
bit 7 : General-purpose signal 8
* Bit 8 to 15 is not used.

* When the bit corresponding to a signal is set to 0,


that signal is not applied.
To apply a signal, set the corresponding bit to 1.

opnlgnrl Pointer to the IODBGNRL structure including the general output


signal image of software operator's panel.

The IODBGNRL structure is as follows.

typedef struct iodbgnrl {


short datano; /* Not used */
short type; /* Data select flag */
char sgnal; /* General-purpose signal 1 to 8 */
} IODBGNRL ;

datano Not used.

type Data select flag is stored.

sgnal General-purpose signal is stored.


bit 0 : General-purpose signal 1 bit 4 : General-purpose signal 5
bit 1 : General-purpose signal 2 bit 5 : General-purpose signal 6
bit 2 : General-purpose signal 3 bit 6 : General-purpose signal 7
bit 3 : General-purpose signal 4 bit 7 : General-purpose signal 8

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

177
(17) Write general output signal of software operator's panel
Function Name: cnc_wropnlgnrl

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wropnlgnrl(unsigned short FlibHndl,
IODBGNRL *opnlgnrl);

Description: Write the general output signal of software operator's panel.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

opnlgnrl Pointer to the IODBGNRL structure to be set the general output


signal of software operator's panel.

The IODBGNRL structure is as follows.

typedef struct iodbgnrl {


short datano; /* Not used */
short type; /* Data select flag */
char sgnal; /* General-purpose signal 1 to 8 */
} IODBGNRL ;

datano Not used.

type Specify the data select flag.


bit 0 : General-purpose signal 1
bit 1 : General-purpose signal 2
bit 2 : General-purpose signal 3
bit 3 : General-purpose signal 4
bit 4 : General-purpose signal 5
bit 5 : General-purpose signal 6
bit 6 : General-purpose signal 7
bit 7 : General-purpose signal 8
* Bit 8 to 15 is not used.

* When the bit corresponding to a signal is set to 0,


that signal is not written.
To write a signal, set the corresponding bit to 1.

sgnal Specify the General-purpose signal.


bit 0 : General-purpose signal 1
bit 1 : General-purpose signal 2
bit 2 : General-purpose signal 3
bit 3 : General-purpose signal 4
bit 4 : General-purpose signal 5
bit 5 : General-purpose signal 6
bit 6 : General-purpose signal 7
bit 7 : General-purpose signal 8

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

178
(18) Read general signal name of software operator's panel

Function Name: cnc_rdopnlgsname

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_rdopnlgsname(unsigned short FlibHndl,
short slct_data, IODBRDNA *brdna);

Description: Read the general signal name of software operator's panel.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

slct_data Specify the data select flag.


bit 0 : General-purpose signal 1
bit 1 : General-purpose signal 2
bit 2 : General-purpose signal 3
bit 3 : General-purpose signal 4
bit 4 : General-purpose signal 5
bit 5 : General-purpose signal 6
bit 6 : General-purpose signal 7
bit 7 : General-purpose signal 8
* Bit 8 to 15 is not used.

* When the bit corresponding to a signal is set to 0,


that signal is not applied.
To apply a signal, set the corresponding bit to 1.

brdna Pointer to the IODBRDNA structure including the general signal


name of software operator's panel.

The IODBRDNA structure is as follows.

typedef struct iodbrdna {


short datano; /* Not used */
short type; /* Data select flag */
char sgnl1_name[9]; /* General signal name 1 (ASCII) */
char sgnl2_name[9]; /* General signal name 2 (ASCII) */
char sgnl3_name[9]; /* General signal name 3 (ASCII) */
char sgnl4_name[9]; /* General signal name 4 (ASCII) */
char sgnl5_name[9]; /* General signal name 5 (ASCII) */
char sgnl6_name[9]; /* General signal name 6 (ASCII) */
char sgnl7_name[9]; /* General signal name 7 (ASCII) */
char sgnl8_name[9]; /* General signal name 8 (ASCII) */
} IODBRDNA ;

datano Not used.

type Data select flag is stored.

sgnl1_name General signal name 1 (ASCII)


sgnl2_name General signal name 2 (ASCII)
sgnl3_name General signal name 3 (ASCII)
sgnl4_name General signal name 4 (ASCII)
sgnl5_name General signal name 5 (ASCII)
sgnl6_name General signal name 6 (ASCII)
sgnl7_name General signal name 7 (ASCII)
sgnl8_name General signal name 8 (ASCII)

179
The specified name is set.
For the end of name(sgnl?_name[8]), NULL character('\0') is set.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

180
(19) Write general signal name of software operator's panel

Function Name: cnc_wropnlgsname

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI cnc_wropnlgsname(unsigned short FlibHndl,
IODBRDNA *brdna);

Description: Write the general signal name of software operator's panel.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

brdna Pointer to the IODBRDNA structure to be set the general signal


name of software operator's panel.

The IODBRDNA structure is as follows.

typedef struct iodbrdna {


short datano; /* Not used */
short type; /* Data select flag */
char sgnl1_name[9]; /* General signal name 1 (ASCII) */
char sgnl2_name[9]; /* General signal name 2 (ASCII) */
char sgnl3_name[9]; /* General signal name 3 (ASCII) */
char sgnl4_name[9]; /* General signal name 4 (ASCII) */
char sgnl5_name[9]; /* General signal name 5 (ASCII) */
char sgnl6_name[9]; /* General signal name 6 (ASCII) */
char sgnl7_name[9]; /* General signal name 7 (ASCII) */
char sgnl8_name[9]; /* General signal name 8 (ASCII) */
} IODBRDNA ;

datano Not used.

type Specify the select flag.


bit 0 : General-purpose signal 1
bit 1 : General-purpose signal 2
bit 2 : General-purpose signal 3
bit 3 : General-purpose signal 4
bit 4 : General-purpose signal 5
bit 5 : General-purpose signal 6
bit 6 : General-purpose signal 7
bit 7 : General-purpose signal 8
* Bit 8 to 15 is not used.

* When the bit corresponding to a signal is set to 0,


that signal is not written.
To write a signal, set the corresponding bit to 1.

sgnl1_name General signal name 1 (ASCII)


sgnl2_name General signal name 2 (ASCII)
sgnl3_name General signal name 3 (ASCII)
sgnl4_name General signal name 4 (ASCII)
sgnl5_name General signal name 5 (ASCII)
sgnl6_name General signal name 6 (ASCII)
sgnl7_name General signal name 7 (ASCII)
sgnl8_name General signal name 8 (ASCII)

Specify the general signal name.


Eight characters from the top of each name

181
(sgnl?_name[0] - sgnl?_name[7]) is set in CNC.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned.
(As for the rest, see "Return status of Library".)

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

182
1.1.13 Function Reference Related to PMC

(1) Read PMC data(area specified)

Function Name: pmc_rdpmcrng

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI pmc_rdpmcrng(unsigned short FlibHndl,short adr_type,
short data_type, short s_number,
short e_number, short length,
IODBPMC *buf);

Description: Reads the PMC data of the specified PMC address/range.

This function is used to exchange the data between the


application of PC and LADDER soft of PMC.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

adr_type Specify the identification code corresponding to the kind of


the PMC address.

<The referenceable range of PMC data of Power Mate>

ID code Kind of PMC address Referenceable range


------------+---------------------------------+---------------------+
0 G (Signal to PMC->CNC) 0000-0255, 1000-1255
1 F (Signal to CNC->PMC) 0000-0255, 1000-1255
2 Y (Signal to PMC->machine) 0000-0127, 1000-1063
3 X (Signal to machine->PMC) 0000-0127, 1000-1063
4 A (Message demand) 0000-0024
5 R (Internal relay) 0000-0999, 9000-9117
6 T (Changeable timer) 0000-0079
7 K (Keep relay) 0000-0019
8 C (Counter) 0000-0079
9 D (Data table) 0000-1859

(*) It is not possible to write to all areas of address 'F' and 'X',
and "R9000",... Moreover, "K0017",..,"K0019".
(*) See the "PROGRAMMING MANUAL" of PMC about CNC which each PMC can
correspond.

data_type Specify the type of the PMC data.


It must be the same one as the type of data of the PMC side.
0 : Byte type
1 : Word type
2 : Long type

s_number Specify the start PMC address number.

e_number Specify the end PMC address number.

length Specify the data block length.


data_type is 0(byte type) : length = 8 + N
data_type is 1(word type) : length = 8 + N * 2
data_type is 2(long type) : length = 8 + N * 4
* N is a number of read data.

183
buf Pointer to the IODBPMC structure.

The IODBPMC structure is as follows.

typedef struct iodbpmc {


short type_a ; /* Kind of PMC address */
short type_d ; /* Type of the PMC data */
short datano_s ; /* Start PMC address number */
short datano_e ; /* End PMC address number */
union {
char cdata[N] ; /* The PMC data(byte type) */
short idata[N] ; /* (word type) */
long ldata[N] ; /* (long type) */
} u ; /* N is a number of read data */
} IODBPMC ;

Example of specifying argument


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(1) D0100(It is assumed the word type) is read.
adr_type 9
data_type 1
s_number 100
e_number 101
length 8+2*1 (=10)
buf.u.idata[0] The content of D0100 is stored.

(2) R0200,..,R0209(It is assumed the byte type) is read.


adr_type 5
data_type 0
s_number 200
e_number 209
length 8+1*10 (=18)
buf.u.cdata[0] --
buf.u.cdata[9] The contents of R0200,..,R0209 are stored.

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_NOPMC There is no PMC.
EW_LENGTH Data block length error
Size of IODBPMC structure(length) is wrong.
EW_NUMBER Data number error
PMC address number(s_number,e_number) is
wrong.
EW_ATTRIB Data attribute error
Kind of PMC address(adr_type) or type of PMC
data (data_type) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

184
(2) Write PMC data(area specified)

Function Name: pmc_wrpmcrng

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI pmc_wrpmcrng(unsigned short FlibHndl,short length,
IODBPMC *buf);

Description: Writes the PMC data of the specified PMC address/range.

This function is used to exchange the data between the


application of PC and LADDER soft of PMC.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

length Specify the data block length.


data_type is 0(byte type) : length = 8 + N
data_type is 1(word type) : length = 8 + N * 2
data_type is 2(long type) : length = 8 + N * 4
* N is a number of written data.

buf Pointer to the IODBPMC structure.

The IODBPMC structure is as follows.

typedef struct iodbpmc {


short type_a ; /* Kind of PMC address */
short type_d ; /* Type of the PMC data */
short datano_s ; /* Start PMC address number */
short datano_e ; /* End PMC address number */
union {
char cdata[N] ;/* The PMC data(byte type) */
short idata[N] ;/* (word type) */
long ldata[N] ;/* (long type) */
} u ; /* N is a number of written data */
} IODBPMC ;

type_a Specify the identification code corresponding to the kind of


the PMC address.

type_d Specify the type of the PMC data.


It must be the same one as the type of data of the PMC side.
0 : Byte type
1 : Word type
2 : Long type

datano_s Specify the start PMC address number.

datano_e Specify the end PMC address number.

See "The referenceable range of PMC data" of "Read PMC data(area


specified)(pmc_rdpmcrng)" about the kind of the PMC address, the
start address, and the end address.

185
Example of specifying argument
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(1) 250 is written in D0100(It is assumed the word type)
buf.type_a 9
buf.type_d 1
buf.datano_s 100
buf.datano_e 101
length 8+2*1 (=10)
buf.u.idata[0] 250

(2)0 is written all of R0200,..,R0209(It is assumed byte type)


buf.type_a 5
buf.type_d 0
buf.datano_s 200
buf.datano_e 209
length 8+1*10 (=18)
buf.u.cdata[0] 0 to all
,..,buf.u.cdata[9]

Return: EW_OK is returned on successful completion, otherwise any value


except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_NOPMC There is no PMC.
EW_LENGTH Data block length error
Size of IODBPMC structure(length) is wrong.
EW_NUMBER Data number error
PMC address number(datano_s,datano_e) is
wrong.
EW_ATTRIB Data attribute error
Kind of PMC address(type_a) or type of PMC
data (type_d) is wrong.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

186
(3) Read PMC data information

Function Name: pmc_rdpmcinfo

Declaration:
#include "Fwlib32.h"
FWLIBAPI short WINAPI pmc_rdpmcinfo(unsigned short FlibHndl,short adr_type,
ODBPMCINF *pmcif);

Description: Read the data information about the attribute of each kind of
PMC,the effective range of address, etc.

Arguments:
FlibHndl Identify the process which uses the library.
The library steering wheel acquired with cnc_allclibhndl() or
cnc_allclibhndl2() is specified.

adr_type Specify the kind of PMC address.


0 <--> : refer to the table pmc_rdpmcrng() function
-1 : all address information

pmcif Pointer to the ODBPMCINF structure including the PMC data


information.

The ODBPMCINF structure is as follows.

typedef struct odbpmcinf {


short datano ; /* number of PMC data information */
struct {
char pmc_adr ; /* kind of PMC address */
char adr_attr ; /* attribute of PMC address */
unsigned short top_num ; /* top number of PMC
address */
unsigned short last_num ; /* end number of PMC
address */
} info[64] ;
} ODBPMCINF ;

datano Number of PMC data information (1 - 64)


* Some PMC address may be divided into several
parts.

pmc_adr Type of PMC address (ASCII CODE)

adr_attr Attribute of PMC address


bit 7 : Write protection
0 : enable
1 : disable
bit 0<-->6 : (Not used)

top_num Top number of PMC address

last_num Last number of PMC address


* Refer to the table of cnc_rdpmcrng() function.

187
Return: EW_OK is returned on successful completion, otherwise any value
except EW_OK is returned. The main error codes are as follows.
(As for the rest, see "Return status of Library".)
--------------------------------------------------------------
Return code Meaning/Error handling
--------------------------------------------------------------
EW_ATTRIB data attribute error
Kind of data(adr_type)is improper.

CNC option: There is no need of CNC option for this function.

CNC parameter: This function does not relate to CNC parameter.

CNC mode: This function can be used in any CNC mode.

188
· No part of this manual may be
reproduced in any form.

· All specifications and designs


are subject to change without
notice.

S-ar putea să vă placă și