News CNCnetPDM About us Support  
         
  

CNC_RDAXISDATA | POSITION

Description

Reads various data relating servo axis/spindle axis that is got by cnc_rdposition, cnc_rdspeed, cnc_rdsvmeter, cnc_rdspmeter, cnc_rdhndintrpt, with supporting "extended axis name".

You have to specify the argument "cls" with the data class to be read, array of short, "type[]" with the kind of data to be read. The number of the array must be specified by the argument "num". The data kind that can be read once is up to 4. If "num" exceeds 4, this function will return the error, EW_ATTRIB.

The argument "(*len)" should be specified with the number of axes to be read. According to "cls", "(*len)" should be specified as follows.

1. In case that "cls" is specified with Position(=1), Servo(=2), Spindle(=3):

This function reads the data from first axis by the specified number of axes. After execution, "(*len)" will have the actual number of axes in case that "(*len)" is specified with the number that is larger than the current effective number of axes. In case that "(*len)" is specified with the number that is smaller than the current effective number of axes, this function reads only the number of data specified by "(*len)".

2. In case that "cls" is specified with Selected spindle(=4), Speed(=5):

This function always reads only one axis data. In case that Selected spindle is specified but there is not a selected spindle, this function will set "(*len)" with 0.

The read data will be stored on the array of ODBAXDATA structure specified by the argument "axdata[]". The number of members of this array must be "num" x "(*len)". The read data will be stored on the array, by the number of specified "(*len)" and order of specified "type[]" like as follows:

Data of type[0] : axdata[ 0] ,..,axdata[ (*len)-1]
Data of type[1] : axdata[ (*len)] ,..,axdata[ 2 x (*len)-1]
Data of type[2] : axdata[ 2 x (*len)] ,..,axdata[ 3 x (*len)-1]
Data of type[3] : axdata[ 3 x (*len)] ,..,axdata[ 4 x (*len)-1]

Even in case that specified "(*len)" is smaller than the actual number of axes, the data will be stored on the array according to the "(*len)" that was specified at calling of this function.

Example of arguments)

In case of reading Absolute position, Machine position, Relative position:

short types[3] = {0, 1, 2}; /* Absolute, Machine, Relative */
len = 3;                    /* Specify 3 axes */
ODBAXDT axdata[3*3];
cnc_rdaxisdata(h, 1, types, 3, &len, axdata);

The contents of the array "axdata" will be as follows.

If the current effective number of axes is 2, (*len) will be returned 2 and array for 3rd axis(axdata[2], [5], [8]) will have no data after the execution.

MTConnect Fanuc Adapter

Universal Fanuc Driver

Fanuc Focas Library CD

Declaration

#include "fwlib32.h" or "fwlib64.h"

 

FWLIBAPI short WINAPI cnc_rdaxisdata(unsigned short FlibHndl, short cls, short* type, short num, short* len, ODBAXDT* axdata);

Arguments

FlibHndl   [ in ]

Specify the library handle. See "Library handle" for details.

cls   [ in ]

Specify the class of data to be read.

1 : Position value
2 : Servo
3 : Spindle
4 : Selected spindle
5 : Speed
type   [ in ]

Specify the pointer for the array that specifies the kind of data to be read. The following value can be specified according to "cls".

      cls = 1 (Position value)
0 : Absolute position
1 : Machine position
2 : Relative position
3 : Distance to go
4 : Handle interruption(Input unit)
5 : Handle interruption(Output unit)
6 : Start point of program restart
7 : Distance to go of program restart
8 : Start point of block restart
9 : Distance to go of block restart

      cls = 2 (Servo)
0 : Servo load meter
1 : Load current (% unit)
2 : Load current (Ampere unit)

      cls = 3 (Spindle) and cls = 4 (Selected spindle)
0 : Spindle load meter
1 : Spindle motor speed
2 : Spindle speed (according to parameter 3799#2)
3 : Spindle speed (got from Spindle motor speed)
4 : Spindle load meter (average of each 250ms)
5 : Spindle load meter(maximum value)
6 : Spindle load meter(maximum value)(average of each 250ms)
7 : Time that spindle can continue processing
? Data by 5, 6, 7 will be influenced by parameter No.4542#7.
So, the value of road meter (type = 0) might exceed maximum value (type = 5,6) depending on timing in which data is acquired.

      cls = 5 (Speed)
0 : Feed rate(F)(Feed per minute)
1 : Spindle speed(S)
2 : Jog speed/Dry run speed
3 : Tool tip speed
4 : Rotation speed of servo motor
5 : Feed rate(F/S) Note
Note) The unit follow the value of parameter No.3107#3 and No.3191#5.
Judge the unit by "unit".
num   [ in ]

Specify the number of array "type".

len   [ in/out ]

Specify the pointer that stores the number of axes to be read.
This function returns the actual read number of axes after the execution.

axdata   [ out ]

Specify the pointer of the array of ODBAXDT structure. Number of "num" x "(*len)" must be required. The ODBAXDT structure is as follows.

typedef struct odbaxdt {
        char    name[4];        /* axis name */
        long    data;           /* data */
        short   dec;            /* decimal point */
        short   unit;           /* unit of data */
        short   flag;           /* flags */
        short   reserve;        /* reserved */
} ODBAXDT ;
name
Axis name will be stored in ASCII code.
The string is NULL terminated.

data
Data to be read

dec
Decimal point of data
In case that following "unit" is "rpm" or "%", this data is always 0.

unit
Unit of data
0 : mm (Position value)
1 : inch (Position value)
2 : degree (Position value)
3 : mm/minute (Feed rate(Feed per minute), jog/dry run speed, Tool tip speed)
4 : inch/minute (Feed rate(Feed per minute), jog/dry run speed, Tool tip speed))
5 : rpm (Spindle speed, spindle motor speed)
6 : mm/round (Feed rate(Feed per revolution), jog/dry run speed, Tool tip speed))
7 : inch/round (Feed rate(Feed per revolution), jog/dry run speed, Tool tip speed))
8 : % (Load meter, load current)
9 : Ampere (Load current)
10 : Second (Time)

flag
Flags
According to "cls", following value will be set.
      cls = 1 (Position value)
bit 0 : Display state  
  1 = Displayed on CNC screen : 0 = Not displayed on CNC screen
bit 1 : Axis detaching state  
  1 = enabled : 0 = disabled
bit 2 : Interlock state  
  1 = enabled : 0 = disabled
bit 3 : Machine lock state  
  1 = enabled : 0 = disabled
bit 4 : Servo off state  
  1 = enabled : 0 = disabled
bit 5 : In-position check  
  1 = Not in-position : 0 = In-position
bit 6 : Mirror image state  
  1 = enabled : 0 = disabled
bit 7 : Diameter and radius setting switching function  
  1 = switching : 0 = not switching
bit 8 : High speed program check mode(only machine coordinate)  
  1 = enabled : 0 = disabled
bit 9 : Optional one axis approach by program restart  
  1 = executing : 0 = not executing
bit 10 : Restart coordinates display on the program restart screen(except machine coordinate)  
  1 = possible : 0 = impossible (display "***********")
bit 11 : Release state of axis(Flexible path axis assignment function)  
  1 = enabled : 0 = disabled
bit 12,..,15 : not used  

      cls = 3, 4(Spindle, Selected spindle)

        ?type = 5,6,7(Spindle load meter(maximum value), Spindle load meter(maximum value)(average of each 250ms), Time that spindle can continue processing)

bit 0 : Data judgment result  
  1 = It has judged. : 0 = Unjudgment
bit 1 : Presence of data  
  1 = Exist : 0 = None
bit 12,..,15 : not used  

      cls = 5 (Speed)
bit 0 : Spindle speed  
  1 = spindle exists : 0 = spindle not exist
bit 1 : Jog speed/Dry run speed  
  1 = Dry run speed : 0 = Jog speed
bit 2,..,15 : not used  

      Others
not used

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 error
Number of axis(*len) is less or equal 0.
EW_NUMBER
(3)
Data number error
Data class(cls) is wrong.
EW_ATTRIB
(4)
Data attribute error
Kind of data(type) is wrong, or The number of kind(num) exceeds 4.
EW_NOOPT
(6)
No option
Required option to read data is not specified.

 

As for the other return codes or the details, see "Return status of Data window function"

CNC option

 

And this function is related to the following CNC option.

The option that corresponds to the data to be read is required.

For HSSB connection,

The extended driver/library function is necessary.

For Ethernet connection,

The Ethernet function and the extended driver/library function are necessary.

However, in case of Series 0i-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.

1020,1025,1026 (influenced by setting)
3131,3132,3133 (influenced by setting)
3104#0,#4,#5,#6,#7 (influenced by setting)
3115#0,#1,#2 (influenced by setting)
3799#2 (influenced by setting)
8163#0 (influenced by setting)
4542#7 (influenced by setting)

 

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) X X O O X X X X X X X X X X X O O
T (Turning) X X O O X - X X X X X X X X X O O
LC (Loader) - - - - - - X X X X X X X X X - -

 

  0i-D 0i-F 16i 18i 30i-A 30i-B
P (Punch press) O O X X - O
L (Laser) - - X - - O
W (Wire) - - X X O O

 


Power Mate i-D X
Power Mate i-H X
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.

 

Example(C Language)

 

Absolute position, machine position, relative position, distance to go,
of all axes are got and displayed.

#include "fwlib32.h"

void example( void )
{
    ODBAXDT pos[4*MAX_AXIS];
    short types[4] = {0, 1, 2, 3};
    short num = sizeof(types) / sizeof(types[0]);
    short len = MAX_AXIS;
    short ret = cnc_rdaxisdata(h, 1, types, 4, &len, pos);
    if(!ret) {
        int i;
        printf("ABSOLUTE:\n");
        for(i = 0 * MAX_AXIS ; i < 0 * MAX_AXIS + len ; i++) {
            printf("%s = %d\n", pos[i].name, pos[i].data);
        }
        printf("MACHINE:\n");
        for(i = 1 * MAX_AXIS ; i < 1 * MAX_AXIS + len ; i++) {
            printf("%s = %d\n", pos[i].name, pos[i].data);
        }
        printf("RELATIVE:\n");
        for(i = 2 * MAX_AXIS ; i < 2 * MAX_AXIS + len ; i++) {
            printf("%s = %d\n", pos[i].name, pos[i].data);
        }
        printf("DISTANCE TO GO:\n");
        for(i = 3 * MAX_AXIS ; i < 3 * MAX_AXIS + len ; i++) {
            printf("%s = %d\n", pos[i].name, pos[i].data);
        }
    }
}

Example(C#)

Absolute position, machine position, relative position, distance to go,
of all axes are got and displayed.

class example
{
    public void sample()
    {
        Focas1.ODBAXDT_data pos = new Focas1.ODBAXDT_data();
        short[] types = { 0, 1, 2, 3 };
        short len = Focas1.MAX_AXIS;

        byte[] bytes = new byte[Marshal.SizeOf(pos) * 4 * Focas1.MAX_AXIS];
        IntPtr ptrWork = Marshal.AllocCoTaskMem(Marshal.SizeOf(pos));

        short ret = Focas1.cnc_rdaxisdata(h, 1, types, 4, ref len, bytes);
        if (ret == Focas1.EW_OK)
        {
            int i;
            Console.WriteLine("ABSOLUTE:");
            for (i = 0 * Focas1.MAX_AXIS; i < 0 * Focas1.MAX_AXIS + len; i++)
            {
                Marshal.Copy(bytes, i * Marshal.SizeOf(pos), ptrWork, Marshal.SizeOf(pos));
                Marshal.PtrToStructure(ptrWork, pos);
                Console.WriteLine("{0} = {1}", pos.name, pos.data);
            }
            Console.WriteLine("MACHINE:");
            for (i = 1 * Focas1.MAX_AXIS; i < 1 * Focas1.MAX_AXIS + len; i++)
            {
                Marshal.Copy(bytes, i * Marshal.SizeOf(pos), ptrWork, Marshal.SizeOf(pos));
                Marshal.PtrToStructure(ptrWork, pos);
                Console.WriteLine("{0} = {1}", pos.name, pos.data);
            }
            Console.WriteLine("RELATIVE:");
            for (i = 2 * Focas1.MAX_AXIS; i < 2 * Focas1.MAX_AXIS + len; i++)
            {
                Marshal.Copy(bytes, i * Marshal.SizeOf(pos), ptrWork, Marshal.SizeOf(pos));
                Marshal.PtrToStructure(ptrWork, pos);
                Console.WriteLine("{0} = {1}", pos.name, pos.data);
            }
            Console.WriteLine("DISTANCE TO GO:");
            for (i = 3 * Focas1.MAX_AXIS; i < 3 * Focas1.MAX_AXIS + len; i++)
            {
                Marshal.Copy(bytes, i * Marshal.SizeOf(pos), ptrWork, Marshal.SizeOf(pos));
                Marshal.PtrToStructure(ptrWork, pos);
                Console.WriteLine("{0} = {1}", pos.name, pos.data);
            }
        }
        Marshal.FreeCoTaskMem(ptrWork);
    }
}

Privacy notice

This website uses cookies. By continuing to use it you agree to our privacy policy. 

https://www.inventcom.net/fanuc-focas-library/position/cnc_rdaxisdata
Fanuc Focas Library | Position | cnc_absolute
Description Reads the absolute position data of axis specified with "axis". The absolute position is stored in "data[0]" of "ODBAXIS". All axes can be read at a time by... [read more]
cnc_absolute
Fanuc Focas Library | Position | cnc_absolute2
Description Differences between functions of cnc_absolute2 and functions of... [read more]
cnc_absolute2
Fanuc Focas Library | Position | cnc_accdecdly
Description Reads the acceleration/deceleration delay amount of axis specified with "axis". The acceleration/deceleration delay amount is stored in "data[0]" of... [read more]
cnc_accdecdly
Fanuc Focas Library | Position | cnc_actf
Description Reads the actual feed rate of the controlled axes of CNC. The actual feed rate is stored in "data" of "ODBACT".... [read more]
cnc_actf
Fanuc Focas Library | Position | cnc_acts
Description Reads the actual rotational speed of the spindle connected to CNC. The actual spindle speed is stored in "data" of "ODBACT".... [read more]
cnc_acts
Fanuc Focas Library | Position | cnc_acts2
Description Reads the actual rotational speed of the spindle connected to CNC. The actual spindle speed is stored in "data[0]" of "ODBACT2". All spindle can be... [read more]
cnc_acts2
Fanuc Focas Library | Position | cnc_canmovrlap
Description Cancel the manual overlapped motion value of axis specified with "axis". It is possible to cancel the manual overlapped motion value of all axes at a... [read more]
cnc_canmovrlap
Fanuc Focas Library | Position | cnc_clr3dplsmov
Description Clears the handle interrupt pulse amount and the handle interrupt move amount. It is only the handle interrupt pulse amount to be able to specify the... [read more]
cnc_clr3dplsmov
Fanuc Focas Library | Position | cnc_clr5axpls
Description Clears the pulse amount for the manual feed for 5-axis machining.... [read more]
cnc_clr5axpls
Fanuc Focas Library | Position | cnc_distance
Description Reads the amount of distance to go of axis specified with "axis". The amount of distance to go is stored in "data[0]" of "ODBAXIS". All axes can be read... [read more]
cnc_distance
Fanuc Focas Library | Position | cnc_exaxisname
Description Reads the name of controlled axis and spindle name from 1st by the specified (*num), with supporting "extended axis name". After execution,... [read more]
cnc_exaxisname
Fanuc Focas Library | Position | cnc_exaxisname2
Description Reads the name of controlled axis and spindle name from 1st by the specified (*num), with supporting "extended axis name". After execution,... [read more]
cnc_exaxisname2
Fanuc Focas Library | Position | cnc_machine
Description Reads the machine position data of axis specified with "axis". The machine position is stored in "data[0]" of "ODBAXIS". All axes can be read at a time... [read more]
cnc_machine
Fanuc Focas Library | Position | cnc_prstwkcd
Description Presets the word coordinate selecting in CNC(absolute position). Preset data is specified by "data[0]" in "IDBWRA". It is... [read more]
cnc_prstwkcd
Fanuc Focas Library | Position | cnc_rd3dmovrlap
Description Reads the movement amount (generally for 5 axes, in case of parallel axis, 5 + 5 = 10 axes) about 3-dimensional handle feed. The number of... [read more]
cnc_rd3dmovrlap
Fanuc Focas Library | Position | cnc_rd3dofschg
Description Read the modification of tool length compensation amount in tool axis direction. The places of decimal points can be got by... [read more]
cnc_rd3dofschg
Fanuc Focas Library | Position | cnc_rd3dpulse
Description Reads the handle interrupt pulse amount about 3-dimensional handle feed. The handle interrupt pulse amount in special handle feed mode(G156#0,... [read more]
cnc_rd3dpulse
Fanuc Focas Library | Position | cnc_rd3dtooltip
Description Reads the absolute position of the tool tip coordinates about 3-dimensional handle feed. The number of each axis and the tool... [read more]
cnc_rd3dtooltip
Fanuc Focas Library | Position | cnc_rd5axmandt
Description Reads the data for the manual feed for 5-axis machining.... [read more]
cnc_rd5axmandt
Fanuc Focas Library | Position | cnc_rd5axovrlap
Description Reads the machine axis movement for the manual feed of 5-axis machining. The axis number(axis) should be specified as 1..max controlled axes (for reading... [read more]
cnc_rd5axovrlap
Fanuc Focas Library | Position | cnc_rdaxisname
Description Reads the axis names from 1st axis to the specified axis number. In case that "*data_num" is bigger than the current controlled axis number, this... [read more]
cnc_rdaxisname
Fanuc Focas Library | Position | cnc_rddynamic
Description Read various data which changes at CNC operation at a time. The data which can be read is as follows. Data Function... [read more]
cnc_rddynamic
Fanuc Focas Library | Position | cnc_rddynamic2
Description Reads various data which changes at CNC operation at a time. This function is the improved version of the... [read more]
cnc_rddynamic2
Fanuc Focas Library | Position | cnc_rdhndintrpt
Description Reads the handle interruption values from 1st axis to the specified axis number. In case that "data_num" is bigger than the current controlled axis... [read more]
cnc_rdhndintrpt
Fanuc Focas Library | Position | cnc_rdmovrlap
Description Read the manual overlapped motion value based on the input unit and based on the output unit. All axes can be read at a time by specifying ALL_AXES for... [read more]
cnc_rdmovrlap
Fanuc Focas Library | Position | cnc_rdposition
Description Reads the positions from 1st axis to the specified axis number. In case that "*data_num" is bigger than the current controlled axis number,... [read more]
cnc_rdposition
Fanuc Focas Library | Position | cnc_rdspcss
Description Reads the following data related to constant surface speed control on CNC side. Converted spindle speed value... [read more]
cnc_rdspcss
Fanuc Focas Library | Position | cnc_rdspdlname
Description Reads the spindle names from 1st spindle to the specified spindle number. In case that "*data_num" is bigger than all spindle number, this function sets... [read more]
cnc_rdspdlname
Fanuc Focas Library | Position | cnc_rdspdlspeed
Description This function does the calculation for serial spindle by which the gear ratio was considered against the rotation speed of spindle motor.... [read more]
cnc_rdspdlspeed
Fanuc Focas Library | Position | cnc_rdspeed
Description Reads the actual feed rate and the actual rotational speed of the spindle. The spindle speed, which can be read in this function, is one of the... [read more]
cnc_rdspeed
Fanuc Focas Library | Position | cnc_rdspgear
Description Reads the gear ratio of the serial spindle. The gear ratio is stored in "data[0]" of "ODBSPN". All spindle can be read at a time by specifying... [read more]
cnc_rdspgear
Fanuc Focas Library | Position | cnc_rdspload
Description Reads the load information of the serial spindle. The load information of the serial spindle is stored in "data[0]" of "ODBSPN". All spindle... [read more]
cnc_rdspload
Fanuc Focas Library | Position | cnc_rdspmaxrpm
Description Reads the maximum r.p.m. ratio of serial spindle. The gear ratio is stored in "data[0]" of "ODBSPN". All spindle can be read at a time by specifying... [read more]
cnc_rdspmaxrpm
Fanuc Focas Library | Position | cnc_rdspmeter
Description Reads the spindle load meter data and the spindle motor speed data from 1st spindle to the specified spindle number. In case that "data_num"... [read more]
cnc_rdspmeter
Fanuc Focas Library | Position | cnc_rdsvmeter
Description Reads the servo load meter data from 1st axis to the specified axis number. In case that "*data_num" is bigger than the servo axis number, this function... [read more]
cnc_rdsvmeter
Fanuc Focas Library | Position | cnc_relative
Description Reads the relative position data of axis specified with "axis". The relative position is stored in "data[0]" of "ODBAXIS". All axes can be read at a time... [read more]
cnc_relative
Fanuc Focas Library | Position | cnc_relative2
Description Differences between functions of cnc_relative2 and functions of... [read more]
cnc_relative2
Fanuc Focas Library | Position | cnc_skip
Description Reads the skipped position of axis specified with "axis". The skipped position is stored in "data[0]" of "ODBAXIS". All axes can be read at a time by... [read more]
cnc_skip
Fanuc Focas Library | Position | cnc_srvdelay
Description Reads the servo delay amount of axis specified with "axis". The servo delay amount is stored in "data[0]" of "ODBAXIS". All axes can be read at a time by... [read more]
cnc_srvdelay
Fanuc Focas Library | Position | cnc_wrrelpos
Description Sets again relative position against the axis specified with "type". Preset data is specified by "data[0]" in "IDBWRR". If 0 is... [read more]
cnc_wrrelpos
Fanuc Focas Library | Position | flist_Position
CNC: Function related to controlled axis/spindle... [read more]
flist_Position
Modified: 2018-09-24