Still Test

Dependencies:   DXL_SDK_For_F446RE RobotControl_7Axis Matrix mbed

Committer:
stanley1228
Date:
Wed Feb 08 00:11:41 2017 +0800
Revision:
3:8a9407817ba9
Parent:
2:fb9508744bc4
Child:
4:53ef39fbf9d9
1.change hal_timeout
2.test getpos for 1 motor ok

Who changed what in which revision?

UserRevisionLine numberNew contents of line
stanley1228 0:1780ffc33286 1 #include "mbed.h"
stanley1228 0:1780ffc33286 2 #include "dynamixel.h"
stanley1228 0:1780ffc33286 3
stanley1228 0:1780ffc33286 4 #define ADDRESS_LED 0x19
stanley1228 2:fb9508744bc4 5 #define GOAL_POSITION 30
stanley1228 0:1780ffc33286 6
stanley1228 0:1780ffc33286 7 DigitalOut myled(LED1);
stanley1228 0:1780ffc33286 8 Serial pc(SERIAL_TX, SERIAL_RX);
stanley1228 0:1780ffc33286 9
stanley1228 0:1780ffc33286 10
stanley1228 0:1780ffc33286 11 int main()
stanley1228 0:1780ffc33286 12 {
stanley1228 0:1780ffc33286 13 int rt =0;
stanley1228 0:1780ffc33286 14
stanley1228 0:1780ffc33286 15 pc.printf("start\n",rt);
stanley1228 0:1780ffc33286 16
stanley1228 0:1780ffc33286 17 rt=dxl_initialize( 1, 1);
stanley1228 0:1780ffc33286 18 pc.printf("dxl_initialize rt=%d\n",rt);
stanley1228 0:1780ffc33286 19
stanley1228 3:8a9407817ba9 20 int nnn=-100;
stanley1228 3:8a9407817ba9 21 pc.printf("nnn=%d\n",nnn);
stanley1228 3:8a9407817ba9 22
stanley1228 3:8a9407817ba9 23 nnn=-1000;
stanley1228 3:8a9407817ba9 24 pc.printf("nnn=%d\n",nnn);
stanley1228 0:1780ffc33286 25 myled = 0; // LED is ON
stanley1228 0:1780ffc33286 26
stanley1228 0:1780ffc33286 27 /**************************
stanley1228 0:1780ffc33286 28 *** Check communication ***
stanley1228 0:1780ffc33286 29 **************************/
stanley1228 2:fb9508744bc4 30 //dxl_write_byte(3,ADDRESS_LED,0);
stanley1228 0:1780ffc33286 31 //dxl_ping(3);
stanley1228 0:1780ffc33286 32
stanley1228 3:8a9407817ba9 33 short int pos=0; //16bit
stanley1228 0:1780ffc33286 34 while(1)
stanley1228 0:1780ffc33286 35 {
stanley1228 2:fb9508744bc4 36
stanley1228 3:8a9407817ba9 37 //pc.printf("before=%d\n",rt);
stanley1228 2:fb9508744bc4 38
stanley1228 2:fb9508744bc4 39 //dxl_write_word(3,GOAL_POSITION,400);
stanley1228 3:8a9407817ba9 40 //setPosition(3,2048,10);
stanley1228 3:8a9407817ba9 41 //pc.printf("after=%d\n",rt);
stanley1228 0:1780ffc33286 42 //myled = 1; // LED is ON
stanley1228 3:8a9407817ba9 43 //wait(4);
stanley1228 2:fb9508744bc4 44 //dxl_write_word(3,GOAL_POSITION,-400);
stanley1228 3:8a9407817ba9 45 //setPosition(3,-2048,10);
stanley1228 0:1780ffc33286 46 //myled = 0; // LED is ON
stanley1228 3:8a9407817ba9 47 //wait(4);
stanley1228 3:8a9407817ba9 48
stanley1228 3:8a9407817ba9 49 pos=dxl_read_word(3,PRESENT_POS);
stanley1228 3:8a9407817ba9 50 pc.printf("pos=%d\n",pos);
stanley1228 3:8a9407817ba9 51 wait_ms(200);
stanley1228 3:8a9407817ba9 52
stanley1228 2:fb9508744bc4 53
stanley1228 0:1780ffc33286 54 }
stanley1228 0:1780ffc33286 55 }