mbed to Dynamixel servo communication.

Dependents:   dynamixel_wheel_test

Committer:
dmgongora
Date:
Wed Aug 19 08:59:16 2015 +0000
Revision:
3:61785d105315
Parent:
1:ce081666d225
Child:
4:92ff8b2f3b3f
Added method to get the return delay time

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dmgongora 0:fb8a2d249639 1 #ifndef DEF_DYNAMIXEL
dmgongora 0:fb8a2d249639 2 #define DEF_DYNAMIXEL
dmgongora 0:fb8a2d249639 3
dmgongora 0:fb8a2d249639 4 #include "mbed.h"
dmgongora 1:ce081666d225 5 const unsigned char BROADCAST_ID = 0xfe;
dmgongora 1:ce081666d225 6 const unsigned char STATUS_PACKET_LENGTH = 0x06;
dmgongora 0:fb8a2d249639 7 // Instruction set
dmgongora 0:fb8a2d249639 8 const unsigned char PING = 0x01;
dmgongora 0:fb8a2d249639 9 const unsigned char READ_DATA = 0x02;
dmgongora 0:fb8a2d249639 10 const unsigned char WRITE_DATA = 0x03;
dmgongora 0:fb8a2d249639 11 const unsigned char REG_WRITE = 0x04;
dmgongora 0:fb8a2d249639 12 const unsigned char ACTION = 0x05;
dmgongora 0:fb8a2d249639 13 const unsigned char RESET = 0x06;
dmgongora 0:fb8a2d249639 14 const unsigned char SYNC_WRITE = 0x83;
dmgongora 0:fb8a2d249639 15 // Control table
dmgongora 0:fb8a2d249639 16 const unsigned char ADDRESS_PRESENT_TEMPERATURE = 0x2B;
dmgongora 0:fb8a2d249639 17 const unsigned char ADDRESS_GOAL_POSITION = 0x1E;
dmgongora 0:fb8a2d249639 18 const unsigned char ADDRESS_LED = 0x19;
dmgongora 0:fb8a2d249639 19 const unsigned char ADDRESS_MOVING_SPEED = 0x20;
dmgongora 3:61785d105315 20 const unsigned char ADDRESS_RETURN_DELAY_TIME = 0x05;
dmgongora 3:61785d105315 21 const unsigned char ADDRESS_MAX_TORQUE = 0x0E;
dmgongora 3:61785d105315 22 const unsigned char ADDRESS_TORQUE_ENABLE = 0x18;
dmgongora 0:fb8a2d249639 23
dmgongora 0:fb8a2d249639 24 class Dynamixel
dmgongora 0:fb8a2d249639 25 {
dmgongora 0:fb8a2d249639 26 public:
dmgongora 0:fb8a2d249639 27 Dynamixel(PinName tx, PinName rx, PinName txEnable, uint8_t motorID, int baudrate);
dmgongora 1:ce081666d225 28 uint8_t ping();
dmgongora 1:ce081666d225 29 uint8_t toggleLED(uint8_t ledState);
dmgongora 1:ce081666d225 30 uint8_t move(uint16_t position);
dmgongora 1:ce081666d225 31 uint8_t setSpeed(uint16_t speed);
dmgongora 3:61785d105315 32 uint8_t setReturnDelayTime(uint16_t speed);
dmgongora 3:61785d105315 33 uint8_t getReturnDelayTime();
dmgongora 0:fb8a2d249639 34 private:
dmgongora 0:fb8a2d249639 35 Serial m_link;
dmgongora 0:fb8a2d249639 36 DigitalOut m_txEnable;
dmgongora 0:fb8a2d249639 37 uint8_t m_motorID;
dmgongora 0:fb8a2d249639 38 const int m_baudrate;
dmgongora 0:fb8a2d249639 39 };
dmgongora 0:fb8a2d249639 40 #endif