Mar-21-2021, 05:17 PM
Hello,
I am developing a cablecam around a raspberry and I have bounce problems with the translation motor.
This camera and others, aim to record music groups in live sessions
The motor has a dual control:
1 °) via a web server a left right and stop command
2 °) via 2 limit switches (hall effect sensors) with 2 magnets at the ends of the cable
my concern is that I have random operations or the motor does the opposite of what we ask it to do
here is the part of the code concerned
merci beaucoup
I am developing a cablecam around a raspberry and I have bounce problems with the translation motor.
This camera and others, aim to record music groups in live sessions
The motor has a dual control:
1 °) via a web server a left right and stop command
2 °) via 2 limit switches (hall effect sensors) with 2 magnets at the ends of the cable
my concern is that I have random operations or the motor does the opposite of what we ask it to do
here is the part of the code concerned
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
class PiTZ: MoteurOutputPinL = 24 MoteurOutputPinR = 23 MoteurOutputPinN = 18 TiltSensorPin = 19 TiltSensorPin2 = 16 Moteur_status = "" t = 0.05 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 .loop() self .configCall( "default" ) self .initPan() self .initTilt() self .initZoom() self .initFocus() self .initIrCut() self .initIMG() self .initccMan() def Pwm( self ): self .V1 = GPIO.PWM( self .MoteurOutputPinN, 1000 ) self .V1.start( 0 ) def initccMan( self ): self .ccMan() self .ccManStop() 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) elif 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 = ""): if ccstop = = "ccstop" and self .Moteur_status = = 1 : 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) elif ccstop = = "ccstop" and self .Moteur_status = = 0 : 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 = 5000 ) GPIO.add_event_detect( self .TiltSensorPin2, GPIO.FALLING, callback = self .ccMan, bouncetime = 5000 ) |