4
Developing Your Own Applications with C-Motion
An example of the reset procedure is also included in the PMDutil.c source file. Every motion processor com-
mand returns a status code of type PMDuint16. The return code for every command executed should be checked
before attempting to execute more commands.
PMDuint16 result,status;
result = PMDUpdate(&hXAxis);
if (result != PMD_ERR_OK)
{
status = result;
if (result == PMD_ERR_CommandError)
PMDGetHostIOError( &hXAxis, &status );
printf(“Error: %s\n”, PMDGetErrorMessage(status));
return;
}
Internally, C-Motion checks the status of the HostIOError bit after issuing a command. If this bit is
set it will return PMD_ERR_CommandError. The application should then call
PMDGetHostIOError to clear the error bit and determine the cause of the error.
Many commands require additional parameters. Some standard values are defined by C-Motion and
can be used with the appropriate commands. Refer to PMDtypes.h for a complete list of defined
types. An example of calling one of the C-Motion functions with the pre-defined types is shown below.
PMDSetBreakpoint(&hXAxis, PMDBreakpoint1, PMDAxis2, PMDBreakpointActionAbruptStop,
PMDBreakpointActualPositionCrossed);
The following functions are provided by C-Motion in addition to the standard chip command set:
C-Motion command
PMDuint16 PMDGetStatus
PMDuint16 PMDHasError
PMDuint16 PMDIsReady
PMDuint16 PMDHasInterrupt
void PMDCloseAxisInterface
char *PMDGetErrorMessage
void GetCMotionVersion
Arguments
axis_handle
axis_handle
axis_handle
axis_handle
axis_handle
errorCode
MajorVersion
MinorVersion
Function description
Returns the result of executing an IO status read operation.
Only returns a valid result when the interface is parallel.
Returns 1 if the error bit is set in the IO status word and
returns 0 if it is not set. Only returns a valid result when
the interface is parallel.
Returns 1 if the ready bit is set in the IO status word and
returns 0 if it is not set. Only returns a valid result when
the interface is parallel.
Returns 1 if the interrupt bit is set in the IO status word
and returns 0 if it is not set. Only returns a valid result
when the interface is parallel.
Should be called to terminate an interface connection.
Returns a character string representation of the
corresponding PMD chip or C-Motion error code.
Returns the major and minor version number of C-Motion.
54
Navigator-PC/104 User’s Guide