Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Configure the code below to satisfy the specifications This exercise consists of two parts: lighting up the external RGB LED, and lighting up the on-board

Configure the code below to satisfy the specifications

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

This exercise consists of two parts: lighting up the external RGB LED, and lighting up the on-board LED. Assume that the timer peripheral clock has a frequency of 16MHz. Assume also that a human eye cannot detect flicker at a refresh rate higher than 100Hz. 2.3.1 RGB LED Control An RGB LED is composed of three different LEDs (red, green, and blue LEDs) combined in a single package. Each individual LED can be turned on to generate a red, green, or blue light. But of course, RGB LEDs are exciting because we can turn on two or even all of them at once to produce different colors. We can even vary the voltage we set at individual pins to vary the intensity of each LED and generate even more colors. You may read more about RGB LEDs here. As you may have expected, we can use PWM to vary the voltage applied at each individual pin to carefully tune the RGB LED and shine a specific color for us. A color hex code is a hexadecimal representation of a color of the form \#RRGGBB, where RR, GG, and BB are hexadecimal values that correspond to the intensities of red, green, and blue in a given color. For a white color with a hex code of \#FFFFFF, the red, green, and blue are at maximum intensities. Meanwhile, we need the minimum intensities of red, green, and blue to produce the black color (\#000000). Try tweaking the red, green, and blue values here, and see how the color changes. For this exercise, the external RGB LED should produce a color based on the last three digits of your student number, xxxxxxabc : digits a,b, and c control the intensities of red, green, and blue, respectively. Each of these digits is assigned a hexadecimal value based on Table 3 to determine the intensity of each light. For a student with a student number of xxxxxx158, the RGB LED should generate a color with a Table 3: Assigned hexadecimal value for a digit. hex code of \#C6398E. Here, we will vary the intensities of red, green, and blue lights by means of pulse width modulation control. We will also treat an RGB LED as three separate LEDs with one common node. To do this exercise, configure the output compare module as follows. The PWM signals for the red, green, and blue LEDs should be center-aligned. Each of these PWM signals should have a switching frequency of 100Hz and a duty cycle that corresponds to the intensity of the light. To obtain the maximum intensity (hexadecimal value is FF), the duty cycle of the PWM signal should be 100%. To obtain the minimum intensity (hexadecimal value is 00 ), the duty cycle should be 0%. For a hex code of \#C6398E, the expected output waveform is shown in Figure 6, where the PWM signals for the red, green, and blue LEDs have a duty cycle of 78%,22%, and 56%, respectively. Here is a sample implementation of this exercise on our development board. Figure 6: Example simulation waveform for the external RGB LED. All pulses are aligned to the center in each period. 2.3.2 On-board LED Control The on-board LED should blink every second, where it is on for 500ms and off for another 500ms. At reset, the brightness of the LED (when on) must be set to 50% of its maximum brightness. Pressing the on-board push-button should either brighten or dim the LED. Initially, a button press should increase the brightness of the LED by 20%. Once the brightness reaches 90%, each of the successive button presses should decrease the brightness by 30%. When the brightness is decreased to 30%, pressing the on-board push-button should increase the brightness by 20%, and so on. Figure 7 shows the expected output waveform. You may also watch this video to observe the behavior of the on-board LED. Figure 7: Simulation waveform for the on-board LED (top) and on-board push-button (bottom), where the LED blinks every second. The brightness of the LED or the duty cycle of the PWM signal is also indicated. 9 As with our previous example, we will vary the duty cycle of a PWM signal to control the brightness of the LED. To achieve a 90% brightness, the duty cycle of the PWM signal should be 90%. For a 30% LED brightness, the duty cycle should also be 30%. In implementing this exercise, set the frequency of the PWM signal to 100Hz

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

What are some keys to successful retirement?

Answered: 1 week ago