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 );

Clone this wiki locally