Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MX64
Revision 5:2fb46c15828f, committed 2019-07-26
- Comitter:
- marcodesilva
- Date:
- Fri Jul 26 12:40:30 2019 +0000
- Parent:
- 4:44a6af68b37a
- Child:
- 6:962b57df95f6
- Commit message:
- Last Version;
Changed in this revision
| MX64.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 |
--- a/MX64.lib Fri Jul 05 14:08:38 2019 +0000 +++ b/MX64.lib Fri Jul 26 12:40:30 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/ppr2013G2/code/MX64/#532cee01f24f +https://os.mbed.com/users/ppr2013G2/code/MX64/#6f85605f793d
--- a/main.cpp Fri Jul 05 14:08:38 2019 +0000
+++ b/main.cpp Fri Jul 26 12:40:30 2019 +0000
@@ -1,8 +1,7 @@
#include "mbed.h"
-#include "MX64.h"
+#include "MX.h"
#include "UARTSerial_half.h"
-using namespace motors;
// It creates an instance of the DigitalOut class.
// myled is the name of the variable (instance).
@@ -10,102 +9,47 @@
DigitalOut myled(LED1);
// se si vuole collegare un mx28 non c'è alcuna differenza
-//MX64(PinName tx, PinName rx, PinName dir, int ID, int baud)
+//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(PG_14,PG_9,PE_15, 1000000);
+UARTSerial_half dxl_port(PB_9,PB_8,PF_13, 1000000);
- MX64 mx64_test(1,1000000,&dxl_port);
+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() {
- float pos = 0 ;
- int Rot0 = 0;
- int Rot1 = 30.0;
- int Rot2 = 60.0;
- int Rot3 = 90.0;
- printf("\nADDRES IS : %x main",&dxl_port);
+
- char data[10];
- for(int i = 0 ; i < 10 ; i++){
- data[i] =i;
- }
-
- dxl_port.write(data,10);
+ bool enableVal[5] = {1,1,1,1,1};
+ mx_MotorChain.SyncTorqueEnable(enableVal);
- mx64_test.FunzioneProva();
-
- while(1);
-
- wait(0.2);
- mx64_test.BufferProva();
- wait(0.2);
- mx64_test.TorqueEnable(0);
- wait(0.5);
- mx64_test.motorSetBaud(3); // 1 Mbps
- wait(0.5);
- mx64_test.OperatingMode(1); // 1 velocity
- wait(0.5);
+ 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);
- printf("\n ------------------------- \n");
- printf("\n SET VELOCITY CONTROL MODE \n");
- printf("\n ------------------------- \n");
-
- mx64_test.TorqueEnable(1);
- wait(0.5);
- mx64_test.SetGoalSpeed(250);
- wait(3);
- mx64_test.SetGoalSpeed(50);
- wait(3);
- mx64_test.TorqueEnable(0);
-
- printf("\n ------------------------- \n");
- printf("\n SET POSITION CONTROL MODE \n");
- printf("\n ------------------------- \n");
-
- mx64_test.TorqueEnable(0);
- wait(0.2);
- mx64_test.motorSetBaud(3); // 1 Mbps
- wait(0.2);
- mx64_test.OperatingMode(3); // 3 velocity
- wait(0.2);
- mx64_test.TorqueEnable(1);
- wait(0.2);
- // reset position to zero
- mx64_test.SetGoal(Rot0);
- wait(0.5);
- pos = mx64_test.GetPosition();
- printf("Position %f\n",pos);
- wait(1);
-
- mx64_test.SetGoal(Rot1);
- wait(0.2);
- pos = mx64_test.GetPosition();
- printf("Position %f\n",pos);
- wait(1);
-
- mx64_test.SetGoal(Rot2);
- wait(0.2);
- pos = mx64_test.GetPosition();
- printf("Position %f\n",pos);
- wait(1);
-
- mx64_test.SetGoal(Rot3);
- wait(0.2);
- pos = mx64_test.GetPosition();
- printf("Position %f\n",pos);
- //return to zero
- wait(0.2);
- mx64_test.SetGoal(Rot0);
- wait(1);
- //motor reset
- mx64_test.Reboot();
- wait(1);
- // at the end shout down the led on board
- myled=0;
+ //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); */
+
}
\ No newline at end of file