News CNCnetPDM About us Support  
       
  

PMC_WRPMCRNG | PMC

TOP

Description

Writes the PMC data of the specified PMC address/range.

This function is used to exchange the data between the application on MMC function and LADDER software on PMC.

MTConnect Fanuc Adapter

Universal Fanuc Driver

Fanuc Focas Library CD

Declaration

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

FWLIBAPI short WINAPI pmc_wrpmcrng(unsigned short FlibHndl, short length,IODBPMC *buf);

Arguments

FlibHndl   [ in ]

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

length   [ in ]
Specify the data block length.
data_type is 0(byte type) : length = 8 + N
data_type is 1(word type) : length = 8 + N × 2
data_type is 2(long type) : length = 8 + N × 4
data_type is 4(32-bit floating-point type) : length = 8 + N × 4
data_type is 5(64-bit floating-point type) : length = 8 + N × 8
* N is the number of written data.
buf   [ in ]

Pointer to the IODBPMC structure.
The IODBPMC structure is as follows.
In case of using PMC memory D in Series 0i-F, 30i/31i/32i/35i-B, PMi-A, define character constant "PMCMEMD" at compiling by the '-D' option.


#if defined (PMCMEMD)
typedef struct iodbpmc {
    short            type_a ;   /* Kind of PMC address */
    short            type_d ;   /* Type of the PMC data */
    unsigned short   datano_s ; /* Start PMC address number */
    unsigned short   datano_e ; /* End PMC address number */
    union {
        char    cdata[N] ;/* The PMC data(byte type) */
        short   idata[N] ;/*             (word type) */
        long    ldata[N] ;/*             (long type) */
        float   fdata[N] ; /*            (32-bit floating-point type)*/
        double  dfdata[N]; /*            (64-bit floating-point type)*/
    } u ;           /* N is the number of read data */
} IODBPMC ;
#else
typedef struct  iodbpmc {
    short   type_a ;    /* Kind of PMC address */
    short   type_d ;    /* Type of the PMC data */
    short   datano_s ;  /* Start PMC address number */
    short   datano_e ;  /* End PMC address number */
    union {
        char    cdata[N] ;/* The PMC data(byte type) */
        short   idata[N] ;/*             (word type) */
        long    ldata[N] ;/*             (long type) */
        float   fdata[N] ; /*            (32-bit floating-point type)*/
        double  dfdata[N]; /*            (64-bit floating-point type)*/
    } u ;           /* N is the number of written data */
} IODBPMC ;
#endif
type_a
Specify the identification code corresponding to the kind of the PMC address.
type_d
Specify the type of the PMC data.
It must be the same one as the type of data of the PMC side.
0:Byte type
1:Word type
2:Long type
4:32-bit floating-point type(30i-B Series/0i-F/PMi-A only)
5:64-bit floating-point type(30i-B Series/0i-F/PMi-A only)
datano_s
Specify the start PMC address number.
datano_e
Specify the end PMC address number.
See "The referenceable range of PMC data" of "Read PMC data(area specified) (pmc_rdpmcrng)" about the kind of the PMC address, the start address, and the end address.

Example of specifying argument

  1. 250 is written in D0100(It is assumed the word type)
  2. buf.type_a 9
    buf.type_d 1
    buf.datano_s 100
    buf.datano_e 101
    length 8+2×1 (=10)
    buf.u.idata[0] 250
  3. 0 is written all of R0200,..,R0209(It is assumed byte type)
  4. buf.type_a 5
    buf.type_d 0
    buf.datano_s 200
    buf.datano_e 209
    length 8+1×10 (=18)
    buf.u.cdata[0]
    ,..,buf.u.cdata[9]
    0 all
  5. 1.1 is written in D0100(It is assumed 32-bit floating-point type)
  6. buf.type_a 9
    buf.type_d 4
    buf.datano_s 100
    buf.datano_e 103
    length 8+4×1 (=12)
    buf.u.idata[0] 1.1
  7. -2.2 and 33.3 are written in R104, R112(It is assumed 64-bit floating-point type)
  8. buf.type_a 5
    buf.type_d 5
    buf.datano_s 104
    buf.datano_e 119
    length 8+8×2 (=24)
    buf.u.idata[0] -2.2
    buf.u.idata[1] 33.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_NOPMC
(1)
There is no PMC.
EW_LENGTH
(2)
Data block length error
Size of IODBPMC structure(length) is wrong.
EW_RANGE
(3)
Address range error
Address range error PMC address number(datano_s,datano_e) is wrong.
EW_ATTRIB
(4)
Data attribute error
Kind of PMC address(type_a) or type of PMC data (type_d) is wrong.
EW_PASSWD
(17)
The data of specified range cannot be written because the data is protected.
(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,

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

0i-D0i-F16i18i30i-A30i-B
P (Punch press)O O O O - O
L (Laser) - - O - - O
W (Wire) - - O O O O


Power Mate i-DO
Power Mate i-HO
Power Motion i-AO

"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

pmc_rdpmcrng   pmc_rdpmcinfo  

Example(C Language)


The following program writes the PMC data within the specified
PMC address range.

#include "fwlib32.h"

/* start/end are start/end PMC address to be written. */
/* values is array of value to be written. */
short example( short start, short end, char* values )
{
        IODBPMC *pmcrng;
        short ret, idx;
        unsigned short length;

        length = 8 + (end - start + 1);
        pmcrng = (IODBPMC *)malloc( length );
        pmcrng->type_a = 0;                       // In case that kind of PMC address is G
        pmcrng->type_d = 0;                       // In case that type of PMC data is Byte
        pmcrng->datano_s = start;
        pmcrng->datano_e = end;
        for (idx = 0; idx < end - start + 1; idx++)
        {
                pmcrng->u.cdata[idx] = values[idx];
        }

        ret = pmc_wrpmcrng( h, length, pmcrng );
        if ( ret )
        {
                printf( "ERROR!(%d)\n", ret );
        }
        free( pmcrng ) ;
        return ( ret ) ;
}

Example(C#)


The following program writes the PMC data within the specified
PMC address range.

class example
{
    /* start/end are start/end PMC address to be written. */
    /* values is array of value to be written. */
    public short sample(short start, short end, byte[] value)
    {
        Focas1.IODBPMC0 pmcHead = new Focas1.IODBPMC0();
        short ret, idx;
        ushort length;

        length = (ushort)(8 + (end - start + 1));
        byte[] bytes = new byte[length];
        IntPtr ptrHead = Marshal.AllocCoTaskMem(Marshal.SizeOf(pmcHead));

        pmcHead.type_a = 0;                    // In case that kind of PMC address is G
        pmcHead.type_d = 0;                    // In case that type of PMC data is Byte
        pmcHead.datano_s = start;
        pmcHead.datano_e = end;
        Marshal.StructureToPtr(pmcHead, ptrHead, false);
        Marshal.Copy(ptrHead, bytes, 0, 8);
        for (idx = 0; idx < end - start + 1; idx++)
        {
            bytes[8 + idx] = value[idx];
        }

        ret = Focas1.pmc_wrpmcrng(h, length, bytes);
        if (ret != Focas1.EW_OK)
        {
            Console.WriteLine("ERROR!({0})", ret);
        }
        Marshal.FreeCoTaskMem(ptrHead);
        return (ret);
    }
}
}

Privacy notice

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

https://www.inventcom.net/fanuc-focas-library/pmc/pmc_wrpmcrng

Fanuc Focas Library | Pmc | flist_Pmc

PMC: Function related to PMC... [read more]
Fanuc Focas Library | Pmc | flist_Pmc

Fanuc Focas Library | Pmc | pmc_crdmsg

Reads the data of 32 bytes transmitted from the PMC. It is necessary to transmit the data on the PMC side to read the... [read more]
Fanuc Focas Library | Pmc | pmc_crdmsg

Fanuc Focas Library | Pmc | pmc_cwrmsg

Writes the data of 32 bytes transmitted to the PMC. It is necessary to receive the data on the PMC side to write the... [read more]
Fanuc Focas Library | Pmc | pmc_cwrmsg

Fanuc Focas Library | Pmc | pmc_getdtailerr

Gets the detailed error information after the function has been executed. The detailed error information is stored in err_no, err_dtno of... [read more]
Fanuc Focas Library | Pmc | pmc_getdtailerr

Fanuc Focas Library | Pmc | pmc_get_current_pmc_unit

Get the current PMC unit type.... [read more]
Fanuc Focas Library | Pmc | pmc_get_current_pmc_unit

Fanuc Focas Library | Pmc | pmc_get_number_of_pmc

Reads the number of existing PMC paths (i.e. number of unit).... [read more]
Fanuc Focas Library | Pmc | pmc_get_number_of_pmc

Fanuc Focas Library | Pmc | pmc_get_pmc_unit_types

Reads the PMC system information that shows what kind of PMC units compose the multi-path PMC system.... [read more]
Fanuc Focas Library | Pmc | pmc_get_pmc_unit_types

Fanuc Focas Library | Pmc | pmc_get_timer_type

Reads the PMC timer type of the specified timer number.... [read more]
Fanuc Focas Library | Pmc | pmc_get_timer_type

Fanuc Focas Library | Pmc | pmc_kpmsiz

Reads the maximum size of the extended backup memory.... [read more]
Fanuc Focas Library | Pmc | pmc_kpmsiz

Fanuc Focas Library | Pmc | pmc_rdalmmsg

Reads the alarm messages from PMC.... [read more]
Fanuc Focas Library | Pmc | pmc_rdalmmsg

Fanuc Focas Library | Pmc | pmc_rdcntldata

Reads the control data to manage PMC data table (address D). This function is not available at PMC-NA. Refer to the programming... [read more]
Fanuc Focas Library | Pmc | pmc_rdcntldata

Fanuc Focas Library | Pmc | pmc_rdcntlgrp

Reads the total number of groups of the control data to manage PMC data table(address D). This function is not available at PMC-NA.... [read more]
Fanuc Focas Library | Pmc | pmc_rdcntlgrp

Fanuc Focas Library | Pmc | pmc_rdkpm

Reads the contents of the extended backup memory of PMC specified by offset, length. The data are stored in data... [read more]
Fanuc Focas Library | Pmc | pmc_rdkpm

Fanuc Focas Library | Pmc | pmc_rdkpm2

Reads the contents of the extended backup memory of PMC specified by offset, length. The data are stored in data... [read more]
Fanuc Focas Library | Pmc | pmc_rdkpm2

Fanuc Focas Library | Pmc | pmc_rdmsg

Reads the data of 32 bytes transmitted from the PMC. It is necessary to transmit the data on the PMC side to read the... [read more]
Fanuc Focas Library | Pmc | pmc_rdmsg

Fanuc Focas Library | Pmc | pmc_rdpmcinfo

Reads the data information about the attribute of each kind of PMC, the effective range of PMC address, etc.... [read more]
Fanuc Focas Library | Pmc | pmc_rdpmcinfo

Fanuc Focas Library | Pmc | pmc_rdpmcparam

The PMC parameter(timer, counter, keep relay, and data) is uploaded by the tape format. When you execute this function, change to... [read more]
Fanuc Focas Library | Pmc | pmc_rdpmcparam

Fanuc Focas Library | Pmc | pmc_rdpmcrng

Reads the PMC data of the specified PMC address/range. This function is used to exchange the data between the... [read more]
Fanuc Focas Library | Pmc | pmc_rdpmcrng

Fanuc Focas Library | Pmc | pmc_rdpmctitle

Reads the PMC title data from PMC. When this function is executed while editing the title data with PMC, the return value... [read more]
Fanuc Focas Library | Pmc | pmc_rdpmctitle

Fanuc Focas Library | Pmc | pmc_rdprmend

End of upload of the PMC parameter(timer, counter, keep relay, and data) by the tape format. This function is executable other... [read more]
Fanuc Focas Library | Pmc | pmc_rdprmend

Fanuc Focas Library | Pmc | pmc_rdprmstart

Starts uploading the PMC parameter(timer, counter, keep relay, and data) of the tape format. To uploading of PMC parameter, this... [read more]
Fanuc Focas Library | Pmc | pmc_rdprmstart

Fanuc Focas Library | Pmc | pmc_select_pmc_unit

Selects PMC that will be the target of other PMC FOCAS2 function by the unit type.... [read more]
Fanuc Focas Library | Pmc | pmc_select_pmc_unit

Fanuc Focas Library | Pmc | pmc_set_timer_type

Writes the PMC timer type of the specified timer number.... [read more]
Fanuc Focas Library | Pmc | pmc_set_timer_type

Fanuc Focas Library | Pmc | pmc_wrcntldata

Writes the control data to manage PMC data table (address D). This function is not available at PMC-NA. Refer to the programming... [read more]
Fanuc Focas Library | Pmc | pmc_wrcntldata

Fanuc Focas Library | Pmc | pmc_wrcntlgrp

Writes the total number of groups of the control data to manage PMC data table(address D). This function is not available at PMC-NA.... [read more]
Fanuc Focas Library | Pmc | pmc_wrcntlgrp

Fanuc Focas Library | Pmc | pmc_wrkpm

Writes the data to the extended backup memory of PMC specified by offset, length. The data must be stored in data as... [read more]
Fanuc Focas Library | Pmc | pmc_wrkpm

Fanuc Focas Library | Pmc | pmc_wrkpm2

Writes the data to the extended backup memory of PMC specified by offset, length. The data must be stored in data as... [read more]
Fanuc Focas Library | Pmc | pmc_wrkpm2

Fanuc Focas Library | Pmc | pmc_wrmsg

Writes the data of 32 bytes transmitted to the PMC. It is necessary to receive the data on the PMC side to write the... [read more]
Fanuc Focas Library | Pmc | pmc_wrmsg

Fanuc Focas Library | Pmc | pmc_wrpmcparam

The PMC parameter(timer, counter, keep relay, and data) is downloaded by the tape format. When you execute this function, set... [read more]
Fanuc Focas Library | Pmc | pmc_wrpmcparam

Fanuc Focas Library | Pmc | pmc_wrprmend

End of download of the PMC parameter(timer, counter, keep relay, and data) by the tape format. Even if the PWE of CNC parameter is... [read more]
Fanuc Focas Library | Pmc | pmc_wrprmend

Fanuc Focas Library | Pmc | pmc_wrprmstart

Starts downloading the PMC parameter(timer, counter, keep relay, and data) of the tape format. To downloading of PMC parameter,... [read more]
Fanuc Focas Library | Pmc | pmc_wrprmstart
Modified: 2023-12-05