ScOpen.c -- Transition commutation from close-loop to open-loop mode
/* ScOpen.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.
*/
/*
:Transition commutation from close-loop to open-loop mode
Warning! This Sample Program Sets DAC output level = 1.0 Volt
Check your system's safe continuous level (i.e., check amplifier
current gain and safe motor continuous current level)
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"
/* Command line arguments and defaults */
long motorNumber = 0;
Arg argList[] = {
{ "-motor", ArgTypeLONG, &motorNumber, },
{ NULL, ArgTypeINVALID, NULL, }
};
int
main(int argc,
char *argv[])
{
MPIControl control; /* motion controller handle */
MPIControlType controlType;
MPIControlAddress controlAddress;
MPIMotor motor; /* motor handle */
MEIMotorConfig motorConfigXmp;
long returnValue;
long argIndex;
/* Parse command line for Control type and address */
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) ||
(motorNumber >= MEIXmpMAX_Motors)) {
meiPlatformConsole("usage: %s %s\n"
"\t\t[-motor # (0 .. %d)]\n",
argv[0],
ArgUSAGE,
MEIXmpMAX_Motors - 1);
exit(MPIMessageARG_INVALID);
}
/* Create motion controller object */
control =
mpiControlCreate(controlType,
&controlAddress);
msgCHECK(mpiControlValidate(control));
/* Initialize motion controller */
returnValue = mpiControlInit(control);
msgCHECK(returnValue);
printf("Going to open loop ...");
motor =
mpiMotorCreate(control,
motorNumber);
msgCHECK(mpiMotorValidate(motor));
returnValue =
mpiMotorConfigGet(motor,
NULL,
&motorConfigXmp);
msgCHECK(returnValue);
motorConfigXmp.Commutation.Mode = MEIXmpCommModeOPEN_LOOP;
/* Warning!!!!! Setting DAC output level = 1.0 Volt */
motorConfigXmp.Commutation.OutputLevel = (float)3277.0;
returnValue =
mpiMotorConfigSet(motor,
NULL,
&motorConfigXmp);
msgCHECK(returnValue);
/* Delete objects */
returnValue = mpiMotorDelete(motor);
msgCHECK(returnValue);
returnValue = mpiControlDelete(control);
msgCHECK(returnValue);
return ((int)returnValue);
}
|