Réglage du sens des moteurs et des codeurs

This commit is contained in:
Samuel 2026-04-18 10:05:13 +02:00
parent bda33196ec
commit 23bc31cfac
2 changed files with 9 additions and 9 deletions

View File

@ -91,22 +91,22 @@ void Moteur_SetVitesse(enum t_moteur moteur, int16_t vitesse ){
case MOTEUR_A: case MOTEUR_A:
pwm_set_chan_level(5, PWM_CHAN_B, u_vitesse); pwm_set_chan_level(5, PWM_CHAN_B, u_vitesse);
if(vitesse > 0){ if(vitesse > 0){
gpio_put(M1_SENS1, 0);
gpio_put(M1_SENS2, 1);
}else{
gpio_put(M1_SENS1, 1); gpio_put(M1_SENS1, 1);
gpio_put(M1_SENS2, 0); gpio_put(M1_SENS2, 0);
}else{
gpio_put(M1_SENS1, 0);
gpio_put(M1_SENS2, 1);
} }
break; break;
case MOTEUR_B: case MOTEUR_B:
pwm_set_chan_level(4, PWM_CHAN_B, u_vitesse); pwm_set_chan_level(4, PWM_CHAN_B, u_vitesse);
if(vitesse < 0){ if(vitesse < 0){
gpio_put(M2_SENS1, 0);
gpio_put(M2_SENS2, 1);
}else{
gpio_put(M2_SENS1, 1); gpio_put(M2_SENS1, 1);
gpio_put(M2_SENS2, 0); gpio_put(M2_SENS2, 0);
}else{
gpio_put(M2_SENS1, 0);
gpio_put(M2_SENS2, 1);
} }
break; break;

6
QEI.c
View File

@ -42,9 +42,9 @@ void QEI_init(int identifiant){
} }
// Initialisation des "machines à états" : // Initialisation des "machines à états" :
// QEI1 : broche 11 et 12 - pio : pio0, sm : 0, Offset : 0, GPIO 11 et 12, clock div : 0 pour commencer // 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, 11, 0); quadrature_encoder_program_init(pio_QEI, 0, offset, 14, 0);
// QEI2 : broche 2 et 3 - pio : pio0, sm : 1, Offset : 0, GPIO 2 et 3, clock div : 0 pour commencer // 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, 2, 0); quadrature_encoder_program_init(pio_QEI, 1, offset, 16, 0);
QEI_A.value=0; QEI_A.value=0;
QEI_B.value=0; QEI_B.value=0;
@ -85,7 +85,7 @@ int QEI_get(enum QEI_name_t qei){
break; break;
case QEI_B_NAME: case QEI_B_NAME:
return -QEI_B.delta; return QEI_B.delta;
break; break;
default: default: