You are viewing an older revision! See the latest version

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     sv.setTorque(0xFD, TORQUE_ON);
00011     
00012     while(1) 
00013     {       
00014         // POS Mode, +159.8 Degree, 100*11.2ms = 1120ms, Green LED On
00015         sv.movePos(0xFD, 1002, 100, GLED_ON);
00016         wait(5);
00017         
00018         // POS Mode, -159.8 Degree, 100*11.2ms = 1120ms, Blue LED On
00019         sv.movePos(0xFD, 21, 100, BLED_ON);
00020         wait(5);
00021 
00022         // TURN Mode, CCW Turn, Green LED On
00023         sv.turn(0xFD, 1023, GLED_ON);
00024         wait(5);
00025         
00026         // TURN Mode, CW Turn, Blue LED On        
00027         sv.turn(0xFD, -1023, BLED_ON);
00028         wait(5);
00029         
00030         // POS Mode, 0 Degree, 100*11.2ms = 1120ms, Red LED On
00031         sv.movePos(0xFD, 512, 100, RLED_ON);
00032         wait(5);
00033         
00034         // Clear error status
00035         sv.clear(0xFD);
00036     }
00037 }

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