Skip to content

4. API: External Module Common Function

waiweng83 edited this page Aug 11, 2015 · 11 revisions

These are the common functions for both the G15 servo motors and sensors.

Function: eEMPing

Send the ping command to external modules. This is used to check whether an external module is connected.

Function Prototype:

EM_ERROR eEMPing(unsigned char ucId);

Parameters:

  • ucId - External Module ID.

Return:

Example:

if (eEMPing(unsigned char ucId) == EM_NO_ERROR) {
    // External module with ID 100 is found.
}
else {
    // External module with ID 100 is not found.
}

Function: eEMGetModel

Get the external module model.

Function Prototype:

EM_ERROR eEMGetModel(unsigned char ucId, EM_MODEL *peModel);

Parameters:

Return:

Example:

EM_MODEL eModel;
EM_ERROR eErrorCode;
eErrorCode = eEMGetModel(100, &eModel);
if ((eErrorCode == EM_NO_ERROR) && (eModel == EM_MODEL_G15)) {
    // Connected external module with ID 100 is G15 servo motor.
}

Function: eEMSetId

Set the external module ID.

Function Prototype:

EM_ERROR eEMSetId(unsigned char ucCurrentId, unsigned char ucNewId);

Parameters:

  • ucCurrentId - External module current ID.
  • ucNewId - External module new ID.

Return:

Example:

// Change the ID from 100 to 200.
eEMSetId(100, 200);

Function: eEMSetAction

Send the set action command to all external module. This is to execute the command previously written with register write.

Function Prototype:

EM_ERROR eEMSetAction(void);

Parameters:

  • Void

Return:

Example:

// Set the G15 position and speed with register write.
eG15SetPositionSpeed( 11, WAIT_ACTION, 500,
                      NORMAL_POSITIONING, 0, POSITION_SPEED_CONTROL );

// Execute the previous command.
eEMSetAction();

Function: eEMFactoryReset

Reset the external module control table to default value.

Function Prototype:

EM_ERROR eEMFactoryReset(unsigned char ucId);

Parameters:

  • ucId - External module ID.

Return:

Example:

// Factory reset the external module with ID 100.
eEMFactoryReset(100);

Clone this wiki locally