Marco - Giancarlo Tesi / Mbed OS Dynamixel_MX_Motors_Series_TOSCA

Dependencies:   MX64

main.cpp

Committer:
marcodesilva
Date:
2019-09-20
Revision:
7:3cc453a7befd
Parent:
5:2fb46c15828f

File content as of revision 7:3cc453a7befd:

#include "mbed.h"
#include "MX.h"
#include "UARTSerial_half.h"
 

// It creates an instance of the DigitalOut class.
// myled is the name of the variable (instance).
// The instance shall 'point' to the pin LED1, that is the led on the board
DigitalOut myled(LED1);

// se si vuole collegare un mx28 non c'è alcuna differenza 
//MX(PinName tx,             PinName rx,        PinName dir, int ID, int baud)
//     PB_9 = D14 = TX,   PB_8 = D15 = RX,   PF_13 = D7 = DIR

//UARTSerial_half CommLayer(PG_14,PG_9,PE_15, 1000000);
//CommLayer.set_baud(1000000); // set UART baud rate from Class UARTSerial_half 
//UARTSerial_half* dxl_port = new UARTSerial_half(PG_14,PG_9,PE_15, 1000000); 

UARTSerial_half dxl_port(PB_9,PB_8,PF_13, 1000000); 

int ID[5] = {1,2,3,4,5};
MX mx_MotorChain(ID, sizeof(ID)/sizeof(int), 1000000, &dxl_port);  

//int MotorID[1] = {3};
//MX mx_SingleMotor(MotorID, 1000000, &dxl_port);    

// Entry point
int main() {

            
            bool enableVal[5] = {1,1,1,1,1};
            mx_MotorChain.SyncTorqueEnable(enableVal);
            
            float Goal_position[5] = {100,20,150,60,75};
            mx_MotorChain.SyncSetGoal(Goal_position); 
             
        /*    float mAmpere[5] = {-4000,5000,-4000,3000,-2000}; 
            mx_MotorChain.SyncGoalCurrent(mAmpere);
        */
               
            //mx_MotorChain.SyncReadPacket(MX64_REG_PRESENT_POSITION, 4); 
            
            //mx_MotorChain.SyncGetPosition();                            
         
         /* printf("\nUn solo motore: Test- ID3 single var&\n");
            float pos3 = 30;
            mx_MotorChain.SyncSetGoal(pos3,3);   
            printf("\nUn solo motore: Test- ID5 single var&\n");
            mx_MotorChain.SyncSetGoal(12,5);   
            printf("\nUn solo motore: Test- ID1 single var&\n");
            mx_MotorChain.SyncSetGoal(pos3/2,1);   
            printf("\nUn solo motore: Test- Id4 single var&\n");
            mx_MotorChain.SyncSetGoal(pos3*5,4);   */  
 
}