Starting from:

$30

ECE40862-Lab 2 Solved

1.    Overview
This assignment deals with 3 different peripherals, namely the PWM, ADC, and RTC on the ESP32 Feather Board. In addition to these peripherals, you will also be using timers and interrupts to implement LED control using a potentiometer and switch. The hardware and software implementation details for this assignment are described in the following sections.

2.    Programming Exercise
2.1. Hardware Interfacing 

Interface the following components to the board:

•      An external push button switch as a GPIO (digital) input.

•      An external potentiometer as an analog input.

•      One external LED as a PWM (Pulse Width Modulation) output.

2.2. Software Implementation 

Your program should implement the following functionalities.

•      The program should start by asking the user to input the current date and time as shown in the following format. Use the user inputs to initialize the RTC (real time clock). Use the current time in the EDT time zone for entering the time.

NOTE: Weekdays: Enter 0 for Monday, 1 for Tuesday, …. 6 for Sunday.  

>>> python ghosh37_lab2.py 

Year? 2021 

Month? 9 

Day? 22 

Weekday? 2  

Hour? 7 

Minute? 30 

Second? 00 

Microsecond? 000000 
•      Use the real-time clock (RTC) and a hardware timer to display the current date and time every 30 seconds. Do not use time.sleep(). Use the RTC and a timer interrupt/callback instead. See this URL for more information on callbacks & interrupts in MicroPython. https://docs.micropython.org/en/latest/library/machine.html#machine-callbacks

•      Initialize another hardware timer and read the analog input (potentiometer/pot values) every 100ms using the timer interrupt/callback and ADC. IMPORTANT: Connect the potentiometer only to a pin associated with ADC1 and not ADC2.

•      Initialize and start a PWM signal on the external LED using a frequency of 10 Hz and a duty cycle of 256. The LED should start blinking at the defined frequency.

•      In the beginning, rotating the pot should have no effect on the LED. The LED should continue blinking at predefined intensity and frequency.

•      Detect a switch press using an interrupt/callback. Implement switch debouncing using another timer-based interrupt/callback. o Alternate switch presses should direct control towards either the frequency or the duty cycle of the LED. o The LED’s PWM signal frequency and duty cycle should be controlled by the pot readings.

o   When you press the switch for the first time, the pot should control the LED’s PWM frequency. Now, if you rotate the pot, your LED should blink faster or slower, as the frequency of PWM changes. No change should occur in the LED’s intensity. o When you press the switch for the second time, the pot should control the LED’s PWM duty cycle. Now, if you rotate the pot, your LED’s intensity should be higher or lower, as the duty cycle of PWM changes. No change in the LED’s blinking frequency.

o   The third switch press should revert the control back to the frequency, the fourth press should give control to the duty cycle and the process should continue forever.
 

More products