Adaptation à la nouvelle carte Propulsion 2026

This commit is contained in:
Samuel 2026-04-20 21:18:35 +02:00
parent 5eb8625916
commit aa5a5d2d64
4 changed files with 42 additions and 37 deletions

View File

@ -6,20 +6,21 @@
#define MOTEUR_B 1
#define MOTEUR_C 2
#define MOTEUR_A_VITESSE 6
#define MOTEUR_B_VITESSE 8
#define MOTEUR_C_VITESSE 10
#define MOTEUR_A_SENS 5
#define MOTEUR_B_SENS 7
#define MOTEUR_C_SENS 9
#define M1_SENS1 7
#define M1_SENS2 13
#define M1_VITESSE 27 //5B
#define M2_SENS1 10
#define M2_SENS2 5
#define M2_VITESSE 9 //4B
#ifdef ROBOT_PROPULSION_2026
#define M1_VITESSE 2 //1A
#define M1_SENS1 3
#define M1_SENS2 4
#define M2_VITESSE 6 //3A
#define M2_SENS1 7
#define M2_SENS2 8
#else
#define M1_SENS1 7
#define M1_SENS2 13
#define M1_VITESSE 27 //5B
#define M2_SENS1 10
#define M2_SENS2 5
#define M2_VITESSE 9 //4B
#endif
uint slice_moteur_A, slice_moteur_B, slice_moteur_C;
int moteur_a_pwm, moteur_b_pwm;
@ -41,13 +42,21 @@ void Moteur_Init(){
gpio_set_function(M1_VITESSE, GPIO_FUNC_PWM);
gpio_set_function(M2_VITESSE, GPIO_FUNC_PWM);
#ifdef ROBOT_PROPULSION_2026
pwm_set_wrap(1, (uint16_t)65535);
pwm_set_wrap(3, (uint16_t)65535);
pwm_set_chan_level(1, PWM_CHAN_A, 0);
pwm_set_chan_level(3, PWM_CHAN_A, 0);
pwm_set_enabled(1, true);
pwm_set_enabled(3, true);
#else
pwm_set_wrap(4, (uint16_t)65535);
pwm_set_wrap(5, (uint16_t)65535);
pwm_set_wrap(4, (uint16_t)65535);
pwm_set_chan_level(5, PWM_CHAN_B, 0);
pwm_set_chan_level(4, PWM_CHAN_B, 0);
pwm_set_enabled(5, true);
pwm_set_chan_level(5, PWM_CHAN_B, 0);
pwm_set_enabled(4, true);
pwm_set_enabled(5, true);
#endif
Moteur_SetVitesse(MOTEUR_A, 0);
Moteur_SetVitesse(MOTEUR_B, 0);
}
@ -90,10 +99,12 @@ void Moteur_SetVitesse(enum t_moteur moteur, int16_t vitesse ){
switch(moteur){
case MOTEUR_A:
pwm_set_chan_level(5, PWM_CHAN_B, u_vitesse);
#ifdef ROBOT_PROPULSION_2026
pwm_set_chan_level(1, PWM_CHAN_A, u_vitesse);
if(vitesse > 0){
#else
pwm_set_chan_level(5, PWM_CHAN_B, u_vitesse);
if(vitesse < 0){
#endif
gpio_put(M1_SENS1, 1);
@ -105,10 +116,11 @@ void Moteur_SetVitesse(enum t_moteur moteur, int16_t vitesse ){
break;
case MOTEUR_B:
pwm_set_chan_level(4, PWM_CHAN_B, u_vitesse);
#ifdef ROBOT_PROPULSION_2026
pwm_set_chan_level(3, PWM_CHAN_A, u_vitesse);
if(vitesse < 0){
#else
pwm_set_chan_level(4, PWM_CHAN_B, u_vitesse);
if(vitesse > 0){
#endif
gpio_put(M2_SENS1, 1);

14
QEI.c
View File

@ -44,15 +44,15 @@ void QEI_init(int identifiant){
}
// Initialisation des "machines à états" :
#ifdef ROBOT_PROPULSION_2026
// QEI1 : broche 11 et 12 - pio : pio0, sm : 0, Offset : 0, GPIO 14 et 15, clock div : 0 pour commencer
// QEI1 : broche 11 et 12 - pio : pio0, sm : 0, Offset : 0, GPIO 10 et 11, clock div : 0 pour commencer
quadrature_encoder_program_init(pio_QEI, 1, offset, 10, 0);
// QEI2 : broche 2 et 3 - pio : pio0, sm : 1, Offset : 0, GPIO 14 et 15, clock div : 0 pour commencer
quadrature_encoder_program_init(pio_QEI, 0, offset, 14, 0);
// QEI2 : broche 2 et 3 - pio : pio0, sm : 1, Offset : 0, GPIO 16 et 17, clock div : 0 pour commencer
quadrature_encoder_program_init(pio_QEI, 1, offset, 16, 0);
#else
// QEI1 : broche 11 et 12 - pio : pio0, sm : 0, Offset : 0, GPIO 11 et 12, clock div : 0 pour commencer
quadrature_encoder_program_init(pio_QEI, 0, offset, 14, 0);
quadrature_encoder_program_init(pio_QEI, 0, offset, 11, 0);
// QEI2 : broche 2 et 3 - pio : pio0, sm : 1, Offset : 0, GPIO 2 et 3, clock div : 0 pour commencer
quadrature_encoder_program_init(pio_QEI, 1, offset, 16, 0);
quadrature_encoder_program_init(pio_QEI, 1, offset, 2, 0);
#endif
QEI_A.value=0;
@ -98,11 +98,7 @@ int QEI_get(enum QEI_name_t qei){
break;
case QEI_B_NAME:
#ifdef ROBOT_PROPULSION_2026
return QEI_B.delta;
#else
return -QEI_B.delta;
#endif
break;
default:

View File

@ -1,7 +1,7 @@
// Changer le define en fonction qu'on soit sur les PAMIs ou sur le robot principal
#define ROBOT_PROPULSION_2026
//#define ROBOT_TYPE_PAMI
//#define ROBOT_PROPULSION_2026
#define ROBOT_TYPE_PAMI
#ifndef ROBOT_PROPULSION_2026
#ifndef ROBOT_TYPE_PAMI

9
main.c
View File

@ -69,8 +69,10 @@ void main(void)
stdio_init_all();
Temps_init();
#ifdef ROBOT_PROPULSION_2026
#else
identifiant_init();
#endif
Localisation_init(get_identifiant());
Trajet_init(get_identifiant());
//i2c_maitre_init();
@ -97,12 +99,7 @@ void main(void)
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT );
gpio_put(PICO_DEFAULT_LED_PIN, 1);
gpio_init(TIRETTE_PIN);
gpio_set_dir(LED1PIN, GPIO_IN);
gpio_pull_up(TIRETTE_PIN);
sleep_ms(5000);
printf("Demarrage...\n");