mbed to Dynamixel servo communication.

Dependents:   dynamixel_wheel_test

Committer:
dmgongora
Date:
Wed Aug 19 06:10:52 2015 +0000
Revision:
1:ce081666d225
Parent:
0:fb8a2d249639
Child:
3:61785d105315
Methods now return the error byte from the status packet.

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 0:fb8a2d249639 20
dmgongora 0:fb8a2d249639 21 class Dynamixel
dmgongora 0:fb8a2d249639 22 {
dmgongora 0:fb8a2d249639 23 public:
dmgongora 0:fb8a2d249639 24 Dynamixel(PinName tx, PinName rx, PinName txEnable, uint8_t motorID, int baudrate);
dmgongora 1:ce081666d225 25 uint8_t ping();
dmgongora 1:ce081666d225 26 uint8_t toggleLED(uint8_t ledState);
dmgongora 1:ce081666d225 27 uint8_t move(uint16_t position);
dmgongora 1:ce081666d225 28 uint8_t setSpeed(uint16_t speed);
dmgongora 0:fb8a2d249639 29 private:
dmgongora 0:fb8a2d249639 30 Serial m_link;
dmgongora 0:fb8a2d249639 31 DigitalOut m_txEnable;
dmgongora 0:fb8a2d249639 32 uint8_t m_motorID;
dmgongora 0:fb8a2d249639 33 const int m_baudrate;
dmgongora 0:fb8a2d249639 34 };
dmgongora 0:fb8a2d249639 35 #endif