Fork from Dynamixel AX12 Servo for MX64 use and not-finishi now

Dependents:   2014-Mx64 2014-mx64-test

Fork of AX12 by Chris Styles

This Library was Fork From Chris Styles's AX12 Library .

Dynamixel MX64 Servo

MX64 is like a new generation Dynamixel Servo Use TTL 2.0 bus, Half-duplex Serial just like a pro-version AX12 300

Quote:

The MX-64T Dynamixel Robot Servo Actuator is the newest generation of Robotis Dynamixel actuator; equipped with an onboard 32bit 72mhz Cortex M3, a contact-less magnetic encoder with 4x the resolution over the AX/RX series, and up to 3mpbs using the new TTL 2.0 bus. Each servo has the ability to track its speed, temperature, shaft position, voltage, and load.

Information

In cace AX12 you can use This Library

Import libraryAX12

new ax12 lib

You need this Dependence Library SerialHalfDuplex library too

Import librarySerialHalfDuplex

Serial Half Duplex implementation

Files at this revision

API Documentation at this revision

Comitter:
ppr2013G2
Date:
Tue May 27 06:24:32 2014 +0000
Parent:
4:acc6261cf054
Child:
6:d8984a551d92
Commit message:
add SetGoalSpeed function

Changed in this revision

MX64.cpp Show annotated file Show diff for this revision Revisions of this file
MX64.h Show annotated file Show diff for this revision Revisions of this file
--- a/MX64.cpp	Fri May 23 09:02:04 2014 +0000
+++ b/MX64.cpp	Tue May 27 06:24:32 2014 +0000
@@ -82,6 +82,42 @@
     return(rVal);
 }
 
+// if flag[0] is set, were blocking
+// if flag[1] is set, we're registering
+// they are mutually exclusive operations
+int MX64::SetGoalSpeed(int degrees, int speed, int flags) {
+
+    char reg_flag = 0;
+    char data[4];
+
+    // set the flag is only the register bit is set in the flag
+    if (flags == 0x2) {
+        reg_flag = 1;
+    }
+
+    // 1023 / 300 * degrees
+    short goal = (1023 * degrees) / 300;
+    short sp = (1023 * speed) / 100;
+    
+#ifdef AX12_DEBUG
+    printf("SetGoalSpeed to 0x%x with speed 0x%x\n",goal,sp);
+#endif
+
+    data[0] = goal & 0xff; // bottom 8 bits
+    data[1] = goal >> 8;   // top 8 bits
+
+    data[2] = sp & 0xff;
+    data[3] = sp >> 8;
+    
+    // write the packet, return the error code
+    int rVal = write(_ID, MX64_REG_GOAL_POSITION, 4, data, reg_flag);
+
+    if (flags == 1) {
+        // block until it comes to a halt
+        while (isMoving()) {}
+    }
+    return(rVal);
+}
 
 // Set continuous rotation speed from -1 to 1
 int MX64::SetCRSpeed(float speed) {
--- a/MX64.h	Fri May 23 09:02:04 2014 +0000
+++ b/MX64.h	Tue May 27 06:24:32 2014 +0000
@@ -113,6 +113,17 @@
      */
     int SetGoal(int degrees, int flags = 0);
 
+    /** Set goal angle in integer degrees, in positional mode
+     *
+     * @param degrees 0-300
+     * @param speed 0-100
+     * @param flags, defaults to 0
+     *    flags[0] = blocking, return when goal position reached 
+     *    flags[1] = register, activate with a broadcast trigger
+     *
+     */
+    int SetGoalSpeed(int degrees, int speed, int flags = 0);
+    
 
     /** Set the speed of the servo in continuous rotation mode
      *