.

     

MPI Application Template
template.c
 

settle1.c -- Configure in-position tolerance and settling time for an axis.
/* settle1.c */

/* Copyright(c) 1991-2006 by Motion Engineering, Inc.  All rights reserved.
 *
 * This software  contains proprietary and  confidential information  of
 * Motion Engineering Inc., and its suppliers.  Except as may be set forth
 * in the license agreement under which  this software is supplied, use,
 * disclosure, or  reproduction is prohibited without the prior express
 * written consent of Motion Engineering, Inc.
 */

/*

:Configure in-position tolerance and settling time for an axis.

A simple settling configuration which sets the Fine Position Tolerance
 and Settling Time for an axis.  Both are required for the
 MPIXmpStatusIN_FINE_POSITION status bit.  The settling criteria are:

    1)  The absolute value of the position error is less than or equal to
        the fine position tolerance.
    2)  The absolute value of the velocity is less than or equal to the
        velocity tolerance.
    3)  Both criteria 1 and 2 above have been satisfied for the settling
        time.  Whenever either criteria 1 or 2 is not satisfied,
        IN_FINE_POSITION is cleared and the settling tier is reset.

Warning!  This is a sample program to assist in the integration of an
 MEI motion controller with your application.  It may not contain all
 of the logic and safety features that your application requires.

*/

#include <stdlib.h>
#include <stdio.h>

#include "stdmpi.h"
#include "stdmei.h"

#include "apputil.h"

#if defined(ARG_MAIN_RENAME)
#define main    settle1Main

argMainRENAME(main, settle1)
#endif

/* Command line arguments and defaults */
long    axisNumber  = 0;

Arg argList[] = {
    {   "-axis",    ArgTypeLONG,    &axisNumber,    },

    {   NULL,       ArgTypeINVALID, NULL,   }
};

int
    main(int    argc,
         char   *argv[])
{
    MPIControl      control;        /* Motion controller handle */
    MPIAxis         axis;           /* Axis handle(s) */

    MPIAxisConfig   axisConfig;     /* Axis configuration */

    long    returnValue;            /* Return value from library */

    MPIControlType      controlType;
    MPIControlAddress   controlAddress;

    long    argIndex;

    argIndex =
        argControl(argc,
                   argv,
                   &controlType,
                   &controlAddress);

    /* Parse command line for application-specific arguments */
    while (argIndex < argc) {
        long    argIndexNew;

        argIndexNew = argSet(argList, argIndex, argc, argv);

        if (argIndexNew <= argIndex) {
            argIndex = argIndexNew;
            break;
        }
        else {
            argIndex = argIndexNew;
        }
    }

    /* Check for unknown/invalid command line arguments */
    if ((argIndex < argc) ||
        (axisNumber >= MPIXmpMAX_Axes)) {
        mpiPlatformConsole("usage: %s %s\n"
                           "\t\t[-axis # (0 .. %d)]\n",
                            argv[0],
                            ArgUSAGE,
                            MPIXmpMAX_Axes - 1);
        exit(MPIMessageARG_INVALID);
    }

    /* Create motion controller object */
    control =
        mpiControlCreate(controlType,
                         &controlAddress);
    msgCHECK(mpiControlValidate(control));

    /* Initialize motion controller */
    returnValue = mpiControlInit(control);
    msgCHECK(returnValue);

    /* Create axis object on controller*/
    axis =
        mpiAxisCreate(control,
                      axisNumber);
    msgCHECK(mpiAxisValidate(axis));

    /* Configure axis */
    returnValue =
        mpiAxisConfigGet(axis,
                         &axisConfig,
                         NULL);
    msgCHECK(returnValue);

    axisConfig.inPosition.tolerance.positionFine = (float)50.0;
    axisConfig.inPosition.tolerance.velocity     = (float)100.0;
    axisConfig.inPosition.settlingTime           = (float)0.5; /* .5 seconds */

    returnValue =
        mpiAxisConfigSet(axis,
                         &axisConfig,
                         NULL);
    msgCHECK(returnValue);

    returnValue = mpiAxisDelete(axis);
    msgCHECK(returnValue);

    returnValue = mpiControlDelete(control);
    msgCHECK(returnValue);

    return ((int)returnValue);
}


      
       Legal Notice  |  Tech Email  |  Feedback
      
Copyright ©
2001-2009 Motion Engineering