mbed to Dynamixel servo communication.

Dependents:   dynamixel_wheel_test

Committer:
dmgongora
Date:
Wed Aug 19 05:39:57 2015 +0000
Revision:
0:fb8a2d249639
Child:
1:ce081666d225
Dynamixel files packed into a library

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 0:fb8a2d249639 5 // Instruction set
dmgongora 0:fb8a2d249639 6 const unsigned char PING = 0x01;
dmgongora 0:fb8a2d249639 7 const unsigned char READ_DATA = 0x02;
dmgongora 0:fb8a2d249639 8 const unsigned char WRITE_DATA = 0x03;
dmgongora 0:fb8a2d249639 9 const unsigned char REG_WRITE = 0x04;
dmgongora 0:fb8a2d249639 10 const unsigned char ACTION = 0x05;
dmgongora 0:fb8a2d249639 11 const unsigned char RESET = 0x06;
dmgongora 0:fb8a2d249639 12 const unsigned char SYNC_WRITE = 0x83;
dmgongora 0:fb8a2d249639 13 // Control table
dmgongora 0:fb8a2d249639 14 const unsigned char ADDRESS_PRESENT_TEMPERATURE = 0x2B;
dmgongora 0:fb8a2d249639 15 const unsigned char ADDRESS_GOAL_POSITION = 0x1E;
dmgongora 0:fb8a2d249639 16 const unsigned char ADDRESS_LED = 0x19;
dmgongora 0:fb8a2d249639 17 const unsigned char ADDRESS_MOVING_SPEED = 0x20;
dmgongora 0:fb8a2d249639 18
dmgongora 0:fb8a2d249639 19 class Dynamixel
dmgongora 0:fb8a2d249639 20 {
dmgongora 0:fb8a2d249639 21 public:
dmgongora 0:fb8a2d249639 22 Dynamixel(PinName tx, PinName rx, PinName txEnable, uint8_t motorID, int baudrate);
dmgongora 0:fb8a2d249639 23 void ping();
dmgongora 0:fb8a2d249639 24 void toggleLED(uint8_t ledState);
dmgongora 0:fb8a2d249639 25 void move(uint16_t position);
dmgongora 0:fb8a2d249639 26 void setSpeed(uint16_t speed);
dmgongora 0:fb8a2d249639 27 private:
dmgongora 0:fb8a2d249639 28 Serial m_link;
dmgongora 0:fb8a2d249639 29 DigitalOut m_txEnable;
dmgongora 0:fb8a2d249639 30 uint8_t m_motorID;
dmgongora 0:fb8a2d249639 31 const int m_baudrate;
dmgongora 0:fb8a2d249639 32 };
dmgongora 0:fb8a2d249639 33 #endif