Description
Outputs the NC part program for DNC operation or M198 operation to CNC.
This function outputs the characters of NC program as long as it is specified by '*length'('length').
However, if there is no room to store the specified number of character, this function stores the
characters as many as possible to fill the buffer and then sets '*length'('length') with the real number of characters which are stored in the buffer.
In case that this function cannot output at least one character, it returns EW_BUFFER, so again call this function with the same arguments.
When DNC operation or M198 operation is aborted on CNC side, this function returns EW_RESET.
In this case, call cnc_dncend2 with
DNC_CANCEL as the output result in order to terminate the output of NC program.
Following shows the format of NC part program to be output.
EOB CMD1 EOB CMD2 EOB ..... CMDn EOB Mxx EOB
CMD1...n | ASCII character string |
EOB | LF(0x0A) |
Mxx | M code that shows the termination of DNC operation. (M02 or M30, etc.) |
In case of M198 operation, 'M99' must be specified to 'Mxx'.
Please be careful !!! When dnc function is used with Ethernet, the transfer rate is not secured by the state of the network. And, this function is not available to Embedded Ethernet. |
Universal Fanuc Driver
Fanuc Focas Library CD
Declaration
Arguments
Specify the library handle. See "Library handle" for details.
The pointer of long type variable where the number of the
characters that are output from MMC function is set.
When this function returns, the actual number of characters
that are output to CNC will be set.
This function returns EW_LENGTH if '*length'('length') has the value of zero or negative.
The pointer of the area where NC part program to be output is stored.
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 |
---|---|
(-2) |
'RESET or STOP' was pushed. Call the cnc_dncend2 function. |
(1) |
|
(2) |
The size of character string is negative. |
(10) |
Retry because the buffer is full. |
(9) |
the following CNC parameter must be set. Series 15/15i 7713#0 = 1 Series 16/18/21, 16i/18i/21i, 0i-A/B/C 8706#1 = 1 |
(6) |
The extended driver/library function is necessary. |
As for the other return codes or the details, see "Return status of Data window function"
CNC option
For HSSB connection,
For Ethernet connection,
The Ethernet function and the extended driver/library function are necessary. However, in case of Series 16i/18i/21i-B, 0i-B/C/D/F, Series 30i and PMi-A, the required CNC option is as follows. When Embedded Ethernet is used,above two optional functions are not required.
When Ethernet board is used,
- only Ethernet function is required.
CNC parameter
This function is related to the following CNC parameter.
See the manual of CNC parameter for details.
7713#0 = 1 (must be set)
0020 = 15 (must be set)
0020 = 15 (must be set)
8706#0 (influenced by setting) (This parameter is effective only in path 1. Set 0 except the 1st path.)
8706#1 = 1 (must be set)
0020 = 15 (must be set)
0020 = 16 (must be set)(In case of HSSB PORT2 function)
0020 = 15 (must be set)
0020 = 16 (must be set)(In case of HSSB PORT2 function and NCGuidePro)
0020 = 6 (must be set)
0020 = 6 (must be set)
CNC mode
Available CNC
0i-A | 0i-B/C(Note) | 0i-D | 0i-F | 15 | 15i | 16 | 18 | 21 | 16i-A | 18i-A | 21i-A | 16i-B | 18i-B | 21i-B | 30i-A | 30i-B | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
M (Machining) | |||||||||||||||||
T (Turning) | - | ||||||||||||||||
LC (Loader) | - | - | - | - | - | - | - | - |
0i-D | 0i-F | 16i | 18i | 30i-A | 30i-B | |
---|---|---|---|---|---|---|
P (Punch press) | - | |||||
L (Laser) | - | - | - | - | ||
W (Wire) | - | - |
Power Mate i-D | |
Power Mate i-H | |
Power Motion i-A | O |
"O" | : | Both Ethernet and HSSB | |
"E" | : | Ethernet | |
"H" | : | HSSB | |
"X" | : | Cannot be used | |
"-" | : | None |
Note) 0i-C does not support the HSSB function.
See Also
cnc_dncstart2 cnc_dncend2 cnc_rddncdgndt
Example(C Language)
The following program executes the NC commands by DNC operation.
M3 S1500 ;
G28 U0 W0 ;
T0101 ;
G0 X35. Z-10. ;
M30 ;
#include "fwlib32.h"
short example( void )
{
char* prg =
"\n"
"M3S1500\n"
"G28U0W0\n"
"T0101\n"
"G0X35.Z-10.\n"
"M30\n"
"%";
char fname[16];
long len, n;
short ret;
ret = cnc_dncstart2( h, fname ) ;
if ( ret ) return ( ret ) ;
len = strlen( prg ) ;
while ( len > 0 ) {
n = len ;
ret = cnc_dnc2( h, &n, prg ) ;
if ( ret == EW_BUFFER ) {
continue ;
}
if ( ret == EW_OK ) {
prg += n ;
len -= n ;
}
if ( ret != EW_OK ) {
break ;
}
}
if ( ret == EW_RESET )
ret = cnc_dncend2( h, DNC_CANCEL ) ;
else
ret = cnc_dncend2( h, DNC_NORMAL ) ;
return ( ret ) ;
}
Example(C#)
The following program executes the NC commands by DNC operation.
M3 S1500 ;
G28 U0 W0 ;
T0101 ;
G0 X35. Z-10. ;
M30 ;
class example
{
public short sample()
{
string strPrg =
"\n" +
"M3S1500\n" +
"G28U0W0\n" +
"T0101\n" +
"G0X35.Z-10.\n" +
"M30\n" +
"%";
char[] fname = new char[16];
int len, n;
short ret;
ret = Focas1.cnc_dncstart2(h, fname);
if (ret != Focas1.EW_OK) return (ret);
int startPos = 0;
len = strPrg.Length;
while (len > 0)
{
char[] prg = new char[1280];
strPrg.CopyTo(startPos, prg, 0, len);
n = len;
ret = Focas1.cnc_dnc2(h, ref n, prg);
if (ret == (short)Focas1.focas_ret.EW_BUFFER)
{
continue;
}
if (ret == Focas1.EW_OK)
{
startPos += n;
len -= n;
}
if (ret != Focas1.EW_OK)
{
break;
}
}
if (ret == (short)Focas1.focas_ret.EW_RESET)
{
ret = Focas1.cnc_dncend2(h, (short)Focas1.focas_ret.DNC_CANCEL);
}
else
{
ret = Focas1.cnc_dncend2(h, (short)Focas1.focas_ret.DNC_NORMAL);
}
return (ret);
}
}