C/C++ header file for CNC/PMC data window functions and structures (*2)(*3)(*4)
FWLIB32.BAS
:
Visual Basic header file for CNC/PMC data window functions and structures (*2)(*3)(*4)
(*1)Processing library for TCP/IP can be used with 0i-B/C, 160i/180i/210i, 150i, Power Mate i-D/H, and FS300i/310i/320i.
(*2)The header file is different in each CNC model.
(*3)The header file for each CNC model can be used by both of HSSB and TCP/IP.
(*4)The header file for TCP/IP is common for the HSSB and the Ethernet version. This file can be used to all CNC models by defining the constant.
Calling convention of Win32 API
This manual describes the interface of 32 bit Data window library. Each function of 32 bit Data window library follows the calling convention of Win32 API. So, each function of this library can be called from 32 bit application development tools, such as Visual C++ or Visual Basic.
Multi-thread
Win32 supports multi-thread. Each function in this library can be called from the multiple threads at a time. The access to the single system resource, such as CNC/PMC's internal memory, at a time is exclusively controlled by this library.
Language for development
CNC/PMC Data window library is tested by using the following development language.
Visual C++ 6.0
Visual Basic 6.0
Besides, 32 bit Data window library is developed with using Microsoft's development tools. The validity of using this library with other vendor's development tools has not been confirmed.
Alignment of structure member
This library is designed to use the 4 byte structure member alignment, for the Win32 environment.
In 4 byte alignment, variables whose size are longer than 4 byte are aligned at the address of multiple of 4. For example, at the following structure,
struct {
short a1; /* 2 bytes */
long a2; /* 4 bytes */
};
there is 2 byte gap between variable a1 and a2. And the size of structure is raised to multiple of 4.
By introducing 4 byte alignment, the size of structures and offset of its members are different from those of 2 byte alignment. Therefore, the application program which uses the size of structures and offset of its members by calculating according to the information described on "FANUC MMC-IV OPERATOR'S MANUAL" will not work correctly. The size of structures should be obtained by using sizeof() operator.
In the header file, FWLIB32.H, the alignment at each structure is specified as 4 byte compulsorily by using "pragma pack(4)". In case that the structures which are required as the application interface with 32 bit data window library have to be re-defined at user source program, specify "pragma pack(4)" or compiler option "/Zp4".
Header file
32 bit Data window library is configured by specifying "dllexport" to each function. To use the functions of this library at C or C++ language, "dllimport" must be specified to each function. The header file, FWLIB32.H, provides this attribute.
As the link error should occur while making the application unless it includes this header file, it is required that the header file is included in the application program.
When you use the array of the 'user definition type' with Visual Basic 6.0
When you use the array of the 'user definition type' with Visual Basic 6.0, you should be define the following new 'user definition type'.
Ex) cnc_rdprogdir3 function
Type MyPrgDir3
DirBuf(0 To 9) As PRGDIR3
End Type' In case that the number is 10.
Example
The following program reads all registration information of NC program, and outputs the program number list.
Type MyPrgDir3
DirBuf(0 To 99) As PRGDIR3
End Type'
Dim ret As Integer
Dim prg As MyPrgDir3
Dim i As Integer
Dim num As Integer
Dim top As Long
Dim dir3 As String
Open "C:\\temp\\sample.dat" For Output As #1
top = 0
Do
num = 100
ret = cnc_rdprogdir3(h, 0, top, num, prg)
If ret = EW_NUMBER Then
Exit Do
ElseIf ret <> 0 Then
dir3 = "ERROR: " + Format(ret, "###0")
Print #1, dir3
Exit Do
End If
For i = 0 To num - 1
dir3 = "O" + Format(prg.DirBuf(i).lNumber, "######0")
Print #1, dir3
Next
top = prg.DirBuf(num - 1).lNumber + 1
Loop While (num >= 100)
Close #1
When you specified the following, the function do not work correctly(the acquired data was wrong or application error occurred etc.).
Dim prg(0 To 9) As PRGDIR3
ret = cnc_rdprogdir3(h, 0, top, num, prg)
Number of axes at Data window
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 differs at each CNC system, so, define the following constant by using the '-D' option which is specified on compiling.
In case of header file for TCP/IP The header file for TCP/IP can be used to all CNC models(both of HSSB and TCP/IP) by the following -D option. Please define "HSSB_LIB" when you use this header file for HSSB.
System
Option(-D)
FS16/18/21, 0i-B, 0i-C, 16i/18i-W, Power Mate i(8 axes)
(none)
FS30i/31i/32i(32 axes)
FS30D
FS15-B/15i Multi axes(24 axes)
M_AXIS2
FS15-B Multi axes(15 axes)
M_AXIS1
FS15-B(10 axes)
FS15BD
FS15i(10 axes)
FS15D
FS0i-A(4 axes)
FS0ID
Power Mate(6 axes)
PMD
note) In case of FS15, please define "FS15BD"(For FS15-B) or "FS15D"(For FS15i) by the series.
#if defined (FS30D)
#define MAX_AXIS 32
#elif defined (M_AXIS2)
#define MAX_AXIS 24
#elif defined(M_AXIS1)
#define MAX_AXIS 15
#elif defined (FS15BD)
#define MAX_AXIS 10
#elif defined (FS15D)
#define MAX_AXIS 10
#elif defined (FS0ID)
#define MAX_AXIS 4
#elif defined (PMD)
#define MAX_AXIS 6
#else
#define MAX_AXIS 8
#endif
In case of header file for Series 16/18/21, 0i-B, 16i/18i-W, Power Mate i
System
Option(-D)
Standard (8 axes)
(none)
#define MAX_AXIS 8
In case of header file of HSSB for Series 0i-A
System
Option(-D)
Standard (4 axes)
(none)
#define MAX_AXIS 4
In case of header file of HSSB for Power Mate
System
Option(-D)
Standard (6 axes)
(none)
#define MAX_AXIS 6
In case of Visual Basic, define that in VB menu "[Tool] -> [Option] -> [Detail Setting] -> [Conditional compile argument]".
'Current controlled axis' can be got by 'Read CNC system information (cnc_sysinfo)' function.
Program number 8 digits (Series 15i, 16/18)
In case of program number 8 digits, the argument and the member of the structure which are related to program number of Data window function, is changed from "short" to "long".
In case of C/C++ language, define character constant "ONO8D" at compiling by option "-D" to switch library for program number 8 digits.
System
Option(-D)
Program number 4 digits
(None)
Program number 8 digits
ONO8D
In case of Visual Basic, define "ONO8D=1" in VB menu "[Tool] -> [Option] -> [Detail Setting] -> [Conditional compile argument]" to switch library for program number 8 digits. If "ONO8D" is not defined or "ONO8D=0" is defined, it becomes for program number 4 digits.
The window function compiled for the program number 8 digits operates normally when CNC side is program number 4 digits. Conversely, if the window function for the program number 4 digits is used when CNC side is the program number 8 digits, it becomes an error(EW_FUNC).
Difference of the function specifications (Series 15 and other CNCs (Series 16/18/21/0, Power Mate))
If you make an application for Series 15i, you must specify the compiling option, which is "FS15D".
In case of C/C++ language, define character constant "FS15D" at compiling by option. In case of Visual Basic, define "FS15D=1" in VB menu " [Tool] -> [Option] -> [Detail Setting] -> [Conditional compile argument] ".
And, there are some differences of the specifications between Series 15i and others (Series 16/18/21/0, Power Mate) about library function. The major differences are as follows.
Data size for all axes
In some function, when you read/write data for all axes, data size that must be allocated is different as follows.
Series 16/18/21/0, Power Mate
:
Size for current controlled axes
Series 15i
:
Size for maximum controlled axes
The following functions are related to this subject.
In case of Series 15i, the number of the program number digits is always 8.
So, it is necessary to switch API to the one for the program number 8 digits in case of Series 15i. Refer to "Program number 8 digits" in order to know how to switch API. The following functions are related to this subject.
In case of Series 15i, the number of the tool number digits is always 8.
In case of Series 15i, the functions for the tool number 4 digits are not supported in the following table. Use the functions for the tool number 8 digits.
Brief description
For tool number 4 digits
For tool number 8 digits
Read tool life management data (tool group number)
Real parameter and real diagnosis data are added for Series 15i.
To support the real data, the specifications of Series 15i are different from those of others about the following functions. See the specifications of each function for details.
In case of Series 15i, unlike others, the alarm status is "long", not "short".
In case of Series 15i, you can use the following functions for short status. However, you cannot read all of alarm status by using these functions. You use the functions for long status as far as you can.
Difference of the function specifications (Series 15-B, Series 15i)
Please note that there are some differences of the specifications between Series 15-B and Series 15i about library function. The major differences are as follows.
Program number 8 digits
The specification of program number is different between Series 15-B and Series 15i.
Series 15-B
:
program number 4 digits
Series 15i
:
program number 8 digits
So, it is necessary to switch API to the one for the program number 8 digits in case of Series 15i. Refer to Program number 8 digits (for Series 15i, 16/18) in order to know how to switch API.
The following functions are related to this subject.
The following list shows whether the function for Series 15-B can be used for Series 15i, or not. Some functions except in this list have the difference of the specifications between Series 15-B and the Series 15i. See the specifications of each function for details.
CNC: Function related to controlled axis/spindle
Function name(15-B)
Brief description
in case of Series 15i
cnc_rddynamic
Read all dynamic data
It is necessary for the application program to switch API to the one which can deal with the program number 8 digits. This function cannot read all alarm status of Series 150i. So, you should better use cnc_rddynamic2.
CNC: Function related to CNC program
Function name(15-B)
Brief description
in case of Series 15i
cnc_dncstart
Start downloading DNC program
These functions are not supported on Series 15i.
cnc_dnc
Download DNC program
cnc_cdnc
Download DNC program(conditional)
cnc_dncend
End of downloading DNC program
cnc_rdmdipntr
Read execution pointer for MDI operation
cnc_wrmdipntr
Write execution pointer for MDI operation
cnc_upstart
Start uploading NC program
It is necessary for the application program to switch API to the one which can deal with the program number 8 digits.
cnc_search
Search specified program
cnc_delete
Delete specified program
cnc_rdprogdir
Read program directory
cnc_rdprogdir2
Read program directory(2)
cnc_rdprgnum
Read program number under execution
CNC: Function related to CNC file data
Function name(15-B)
Brief description
in case of Series 15i
cnc_rdparam
Read parameter
The structures including the data are changed in order to read and write the real parameter.
cnc_wrparam
Write parameter
cnc_rdparar
Read parameter(area specified)
cnc_wrparas
Write parameter(area specified)
cnc_rdparainfo
Read parameter information
cnc_rdset
Read setting data
cnc_wrset
Write setting data
cnc_rdsetr
Read setting data(area specified)
cnc_wrsets
Write setting data(area specified)
cnc_rdsetinfo
Read setting data information
cnc_rdhpccset
Read setting data for HPCC
These functions are not supported on Series 15i. Read/write parameter function (cnc_rdparam, cnc_wrparam, cnc_rdparar, and cnc_wrparas) can be substituted for these functions.
cnc_wrhpccset
Write setting data for HPCC
cnc_rdhpcctupr
Read tuning data(parameter input) for HPCC
cnc_wrhpcctupr
Write tuning data(parameter input) for HPCC
cnc_rdhpcctuac
Read tuning data(acc./dec. input) for HPCC
cnc_wrhpcctuac
Write tuning data(acc./dec. input) for HPCC
CNC: Function related to tool life management data
Function name(15-B)
Brief description
in case of Series 15i
cnc_rdgrpid
Read tool group number
This function is not supported on Series 15i. Use "cnc_rdgrpid2".
cnc_rd1length
Read tool length number-1
These functions are not supported on Series 15i. Use "cnc_rd1tlifedat2" instead of these function.
cnc_rd1radius
Read cutter compensation number-1
cnc_t1info
Read tool information-1
cnc_rd1tlifedata
Read tool data1
This function is not supported on Series 15i. Use "cnc_rd1tlifedat2".
cnc_wr1tlifedata
Write tool data1
This function is not supported on Series 15i. Use "cnc_wr1tlifedat2".
CNC: Function related to history data
Function name(15-B)
Brief description
in case of Series 15i
cnc_rdophistry
Read operation history data
This function is not supported on Series 15i. Use "cnc_rdophistry2".
cnc_rdalmhistry
Read alarm history data
This function is not supported on Series 15i. Use "cnc_rdalmhistry2".
CNC: Function related to Servo/spindle
Function name(15-B)
Brief description
in case of Series 15i
cnc_rdwaveprm
Read waveform diagnosis parameter
This function is not supported on Series 15i. Use "cnc_rdwaveprm2".
cnc_wrwaveprm
Write waveform diagnosis parameter
This function is not supported on Series 15i. Use "cnc_wrwaveprm2".
CNC: Function related to Others
Function name(15-B)
Brief description
in case of Series 15i
cnc_sysconfig
Read CNC configuration information
This function is not supported on Series 15i. Use "cnc_rdsyssoft".
cnc_rdmdlconfig
Read module configuration of CNC system
This function is not supported on Series 15i. Use "cnc_rdmdlconfig2".
cnc_alarm
Read alarm status
This function cannot read all alarm status of Series 15i. So, you should better use "cnc_alarm2".
cnc_modal
Read modal data
This function is not supported on Series 15i. Use "cnc_rdgcode" and "cnc_rdcommand" instead of this function.
cnc_diagnoss
Read diagnosis data
The structures including the data are changed in order to read and write the real diagnosis data.
cnc_diagnosr
Read diagnosis data(area specified)
cnc_rddiaginfo
Read diagnosis data information
PMC: Function related to PMC
Function name(15-B)
Brief description
in case of Series 15i
pmc_rdmsg
Read message from PMC to MMC
These functions are not supported on Series 15i.
pmc_wrmsg
Write message from MMC to PMC
pmc_crdmsg
Read message from PMC to MMC (conditional)
pmc_cwrmsg
Write message from MMC to PMC (conditional)
Difference of the function specifications (FS30i and other CNCs)
Please note that there are some differences of the specifications between the library except Series 30i and Series 30i about library function. The major differences are as follows.
Data size at all axes specification
In some function, when you read/write data for all axes, data size that must be allocated is different as follows.
the library except Series 30i
:
number of the actual control axis.
the library for Series 30i
:
number of maximum axes in interface.
The number of maximum axes is defined in the header file as MAX_AXIS(=32).
The following functions are related to this subject.
In Series 30i, the maximum spindle number has been extended to 8 from 4. So, data size of function related to the spindle that must be allocated is different as follows.
The number of maximum spindles is defined in the header file as MAX_SPINDLES(=8).
The following functions are related to this subject.
The management of the program came to be managed by the file name and the hierarchical directory. So, the function specification was changed completely.
Real type parameter/Real type diagnosis data
In Series 30i, the real type parameter and the real type diagnosis data are added. The structures including these data are changed in order to read and write them.
The following functions are related to this subject.
In Series 30i, the alarm status become the 32 bits. All the alarm status of Series 30i cannot be read though the cnc_alarm function is supported. Use the "cnc_alarm2".
The content of the alarm status is also different from FOCAS1.
And the area where axis information in structure used by the cnc_rdalminfo is stored is expanded from "short" into "long".
Modal/Command
All the modal/command information of Series 30i cannot be read though the cnc_modal function is supported. Use the "cnc_rdgocde" and "cnc_rdcommand".
The specification of "block after next block(=2)" cannot be specified for the block of the reading object on the cnc_modal.
In Series 30i, the command value(mainly I,J and K) is extended to the 12 digits. So, the data which overflows when the value of 12 digits is converted into the integer in four bytes is rounded. And the number of places of decimals is set. So, the number of places of decimals might be set besides F code.
The number of places of decimals might become negative value, so, the number of places of decimals is changed to "8 bits with sign" from "3 bits without sign".
Advanced mode(32 axes) and traditional mode(8 axes) for FS300i
The original mode (advanced mode) and the compatible mode (traditional mode) is switched by the cnc_setlibopt. The default is advanced mode.
The specification of each mode is as follows.
Item
Advanced mode
traditional mode
Number of maximum controlled axes
32
8
Number of maximum controlled spindles
8
4
Read/Write of all axis specification.
The size of the allocated buffer is always the size of the maximum controlled axes.
The size of the allocated buffer is the size of the current controlled axes. (It is similar to FS16i.)
Real type of parameter and diagnosis data
8 bytes with sign
The conversion to 4 bytes integer.
Alarm status
32 bits
16 bits
The number of axes shows the number of buffers used to access to the data of axis.
In the following cases, the traditional mode can not be used.
When the number of current controlled axes in the system exceeds 8.
When the number of controlled spindles in the system exceeds 4.
The differences of the data structures between the advanced mode and the traditional mode are as follows.
Parameter/Diagnosis
In traditional mode, the real type parameter and the real type diagnosis data are converted into two word integer type by which a minimum setting unit is assumed to be the first digit.
Example) In case of 1.230 : data=1230, number of places of decimals=3
In advanced mode, the function of library is expanded the part of the specification along with the support of parameter/diagnosis data of FS30i.(Part in bold line) In traditional mode, this extended part is never input and output.
type : Attribute of parameter which was read is stored.
0
:
bit type
1
:
byte type
2
:
word type
3
:
2-word type
4
:
real type
cnc_diagnosr "From the explanation of "type in the ODBDGN structure""
type : Attribute of diagnosis which was read is stored.
0
:
byte type
1
:
word type
2
:
2-word type
3
:
but type(8 bit)
4
:
bit type(1 bit)
5
:
real type
cnc_rdparainfo "From the explanation of "prm_type in the ODBPARAIF structure""
info[N].prm_type : Attribute of parameter. The following attributes are set.
bit 0,1
:
type attribute
0
:
bit type
1
:
byte type
2
:
word type
3
:
2-word type or real type
: :
bit 12
:
in case that type attribute = 3
0
:
except real type
1
:
real type
cnc_rddiaginfo "From the explanation of "diag_type in the ODBDIAGIF structure""
info[N].diag_type : Attribute of diagnosis data. The following attributes are set.
bit 0,1
:
type attribute(It is effective when bit 3 = 0)
0
:
bit type (8 bit)
1
:
byte type
2
:
word type
3
:
2-word type or real type
: :
bit 12
:
in case that type attribute = 3
0
:
except real type
1
:
real type
Alarm status
In order to get every alarm by using 16 bits alarm status, in the traditional mode, when a alarm which is shown by the upper word (from bit 16 to 31) in the 32 bits alarm status of cnc_alarm2 function occurs, bit 14 in the 16 bit alarm status of cnc_alarm function is turned on. In the advanced mode, bit 14 is reserved.
#00
:
Parameter switch on
(SW)
#01
:
Power off parameter set
(PW)
:
:
#13
:
Syncronized error
(SN)
#14
:
Others(#16 to #31)
#15
:
External alarm message
(EX)
Then, when 14 is passed to the alarm type parameter of cnc_rdalminfo function, all alarm information from bit 16 to 32 can be retrieved.
Difference of the HSSB version and the Ethernet version
4 status (EW_SOCKET, EW_PROTOCOL, EW_ALARM, EW_STOP) are added to the return status of the functions.  
The following functions of the HSSB are not supported. Use the function in the right side of the following table.
The following functions are not supported in the Ethernet.
Function related to Data Server, DNC1, DNC2, OSI-Ethernet
Function related to servo learning data
Message translation with LADDER program (pmc_rdmsg, pmc_wrmsg)
NC's BOOT/IPL function (backup/restore SRAM, exchanging system software, etc.) is not supported by the Ethernet version.  
Cannot access to the loader control board (5th path) by the Ethernet version. (except FS30i)   There is a limitation about maximun number of applications which can access to one CNC at the same time. See "Communication with Ethernet Board" for details.
Specifying the folder and file name for FS30i.
In FS30i, the folder name specify by "Drive Name + Folder Name".
And, the file name specify "Drive Name + folder Name + File Name".
In case of folder name, place "/"(slash) at the end of string. If there is no "/", it is regarded as the string for file.
The format is as follows.
//Drive Name/Filder Name 1/Folder Name 2/.../Folder Name n/File Name
Ex.1) The "USER/PATH1" folder in CNC memory.
//CNC_MEM/USER/PATH1/
Ex.2) The "PART1.PRG" file in "NCDATA/MACHINE1" folder in Data server.