|
/* motorDemandGet(...) demonstrates how to read the primary and
auxiliary motor demand signals. mpiMotorMemory(...) obtains the
motor control memory pointer. The pointer's address is then
passed into mpiMotorMemoryGet(...) to obtain the demand values.
Note: MEIXmpMotor *memory must be casted as (void *) in
mpiMotorMemory.
*/
long motorDemandGet(MPIMotor motor,
float *primary,
float *aux)
{
MEIXmpMotor *memory;
long returnValue;
/* Get motor control memory pointer */
returnValue =
mpiMotorMemory(motor,
(void *)&memory);
/* Get primary motor demand value */
if(returnValue == MPIMessageOK)
{
returnValue =
mpiMotorMemoryGet(motor,
primary,
&memory->IO.Demand.Channel[0].Level,
sizeof(memory->IO.Demand.Channel[0].Level));
}
/* Get auxiliary motor demand value */
if(returnValue == MPIMessageOK)
{
returnValue =
mpiMotorMemoryGet(motor,
aux,
&memory->IO.Demand.Channel[1].Level,
sizeof(memory->IO.Demand.Channel[1].Level));
}
return returnValue;
}
|