Avec butées logicielles , pas de multitour !

This commit is contained in:
Samuel 2025-08-16 12:55:29 +02:00
parent f2c39d9117
commit 13098e9112

View File

@ -98,14 +98,14 @@ enum etat_t test_ping()
} }
enum etat_t configure_servomoteur(){ enum etat_t configure_servomoteur(){
sms_sts.ServoMode(SERVO_ID); sms_sts.writeByte(SERVO_ID, SMS_STS_MODE, 3);
sms_sts.writeByte(SERVO_ID, 0x09, 0); // Butée min à 0 sms_sts.writeByte(SERVO_ID, 0x09, 0); // Butée min à 0
sms_sts.writeByte(SERVO_ID, 0x0A, 0); // Butée min à 0 sms_sts.writeByte(SERVO_ID, 0x0A, 0); // Butée min à 0
sms_sts.writeByte(SERVO_ID, 0x0B, 0); // Buté max à 0, pour activer le multitour sms_sts.writeByte(SERVO_ID, 4095 & 0xFF, 0); // Buté max à 4095
sms_sts.writeByte(SERVO_ID, 0x0C, 0); // Buté max à 0, pour activer le multitour sms_sts.writeByte(SERVO_ID, (4095>>8) & 0xFF, 0); // Buté max à 4095
sms_sts.writeByte(SERVO_ID, 0x1E, 3); sms_sts.writeByte(SERVO_ID, 0x1E, 1);
sms_sts.writeByte(SERVO_ID, 0x12, 0x7C); // Registre de "Phase", valeur par défaut 108 (0x6C) sms_sts.writeByte(SERVO_ID, 0x12, 0x6C); // Registre de "Phase", valeur par défaut 108 (0x6C)
return TERMINE; return TERMINE;
@ -123,11 +123,12 @@ enum etat_t mouvement_servomoteur(){
temps_pas_ms = millis(); temps_pas_ms = millis();
// On avance ou recule de d'un pas // On avance ou recule de d'un pas
position += pas_servo; position += pas_servo;
sms_sts.WritePosEx(SERVO_ID, pas_servo, 4800);
// si position > 5000 ou position < 0 // si position > 5000 ou position < 0
if(position > 40100 || position < 0){ if(position > 40100 || position < 0){
pas_servo = -pas_servo; pas_servo = -pas_servo;
} }
sms_sts.WritePosEx(SERVO_ID, position, 4800);
} }
if(millis() - temps_aff_ms > 10 ){ if(millis() - temps_aff_ms > 10 ){
@ -145,7 +146,7 @@ enum etat_t mouvement_servomoteur(){
} }
int lire_registre(int servo_id, int registre_adresse){ int lire_registre(int servo_id, int registre_adresse){
return sms_sts.readByte(servo_id, registre_adresse); return sms_sts.readByte(servo_id, registre_adresse); // Resolution à 1
} }
void lire_tous_les_registres(int servo_id){ void lire_tous_les_registres(int servo_id){