HerkuleX-HelloWorld
This herkulex library is based on DongBu Robot documentation and protocol.
http://dasarobot.com/guide/herkulexeng.pdf
main.cpp@2:7004e3d0281f, 2013-01-14 (annotated)
- Committer:
- passionvirus
- Date:
- Mon Jan 14 21:04:59 2013 +0000
- Revision:
- 2:7004e3d0281f
- Parent:
- 1:ef646c52e08f
new example code (rxPacket, getStatus, getPosition)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
passionvirus | 0:50f3665aec00 | 1 | #include "mbed.h" |
passionvirus | 0:50f3665aec00 | 2 | #include "herkulex.h" |
passionvirus | 0:50f3665aec00 | 3 | |
passionvirus | 1:ef646c52e08f | 4 | // set serial port and baudrate, (mbed <-> HerculexX) |
passionvirus | 0:50f3665aec00 | 5 | Herkulex sv(p9, p10, 115200); |
passionvirus | 0:50f3665aec00 | 6 | |
passionvirus | 0:50f3665aec00 | 7 | int main() |
passionvirus | 0:50f3665aec00 | 8 | { |
passionvirus | 1:ef646c52e08f | 9 | sv.clear(0xFD); |
passionvirus | 2:7004e3d0281f | 10 | |
passionvirus | 0:50f3665aec00 | 11 | sv.setTorque(0xFD, TORQUE_ON); |
passionvirus | 1:ef646c52e08f | 12 | |
passionvirus | 2:7004e3d0281f | 13 | sv.getStatus(0xFD); |
passionvirus | 2:7004e3d0281f | 14 | |
passionvirus | 2:7004e3d0281f | 15 | sv.getPos(0xFD); |
passionvirus | 2:7004e3d0281f | 16 | |
passionvirus | 0:50f3665aec00 | 17 | while(1) |
passionvirus | 2:7004e3d0281f | 18 | { |
passionvirus | 1:ef646c52e08f | 19 | // POS Mode, +159.8 Degree, 100*11.2ms = 1120ms, Green LED On |
passionvirus | 2:7004e3d0281f | 20 | sv.positionControl(0xFD, 1002, 100, GLED_ON); |
passionvirus | 1:ef646c52e08f | 21 | wait(5); |
passionvirus | 0:50f3665aec00 | 22 | |
passionvirus | 1:ef646c52e08f | 23 | // POS Mode, -159.8 Degree, 100*11.2ms = 1120ms, Blue LED On |
passionvirus | 2:7004e3d0281f | 24 | sv.positionControl(0xFD, 21, 100, BLED_ON); |
passionvirus | 1:ef646c52e08f | 25 | wait(5); |
passionvirus | 1:ef646c52e08f | 26 | |
passionvirus | 1:ef646c52e08f | 27 | // TURN Mode, CCW Turn, Green LED On |
passionvirus | 2:7004e3d0281f | 28 | sv.velocityControl(0xFD, 1023, GLED_ON); |
passionvirus | 1:ef646c52e08f | 29 | wait(5); |
passionvirus | 1:ef646c52e08f | 30 | |
passionvirus | 1:ef646c52e08f | 31 | // TURN Mode, CW Turn, Blue LED On |
passionvirus | 2:7004e3d0281f | 32 | sv.velocityControl(0xFD, -1023, BLED_ON); |
passionvirus | 1:ef646c52e08f | 33 | wait(5); |
passionvirus | 1:ef646c52e08f | 34 | |
passionvirus | 1:ef646c52e08f | 35 | // POS Mode, 0 Degree, 100*11.2ms = 1120ms, Red LED On |
passionvirus | 2:7004e3d0281f | 36 | sv.positionControl(0xFD, 512, 100, RLED_ON); |
passionvirus | 1:ef646c52e08f | 37 | wait(5); |
passionvirus | 1:ef646c52e08f | 38 | |
passionvirus | 1:ef646c52e08f | 39 | // Clear error status |
passionvirus | 1:ef646c52e08f | 40 | sv.clear(0xFD); |
passionvirus | 0:50f3665aec00 | 41 | } |
passionvirus | 0:50f3665aec00 | 42 | } |