Reads the commanded data of CNC. Various information is stored in each member of ODBCMD.
The readable data are the modal data except G code, and the commanded data.
This function cannot be used for Series 15, 16i/18i/21i, 0i-A/B/C and Power Mate i, so use cnc_modal function instead of cnc_rdcommand function.
MTConnect Fanuc Adapter
#include "fwlib32.h" or "fwlib64.h"
FWLIBAPI short WINAPI cnc_rdcommand(unsigned short FlibHndl, short type, short block, short *num_cmd, ODBCMD *command);
Arguments
FlibHndl
[ in ]
Specify the library handle. See "Library handle" for details.
type
[ in ]
Specify the commanded data.
0 to 29
:
Read modal data except G code one by one.
-1
:
Read all modal data except G code at a time.
100 to 129
:
Read commanded data one by one.
-2
:
Read all commanded data at a time.
200 to 223
:
Read commanded data concerning axis one by one.
-3
:
Read all commanded data concerning axis at a time.
block
[ in ]
Specify the block to be read.
0
:
previous block
1
:
active block
2
:
next block
num_cmd
[ in/out ]
Pointer to the number of commanded data to be read. Specify the number of commanded data to be read before function call, and the number of commanded data which was/were read actually is stored after the function call.
command
[ out ]
Specify the address of the array of ODBCMD structure including the commanded data. The number of array must be 1 for reading data one by one. The number of array must be the number of commanded data to be read (*num_cmd) for reading all data at a time.
The ODBCMD structure is as follows.
typedef struct odbcmd {
char adrs ; /* command address */
char num ; /* M code number or axis number */
short flag ; /* additional information */
long cmd_val ; /* commanded data */
long dec_val ; /* decimal point of commanded data */
} ODBCMD ;
Refer to the following explanation about the ODBCMD structure.
(1) Reading the modal data except G code
The readable modal data are commanded data D, E, F, H, L, M, N, O, S, T, and second auxiliary function (A, B, C, U, V, or W).
Reading data one by one
Specify 1 for "num_cmd". Specify the commanded address in the following table for "type". Specify the block to be read for "block". Then modal data except G code in the objective block specified by "block" is set in the ODBCMD structure.
type
commanded address
type
commanded address
0
A (2nd auxiliary function)
15
P (not used)
1
B (2nd auxiliary function)
16
Q (not used)
2
C (2nd auxiliary function)
17
R (not used)
3
D
18
S
4
E
19
T
5
F
20
U (2nd auxiliary function)
6
G (not used)
21
V (2nd auxiliary function)
7
H
22
W (2nd auxiliary function)
8
I (not used)
23
X (not used)
9
J (not used)
24
Y (not used)
10
K (not used)
25
Z (not used)
11
L
26
M (2nd M code)
12
M
27
M (3rd M code)
13
N
28
M (4th M code)
14
O
29
M (5th M code)
The following data are set in the ODBCMD structure.
adrs
The commanded address is stored in ASCII code.
num
The following values are stored when "adrs" is M (=77).
1
:
1st M code
2
:
2nd M code
3
:
3rd M code
4
:
4th M code
5
:
5th M code
flag
The following flags are stored.
#3
=
1
:
command differ from the previous block (only Series 30i, 0i-D/F, PMi-A)
#4
=
1
:
There is a command of a decimal point.
#5
=
1
:
Negative
#6
=
1
:
1 digit
#11
=
1
:
There is a command after RESET.
#15
=
1
:
There is a command in the present block.
cmd_val
The commanded data is stored.
dec_val
The number of places of decimals of commanded data is stored.
The commanded data is calculated by the following expression.
Commanded data = cmd_val * 10 ** (-dec_val)
(Example) The following data are read when "F1000.0" is commanded.
adrs
=
F (=70)
cmd_val
=
10000
dec_val
=
1
Reading all data at a time
Specify the number of modal data to be read for "num_cmd". Specify -1 for "type". Specify the block to be read for "block". Then all modal data except G code in the objective block specified by "block" is set in the ODBCMD structure.Specify the number in the following table for "num_cmd" in order to read all modal data. The number of modal data which were read actually is stored in "num_cmd" after the function call.
Some same M codes may be read at a time with "multiple M commands in a single block".
With "2nd auxiliary function"
Without "2nd auxiliary function"
With "multiple M commands in a single block"
15
14
Without "multiple M commands in a single block"
11
10
(2) Reading commanded data
Reading data one by one
Specify 1 for "num_cmd". Specify the commanded address in the following table for "type". Specify the block to be read for "block". Then commanded data which is commanded in the objective block specified by "block" is set in the ODBCMD structure. When no data is commanded in the objective block specified by "block", zero is set in "num_cmd".
type
commanded address
type
commanded address
100
A
115
P
101
B
116
Q
102
C
117
R
103
D
118
S
104
E
119
T
105
F
120
U
106
G (not used)
121
V
107
H
122
W
108
I
123
X
109
J
124
Y
110
K
125
Z
111
L
126
M (2nd M code)
112
M
127
M (3rd M code)
113
N
128
M (4th M code)
114
O
129
M (5th M code)
The following data are set in the ODBCMD structure.
adrs
The commanded address is stored in ASCII code.
num
The following values are stored when "adrs" is M (=77).
1
:
1st M code
2
:
2nd M code
3
:
3rd M code
4
:
4th M code
5
:
5th M code
flag
The following flags are stored.
#4
=
1
:
There is a command of a decimal point.
#5
=
1
:
Negative
#6
=
1
:
1 digit
#11
=
(always)
1
:
There is a command after RESET.
#15
=
(always)
1
:
There is a command in the present block.
cmd_val
The commanded data is stored.
dec_val
The number of places of decimals of commanded data is stored.
The commanded data is calculated by the following expression.
Commanded data = cmd_val * 10 ** (-dec_val)
(Example) The following data are read when "X200.00" is commanded.
adrs
=
X (=88)
cmd_val
=
20000
dec_val
=
2
Reading all data at a time
Specify the number of commanded data to be read for "num_cmd". Specify -2 for "type". Specify the block to be read for "block". Then all commanded data in the objective block specified by "block" is set in the ODBCMD structure. Specify the number in the following table for "num_cmd" in order to read all commanded data. The number of commanded data which were read actually is stored in "num_cmd" after the function call.
With "multiple M commands in a single block"
:
29
Without "multiple M commands in a single block"
:
25
(3) Reading commanded data concerning axis
Reading data one by one
Specify 1 for "num_cmd". Specify axis number (200 to 223) in the following table for "type". Specify the block to be read for "block". Then commanded data concerning axis which is commanded in the objective block specified by "block" is set in the ODBCMD structure. When no axis is commanded in the objective block specified by "block", zero is set in "num_cmd".
Series 15i
type
axis
200
1st axis
201
2nd axis
:
:
209
10th axis
210
11th axis
:
:
222
23th axis
223
24th axis
* When MAX_AXIS=15, type=215,..,223 are not used.
* When MAX_AXIS=10, type=210,..,223 are not used.
Series 30i, 0i-D/F, PMi-A
type
axis
200
1st axis
201
2nd axis
:
:
209
10th axis
210
11th axis
:
:
230
31th axis
231
32th axis
The following data are set in the ODBCMD structure.
adrs
The commanded address is stored in ASCII code.
num
The axis number (1 to max. controlled axes) is stored in binary.
flag
The following flags are stored.
#4
=
1
:
There is a command of a decimal point.
#5
=
1
:
Negative
#6
=
1
:
1 digit
#11
=
(always)
1
:
There is a command after RESET.
#15
=
(always)
1
:
There is a command in the present block.
cmd_val
The commanded data is stored.
dec_val
The number of places of decimals of commanded data is stored.
The commanded data is calculated by the following expression.
Commanded data = cmd_val * 10 ** (-dec_val)
(Example) The following data are read when 2nd axis is "Y" and "Y50.0" is commanded.
adrs
=
Y (=89)
num
=
2
cmd_val
=
500
dec_val
=
1
Reading all data at a time
Specify the number of commanded data concerning axis to be read for "num_cmd". Specify -3 for "type". Specify the block to be read for "block". Then all commanded data concerning axis in the objective block specified by "block" is set in the ODBCMD structure. Specify the following values for "num_cmd" in order to read all commanded data concerning axis. The number of commanded data which were read actually is stored in "num_cmd" after the function call.
MAX_AXIS = 25 to 32
:
25 to 32(only Series 30i, 0i-D/F, PMi-A)
MAX_AXIS = 24
:
24
MAX_AXIS = 15
:
15
MAX_AXIS = 10
:
10
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 The number of G code data to be read (num_cmd) is wrong.
EW_NUMBER (3)
Data number error The specification of commanded data (type) is wrong.
EW_ATTRIB (4)
Data attribute error The specification of block (block) is wrong.