Microcomputers Lab: Exploring PWM
Objectives: To gain a better understanding of Pulse Width Modulation.
What you will need: Arduino UNO, Analog Discovery Kit (ADK), LU EE Component Kit, jump wires, a computer with installed Arduino IDE and ADK.
Assignment:
1. Connect an LED to PWM pin 10. Use an appropriate resistor. Connect the oscilloscope channel 1 of Analog Discovery kit (ADK) to the same Arduino pin. Connect together grounds of Arduino and ADK.
2. Open "Fade" example from "Basics" and modify it for the pin 10. Upload the sketch to Arduino and observe the LED fading in.
3. Modify the sketch so that the LED would fade slower, start the ADK's oscilloscope and observe the voltage on the pin.
4. Adjust the scope's time base so that you would see a train of pulses. Take screenshots for two different pulse durations. Connect a 4.7 µF capacitor in parallel to the LED. Are there any changes in the pulses' shape? Take a screenshot and then remove the capacitor.
5. Adjust the scope's time base so that you would see a signal resembling a sawtooth. Take a screenshot. Connect a 220 µF capacitor in parallel to the LED. Take a screenshot and then remove the capacitor.
6. Write a code that would modify the LED brightness according to a low-frequency sinusoid. Observe the corresponding voltage waveform on the scope, take a screenshot.
In your report:
1. Report the screenshots you have collected. Based on your observations, what do you conclude regarding the PWM operation?
2. Report the code you produced in 6. Comment on it.
3. Can you propose any ways to make the PWM digital signal closer to the analog signal?