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 | Meaning | Byte size |
---|---|---|
Bit parameter | Every bits have each definition. | 1 |
Bit parameter with axis | Every bits have each definition. (each axis) | 1 |
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 |
Real parameter (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 parameter 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 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.
Universal Fanuc Driver
Fanuc Focas Library CD
Declaration
Arguments
Specify the library handle. See "Library handle" for details.
Specify the start parameter number.
The parameter number which was read first actually is returned.
See the "PARAMETER MANUAL" of CNC about available parameter number. It can be got by cnc_rdparanum function and cnc_rdparainfo function.
Specify the end parameter number.
The parameter number which was read last actually 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) may be returned or the application program may not work correctly. In order to avoid these problems, specify only the continuous numbers of existing parameters as the reading range.
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 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".
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.
[= 4+(byte size of each parameter)*(number of axis)]
Because the size which was read actually is returned, it is possible to specify the length more than the actual size.
In case that the size of parameter is 2 byte, the IODBPSD structure is as follows. In case that the size of parameter is 1 or 2 byte and the length per 1 parameter 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 parameter or 1 axis is 4 or 8 byte, and so 'dummy' is not necessary.
IODBPSD
no axis/1 axis | all axes |
---|---|
n = Maximum controlled axes
In case of Series 15i, 16/18/21, 16i/18i/21i, 0i, 30i, Power Mate i and PMi-A, the spindle parameters have an axis attribute, and the data for number of spindle are valid.
Pointer to the area to store the parameters.
Each parameter can be referred by using the IODBPSD structure.
Series 15, 16/18/21, 16i/18i/21i, 0i-A/B and Power Mate i
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 */
Series 15i, 30i, 0i-D/F, PMi-A and Ethernet connection
typedef struct realprm { /* real parameter */
long prm_val; /* value of variable */
long dec_val; /* number of places of decimals */
} REALPRM;
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 */
REALPRM rdata; /* real 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 */
REALPRM rdatas[MAX_AXIS];/* real 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 4 : 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 parameter is stored.
The value of variable is stored in prm_val, and the number of places of decimals is stored in dec_val. -
Real parameter = prm_val * 10 ** (-dec_val)
(Example) When the value of real parameter is 12.345, prm_val and dec_val are read as follows.
prm_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 |
---|---|
(2) |
Size of area to store parameter(length) is wrong. |
(3) |
Parameter number(s_number,e_number) is wrong. |
(4) |
Axis number(axis) is wrong. |
(17) |
( Series 16i/18i/21i, 0i-A/B/C ) |
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 not related to CNC parameter.
CNC mode
This function can be used in any 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_rdparam cnc_wrparam cnc_wrparas cnc_rdparam_ext cnc_rdparainfo cnc_rdparanum
Example(C Language)
The following program reads the parameter within the specified number range and axis, and displays them.( Series 16i/18i/21i, 0i-A/B/C )
#include "fwlib32.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 ;
short length;
cnc_sysinfo( h, &info ) ;
axno = atoi( info.axes ) ;
length = sizeof(IODBPSD) * (end - start + 1); // In case of axis type parameters
param = (IODBPSD *)calloc( 1, length ) ;
ret = cnc_rdparar( h, &start, axis, &end, &length, 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+MAX_AXIS*inc) ;
/* MAX_AXIS = 8 */
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+3 ; break ;
case 1:
printf( " %d\n", ptr->u.cdata ) ;
inc = 1+3 ; break ;
case 2:
printf( " %d\n", ptr->u.idata ) ;
inc = 2+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 ) ;
}
Example(C#)
The following program reads the parameter within the specified number range and axis, and displays them.( Series 16i/18i/21i, 0i-A/B/C )
class example
{
/* start/end are start/end number to be read, axis is axis number. */
public short sample(short start, short end, short axis)
{
Focas1.ODBSYS info = new Focas1.ODBSYS();
Focas1.IODBPSD param = new Focas1.IODBPSD();
short ret, idx1, idx2, axno, inc;
short length;
Focas1.cnc_sysinfo( h, info ) ;
axno = short.Parse( new string(info.axes) );
length = (short)(Marshal.SizeOf(param) * (end - start + 1)); // In case of axis type parameters
byte[] bytes = new byte[length];
IntPtr ptrWork = Marshal.AllocCoTaskMem(Marshal.SizeOf(param));
ret = Focas1.cnc_rdparar(h, ref start, axis, ref end, ref length, bytes);
if (ret == Focas1.EW_OK)
{
inc = 0;
int pos = 0;
for (idx1 = start; idx1 <= end; idx1++)
{
Marshal.Copy(bytes, pos, ptrWork, Marshal.SizeOf(param));
Marshal.PtrToStructure(ptrWork, param);
if ((start != 0) && (param.datano == 0)) break;
Console.Write("No.{0:d5} ", param.datano);
switch (param.type >> 8)
{
case 0: Console.Write("BIT "); break;
case 1: Console.Write("BYTE"); break;
case 2: Console.Write("WORD"); break;
case 3: Console.Write("2WRD"); break;
}
switch (param.type & 0xff)
{
case 0xff:
for (idx2 = 0; idx2 < axno; idx2++)
{
Console.Write(" #{0}:", idx2 + 1);
switch (param.type >> 8)
{
case 0:
Console.Write("0x{0:X2}", param.u.cdatas[idx2]);
inc = 1; break;
case 1:
Console.Write("{0}", (sbyte)(param.u.cdatas[idx2]));
inc = 1; break;
case 2:
Console.Write("{0}", param.u.idatas[idx2]);
inc = 2; break;
case 3:
Console.Write("{0}", param.u.ldatas[idx2]);
inc = 4; break;
}
}
Console.Write('\n');
pos += (short)(4 + Focas1.MAX_AXIS * inc);
/* MAX_AXIS = 8 */
break;
case 0:
switch (param.type >> 8)
{
case 0:
Console.WriteLine(" 0x{0:X2}", param.u.cdata);
inc = 1 + 3; break;
case 1:
Console.WriteLine(" {0}", (sbyte)(param.u.cdata));
inc = 1 + 3; break;
case 2:
Console.WriteLine(" {0}", param.u.idata);
inc = 2 + 2; break;
case 3:
Console.WriteLine(" {0}", param.u.ldata);
inc = 4; break;
}
pos += (short)(4 + inc);
break;
default:
Console.Write(" #{0}:", param.type & 0xff);
break;
}
}
}
else
{
Console.WriteLine("ERROR!({0})", ret);
}
Marshal.FreeCoTaskMem(ptrWork);
return (ret);
}
}