HerkuleX

Table of Contents

  1. Hello World!
  2. Library

This herkulex library is based on DongBu Robot documentation and protocol.

http://dasarobot.com/guide/herkulexeng.pdf

/media/uploads/passionvirus/mbedandherkulex_i.png /media/uploads/passionvirus/range.png

Hello World!

Import program

00001 #include "mbed.h"
00002 #include "herkulex.h"
00003 
00004 // set serial port and baudrate, (mbed <-> HerculexX)
00005 Herkulex sv(p9, p10, 115200);
00006 
00007 int main() 
00008 {   
00009     sv.clear(0xFD);
00010     
00011     sv.setTorque(0xFD, TORQUE_ON);
00012     
00013     sv.getStatus(0xFD);
00014     
00015     sv.getPos(0xFD);
00016    
00017     while(1) 
00018     {   
00019         // POS Mode, +159.8 Degree, 100*11.2ms = 1120ms, Green LED On
00020         sv.positionControl(0xFD, 1002, 100, GLED_ON);
00021         wait(5);
00022         
00023         // POS Mode, -159.8 Degree, 100*11.2ms = 1120ms, Blue LED On
00024         sv.positionControl(0xFD, 21, 100, BLED_ON);
00025         wait(5);
00026 
00027         // TURN Mode, CCW Turn, Green LED On
00028         sv.velocityControl(0xFD, 1023, GLED_ON);
00029         wait(5);
00030         
00031         // TURN Mode, CW Turn, Blue LED On        
00032         sv.velocityControl(0xFD, -1023, BLED_ON);
00033         wait(5);
00034         
00035         // POS Mode, 0 Degree, 100*11.2ms = 1120ms, Red LED On
00036         sv.positionControl(0xFD, 512, 100, RLED_ON);
00037         wait(5);
00038         
00039         // Clear error status
00040         sv.clear(0xFD);
00041     }
00042 }

Library

Import library

Public Member Functions

Herkulex (PinName tx, PinName rx, uint32_t baudRate)
Create an Herkulex servo object connected to the serial pins and baudrate.
~Herkulex ()
Destroy an Herkulex servo object.
void txPacket (uint8_t packetSize, uint8_t *data)
Transmit packet datas.
void rxPacket (uint8_t packetSize, uint8_t *data)
Receive packet datas.
void clear (uint8_t id)
Clear error status.
void setTorque (uint8_t id, uint8_t cmdTorue)
Set torque setting.
void positionControl (uint8_t id, uint16_t position, uint8_t playtime, uint8_t setLED)
Position Control.
void velocityControl (uint8_t id, int16_t speed, uint8_t setLED)
Velocity Control.
int8_t getStatus (uint8_t id)
Get Status.
int16_t getPos (uint8_t id)
Get Position.

All wikipages