Repository navigation
5. API: G15 Function
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 );
Set the state of G15 LED.
Function Prototype:
EM_ERROR eG15SetLed( unsigned char ucId,
EM_WRITE_MODE eWriteMode,
unsigned char ucLed);
Parameters:
- ucId - G15 ID.
- eWriteMode - Write immediately or wait for action command.
- ucLed - LED state (0 = Off, 1 = On).
Return:
Example:
// Turn on the G15 LED.
eG15SetLed(100, WRITE_NOW, 1);
Set the state of G15 torque.
Function Prototype:
EM_ERROR eG15SetTorque( unsigned char ucId,
EM_WRITE_MODE eWriteMode,
unsigned char ucTorque );
Parameters:
- ucId - G15 ID.
- eWriteMode - Write immediately or wait for action command.
- ucTorque - Torque state (0 = Off, 1 = On).
Return:
Example:
// Turn on the G15 torque.
eG15SetTorque(100, WRITE_NOW, 1);
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:
- ucId - G15 ID.
- eWriteMode - Write immediately or wait for action command.
- ucTorque - Torque state (0 = Off, 1 = On).
- ucLed - LED state (0 = Off, 1 = On).
Return:
Example:
// Turn on the G15 torque and LED.
eG15SetTorque(100, WRITE_NOW, 1, 1);
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);
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);
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);
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);