I want to drive an IR LED Emitter with certain pulse waveforms to emulate an IR remote control using the PiGPIO Library on a Raspberry Pi Zero W (1.1).
Based on the examples of the PiGPIO library the generation of a dedicated waveform should be rather simple and I implemented the following test program for the waveform generation:
import sys import time import pigpio IRLEDGPIO = 13 pi = pigpio.pi() if not pi.connected: sys.exit() pi.set_mode(IRLEDGPIO, pigpio.OUTPUT) pi.set_pull_up_down(IRLEDGPIO, pigpio.PUD_OFF) # ON OFF DELAY on=[pigpio.pulse(1<<IRLEDGPIO, 0, 21300), pigpio.pulse(0 , 1<<IRLEDGPIO, 840), pigpio.pulse(1<<IRLEDGPIO, 0, 1700), pigpio.pulse(0 , 1<<IRLEDGPIO, 84350)] pi.wave_clear() pi.wave_add_generic(on) onid = pi.wave_create() pi.wave_send_using_mode(onid, pigpio.WAVE_MODE_REPEAT_SYNC) time.sleep(2) pi.wave_tx_stop() pi.wave_clear() # clear all waveforms pi.stop()
The IR LED is connected to GPIO13 (BCM) through a bipolar NPN transistor supplied with 5V to not get any switching noise on the 3.3V rails. I checked the supply voltages and they look good that there is no noise disturbing the Pi in operation.
I would expect a train of on-pulses with 21.3ms and 1.7ms duration, with off-states of 0.84ms and 84.35ms respectively.
However the timings of the two on-pulses set in above script (measured with an IR detector connected to an digital oscilloscope) are quite varying between 4 and 10msec, whereas the off state with 840µs seems to be captured about correctly.
Sometimes the pigpio-daemon seems to crash, not switching the signal off or the channel stays on full on. All in all a rather unstable behaviour.
I already changed the clock frequency with
according to this post
Am I overlooking something in above setup? Is the setup of the pulse definition and the wave creation correct?
Read more here: Source link