Unable to get multiple PWM pins to work simultaneously

Hi topherbuckley,

Your behavior is caused from the flow you configure the PWM.

Please refer to the following modification in your python script

    # Pin Setup:
    # Board pin-numbering scheme
    GPIO.setmode(GPIO.BOARD)
    # set pin as an output pin with optional initial state of HIGH
-   GPIO.setup(pwm_pins, GPIO.OUT, initial=GPIO.HIGH)

    _frequency_hz = 50
    _duty_cycle_percent = 25
    incr = 5

    # p1 is a PWM object.
    # ERROR the order of the p1 and p2 initialization determines which one works
    # and which one fails. Whichever is initialized last will work, and whichever is
    # first will fail. (verified with oscilloscope and stepping through with pdb). 
+   GPIO.setup(pwm_pins[0], GPIO.OUT, initial=GPIO.HIGH)
    p1 = GPIO.PWM(pwm_pins[0], _frequency_hz)
    p1.start(_duty_cycle_percent)
+
+   GPIO.setup(pwm_pins[1], GPIO.OUT, initial=GPIO.HIGH)
    p2 = GPIO.PWM(pwm_pins[1], _frequency_hz)
    p2.start(_duty_cycle_percent)
1 Like