Repository navigation
5. API: G15 Function
waiweng83 edited this page Aug 11, 2015
·
19 revisions
These are the functions to communicate with the G15 servo motors.
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);
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:
- ucId - G15 ID.
- eWriteMode - Write immediately or wait for action command.
- usPosition - Goal position (0 - 1087).
- ePositioningMode - Positioning mode.
Return:
Example:
// Set the goal position of G15 to 500.
eG15SetPosition(100, WRITE_NOW, 500, NORMAL_POSITIONING);
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:
- ucId - G15 ID.
- eWriteMode - Write immediately or wait for action command.
-
usSpeed - Goal speed.
~ Position mode speed control: 1 to 1023, 0 for maximum.
~ Position mode time control: 0 to 4095 (Unit = 100ms).
~ Wheel mode: 0 to 1023. - eSpeedControlMode - Speed control mode.
Return:
Example:
// Set the speed of G15 in wheel mode to full speed.
eG15SetSpeed( 100, WRITE_NOW, 1023, WHEEL_CW );
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:
- ucId - G15 ID.
- eWriteMode - Write immediately or wait for action command.
- usPosition - Goal position (0 - 1087).
- ePositioningMode - Positioning mode.
-
usSpeed - Goal speed.
~ Position mode speed control: 1 to 1023, 0 for maximum.
~ Position mode time control: 0 to 4095 (Unit = 100ms).
~ Wheel mode: 0 to 1023. - eSpeedControlMode - Speed control mode.
Return:
Example:
// Move the G15 to position 500 in 2 seconds.
eG15SetPositionSpeed( 100, WRITE_NOW, 500,
NORMAL_POSITIONING, 20, POSITION_TIME_CONTROL );