Reads the diagnosis data specified by "s_number","e_number","axis"(only for the diagnosis data with axis). The data format depends on each diagnosis data.
The format of Byte/Word/2-Word diagnosis data is generally signed binary.
Reads the diagnosis data for all axes specified range by specifying 'ALL_AXES' in 'axis'.
The attribute of CNC diagnosis data depends on the type and axis, and it is different for each diagnosis data. It is as follows, and can be got by cnc_rddiaginfo function.
Diagnosis data type
Meaning
Byte size
Bit diagnosis data
Every bits have each definition.
1
Bit diagnosis data with axis
Every bits have each definition. (each axis)
1
Byte diagnosis data
1-byte data is stored.
1
Byte diagnosis data with axis
1-byte data is stored. (each axis)
1
Word diagnosis data
2-byte data is stored.
2
Word diagnosis data with axis
2-byte data is stored. (each axis)
2
2-Word diagnosis data
4-byte data is stored.
4
2-Word diagnosis data with axis
4-byte data is stored. (each axis)
4
Real diagnosis (Series 15i, 30i, 0i-D/F, PMi-A)
4-byte data which indicates value of variable and 4-byte data which indicates number of places of decimals are stored.
8
Real diagnosis with axis (Series 15i, 30i, 0i-D/F, PMi-A)
4-byte data which indicates value of variable and 4-byte data which indicates number of places of decimals are stored. (each axis)
8
It is impossible to read any bit diagnosis data bit by bit. 8 bits (i.e. 1 byte) which belong to the same diagnosis data number are read at the same time.
See the "MAINTENANCE MANUAL" of CNC for details of each diagnosis data.
#include "fwlib32.h" or "fwlib64.h"FWLIBAPI short WINAPI cnc_diagnosr(unsigned short FlibHndl, short *s_number, short axis, short *e_number, short *length, void *diag);
Arguments
FlibHndl
[ in ]
Specify the library handle. See "Library handle" for details.
s_number
[ in/out ]
Specify the start diagnosis data number. The first diagnosis data number which was read actually is returned.
See the "MAINTENANCE MANUAL" of CNC about available diagnosis data number. It can be got by cnc_rddiagnum function and cnc_rddiaginfo function.
e_number
[ in/out ]
Specify the end diagnosis data number. The last diagnosis data number which was read actually is returned.
The new diagnosis data may be added according to updating CNC software, addition of the new function, etc. If the new diagnosis data is added within reading range, the error(Return:EW_LENGTH) may be returned or the application program may not work correctly. In order to avoid these problems, specify the continuous numbers of existing diagnoses as the reading range.
axis
[ in ]
Specify the axis number.
0
:
assigns no axis
1,..,m
:
assigns 1 axis (m=maximum controlled axes)
ALL_AXES
:
assigns all axes (ALL_AXES=-1)
None axis type diagnosis data can be read even if any value is specified in "axis". In case that an axis type diagnosis data exists in the specified range, the error(Retuen:EW_ATTRIB) is returned by specifying "axis=0".
length
[ in ]
Specify the data block length which is enough to store the specified diagnosis data.
The structure per 1 diagnosis data is as follows, and each diagnosis data is lined up in order of number.
[= Sum of (4+(byte size of each diagnosis data) * (number of axis))]
Because the size of data which was read actually is returned, it is possible to specify the length more than the actual size.
In case that the size of diagnosis data is 2 byte, the ODBDGN structure is as follows. In case that the size of diagnosis data is 1 or 2 byte and the length per 1 diagnosis data is not a multiple of 4, 'dummy' is necessary at the end of structure. In case that its size is 4 or 8 byte, the size of data part per 1 diagnosis data or 1 axis is 4 or 8 byte, and so 'dummy' is not necessary.
ODBDGN
no axis/1 axis
all axes
n : Maximum controlled axes
diag
[ out ]
Pointer to the area to store the diagnoses. Each diagnosis data can be referred by using the ODBDGN structure.
Series 15, 16/18/21, 16i/18i/21i, 0i-A/B/C, Power Mate i
typedef struct odbdgn {
short datano; /* diagnosis data number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte diagnosis data */
short idata; /* word diagnosis data */
long ldata; /* 2-word diagnosis data */
char cdatas[MAX_AXIS]; /* bit/byte diagnosis data with axis*/
short idatas[MAX_AXIS]; /* word diagnosis data with axis */
long ldatas[MAX_AXIS]; /* 2-word diagnosis data with axis */
} u ;
} ODBDGN ; /* MAX_AXIS : max. controlled axes */
Series 15i, 30i, 0i-D/F, PMi-A
typedef struct realdgn { /* real diagnosis data */
long dgn_val; /* value of variable */
long dec_val; /* number of places of decimals */
} REALDGN ;
typedef struct odbdgn {
short datano; /* diagnosis data number */
short type; /* upper byte:type */
/* lower byte:axis */
union {
char cdata; /* bit/byte diagnosis data */
short idata; /* word diagnosis data */
long ldata; /* 2-word diagnosis data */
REALDGN rdata; /* real diagnosis data */
char cdatas[MAX_AXIS];/*bit/byte diagnosis data with axis*/
short idatas[MAX_AXIS];/* word diagnosis data with axis */
long ldatas[MAX_AXIS];/* 2-word diagnosis data with axis */
REALDGN rdatas[MAX_AXIS];/* real diagnosis data with axis */
} u ;
} ODBDGN ; /* MAX_AXIS : max. controlled axes */
datano
diagnosis data number which was read is stored.
type
Attribute of diagnosis data which was read is stored.
Upper byte : type
0
:
byte type
1
:
word type
2
:
2-word type
3
:
bit type(8 bit)
4
:
bit type(1 bit : except Series 15/15i)
5
:
real type(Series 15i, 30i, 0i-D/F, PMi-A)
Lower byte : axis
0
:
no axis
1,..,m
:
1 axis(m=max. controlled axes)
ALL_AXES
:
all axes(ALL_AXES=-1)
rdata, rdatas (Series 15i, 30i, 0i-D/F, PMi-A)
Real diagnosis data is stored.
The value of variable is stored in dgn_val, and the number of places of decimals is stored in dec_val.
Real diagnosis data = dgn_val * 10 ** (-dec_val)
(Example) When the value of real diagnosis data is 12.345, dgn_val and dec_val are read as follows.
dgn_val = 12345 dec_val = 3
Return
EW_OK is returned on successful completion, otherwise any value except EW_OK is returned.
The major error codes are as follows.
Return code
Meaning/Error handling
EW_LENGTH (2)
Data block length error
Size of area to store diagnosis data (length) is wrong.
EW_NUMBER (3)
Data number error
diagnosis data number (s_number, e_number) is wrong.