Tested on MX-28

Dependencies:   Dynamixel mbed

Fork of dynamixel_test by Dan Gongora

Revision:
4:7ee9ae120e73
Parent:
1:ef90d942ce78
--- a/main.cpp	Wed Aug 19 05:42:25 2015 +0000
+++ b/main.cpp	Sun Oct 25 05:41:42 2015 +0000
@@ -1,7 +1,7 @@
 /*****************************************************
 - Description: mbed to Dynamixel connection test using
     the library
-- Requirements: 
+- Requirements:
     Dynamixel (i.e. DX116, RX28)
     MAX3088/MAX485 (RS485 transceiver)
 - Connections:
@@ -10,30 +10,47 @@
     Pin 1       --  Pin 14
     Pin 2       --  Pin 15
     Pin 4       --  Pin 13
-    
+
 - Comments:
-    See schematic for wiring details and class 
+    See schematic for wiring details and class
     documentation for available methods.
 *****************************************************/
 #include "mbed.h"
 #include "Dynamixel.h"
 
+DigitalOut debug1(LED1);
+DigitalOut debug2(LED2);
+DigitalOut debug3(LED3);
+DigitalOut debug4(LED4);
 int main()
 {
-    Dynamixel DX116(p13, p14, p15, 9, 57600);
-    
-    DX116.toggleLED(1);
-    wait(0.5);
-    DX116.toggleLED(0);
-    DX116.setSpeed(0);
-    wait(0.5);
-    DX116.move(0);          // MOVE
+    debug1 = 0;
+    debug2 = 0;
+    debug3 = 0;
+    debug4 = 0;
+    Dynamixel motor2(p13, p14, p15, 1, 57600); // TX, RX, TX_ENABLE, MOTOR_ID, BD
+
+    /**************************
+    *** Check communication ***
+    **************************/
+    motor2.toggleLED(1);
     wait(1);
-    DX116.setSpeed(100);
+    motor2.toggleLED(0);
+    /**************************
+    ***** Set max angles  *****
+    **************************/
+    motor2.setAngleLimit(0, ADDRESS_CW_ANGLE_LIMIT);
+    wait(0.5);
+    motor2.setAngleLimit(0, ADDRESS_CCW_ANGLE_LIMIT);
     wait(0.5);
-    DX116.move(1023);       // MOVE
-    wait(1);
-    DX116.setSpeed(1023);
-    wait(1);
-    DX116.move(0);          // MOVE
-}   
\ No newline at end of file
+    /**************************
+    ******** Set speed ********
+    **************************/
+    motor2.setSpeed(50); // 0-1023 CW
+    debug1 = 1;
+    wait(2);
+    motor2.setSpeed(2000); // 1024-2047 CCW
+    wait(2);
+    debug2 = 1;
+    motor2.setSpeed(0);
+}
\ No newline at end of file