PWM stop() requires a 0.2 second pause before channel can be set HIGH
A Python module to control the GPIO on a Raspberry Pi
Brought to you by:
croston
After stopping a PWM it's necessary to wait before it is possible to set the port to HIGH.
For example:
self.pulse.stop()
time.sleep(0.2)
GPIO.output(self.port,GPIO.HIGH)
Line 3 will not set the port HIGH if the SLEEP is 0.1, nor even 0.15
Not sure what you can do?
Add a queue somewhere?
This is probably because in https://sourceforge.net/p/raspberry-gpio-python/code/ci/default/tree/source/soft_pwm.c#l90 it only checks if the PWM has been stopped after the thread has slept for both the on_time and the off_time, and so if you try to set the port to HIGH immediately after stopping the PWM (and you're using a "low" frequency) then the PWM-thread is probably still sleeping when you do GPIO.output, and so by the time the PWM-thread terminates, the GPIO.output call has been-and-gone.
It's not a proper fix, but I guess one way of reducing the impact of this would be to add
at https://sourceforge.net/p/raspberry-gpio-python/code/ci/default/tree/source/soft_pwm.c#l102
Looks like a possible duplicate of https://sourceforge.net/p/raspberry-gpio-python/tickets/76/ ?