Skip to content

5. API: G15 Function

waiweng83 edited this page Aug 11, 2015 · 19 revisions

These are the functions to communicate with the G15 servo motors.

Function: eG15GetPosition

Get the current position (0 - 1087).

Function Prototype:

EM_ERROR eG15GetPosition(unsigned char ucId, unsigned short *pusPosition);

Parameters:

  • ucId - G15 ID.
  • pusPosition - Buffer to return the current position.

Return:

Example:

// Get the G15 current position.
unsigned short usPosition;
eG15GetPosition(100, &usPosition);

Function: eG15SetPosition

Set the goal position for G15 servo motor.

Function Prototype:

EM_ERROR eG15SetPosition( unsigned char ucId,
                          EM_WRITE_MODE eWriteMode,
                          unsigned short usPosition,
                          G15_POSITIONING_MODE ePositioningMode );

Parameters:

Return:

Example:

// Set the goal position of G15 to 500.
eG15SetPosition(100, WRITE_NOW, 500, NORMAL_POSITIONING);

Function: eG15SetSpeed

Set the speed for G15 servo motor.

Function Prototype:

EM_ERROR eG15SetSpeed( unsigned char ucId,
                       EM_WRITE_MODE eWriteMode,
                       unsigned short usSpeed,
                       G15_SPEED_CONTROL_MODE eSpeedControlMode );

Parameters:

Return:

Example:

// Set the speed of G15 in wheel mode to full speed.
eG15SetSpeed(100, WRITE_NOW, 1023, WHEEL_CW);

Function: eG15SetPositionSpeed

Set the goal position and speed for G15 servo motor.

Function Prototype:

EM_ERROR eG15SetPositionSpeed( unsigned char ucId,
                               EM_WRITE_MODE eWriteMode,
                               unsigned short usPosition,
                               G15_POSITIONING_MODE ePositioningMode,
                               unsigned short usSpeed,
                               G15_SPEED_CONTROL_MODE eSpeedControlMode );

Parameters:

Return:

Example:

// Move the G15 to position 500 in 2 seconds.
eG15SetPositionSpeed( 100, WRITE_NOW, 500,
                      NORMAL_POSITIONING, 20, POSITION_TIME_CONTROL );

Function: eG15SetLed

Set the state of G15 LED.

Function Prototype:

EM_ERROR eG15SetLed( unsigned char ucId,
                     EM_WRITE_MODE eWriteMode,
                     unsigned char ucLed);

Parameters:

Return:

Example:

// Turn on the G15 LED.
eG15SetLed(100, WRITE_NOW, 1);

Function: eG15SetTorque

Set the state of G15 torque.

Function Prototype:

EM_ERROR eG15SetTorque( unsigned char ucId,
                        EM_WRITE_MODE eWriteMode,
                        unsigned char ucTorque );

Parameters:

Return:

Example:

// Turn on the G15 torque.
eG15SetTorque(100, WRITE_NOW, 1);

Function: eG15SetTorqueLed

Set the state of G15 torque and LED.

Function Prototype:

EM_ERROR eG15SetTorqueLed( unsigned char ucId,
                           EM_WRITE_MODE eWriteMode,
                           unsigned char ucTorque,
                           unsigned char ucLed );

Parameters:

Return:

Example:

// Turn on the G15 torque and LED.
eG15SetTorque(100, WRITE_NOW, 1, 1);

Function: eG15GetAngleLimit

Get the G15 CW and CCW angle limit.

Function Prototype:

EM_ERROR eG15GetAngleLimit( unsigned char ucId,
                            unsigned short *pusLimitCw,
                            unsigned short *pusLimitCcw );

Parameters:

  • ucId - G15 ID.
  • pusLimitCw - Buffer to return the CW Angle Limit (0 - 1087).
  • pusLimitCcw - Buffer to return the CCW Angle Limit (0 - 1087).

Return:

Example:

// Read the angle limits from G15.
unsigned short usCwLimit;
unsigned short usCCwLimit;
eG15GetAngleLimit(100, &usCwLimit, &usCcwLimit);

Function: eG15SetAngleLimit

Set the G15 CW and CCW angle limit. G15 will be in wheel mode if CW limit == CCW limit.

Function Prototype:

EM_ERROR eG15SetAngleLimit( unsigned char ucId,
                            unsigned short usLimitCw,
                            unsigned short usLimitCcw );

Parameters:

  • ucId - G15 ID.
  • usLimitCw - CW Angle Limit (0 - 1087).
  • usLimitCcw - CCW Angle Limit (0 - 1087).

Return:

Example:

// Set the G15 to wheel mode.
eG15SetAngleLimit(100, 0, 0);

Function: eG15SetTorqueLimit

Set the G15 torque limit.

Function Prototype:

EM_ERROR eG15SetTorqueLimit(unsigned char ucId, unsigned short usTorqueLimit);

Parameters:

  • ucId - G15 ID.
  • usTorqueLimit - G15 torque Limit (0 - 1023).

Return:

Example:

// Set the G15 torque limit to maximum.
eG15SetTorqueLimit(100, 1023);

Function: eG15ResetRegister

Reset the G15 control table to default value except the ID.

Function Prototype:

EM_ERROR eG15ResetRegister(unsigned char ucId);

Parameters:

  • ucId - G15 ID.

Return:

Example:

// Reset the G15 with ID 100.
eG15ResetRegister(100);