OK, navigating constraints.
There are times when I need a short cycle (<1s), and times when I need a long cycle (up to minutes). Sometimes I want PWM within PWM and sometimes I don't.
I can address a pin as either GPIO or PWM. If I want to switch between the two, I can go from GPIO to PWM at will, but PWM to GPIO fails. As in
Code: Select all
>>> import Adafruit_BBIO.PWM as PWM
>>> import Adafruit_BBIO.GPIO as GPIO
>>> GPIO.setup('P8_13', GPIO.OUT)
>>> GPIO.output('P8_13', GPIO.HIGH)
>>> PWM.start('P8_13', 50, 1000)
>>> PWM.stop('P8_13')
>>> PWM.cleanup()
works but the reverse fails silently. No signal, no error message. The only way I have found to switch back is to reboot. Which doesn't work when I am trying to wrap this in a service that can be controlled by end users, that can run with minimal involvement from me.
So I try dispensing with GPIO and do PWM with a duty cycle of 100. Call it a degenerate case of PWM within PWM.
Code: Select all
import Adafruit_BBIO.PWM as PWM
from time import sleep
while True:
PWM.start('P8_13', 100, 1000)
sleep(2)
PWM.stop('P8_13')
sleep(2)
This works... on the first cycle. On subsequent cycles, I see an odd flash and then nothing, over and over. When I look in the filesystem I see
Code: Select all
0s #> cat /sys/devices/ocp.3/pwm_test_P8_13*/duty
0
I don't see this problem with a 50% duty cycle.
If I try
Code: Select all
while True:
PWM.start('P8_13', 100, 1000)
sleep(2)
PWM.set_duty_cycle('P8_13', 0)
PWM.set_frequency('P8-13', 1000)
sleep(2)
It works... for about twenty minutes.
If I try
Code: Select all
while True:
PWM.start('P8_13', 100, 1000)
sleep(2)
PWM.start('P8_13', 0, 1000)
sleep(2)
It works... for about ten minutes.
In both cases I see a 0 in /sys/devices/ocp.3/pwm_test_P8_13*/duty as above, when it should be 100.
Ideas? Why would this be?