Color Sines Color Vision, Periodic Functions and Computer Technology Overview: Your task in this activity is to control the color of a single pixel—one of the thousands of colored dots which combine to make up the display on a television or computer monitor. You will start with direct control of the pixel, then move on to create mathematical functions that control the color automatically as a function of time. Background: Color is a complex topic with links to many different fields of research and many different types of applications. Major contributions to our understanding of color have come from people as diverse as physicists Isaac Newton and Albert Einstein, biologist Margaret Livingstone, psychologist Kimberly Jameson, medical researcher David Hubel, artist Johannes Itten and many others. Important contemporary uses of color range from packaging to interior design to oil painting to the intense competition among TV manufacturers trying to produce the biggest, sharpest, brightest and most realistic images. Much discussion about color focuses on the three “primary colors,” but there are several different sets of primary colors in wide use. Artists typically use red, yellow and blue as their primary colors when they mix oil pigments. Printers (including both commercial printers and color desktop printers) typically use magenta, yellow and cyan as their primary colors and add black as a fourth ink. Both of these systems are designed to produce color in reflected light. Devices which emit light (such as TV screens, computer monitors and multi-colored signs) almost always use red, green and blue (RGB) as their primary colors. These RGB emitters of light correspond most directly with the receptor cells that absorb light in the human eye. Despite all the talk about primary colors, light actually exists as a continuous spectrum of colors. Modern physicists and chemists understand that none of the “primary colors” are substantially different from the other colors of the spectrum—orange, violet, etc. From their perspective, each true color corresponds to a specific wavelength of electromagnetic waves and to a specific energy level for its photons. Red light, for example, has a longer wavelength than violet light. Red light is also emitted and absorbed in wave-packets (photons), each of which has less energy than a photon of violet light. The physicists and chemists also like to emphasize that visible light is just one small part of the full electromagnetic spectrum, which also includes radio waves, microwaves, infrared, ultraviolet, x-rays and gamma rays. The “primary colors” of visible light remain extremely important, however, to human perception. The existence of “primary colors” is caused by features of the human eye, not by the physical nature of light. The retina of the human eye has three types of cones (color receptor cells) and people perceive color based on the strength of response from these cells. The human eye cannot distinguish, for example, between a true yellow and the combination of red and green, since both produce the same pattern of excitement in the cones. Spectrometers, prisms and other devices can let us see the “truth” about color, but most technical and artistic applications only aim to produce Color Sines Participant Handout Mar. 7, 2006 page 1 the desired response from the people who view their products directly. It is less expensive and just as effective, for example, to create the appearance of “orange” by mixing red and green light in the correct proportion rather than adding an extra orange emitter to every pixel on a TV screen or computer monitor. PART 1 Exploring and Adjusting the Apparatus Connect the RGB Color Mixer to the DIG/SONIC port on the CBL2 or the DIG/SONIC 1 port on the LabPro. Also be sure the calculator is connected correctly to the CBL2 or LabPro interface. Run the CLRSINES program and select the option to “set white.” The ball (which represents a pixel) should glow. You may need to reduce the light in the room to see the glow clearly. Like most apparatus, the RGB Color Mixer needs to be calibrated. There are similar adjustments, either automatic or manual, on TVs and computer monitors. To calibrate the Color Mixer for maximum brightness and correct color: Use a small screwdriver to turn the white screw on each of the blue potentiometers fully (but gently) clockwise. This should give you maximum brightness, but the display may not yet be white. If the display is not white, turn down the one or two colors that appear until the display is white. At least one of the three potentiometers should still be at its maximum clockwise position. 1. Be very careful not to touch the incandescent bulb. After you complete the white adjustment, compare the white color of the RGB Color Mixer with the color of an ordinary incandescent light bulb, using just your eye to view them both. Are both lights the same shade of white, or does one appear bluer or more orange that the other? Write your answer on the Report Form. 2. Now use the spectrometer to view both the RGB Color Mixer and the incandescent bulb. On the Report Form, sketch the two spectra as seen through the spectrometer, being careful to show how the colors align with the numbered scale. One of the great achievements in the establishment of modern quantum physics was the realization that the energy of a photon of light can be calculated as E = h c / λ, where h is Planck’s constant (6.63 x 10-34 Js), c is the speed of light (3.00 x 108 m/s), and λ (lambda) is the wavelength of the light in meters. Most spectrometers show the wavelength of the light in nanometers (nm), and the wavelengths for visible light fall between about 400 and 700 nm. (One nanometer is 1 x 10-9 meters. Some spectrometers use the older unit of angstroms, Ǻ, where 1 angstrom is 1 x 10-10 meters.) 3. Record on the Report Form the wavelength of light at the center of each of the three color bands produced by the Color Mixer. Use the relationship above to calculate the energy of one photon of each color. Record your answers in both joules (J) and electron-volts (eV), where 1 eV = 1.60 x 10-19 J. Color Sines Participant Handout Mar. 7, 2006 page 2 The integrated circuit used in the RGB Color Mixer combines three separate LEDs (light emitting diodes) into a single package. You can see the three diodes in you remove the ball and look closely while the LEDs are off. The manufacturer of the circuit, Sharp Microelectronics of the Americas, reports that the typical forward voltage to produce red light is 2.3 V and the typical voltage needed to produce either green or blue light is 4.2 V. 4. On the Report Form, calculate the energy released by 1 electron as it passes through each of the three diodes, where E = charge x voltage. Express the charge in electrons and the energy in electron-volts. Compare these values to the values you found in question 3. 5. Does it require more energy to produce long wavelength light or short wavelength light? How do you know? Record your answer on the Report Form. Color Sines Participant Handout Mar. 7, 2006 page 3 Color Sines REPORT FORM (Part 1) NAME(S) ____________________________________________________________________ 1. Compare the white color of the RGB Color Mixer with the color of an ordinary incandescent light bulb, using just your eye to view them both. Are both lights the same shade of white, or does one appear bluer or more orange that the other? 2. Sketch below the spectra you observed for the incandescent bulb and the Color Mixer. Label the major colors you see in each spectrum. Incandescent Bulb Color Mixer 3. Calculate the energy of a typical photon of red, green and blue light from the Color Mixer. Record your answer in both joules (J) and electron-volts (eV), where 1 eV = 1.60 x 10-19 J. Wavelength (nm) Wavelength (m) Energy (J) Energy (eV) RED GREEN BLUE 4. Calculate the energy released by 1 electron as it passes through each of the three diodes, where E = charge x voltage. Express the charge in electrons and the energy in electron-volts. Compare these values to the values you found in question 3. Energy (eV) RED GREEN BLUE 5. Does it require more energy to produce a photon of long wavelength light or a photon of short wavelength light? How do you know? Color Sines Participant Handout Mar. 7, 2006 page 4 PART 2 “True Color” and Reasonable Approximations Computer monitors are often rated in terms of their “screeen resolution” and “color depth.” Screen resolution refers to the number of individual pixels on a screen. A monitor might, for example have a screen resolution of “1152 x 864” pixels, meaning that there are 1152 pixels across and 864 down. This requires a total of 1152 x 864 or 995,328 individual emitters, each providing the red, green and blue colors. 1. To get a sense of scale, calculate the width and height of a computer monitor made up of 995,328 ping-pong ball sized pixels like the one on the RGB Color Mixer. The diameter of a ping-pong ball is about 40 mm. Show your work on the report form. “Color depth” or “color quality” refers to the number of different colors the screen can display at each pixels. In a sense, the color depth is always three, since monitors can only display red, green and blue. On the other hand, many monitors claim to show “true color” in 16,777,216 variations. This definition of “true color” comes from the monitor’s ability to set each one of the red, green or blue emitters to any of 256 levels of brightness (numbered as integers from 0 through 255. Since any level of one color can be combined with any level of the other two colors, that allows for 256 x 256 x 256 = 16,777,216 possible combinations. There could be even more Color selection tool with RGB values combinations if the monitor allowed more than 256 in Corel’s Paint Shop Pro brightness levels, but 256 is a convenient value for computers since it corresponds to the information stored in 1 byte (8 bits) of memory for each of the three colors in a pixel. It is also good enough for almost all practical purposes, since not even the most artisitic human eye can actually recognize all the differences among 16 million colors. Some monitors save computing power by using “high color” instead of “true color.” “High color” uses 32 distinct levels of red, 32 levels of blue and 64 levels of blue. This allows 32 x 32 x 64 or 65,536 possible color combinations, still more than enough for most people. Using “high color” means that the memory required to store the color on each pixel is reduced from 3 bytes to 2 bytes. Earlier computer designers were even more concerned with efficient use of computer memory and computational power and used just 1 byte per pixel, allowing 256 distinct color combinations. As operated by the Color Sines calculator program and a CBL2 or LabPro, the RGB Color Mixer allows 16 distinct color levels for each of its three primary colors, with the levels numbered as integers from 0 through 15. A level of “0” means that the emitter is off and that color is not emitted. A level of 15 means the color is emitted at the maximum intensity allowed by the physical system. Intermediate levels provide intermediate intensity. A level of “5” on the blue emitter, for example, means that blue is emitted at 5/15ths or one-third of its maximum possible value and value of “10” on the green emitter will produce green light at two-thirds of its Color Sines Participant Handout Mar. 7, 2006 page 5 maximum. If both occur simultaneously, the light appears as a shade of aqua (between green and blue) but closer to the green.1 2. On the Report Form, calculate the “color depth” of the RGB Color Mixer. Use the COLOR SINES calculator program to experiment with various combinations of red, green and blue. Start the COLOR SINES program (abreviated as CLRSINES) on the calculator and reset the white if necessary. Select DIGITAL METHODS and try enterring various combination of integers from 0 and 15. 3. The Report Form provides a table of input values and asks you to describe the resulting color. Note that color names are very subjective and yours may not be the same as the names suggested by others. 4. The second table on the Report Form describes colors and asks you to find a combination of integers which reproduces that color reasonably well. 1 Good observers might note that the RGB Color Mixer is a digital system, which means it is either on or off, never part way between. In a practice common to LEDs and other electronic devices, the Mixer uses “pulse width modulation” to achieve intermediate power. When the level is “5,” for example, the emitter is turned on one-third of the time and off two-thirds of the time. The on-off cycle is completed in about 1 millisecond—too fast for the human eye to detect that the color is actually going on and off. Color Sines Participant Handout Mar. 7, 2006 page 6 Color Sines REPORT FORM (Part 2) NAME(S) ____________________________________________________________________ 1) Calculate the width and height of a computer monitor made up of 995,328 ping-pong ball sized pixels like the ball on the RGB Color Mixer. The diameter of a ping-pong ball is about 40 mm. Show your work here. 2) Calculate the “color depth” of the RGB Color Mixer. 3) Test each set of input values and describe or name the resulting color. Color names are very subjective and yours may not be the same as the names suggested by others. Red Green Blue Red Green Blue Red Green Blue = = = = = = = = = 0 15 0 8 0 15 15 15 0 Red Green Blue Red Green Blue Red Green Blue = = = = = = = = = 13 2 0 8 8 0 10 15 10 4) Experiment to find a combination of integers which gives a reasonable approximation for each color described below. Red Aqua Red Green Blue Red Green Blue = = = = = = ___ ___ ___ ___ ___ ___ White with a bluish tint Red-orange Red Green Blue Red Green Blue = = = = = = Color Sines Participant Handout Mar. 7, 2006 page 7 ___ ___ ___ ___ ___ ___ PART 3 Oscillating Colors The screen of a TV or computer monitor has many thousands of pixels and millions of possible colors and these need to be updated many times per second—far faster than any human could do the calculations or make the adjustments. The technology relies on its electronics to carry out the calculations, but the people who design and maintain that technology still have to understand how it can be done. Demanding users—people who strive to achieve the best possible results from the equipment they buy—also benefit from understanding how color can be programmed mathematically. This activity has a second purpose as well, since the mathematics used in this activity applies generally to all “harmonic oscillations.” Light itself considers of electrical and magnetic fields in harmonic ocsillation, but other examples include tuning circuits in radios and TVs, the vibrations caused by earthquakes, the musical notes produced by a violin, and the resonances that can destroy a bridge.You may never again program colors quite this way, but the exercise will help you understand and control the mathematics which describes all oscillations. Your immediate assignment, however, is to program the colors of the RGB Color Mixer so they oscillate in controlled, predicable, harmonic ways. The general equation to describe simple harmonic motion can be written as shown below. Calculators must be in radian mode to use the function as written. Y = C + A sin(2л f t + φ) In this equation, “C” is the “central offset.” It specifies the center point for the oscillation. In many case the offset is zero since the oscillation is alternately positive and negative. Particularly in electronic systems, however, the offset must often be set to a value above zero in order to keep the oscillation from becoming negative. In our color programs, the offset will be “7.5,” which is the middle of our 0 to 15 brightness scale. (It would not make physical sense to progam our light emitter for a negative brightness, unless perhaps we had a device that actually sucked in light rather than emitting it.) “A” is the “amplitude.” It specifies how far the oscillation can vary from the center point. “A” is always a positive number, but the equation still allows the oscillation to either rise above the center point or drop below the center point by the amoun “A.” Since the maxium brightness availabe with our system is 15 and the minimum is 0, the largest possible amplitude with our system is 7.5. “f” is the “frequency.” It specifies the number of complete oscillations per second, and has units of hertz (Hz). The higher the frequency, the more rapidly the oscillation progresses. “φ” (the Greek letter “phi”) is the “phase angle.” It specifies the point in the cycle at which the vibration begins. If φ = 0, then when when t = 0 the oscillation starts at its center point and is increasing. If φ = л/2, the oscillation has a quarter-cycle “head start,” and has already reached its maximum when t = 0. “φ” is most important when you need to consider how two or more different oscillation work together. That happens, for example, if you must coordinate the oscillation of a red LED with the oscillation of a green LED. Color Sines Participant Handout Mar. 7, 2006 page 8 “t” is the elapsed time, measured in seconds. Unlike the four constants described above, t is a variable that changes during the vibration. It will begin with a value of zero when you start the oscillation and keep increasing without limit until you or someone else stops the oscillation. “Y” is the quantity that is oscillating. In this activity Y specifies the instantaneous brightness of an individual color within our pixel. For our physical system, Y must have an integral value from 0 to 15, but that is not necessarily true for the equation itself. If the equation were to tell the RGB Color Mixer to implement a brightness of “-5,” for example, the system will convert that to its minimum output of “0.” If the equation were to specify a value greater that our system’s maximum of 15, the actual output will be reduced to 15. Since there are only 16 discrete outputs possible (including “0” or off), all non-integral values produced by the equation are rounded automatically to the nearest integer. Quit the COLOR SINES program if it is running and press the calculator’s “y=” key at the top left of the keypad to display the “Y functions.” In our program, Y1 controls the brightness of the red LED, Y2 controls the green LED and Y3 controls the blue LED within the RGB integrated circuit. Enter the three Y functions as shown in the middle screen at right. Note that there must be a function specified for each of the three LEDs, even if that function is a simple “0” as shown for Y3. Press 2nd QUIT to exit the function editor and restart the COLOR SINES program. Select “Calculate Colors” and run the functions you programmed. This system is far too slow for a real computer monitor, therefore providing a opportunity to analyze and control in detail how the harmonic oscillation function works. Note that the program updates just once every 5 seconds and that there is a transition period during which the colors go off. Time lags, refresh rates and transitional behavior are also a concern in the design of real monitors, where they normally occur too fast for the human eye to detect. 1. The table on the Report Form shows the digital output produced by the functions above during the first 60 seconds after the program starts. First predict from the digital values what colors you expect to see with each 5-second update, then restart the calculator to check your predictions. 2. Match the functions shown above for the red and green LEDs with the general equation for simple harmonic motion. On the Report Form, identify the values for each constant. 3. On the Report Form, show sample calculations to replicate the program’s answers for one of the “t” values. 4. Modify Y1 or Y2 or both so the RGB Color Mixer will oscillate with the same frequency as before but showing only yellow light. The light should begin at a medium level, increase to maximum brightness after 10 seconds, emit no light when t = 30 seconds, and return to maximum brightness when t = 50 seconds. It should also be at maximum brightness when t = 90 s, 130 s, 170s, etc. Test your results and record the functions you use on the Report Form. Also answer questions 5 – 8 on the Report Form. Color Sines Participant Handout Mar. 7, 2006 page 9 Color Sines REPORT FORM (Part 3) NAME(S) ____________________________________________________________________ 1) Complete the table below to show first the color you expect and then the color you observe at each 5-second interval as the program runs. Time, t (seconds) 0 5 10 15 20 25 30 35 40 45 50 55 60 Brightness Levels Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue Red Green Blue = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Color Expected Color Observed 8 8 0 13 2 0 15 0 0 13 2 0 8 8 0 2 13 0 0 15 0 2 13 0 8 8 0 13 2 0 15 0 0 13 2 0 8 8 0 Color Sines Participant Handout Mar. 7, 2006 page 10 2) Compare the specific functions used by the calculator with the general function for simple harmonic oscillations, Y = C + A sin(2л f t + φ). Identify the value used for each constant. For the red LED For the green LED C = ______ C = ______ A = ______ A = ______ f = ______ f = ______ φ = ______ φ = ______ 3) Pick one of the values for t between 0 and 60 seconds. Do your own calculation below to show how the program found the values it found for Y1 and Y2. Remember that the calculator must be in radian mode. t = _____ seconds Red LED Green LED sin(2л f t + φ) = A sin(2л f t + φ) = C + A sin(2л f t + φ) = 4) Record below the function for Y1 and Y2 which make the RGB Color Mixer in yellow light, beginning at a medium level, increasing to maximum brightness after 10 seconds, emitting no light when t = 30 seconds, and returning to maximum brightness when t = 50 seconds. It should also be at maximum brightness when t = 90 s, 130 s, 170s, etc. Y1 =. Y2 =. 5) Modify as many of the function as necessary to make the RGB Color Mixer oscillate with the same timing as in question 4, but showing only violet light. Y1 =. Y2 =. Y3 =. Color Sines Participant Handout Mar. 7, 2006 page 11 6) Modify as many of the function as necessary to make the RGB Color Mixer oscillate twice as fast as in the previous question while showing only white light. Y1 =. Y2 =. Y3 =. 7) Modify as many of the function as necessary to make the RGB Color Mixer oscillate so it (a) begins with a maximum intensity of white light, (b) decreases to zero after 25 seconds and (c) returns to maximum intensity once every 50 seconds. Y1 =. Y2 =. Y3 =. 8) Modify as many of the function as necessary to make the RGB Color Mixer oscillate so it (a) begins with a maximum intensity of white light, (b) becomes pure blue after 25 seconds and (c) returns to maximum white intensity after 50 seconds. Y1 =. Y2 =. Y3 =. CHALLENGE QUESTION: 9) Find a different set of functions which do not use the sine function but achieve exactly the same result as your answer to question 8. Y1 =. Y2 =. Y3 =. Color Sines Participant Handout Mar. 7, 2006 page 12