URL: https://linuxfr.org/forums/programmation-python/posts/probleme-rebond-moteur-python-3-coo Title: problème rebond moteur Python 3 COO Authors: yome22 Date: 2021年03月14日T11:48:41+01:00 License: CC By-SA Tags: python3 et raspberry_pi Score: 3 Bonjour, Je suis en train de mettre au point une cablecam ptz pilotée grâce à une Raspberry P4 en Python 3 et commandé via un un server web. J'ai une fonction manuel et auto pour la faire avancer sur le câble. En gros il y a des fins de course qui font repartir la bête à chaque extrémité du câble. Mon soucis c'est que pour avoir un démarrage progressif du moteur j'ai utilisé: ````python for dc in range(0, 101, 10): self.V1.ChangeDutyCycle(dc) time.sleep(self.t) ```` pour les fonctions de translation, mais dés que j'active la fonction stop j'ai un rebond moteur qui le fait repartir dans le sens inverse pendant 1 sec. Si je retire ces ligne tout fonctionne correctement. la ligne de code concernée: ````python def __init__(self): GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(self.MoteurOutputPinL, GPIO.OUT) GPIO.setup(self.MoteurOutputPinR, GPIO.OUT) GPIO.setup(self.MoteurOutputPinN, GPIO.OUT) GPIO.setup(self.TiltSensorPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(self.TiltSensorPin2, GPIO.IN, pull_up_down=GPIO.PUD_UP) self.Pwm() self.initccMan() self.loop() self.Moteur_status = "" def Pwm(self): self.V1=GPIO.PWM(self.MoteurOutputPinN, 1000) self.V1.start(0) 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) if ccDir=="ccstop": GPIO.output(self.MoteurOutputPinR,GPIO.LOW) GPIO.output(self.MoteurOutputPinL,GPIO.LOW) def loop(self): GPIO.add_event_detect(self.TiltSensorPin, GPIO.FALLING, callback=self.ccMan, bouncetime = 3000) GPIO.add_event_detect(self.TiltSensorPin2, GPIO.FALLING, callback=self.ccMan, bouncetime = 3000) ```` je vous remercie d'avance pour votre aide. j'ai passé quelques heures à chercher et je n'ai rien trouvé. je tiens a préciser que je suis un découvreur de python yôme

AltStyle によって変換されたページ (->オリジナル) /