yome22 a écrit 5 commentaires

  • # modification de la fonction stop

    Posté par  . En réponse au message problème rebond moteur Python 3 COO. Évalué à 1.

    pour que la fonction stop soit réellement opérationnelle et que le moteur ralentisse en s'arrêtant , voici le code complet

    def ccMan(self,ccDir=""):
            global Moteur_status
            self.Moteur_status = not self.Moteur_status
            GPIO.output(self.MoteurOutputPinL, self.Moteur_status)
            GPIO.output(self.MoteurOutputPinR, self.Moteur_status)
            GPIO.output(self.MoteurOutputPinN, self.Moteur_status)
            if self.Moteur_status == 1 or ccDir=="ccleft":
                GPIO.output(self.MoteurOutputPinL,GPIO.HIGH)
                GPIO.output(self.MoteurOutputPinR,GPIO.LOW)
                GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
                for dc in range(0, 101, 10):
                    self.V1.ChangeDutyCycle(dc)
                    time.sleep(self.t)           
            if self.Moteur_status == 0 or ccDir=="ccright":
                GPIO.output(self.MoteurOutputPinL,GPIO.LOW)
                GPIO.output(self.MoteurOutputPinR,GPIO.HIGH)
                GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
                for dc in range(0, 101, 10):
                    self.V1.ChangeDutyCycle(dc)
                    time.sleep(self.t)
    def ccManStop(self,ccstop=""):
            global Moteur_status
            GPIO.output(self.MoteurOutputPinL, self.Moteur_status)
            GPIO.output(self.MoteurOutputPinR, self.Moteur_status)
            GPIO.output(self.MoteurOutputPinN, self.Moteur_status)
            if self.Moteur_status == 1 and ccstop=="ccstop":
                GPIO.output(self.MoteurOutputPinL,GPIO.HIGH)
                GPIO.output(self.MoteurOutputPinR,GPIO.LOW)
                GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
                for dc in range(100, -1, -10):
                    self.V1.ChangeDutyCycle(dc)
                    time.sleep(self.t)         
            if self.Moteur_status == 0 and ccstop=="ccstop":
                GPIO.output(self.MoteurOutputPinL,GPIO.LOW)
                GPIO.output(self.MoteurOutputPinR,GPIO.HIGH)
                GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
                for dc in range(100, -1, -10):
                    self.V1.ChangeDutyCycle(dc)
                    time.sleep(self.t)
    def loop(self):
            GPIO.add_event_detect(self.TiltSensorPin, GPIO.FALLING, callback=self.ccMan, bouncetime = 10000)
            GPIO.add_event_detect(self.TiltSensorPin2, GPIO.FALLING, callback=self.ccMan, bouncetime = 10000)

    je me suis aidé tout seul ;-) mais si ça peut servir à d'autre

  • # J'ai fini par trouver ;-)

    Posté par  . En réponse au message problème rebond moteur Python 3 COO. Évalué à 2.

    alors pour ceux qui en auraient besoin
    j'ai séparé la fonction stop et créer une nouvelle définition,
    et modifier l'adresse de la fonction stop dans le serveur

    def ccManStop(self,ccstop=""):
    
            if ccstop=="ccstop":
                GPIO.output(self.MoteurOutputPinL,GPIO.LOW)
                GPIO.output(self.MoteurOutputPinR,GPIO.LOW)
                GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
                for dc in range(100, -1, -10):
                    self.V1.ChangeDutyCycle(dc)
                    time.sleep(self.t)
  • [^] # Re: betement

    Posté par  . En réponse au message problème rebond moteur Python 3 COO. Évalué à 1. Dernière modification le 14 mars 2021 à 21:36.

    le liens vers la vidéo qui montre en action le moteur avec l'utilisation du moteur avec le script de ralentissement.
    vidéo moteur commande gauche, puis stop et droite

  • [^] # Re: betement

    Posté par  . En réponse au message problème rebond moteur Python 3 COO. Évalué à 1.

    Bonsoir,

    Je l'ai fait mais ça crée un boucle plus longue à l'arrêt
    un aller et un retour

    if ccDir=="ccstop":
                GPIO.output(self.MoteurOutputPinL,GPIO.LOW)
                GPIO.output(self.MoteurOutputPinR,GPIO.LOW)
                GPIO.output(self.MoteurOutputPinN,GPIO.HIGH)
                for dc in range(100, -1, -10):
                    self.V1.ChangeDutyCycle(dc)
                    time.sleep(self.t)
  • [^] # Re: betement

    Posté par  . En réponse au message problème rebond moteur Python 3 COO. Évalué à 1.

    Bonsoir,

    Je l'ai fait mais ça crée un boucle plus longue à l'arrêt
    un aller et un retour