I'm running pigpiod on the Pi, with a Windows PC using the pigpio Python module. I create a connection to the Pi with pigpio.pi() and then send the wave repeat command to create a straightforward frequency output. When I need to change the frequency I create a new wave, stop the previous wave, and send the new one (with wave repeat). This works great, most of the time.
The problem I'm seeing is that periodically the Pi hangs after a new wave repeat command.
The mystery is that it works "most of the time" (like 200 times I can change the frequency by sending a new wave repeat command) but every once in a while the wave repeat command results in a network timeout. I have a display hooked up to the Pi and I can correlate the new wave repeat command with the display going blank -- so I know it's this wave command that is killing the Pi.
Has anyone seen this behaviour? I have heard that power adapters have been problematic on some Pis, but I've been using this same adapter for other work on the same Pi, and so far haven't seen an issue (other than this one of course).
I'd love to hear any ideas!
Edit: Added code
import time import pigpio import ventureredlion FREQUENCY_GENERATOR_BIT = 25 # this is a BroadComm number US_FUDGE_FACTOR = 0 class AutomatedIO: def initialize(self, skipCommunications=False, skipPowerCycle=False): # now connect to the pigpiod daemon running on the Pi piHost = "192.168.10.101" startTime = time.time() self.pi = pigpio.pi(host=piHost) elapsed = time.time() - startTime print "Connected to pigpiod on %s OK in %.3f s" % (piHost, elapsed) self._initPi() def close(self): self._deInitPi() def simulateFrequencyInput(self, frequencyHz): if frequencyHz > 0: period = 1.0 / frequencyHz period_us = 1E6 * period half_period_us = int(period_us / 2 - US_FUDGE_FACTOR) pulses = [pigpio.pulse(1<<FREQUENCY_GENERATOR_BIT, 0, half_period_us), pigpio.pulse(0, 1<<FREQUENCY_GENERATOR_BIT, half_period_us)] self.pi.wave_add_generic(pulses) waveform = self.pi.wave_create() self.pi.wave_send_repeat(waveform) else: self.pi.wave_tx_stop() def _initPi(self): self.pi.set_mode(FREQUENCY_GENERATOR_BIT, pigpio.OUTPUT) self.pi.wave_clear() self.simulateFrequencyInput(0) def _deInitPi(self): self.pi.wave_clear() self.pi.stop() if __name__ == "__main__": A = AutomatedIO() print "created OK" A.initialize() print "initialized OK" for f in range(50, 5000, 50): A.simulateFrequencyInput(f) print "\rsimulated frequency %d" % f, print A.close() print "closed OK"