In this notebook, The Pmod PWM driver is exercised. Specifically, An AXI Timer is used to a generate pulse width modulated (PWM) signal.
To see the results of this notebook, you will need a Digilent Analog Discovery 2
and WaveForms 2015
In [1]:
from pynq import Overlay
Overlay("base.bit").download()
In this example, we choose the Digilent Analog Discovery 2 as the scope.
1+
pin (of channel 1) has to be connected to pin 0 on PMODA interface. 1-
pin (of channel 1) has to be connected to GND
on PMODA interface. This example uses PMODA interface. In order to use PMODB interface, users can replace PMODA to PMODB in the examples below. Similarly, users can change the pin number.
In [2]:
from pynq.iop import Pmod_PWM
from pynq.iop import PMODA
pwm = Pmod_PWM(PMODA, 0)
In this example, we generate a $10\,\mu$s clocks with $50\%$ duty cycle for 4 seconds and the stop. Issuing stop command stops both timer sub-modules.
Users have to choose channel 1 for waveform display in the scope.
The output would look like this:
In [3]:
import time
# Generate a 10 us clocks with 50% duty cycle
period=10
duty=50
pwm.generate(period,duty)
# Sleep for 4 seconds and stop the timer
time.sleep(4)
pwm.stop()
In [4]:
import time
# Generate a 20 us clocks with 25% duty cycle
period=20
duty=25
pwm.generate(period,duty)
# Sleep for 5 seconds and stop the timer
time.sleep(5)
pwm.stop()