mouvement AX12 petit robot
Fork of command_AX12 by
main.cpp
- Committer:
- ConstantMBED
- Date:
- 2017-03-21
- Revision:
- 1:b3ff77670606
- Parent:
- 0:a2a44c043932
- Child:
- 2:99b1cb0d9f5e
File content as of revision 1:b3ff77670606:
#include "mbed.h" #include "AX12.h" #include "cmsis.h" /* DECLARATION VARIABLES */ Timer t; Ticker flipper; static char TAB1[25]= {0x06,0x0A, 0x01, 0xFF, 0x00, 0x12,0xBC, 0x02, 0xFF, 0x00, 0x04,0xE9, 0x00, 0xFF, 0x00, 0x07,0x4D, 0x01, 0xFF, 0x00, 0x0F,0x90, 0x01, 0xFF, 0x00}; static char TAB2[25]= {0x06,0x0A, 0x01, 0xFF, 0x00, 0x12,0x25, 0x02, 0xFF, 0x00, 0x04,0x15, 0x02, 0xFF, 0x00, 0x07,0x4D, 0x01, 0xFF, 0x00, 0x0F,0x90, 0x01, 0xFF, 0x00}; static char TAB3[25]= {0x06,0x0A, 0x01, 0xFF, 0x00, 0x12,0x2C, 0x01, 0xFF, 0x00, 0x04,0x15, 0x02, 0xFF, 0x00, 0x07,0x4D, 0x01, 0xFF, 0x00, 0x0F,0x90, 0x01, 0xFF, 0x00}; static char TAB4[25]= {0x06,0x0A, 0x01, 0xFF, 0x00, 0x12,0x2C, 0x01, 0xFF, 0x00, 0x04,0x4D, 0x01, 0xFF, 0x00, 0x07,0x4D, 0x01, 0xFF, 0x00, 0x0F,0x90, 0x01, 0xFF, 0x00}; static char TAB5[25]= {0x06,0x0A, 0x01, 0xFF, 0x00, 0x12,0x2C, 0x01, 0xFF, 0x00, 0x04,0x4D, 0x01, 0xFF, 0x00, 0x07,0x6E, 0x01, 0xFF, 0x00, 0x0F,0x90, 0x01, 0xFF, 0x00}; /* ANGLE */ /* 10° = 0x21, 0x00 | 110°= 0x6E, 0x01 | 210°= 0xBC, 0x02 20° = 0x42, 0x00 | 120°= 0x90, 0x01 | 220°= 0xDD, 0x02 30° = 0x64, 0x00 | 130°= 0xB1, 0x01 40° = 0x85, 0x00 | 140°= 0xD2, 0x01 50° = 0xA6, 0x00 | 150°= 0xF4, 0x01 60° = 0xC8, 0x00 | 160°= 0x15, 0x02 70° = 0xE9, 0x00 | 170°= 0x36, 0x02 80° = 0x0A, 0x01 | 180°= 0x58, 0x02 90° = 0x2C, 0x01 | 190°= 0x79, 0x02 100°= 0x4D, 0x01 | 200°= 0x9A, 0x02 */ /* NUMERO AX12 */ /* 0 = 0x00 | 9 = 0x09 | 18 = 0x12 1 = 0x01 | 10 = 0x0A 2 = 0x02 | 11 = 0x0B 3 = 0x03 | 12 = 0x0C 4 = 0x04 | 13 = 0x0D 5 = 0x05 | 14 = 0x0E 6 = 0x06 | 15 = 0x0F 7 = 0x07 | 16 = 0x10 8 = 0x08 | 17 = 0x11 */ /*static char Tab1[5]={ 0x09, 0x5E, 0x01, 0x70, 0x01};*/ /*static char Tab2[5]={ 0x05, 0x96, 0x01, 0x85, 0x05};*/ float angle=0.0; float test_socle=0.0,test_bas=0.0,test_milieu=0.0,test_haut=0.0,test_ventouse=0.0, test_calcul=0.0, valeur_test=0.0; /* DECLARATION PROTOTYPES & POINTEURS */ short vitesse=700; // Vitesse angulaire (0-1023) AX12 *dixhuit_myAX12, *quatre_myAX12,*six_myAX12, *sept_myAX12, *quinze_myAX12, *multiple_AX12; void Init_AX12(void); void Lecture(void); void Flip(void); /* FONCTIONS */ void Init_AX12() // Initialisation des différents paramétres { dixhuit_myAX12-> Set_Goal_speed(vitesse); // vitesse (0-1023) quatre_myAX12-> Set_Goal_speed(vitesse); six_myAX12-> Set_Goal_speed(vitesse); sept_myAX12-> Set_Goal_speed(vitesse); quinze_myAX12-> Set_Goal_speed(vitesse); dixhuit_myAX12-> Set_Mode(0); // Mode Position(0) Mode Continu(1) quatre_myAX12-> Set_Mode(0); six_myAX12-> Set_Mode(0); sept_myAX12-> Set_Mode(0); quinze_myAX12-> Set_Mode(0); } /*void Lecture() { angle= socle_myAX12-> Get_Position(); test_socle = socle_myAX12 -> read_and_test(angle,TAB); angle= bas_myAX12-> Get_Position(); test_bas = bas_myAX12-> read_and_test(angle,TAB); angle= milieu_myAX12-> Get_Position(); test_milieu = milieu_myAX12-> read_and_test(angle,TAB); angle= haut_myAX12-> Get_Position(); test_haut = haut_myAX12-> read_and_test(angle,TAB); angle= ventouse_myAX12-> Get_Position(); test_ventouse = ventouse_myAX12-> read_and_test(angle,TAB); valeur_test=test_bas+test_milieu+test_haut+test_socle+test_ventouse; #ifdef AX12_DEBUG printf("\ntest_socle = %f",test_socle); #endif #ifdef AX12_DEBUG printf("\ntest_bas = %f",test_bas); #endif #ifdef AX12_DEBUG printf("\ntest_milieu = %f",test_milieu); #endif #ifdef AX12_DEBUG printf("\ntest_haut = %f",test_haut); #endif #ifdef AX12_DEBUG printf("\ntest_ventouse = %f",test_ventouse); #endif #ifdef AX12_DEBUG printf("\nvaleur_test = %f",valeur_test); #endif }*/ /* PROGRAMME PRINCIPAL*/ int main() { // flipper.attach(&Flip, 2.0); dixhuit_myAX12 = new AX12(p13, p14, 18, 1000000); quatre_myAX12 = new AX12(p13, p14, 4, 1000000); six_myAX12 = new AX12(p13, p14, 6, 1000000); sept_myAX12 = new AX12(p13, p14, 7, 1000000); quinze_myAX12 = new AX12(p13, p14, 15, 1000000); multiple_AX12 = new AX12(p13,p14,0xFE,1000000); // Création objet : data pin 9&10, ID Broadcast, baud multiple_AX12->multiple_goal_and_speed(5,TAB1); wait(2); multiple_AX12->multiple_goal_and_speed(5,TAB2); wait(2); multiple_AX12->multiple_goal_and_speed(5,TAB3); wait(2); multiple_AX12->multiple_goal_and_speed(5,TAB4); wait(2); multiple_AX12->multiple_goal_and_speed(5,TAB5); //six_myAX12 -> Set_Secure_Goal(200); /*quatorze_myAX12 -> Set_Secure_Goal(260); gauche_myAX12 -> Set_Secure_Goal(280); quatorze_myAX12 -> Set_Secure_Goal(300); //avoir ax12 14 a 90°*/ /* while(valeur_test<4) { Lecture(); }*/ }