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.
Dependents: Asserv_mot Asserv_mot
Revision 2:dc3ec8d77b6a, committed 2019-05-27
- Comitter:
- kyxstark
- Date:
- Mon May 27 09:54:41 2019 +0000
- Parent:
- 1:162aa6608ffe
- Commit message:
- v2019
Changed in this revision
--- a/Asservissement.cpp Wed Apr 19 17:41:35 2017 +0000
+++ b/Asservissement.cpp Mon May 27 09:54:41 2019 +0000
@@ -1,5 +1,5 @@
+
#include "Asservissement.h"
-#include "My_ident.h"
/*********************************************************************************************************/
/* FUNCTION NAME: SendRawId */
@@ -10,8 +10,8 @@
CANMessage msgTx=CANMessage();
msgTx.id=id;
msgTx.len=0;
- can1.write(msgTx);
- //wait_us(200);
+ can.write(msgTx);
+ wait_us(200);
}
/*********************************************************************************************/
@@ -29,9 +29,55 @@
msgTx.data[0]=(unsigned char)from;
msgTx.data[1]=(unsigned char)(from>>8);
- can1.write(msgTx);
+ can.write(msgTx);
+}
+
+
+void Send2Short(unsigned short id, unsigned short d1, unsigned short d2)
+{
+ CANMessage msgTx=CANMessage();
+ msgTx.id=id;
+ msgTx.len=4;
+ msgTx.format=CANStandard;
+ msgTx.type=CANData;
+ // from sur 2 octets
+ msgTx.data[0]=(unsigned char)d1;
+ msgTx.data[1]=(unsigned char)(d1>>8);
+ msgTx.data[2]=(unsigned char)d2;
+ msgTx.data[3]=(unsigned char)(d2>>8);
+
+ can.write(msgTx);
}
+void SendMsgCan(unsigned short id, unsigned char* data, int len)
+{
+ CANMessage msgTx=CANMessage();
+ msgTx.id=id;
+ msgTx.len=len;
+ msgTx.format=CANStandard;
+ msgTx.type=CANData;
+ // from sur 2 octets
+ for(int i = 0; i<len; i++)
+ {
+ msgTx.data[i]=data[i];
+ }
+
+ can.write(msgTx);
+}
+void SendCharCan(unsigned short id, unsigned char data)
+{
+ CANMessage msgTx=CANMessage();
+ msgTx.id=id;
+ msgTx.len=1;
+ msgTx.format=CANStandard;
+ msgTx.type=CANData;
+ msgTx.data[0]=data;
+
+ can.write(msgTx);
+}
+
+
+
/*********************************************************************************************/
/* FUNCTION NAME: GoToPosition */
/* DESCRIPTION : Transmission CAN correspondant à un asservissement en position (x,y,theta) */
@@ -56,14 +102,14 @@
msgTx.data[5]=(unsigned char)(theta>>8);
msgTx.data[6]=sens;
- can1.write(msgTx);
+ can.write(msgTx);
}
/****************************************************************************************/
/* FUNCTION NAME: Rotate */
/* DESCRIPTION : Transmission CAN correspondant à une rotation */
/****************************************************************************************/
- void Rotate (signed short angle)
+void Rotate (signed short angle)
{
CANMessage msgTx=CANMessage();
msgTx.id=ASSERVISSEMENT_ROTATION; // Tx rotation autour du centre du robot
@@ -74,7 +120,7 @@
msgTx.data[0]=(unsigned char)angle;
msgTx.data[1]=(unsigned char)(angle>>8);
- can1.write(msgTx);
+ can.write(msgTx);
}
@@ -108,7 +154,7 @@
//Enchainement sur 1 octet
msgTx.data[5]=isEnchainement;
- can1.write(msgTx);
+ can.write(msgTx);
//wait_ms(500);
}
@@ -134,7 +180,7 @@
// Enchainement sur 1 octet
msgTx.data[5]=enchainement;
- can1.write(msgTx);
+ can.write(msgTx);
}
void SetOdometrie (unsigned short canId, unsigned short x,unsigned short y,signed short theta)
@@ -155,7 +201,7 @@
msgTx.data[4]=(unsigned char)theta;
msgTx.data[5]=(unsigned char)(theta>>8);
- can1.write(msgTx);
+ can.write(msgTx);
}
/****************************************************************************************/
@@ -172,25 +218,95 @@
// Angle signé sur 2 octets
msgTx.data[0]=(unsigned char)((enable==0)?0:1);
- can1.write(msgTx);
+ can.write(msgTx);
}
/****************************************************************************************/
+/* FUNCTION NAME: SendSpeed accel decel */
+/* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */
+/****************************************************************************************/
+void SendSpeedAccelDecel (unsigned short vitesse, unsigned short acceleration,unsigned short deceleration)
+{
+ CANMessage msgTx=CANMessage();
+ msgTx.id=ASSERVISSEMENT_CONFIG;
+ msgTx.format=CANStandard;
+ msgTx.type=CANData;
+ msgTx.len=8;
+ msgTx.data[0]=(unsigned char)(vitesse&0x00FF);
+ msgTx.data[1]=(unsigned char)((vitesse&0xFF00)>>8);
+
+ msgTx.data[2]=(unsigned char)(acceleration&0x00FF);
+ msgTx.data[3]=(unsigned char)((acceleration&0xFF00)>>8);
+
+ msgTx.data[4]=(unsigned char)(deceleration&0x00FF);
+ msgTx.data[5]=(unsigned char)((deceleration&0xFF00)>>8);
+
+ msgTx.data[6]=(unsigned char)(acceleration&0x00FF);//cloto
+ msgTx.data[7]=(unsigned char)((acceleration&0xFF00)>>8);//cloto
+
+ can.write(msgTx);
+
+}
+
+/****************************************************************************************/
/* FUNCTION NAME: SendSpeed */
/* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */
/****************************************************************************************/
-void SendSpeed (unsigned short vitesse, unsigned short acceleration)
+void SendSpeed (unsigned short vitesse)
+{
+ CANMessage msgTx=CANMessage();
+ msgTx.id=ASSERVISSEMENT_CONFIG_VIT;
+ msgTx.format=CANStandard;
+ msgTx.type=CANData;
+ msgTx.len=2;
+ msgTx.data[0]=(unsigned char)(vitesse&0x00FF);
+ msgTx.data[1]=(unsigned char)((vitesse&0xFF00)>>8);
+
+ can.write(msgTx);
+
+}
+
+/****************************************************************************************/
+/* FUNCTION NAME: SendSpeed */
+/* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */
+/****************************************************************************************/
+void SendAccel(unsigned short acceleration,unsigned short deceleration)
{
CANMessage msgTx=CANMessage();
- msgTx.id=ASSERVISSEMENT_CONFIG;
+ msgTx.id=ASSERVISSEMENT_CONFIG_ACCEL;
+ msgTx.format=CANStandard;
+ msgTx.type=CANData;
+ msgTx.len=4;
+ msgTx.data[0]=(unsigned char)(acceleration&0x00FF);
+ msgTx.data[1]=(unsigned char)((acceleration&0xFF00)>>8);
+
+ msgTx.data[2]=(unsigned char)(deceleration&0x00FF);
+ msgTx.data[3]=(unsigned char)((deceleration&0xFF00)>>8);
+
+ can.write(msgTx);
+
+}
+
+/****************************************************************************************/
+/* FUNCTION NAME: SendSpeedDecel */
+/* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */
+/****************************************************************************************/
+ /*
+void SendSpeedDecel (unsigned short vitesse, unsigned short deceleration)
+{
+ CANMessage msgTx=CANMessage();
+ msgTx.id=ASSERVISSEMENT_CONFIG_DECEL;
msgTx.format=CANStandard;
msgTx.type=CANData;
msgTx.len=4;
msgTx.data[0]=(unsigned char)(vitesse&0x00FF);
msgTx.data[1]=(unsigned char)((vitesse&0xFF00)>>8);
- msgTx.data[2]=(unsigned char)(acceleration&0x00FF);
- msgTx.data[3]=(unsigned char)((acceleration&0xFF00)>>8);
-
- can1.write(msgTx);
-}
\ No newline at end of file
+ msgTx.data[2]=(unsigned char)(deceleration&0x00FF);
+ msgTx.data[3]=(unsigned char)((deceleration&0xFF00)>>8);
+
+ can.write(msgTx);
+
+}*/
+
+
\ No newline at end of file
--- a/Asservissement.h Wed Apr 19 17:41:35 2017 +0000 +++ b/Asservissement.h Mon May 27 09:54:41 2019 +0000 @@ -1,8 +1,10 @@ #ifndef CRAC_ASSERVISSEMENT #define CRAC_ASSERVISSEMENT +#include "main.h" -#include "global.h" - +void Send2Short(unsigned short id, unsigned short d1, unsigned short d2); +void SendMsgCan(unsigned short id, unsigned char* data, int len); +void SendCharCan(unsigned short id, unsigned char data); /*********************************************************************************************************/ /* FUNCTION NAME: SendRawId */ /* DESCRIPTION : Envoie un message sans donnée, c'est-à-dire contenant uniquement un ID, sur le bus CAN */ @@ -61,7 +63,8 @@ /* FUNCTION NAME: SendSpeed */ /* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */ /****************************************************************************************/ -void SendSpeed (unsigned short vitesse, unsigned short acceleration); - +void SendSpeed (unsigned short vitesse); +void SendSpeedAccelDecel (unsigned short vitesse, unsigned short acceleration,unsigned short deceleration) +void SendAccel(unsigned short acceleration,unsigned short deceleration) #endif \ No newline at end of file
--- a/Globals/constantes.h Wed Apr 19 17:41:35 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -#ifndef CRAC_CONSTANTES -#define CRAC_CONSTANTES -// **************************************************************************************** -// * CONSTANTES SYMBOLIQUES * -// **************************************************************************************** - - - -#define SIZE_FIFO 25 //Taille du buffer pour le bus CAN - -#define SIZE 750 //Taille d'une ligne du fichier -#define SIZE_BUFFER_FILE 150 //Taille du buffer d'instruction - - - -/**** -** Variable à modifier en fonction du robot -***/ -#define ROBOT_BIG//Indique que l'on va compiler pour le gros robot -//#define ROBOT_SMALL - -#ifdef ROBOT_BIG - - #define NOMBRE_CARTES 5 //Le nombre de carte présente sur le gros robot - #define POSITION_DEBUT_X 765 - #define POSITION_DEBUT_Y 100 - #define POSITION_DEBUT_T 900 - - #define BALISE_TIMEOUT 6000 - -#else - - #define NOMBRE_CARTES 3 //Le nombre de carte présente sur le petit robot - #define POSITION_DEBUT_X 990 - #define POSITION_DEBUT_Y 150 - #define POSITION_DEBUT_T 0 - - #define BALISE_TIMEOUT 2000 - -#endif - - - -#endif \ No newline at end of file
--- a/Globals/global.h Wed Apr 19 17:41:35 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -#include "mbed.h" -#include "constantes.h" -#include "ident_crac.h" -#include "Asservissement.h" -//#include "AX12.h" -//#include "Strategie.h" - -extern CAN can1; -extern CANMessage msgRxBuffer[SIZE_FIFO]; -extern unsigned char FIFO_ecriture; -
--- a/MY_Asserv.cpp Wed Apr 19 17:41:35 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-#include "mbed.h"
-#include "Nucleo_Encoder_16_bits.h"
-#include "MYCRAC_utility.h"
-#include "Asservissement.h"
-#include "global.h"
-#include "MY_Asserv.h"
-
-
-/****************************************************************************************/
-/* FUNCTION NAME: Send_assev_info_comfig */
-/* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */
-/****************************************************************************************/
-void Send_assev_info_comfig(void)
-{
- CANMessage msgTx=CANMessage();
- msgTx.id=ASSERVISSEMENT_INFO_CONSIGNE; // si proposition accepter remplacer par "ACKNOWLEDGE_MOTEUR"
- msgTx.format=CANStandard;
- msgTx.type=CANData;
- msgTx.len=6;
- msgTx.data[0]=(unsigned char)(((short)Kpp1)&0xFF);
- msgTx.data[1]=(unsigned char)(((short)Kpp1 >> 8)&0xFF);
- msgTx.data[2]=(unsigned char)(((short)Kip1)&0xFF);
- msgTx.data[3]=(unsigned char)(((short)Kip1 >> 8)&0xFF);
- msgTx.data[4]=(unsigned char)(((short)Kdp1)&0xFF);
- msgTx.data[5]=(unsigned char)(((short)Kdp1 >> 8)&0xFF);
-
- can1.write(msgTx);
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: Send_odometrie */
-/* DESCRIPTION : Envoie de l'odometrie */
-/****************************************************************************************/
-void Send_odometrie(void)
-{
- CANMessage msgTx=CANMessage();
- msgTx.id=ODOMETRIE_SMALL_POSITION; // si proposition accepter remplacer par "ACKNOWLEDGE_MOTEUR"
- msgTx.format=CANStandard;
- msgTx.type=CANData;
- msgTx.len=6;
- msgTx.data[0]=((short)Odo_x) & 0xFF;
- msgTx.data[1]=((short)Odo_x >> 8) & 0xFF;
- msgTx.data[2]=((short)Odo_y) & 0xFF;
- msgTx.data[3]=((short)Odo_y >> 8) & 0xFF;
- msgTx.data[4]=((short)Odo_theta % 3600) & 0xFF;
- msgTx.data[5]=(((short)Odo_theta % 3600) >> 8) & 0xFF;
-
- can1.write(msgTx);
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: Debug_Asserv */
-/* DESCRIPTION : Envoie vall encod + consigne_pos */
-/* Ps : les encodeurs sont sur 32 bits, là on ne prend que les 16 premiérs */
-/****************************************************************************************/
-void Debug_Asserv(void)
-{
- CANMessage msgTx=CANMessage();
- msgTx.id=DEBUG_ASSERV; // si proposition accepter remplacer par "ACKNOWLEDGE_MOTEUR"
- msgTx.format=CANStandard;
- msgTx.type=CANData;
- msgTx.len=6;
- msgTx.data[0]=(short)encoder1.GetCounter();
- msgTx.data[1]=(short)encoder1.GetCounter()>>8;
- msgTx.data[2]=(short)encoder2.GetCounter();
- msgTx.data[3]=(short)encoder2.GetCounter()>>8;
- msgTx.data[4]=(short)(consigne_pos);
- msgTx.data[5]=(char)consigne_pos >> 8;
-
- can1.write(msgTx);
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: motor_of */
-/* DESCRIPTION : prevenir que les moteur sont à l'arret */
-/****************************************************************************************/
-void motor_of(void)
-{
- CANMessage msgTx=CANMessage();
- msgTx.id=INSTRUCTION_END_MOTEUR;
- msgTx.format=CANStandard;
- msgTx.type=CANData;
- msgTx.len=2;
- msgTx.data[0]= 0;
- msgTx.data[1]= 0;
-
- can1.write(msgTx);
-}
--- a/MY_Asserv.h Wed Apr 19 17:41:35 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -#include "global.h" - - -extern Nucleo_Encoder_16_bits encoder1; -extern Nucleo_Encoder_16_bits encoder2; - -/****************************************************************************************/ -/* FUNCTION NAME: Send_assev_info_comfig */ -/* DESCRIPTION : Envoie un asservissement paramètre retournant à une vitesse */ -/****************************************************************************************/ -void Send_assev_info_comfig(void); - -/****************************************************************************************/ -/* FUNCTION NAME: Debug_Asserv */ -/* DESCRIPTION : Envoie vall encod + consigne_pos */ -/* Ps : les encodeurs sont sur 32 bits, là on ne prend que les 16 premiérs */ -/****************************************************************************************/ -void Debug_Asserv(void); - -/****************************************************************************************/ -/* FUNCTION NAME: Send_odometrie */ -/* DESCRIPTION : Envoie de l'odometrie */ -/****************************************************************************************/ -void Send_odometrie(void); - -/****************************************************************************************/ -/* FUNCTION NAME: motor_of */ -/* DESCRIPTION : prevenir que les moteur sont à l'arret */ -/****************************************************************************************/ -void motor_of(void); \ No newline at end of file
--- a/My_ident.h Wed Apr 19 17:41:35 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -//#define ASSERVISSEMENT_LIGNE_DROITE 0x024 -//#define ASSERVISSEMENT_RECALAGE 0x025 // Moteur tout droit (recalage : 0 mouvement seul, 1 x, 2y valeur : coordonnée à laquelle est recalé x/y; enchainement => 1 oui, 0 => non) - - -//A voir - -#define MOTOR_IMOBILE 0x030 \ No newline at end of file