Servo sur esp32S2

Bonjour,

Je passe petit à petit des projets réalisés en ESP32 sur ESP32-S2 et je découvre des trucs...
Par exemple la bibliothèque ESP32Servo et son usage passe à la compil mais fait rebooter quand on veut l'utiliser...
Aucun tuto sur le web , enfin grâce à glouglou je découvre qu'il y a une bibliothèque intégrable dans le gestionnaire de bibliothèques : SP32_New_ISR_Servo

L'auteur a dû vouloir régler leur compte à tous les "variants" ESP32 qui apparaissent et pour moi c'est too much.
Pour me faire un exemple comme aide mémoire j'ai simplifié l'exemple

// janvier 2022   fonctionne

//  version détaillée


#define TIMER_INTERRUPT_DEBUG       0
#define ISR_SERVO_DEBUG             1
#define USE_ESP32_TIMER_NO          3
//#define LED_BUILTIN       15
//#define PIN_LED           15
#define PIN_D2            2
#define PIN_D3            3
#define MIN_MICROS      800                 //544
#define MAX_MICROS      2450
#define NUM_SERVOS    2
#include "ESP32_New_ISR_Servo.h"

typedef struct {
  int servoIndex;
  uint8_t servoPin;
} ISR_servo_t;
ISR_servo_t ISR_servo[NUM_SERVOS] = {{ -1, PIN_D2 }, { -1, PIN_D3 }};

void setup() {
  Serial.begin(115200);
  delay(5000);
  Serial.print("\r\n testServoEsp32S2_2 .ino\r\n");
  delay(200);


  ESP32_ISR_Servos.useTimer(USE_ESP32_TIMER_NO);
  for (int index = 0; index < NUM_SERVOS; index++)  {
    ISR_servo[index].servoIndex = ESP32_ISR_Servos.setupServo(ISR_servo[index].servoPin, MIN_MICROS, MAX_MICROS);
  }
}

void loop() {
  int position;                          // position in degrees
  for (position = 0; position <= 180; position += 2)  {
    ESP32_ISR_Servos.setPosition(ISR_servo[0].servoIndex, position  );
    ESP32_ISR_Servos.setPosition(ISR_servo[1].servoIndex, position  );
    Serial.println(position);
    delay(200);
  }
  for (position = 180; position <= 0; position -= 2)  {
    ESP32_ISR_Servos.setPosition(ISR_servo[0].servoIndex, position  );
    ESP32_ISR_Servos.setPosition(ISR_servo[1].servoIndex, position  );
    delay(200);
  }
  delay(5000);

  ESP32_ISR_Servos.setPosition(ISR_servo[0].servoIndex, (90));
  ESP32_ISR_Servos.setPosition(ISR_servo[1].servoIndex, (90));
  delay(5000);
}

En partulier j'ai viré les sorties sur le port com SAUF que la bibliothèques affiche encore des sorties sur la com.

Quelqu'un peut-il me dire où je dois modifier car y a tellement de define que je ne sais pas où c'est le mieux d'intervenir

Merci d'avance

Bonsoir @fr

il n'y aurait pas une option DEBUG active par défaut dans l'un des fichiers de la libaririe ?
(option souvent présente)

J'ai essayé de voir cela mais je suis trop novice pour la découvrir.

Dépot de la librairie en question : https://github.com/khoih-prog/ESP32_ISR_Servo

au début du fichier ESP32_ISR_Servo.cpp on voit ça :

#ifndef ISR_SERVO_DEBUG
  #define ISR_SERVO_DEBUG               1
#endif

en mettant la valeur 0 au lieu de 1 que se passe-t-il ?

Dans README.md il y a ceci

Debug
Debug is enabled by default on Serial.

You can also change the debugging level from 0 to 2. Be careful and using level 2 only for temporary debug purpose only.

#define TIMER_INTERRUPT_DEBUG       1
#define ISR_SERVO_DEBUG             1

Dans les codes en exemple avec la librairie, on trouve d'ailleurs ces lignes au début du code

#define TIMER_INTERRUPT_DEBUG       1
#define ISR_SERVO_DEBUG             1

Je suppose qu'il faut placer ces lignes dans ton code, après le #include qui inclut la librairie en remplaçant le 1 par un 0

Pas de changement

// basé sur exemple multipleServos   de la bibliothèque
// janvier 2022   fonctionne

//  version détaillée


#define TIMER_INTERRUPT_DEBUG       0   
#define ISR_SERVO_DEBUG             0

/*  Avec define TIMER_INTERRUPT_DEBUG       1 
 *   et   define ISR_SERVO_DEBUG             1
 *  testServoEsp32S2_2 .ino
[ISR_SERVO] ESP32_S2_TimerInterrupt: _timerNo = 3 , _fre = 1000000
[ISR_SERVO] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
[ISR_SERVO] _timerIndex = 1 , _timerGroup = 1
[ISR_SERVO] _count = 0 - 10
[ISR_SERVO] timer_set_alarm_value = 10.00
[ISR_SERVO] Starting  ITimer OK

Avec define TIMER_INTERRUPT_DEBUG       0 
 *   et   define ISR_SERVO_DEBUG             1
testServoEsp32S2_2 .ino
[ISR_SERVO] ESP32_S2_TimerInterrupt: _timerNo = 3 , _fre = 1000000
[ISR_SERVO] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
[ISR_SERVO] _timerIndex = 1 , _timerGroup = 1
[ISR_SERVO] _count = 0 - 10
[ISR_SERVO] timer_set_alarm_value = 10.00
[ISR_SERVO] Starting  ITimer OK

Avec define TIMER_INTERRUPT_DEBUG       0 
 *   et   define ISR_SERVO_DEBUG            0
testServoEsp32S2_2 .ino
[ISR_SERVO] ESP32_S2_TimerInterrupt: _timerNo = 3 , _fre = 1000000
[ISR_SERVO] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
[ISR_SERVO] _timerIndex = 1 , _timerGroup = 1
[ISR_SERVO] _count = 0 - 10
[ISR_SERVO] timer_set_alarm_value = 10.00
[ISR_SERVO] Starting  ITimer OK

 */

#define USE_ESP32_TIMER_NO          3
//#define LED_BUILTIN       15
//#define PIN_LED           15
#define PIN_D2            2
#define PIN_D3            3
#define MIN_MICROS      800                 //544
#define MAX_MICROS      2450
#define NUM_SERVOS    2
#include "ESP32_New_ISR_Servo.h"

typedef struct {
  int servoIndex;
  uint8_t servoPin;
} ISR_servo_t;
ISR_servo_t ISR_servo[NUM_SERVOS] = {{ -1, PIN_D2 }, { -1, PIN_D3 }};

void setup() {
  Serial.begin(115200);
  delay(5000);
  Serial.print("\r\n testServoEsp32S2_2 .ino\r\n");
  delay(200);


  ESP32_ISR_Servos.useTimer(USE_ESP32_TIMER_NO);
  for (int index = 0; index < NUM_SERVOS; index++)  {
    ISR_servo[index].servoIndex = ESP32_ISR_Servos.setupServo(ISR_servo[index].servoPin, MIN_MICROS, MAX_MICROS);
  }
}

void loop() {
  int position;                          // position in degrees
  for (position = 0; position <= 180; position += 2)  {
    ESP32_ISR_Servos.setPosition(ISR_servo[0].servoIndex, position  );
    ESP32_ISR_Servos.setPosition(ISR_servo[1].servoIndex, position  );
    Serial.println(position);
    delay(30);
  }
  for (position = 180; position <= 0; position -= 2)  {
    ESP32_ISR_Servos.setPosition(ISR_servo[0].servoIndex, position  );
    ESP32_ISR_Servos.setPosition(ISR_servo[1].servoIndex, position  );
    delay(30);
  }
  delay(5000);

  ESP32_ISR_Servos.setPosition(ISR_servo[0].servoIndex, (90));
  ESP32_ISR_Servos.setPosition(ISR_servo[1].servoIndex, (90));
  delay(5000);
}

Je vais tenter de demander une issue au développeur

Le dossier sur github est archivé donc pas d'issue possible

J'ai osé entrer dans la bibliothèque !

Dans

#ifndef ISR_SERVO_DEBUG
  #define ISR_SERVO_DEBUG               1
#endif

Qui pour moi indique que si ISR_SERVO_DEBUG n'est pas défini on le force à 1
Il devrait être à 0 puisqu'il est mis
#define ISR_SERVO_DEBUG 0
dans le script

J'ai donc mis

#ifndef ISR_SERVO_DEBUG
  #define ISR_SERVO_DEBUG               0
#endif

Et cela fait le travail : pas de sortie en com, juste 2 warnings

Si quelqu'un peut m'expliquer pourquoi d'origine le define du script n'est pas pris en compte je me coucherais ce soir moins ignorant

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.