MX106 servo control

Dependencies:   MX28 mbed

Files at this revision

API Documentation at this revision

Comitter:
roger5641
Date:
Sat Jul 23 13:52:03 2016 +0000
Commit message:
MX106 practicing

Changed in this revision

MX28.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 1c2a151939d0 MX28.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MX28.lib	Sat Jul 23 13:52:03 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/LDSC_Robotics_TAs/code/MX28/#2e32ee9f0e51
diff -r 000000000000 -r 1c2a151939d0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jul 23 13:52:03 2016 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "Mx28.h"
+
+
+#define SERVO_ID 0x01               // ID of which we will set Dynamixel too 
+#define SERVO_ControlPin D11       // Control pin of buffer chip, NOTE: this does not matter becasue we are not using a half to full contorl buffer.
+#define SERVO_SET_Baudrate 115200  // Baud rate speed which the Dynamixel will be set too (1Mbps)
+#define TxPin D10
+#define RxPin D2
+#define CW_LIMIT_ANGLE 0x001        // lowest clockwise angle is 1, as when set to 0 it set servo to wheel mode
+#define CCW_LIMIT_ANGLE 0xFFF       // Highest anit-clockwise angle is 0XFFF, as when set to 0 it set servo to wheel mode
+
+DynamixelClass dynamixelClass(SERVO_SET_Baudrate,SERVO_ControlPin,TxPin,RxPin);
+
+int main() 
+{
+    dynamixelClass.setMode(SERVO_ID, SERVO, CW_LIMIT_ANGLE, CCW_LIMIT_ANGLE);    // set mode to SERVO and set angle limits
+          
+    while(1)
+    {
+        dynamixelClass.ledState(SERVO_ID, ON);
+        dynamixelClass.servo(SERVO_ID,0x001,0x040);   // Move servo to angle 1(0.088 degree) at speed 100
+        wait(8);
+        
+        dynamixelClass.ledState(SERVO_ID, OFF);
+        dynamixelClass.servo(SERVO_ID,0xFFF,0x3FF);  //  Move servo to max angle at max speed
+        wait(5);               
+    }  
+}
diff -r 000000000000 -r 1c2a151939d0 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jul 23 13:52:03 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file