======Group 3 — Lighting====== Presentation Video: [[https://www.youtube.com/watch?v=q0g2r_Np8HI&list=UUzhauk6375F5jhWDX10hYxA|Link]] =====Group Members===== ^ Students | | Daniel Fink | | David Haidl | | Benjamin Neldner | | Moritz Skowronski | | Jonathan Wieland | | Marcel Borowski | ---- =====Inspiration Card Workshop===== ====Inspiration Cards==== In this section you can view our inspiration cards we created for and used during the workshop. ===Domain Card=== * {{:domaincard_lighting.pdf|Lighting}} ===Subdomain Cards=== * {{:ideation_workshop:subdomain-ambient_lighting.pdf|Ambient Lighting}} * {{:ideation_workshop:subdomain-lighting_as_indication_of_the_system_state.pdf|Lighting as Indication of the System State}} * {{:ideation_workshop:subdomain-lighting_in_the_context_of_security.pdf|Lighting in the Context of Security}} * {{:ideation_workshop:subdomain-notification_lights.pdf|Notification Lights}} * {{:ideation_workshop:subdomain-situationaldimming.pdf|Situational Dimming}} * {{:ideation_workshop:subdomain-tv_evening.pdf|TV Evening}} ===Technology Cards=== * {{:ideation_workshop:group_3:ambilight.pdf|Ambilight}} * {{:technologycard_cellphone.pdf|Cellphone Disco}} * {{:ideation_workshop:technologycard_the_clapper.pdf|The Clapper}} * {{:ideation_workshop:technologycard_wake_up_light.pdf|Wake up light}} * {{:basic_content:inspirationcards:technologycardsfink.pdf|Lifx}} (from the [[inspirationcards|Inspiration Cards]] page) * {{:basic_content:inspirationcards:poldis_stairwaylight.pdf|Poldis Stairwaylight}} (from the [[inspirationcards|Inspiration Cards]] page) * {{:basic_content:inspirationcards:theworkoutorb.pdf|The Workout Orb}} (from the [[inspirationcards|Inspiration Cards]] page) ====Design Concepts==== After presenting our domain and technology cards our first decision, during the Inspiration Card Workshop, was to create something for indoor rooms in the user’s homes. So we excluded for example exteriors, cars or gardens from our further ideas. To get a better overview we then thought about combinations of our domain cards — so which domain could get covered by a single technology — and also assigned the technology cards to the domain cards. ===Rooms=== {{ :ideation_workshop:group_3:rooms.jpg?direct&700 |Rooms}} Our next step was to further assign our domain cards to the several rooms in a house. So for example the {{:ideation_workshop:subdomain-tv_evening.pdf|TV Evening}} subdomain was only suitable for the living room or the bed room, because these are the most common places for a television. In contrast to that some other domains like {{:ideation_workshop:subdomain-notification_lights.pdf|Notification Lights}} were suited for nearly all rooms. Therefore we also created a general category “All Rooms”. ===Wireless Ambient Lighting System=== {{ :ideation_workshop:group_3:functions.jpg?direct&350|Functions}} After discussing we resulted in the idea of an ambient lighting system. This system builds on the [[ikea_led_control|IKEA LED Control]], the side project of one of our members, and makes the interface easier to use and even addressable via Wi-Fi. The main functions of the system are: * Improving the room ambience via colorful light. * Enhancing the immersion of movies or games by lighting the room according to the TV screen. The immersion gets even more enhanced by the use of a projector, which projects light around the TV, that will create an effect, similar to the {{:ideation_workshop:group_3:ambilight.pdf|Ambilight}} by Philips and the [[http://research.microsoft.com/en-us/projects/illumiroom/|IllumiRoom]] by Microsoft. Some ideas for further functions are: * Showing notifications or system states by changing the color of the light. * Security features, like turning the light on when entering the house. ===Hardware Requirements=== For creating our system we need the following hardware: * Arduino Yun (for a wireless solution. If it's not possible we will use an Uno for a wired solution) * Power supply with 12V and a minimum of 2A (2000mA) for example [[http://www.reichelt.de/Universalnetzteile/MW-3H36GS/3/index.html?&ACTION=3&LA=2&ARTICLE=89789&GROUPID=4945&artnr=MW+3H36GS|here]] (for the breadboard or board) * Compressed board of the following circuit diagram {{ :ideation_workshop:group_3:ikea_led_schaltplan_neu.png?direct&600 | Circuit Diagram}} ---- =====Workflow===== Our workflow can be roughly divided into three iterative steps: * [[group_3#Ambilight LED Control via USB|Control of Ambilight LEDs via USB (Arduino Uno)]] * [[group_3#Projector Rendering]] * [[group_3#Ambilight LED Control via WLAN|Updating existing LED Control Solution to work over WLAN (Arduino Yun)]] ===Ambilight LED Control via USB=== For this part of the project we relied in parts on the [[ikea_led_control|Sideproject]] of Daniel, one member of our team, and his already working solution for changing the RGB Colors of a LED via an Arduino Uno. Since his application for changing the RGB values was written in C# the first task was to port his approach to VVVV. Subsequently we had to find a solution to change the RGB colors in the same manner as the borders of the television screen. VVVV provides a [[http://vvvv.org/documentation/screenshot-%28ex9.texture%29|Screenshot Node]] which takes a screenshot of a given part of the screen which we used to capture a few pixels for every side of the screen (left, right, top, down) and combining their respective color to get an average color for every side. For a more detailed explanation of the modified [[http://vvvv.org/documentation/screenshot-%28ex9.texture%29|Screenshot Node]] see [[group_3#AmbilightColor Node]]. {{ :group_project:group_3:rendererblack.png?direct&400|Final Projector image}} ===Projector Rendering=== The second big part of our system was the extension of the screen by using a projector and a similar approach like Microsoft's IllumiRoom. Microsoft extends the screen in video games by computing a larger field of view of the scene and projecting it around the TV. In our case, we just have a the information about what is on the screen. Therefore we can't compute any larger field of view. After some discussion we came up with the idea of just using a blurred version of the TV image and projecting it around the TV. In a first test we outright liked the result and therefore stayed with this concept. Later we optimized this concept by using a pillow for a more smooth border of the projection and reducing the brightness to get a better contrast to the TV. {{ :group_project:group_3:renderer.png?direct&400|Result}} Another important feature is the black rectangle in the center of the projection, which can be resized to the size of the TV. This is important, because without it the TV reflects much more light, which reduced the overall image quality. The final projection can be seen on the top image. All in all this approach results in a very reasonable outcome, which nicely extends the screen of the TV. You can see what the result looks like on the bottom image.   ===Ambilight LED Control via WLAN=== On switching the controlling of the LED Stripes from USB to WLAN several issues arose. To be able to control the LED Stripes via WLAN one has to send REST Calls to the Arduino Yun to be able to change the color. This is simply done by calling a specific URL. However, one was only able to change one of the RGB values per call (i.e. either red, green or blue) - For this we had to modify the code of the Arduino Bridge (see [[group_3#RGB LED Bridge]]) to make it possible to send all three values with one REST Call. It isn't possible to perform more than 2 REST Calls per second without experiencing strong lags though. Yet using only 2 color changes per second isn't enough to make color transitions look smooth. For this we modified the Arduino Bridge again to be able to change from one color to another smoothly (for a more detailed explanation see [[group_3#RGB LED Bridge]]). Now we only had to be able to send REST Calls to two Arduino Yuns simultaneously. This can be easily done by connecting one Yun via Wlan to the other, therefore being able to connect to both Yuns with your Device using only one WLAN Connection. ---- =====Final Project===== ====Hardware==== According to the hardware we developed (as listed below) two different techniques to control nearly any RGB LED strip either wired over USB or wireless over WLAN. In both cases the circuit keeps the same with the difference that you need the [[http://arduino.cc/en/Main/ArduinoBoardYun?from=Products.ArduinoYUN|Arduino Yun]] for the wireless solution. ===Wired Control (USB) with any Arduino=== To control nearly any RBG LED strip with nearly any arduino over USB we use the following VVVV patch with the arduino node: {{ :group_project:group_3:ledcontrolusb.png?direct&800 |VVVV USB LED Control Patch}} The Arduino runs with the "Standard Firmata" of the Arduino IDE. ===Wireless Control (WLAN) with the Arduino Yun=== The Arduino Yun has two processors. One is the ATmega32u4 the other is the Atheros AR9331. In contrast to the AR9331 the 32u4 is not connected the network interfaces. Therefore we send REST commands over WLAN to the AR9331 which runs with the Linux distribution OpenWrt-Yun. The communication between the two processors is done with so called "Bridge" which gets the REST calls from the AR9331, interprets them and finally sends the encoded commands to the 32u4 which controls the digital/analog pins of the Yun. [[http://arduino.cc/en/Main/ArduinoBoardYun?from=Products.ArduinoYUN|{{ :group_project:group_3:bridgeinshort.png?600 | Arduino YUN Bridge}}]] ==RGB LED Bridge== To build our RGB LED Bridge we adapted the example bridge from the Arduino IDE. The example bridge provides the following REST-commands: ^ REST-command ^ Function ^ | http://myArduinoYun.local/arduino/digital/13 | calls digitalRead(13); | | http://myarduinoyun.local/arduino/digital/13/1 | calls digitalWrite(13,1); | | http://myarduinoyun.local/arduino/analog/9/123 | analogWrite(9,123); | | http://myarduinoyun.local/arduino/analog/2 | analogRead(2); | | http://myarduinoyun.local/arduino/mode/13/input | pinMode(13, INPUT); | | http://myarduinoyun.local/arduino/mode/13/output | pinMode(13, OUTPUT); | Performing the following modifications to the example bridge we get the possibility to set the values of three pins (red, green, blue) at once: int oldRed = 255; int oldGreen = 255; int oldBlue = 255; void process(YunClient client) { // read the command String command = client.readStringUntil('/'); // is "digital" command? if (command == "digital") { digitalCommand(client); } // is "analog" command? if (command == "analog") { analogCommand(client); } // is "mode" command? if (command == "mode") { modeCommand(client); } // is "rgbLed" command? if (command == "rgbLed") { rgbLedCommand(client); } } void rgbLedCommand(YunClient client) { int pin1, pin2, pin3, value1, value2, value3, tempRed, tempGreen, tempBlue; //Read first pin (Red) pin1 = client.parseInt(); //Read first value (Red) value1 = client.parseInt(); //Read second pin (Green) pin2 = client.parseInt(); //Read second value (Green) value2 = client.parseInt(); //Read third pin (Blue) pin3 = client.parseInt(); //Read third value (Blue) value3 = client.parseInt(); //For-Loop for smoothing for(float i = 1; i < 11; i++){ tempRed = (float) oldRed * ((10.0f - i)/10.0f) + (float) value1 * (i/10.0f); tempGreen = (float) oldGreen * ((10.0f - i)/10.0f) + (float) value2 * (i/10.0f); tempBlue = (float) oldBlue * ((10.0f - i)/10.0f) + (float) value3 * (i/10.0f); analogWrite(pin1, tempRed); analogWrite(pin2, tempGreen); analogWrite(pin3, tempBlue); delay(20); } oldRed = value1; oldGreen = value2; oldBlue = value3; } Now the following command can be used to set e.g. the color to white (255,255,255) when the led strip is connected to the pins 9, 10, 11 of the arduino yun: ^ REST-command ^ Function ^ | http://myArduinoYun.local/arduino/rgbLed/9/255/10/255/11/255 | calls\\ analogWrite(9,255);\\ analogWrite(10,255);\\ analogWrite(11,255);\\ and performs a smoothing function between the old RGB-values and the new ones| As mentioned above a smoothing function is used to interpolate between two RGB values sent via REST-calls to the Arduino. This is needed because the number of REST-calls per second is limited due to technical reasons. The smoothing function calculates for each value (red, green and blue) 9 values which lie between the old value and the new one and sends them to the RGB LED strip. The tenth value calculated by the smoothing function is the new value. ==VVVV Patch== The VVVV patch finally calls the respective URL for the given input color and pins two times in a second. {{ :group_project:group_3:ledcontrolwlan.png?direct&500 |VVVV WLAN LED Control Patch}} ===Wiring=== Both the wired and the wireless solution are based on the same [[group_3#Hardware Requirements|above]] shown circuit. The only difference is that the wireless solution needs the Arduino Yun and the wired solution can be build with nearly any Arduino (e.g. Uno or Mega). ====Software==== ===VVVV Ambilight System=== The Ambilight system, our main application, consists of several modules. Below you can see an image of our root patch. {{ :group_project:group_3:root.png?direct&700 |Root Patch}} ==MyScreenShotVideo Node== {{ :group_project:group_3:myscreenshotvideo.png?direct&550|MyScreenShotVideo Node}} This node generates the textures, which are used by the other nodes in the root patch. It can either generate textures of the screen by using the ScreenShot node of VVVV or play a video file using FileStream and VideoTexture nodes of VVVV. The former method works great on Windows 7, but has huge performance problems in Windows 8.1 resulting in a maximum of about 15 frames per second in the projector rendering even on a desktop PC. Because of that we thought of another way to watch video files on Windows 8.1, which ended up in using the FileStream node of VVVV. But this also wasn't exactly brilliant: The DirectX render of VVVV has many issues with multiple displays — a feature which was mandatory for us. Therefor this work-around needed another work-around: We created two FileStream and VideoTexture nodes, one for each texture. The node then finally puts out the original texture, which is used by the Video Renderer for video playback, and the blurred texture of either the screenshot or the video playback. ==Video Renderer== This renderer is only used when playing videos directly in VVVV. It isn't needed when using the screenshot method. ==BeamerOutput Node== This node generates the final rendering for the projector. It renders the blurred texture on a pillow and adds the black rectangle on top of it. The node also allows to change various settings, like the scale and position of the black rectangle or the brightness and fade amount of the pillow with the blurred texture. You can find an image of the resulting rendering in section [[group_3#Projector Rendering]]. {{ :group_project:group_3:ambilightcolor.png?direct&200|AmbilightColor Node}} ==AmbilightColor Node== This node computes the colors for the LED strips. It can compute the color for each side of the screen plus the center. To compute the final color the node averages the color of five sample points from the blurred texture. We use the blurred texture here to indirectly average over an even bigger area and to reduce the impact of noise, which can easily occur in images and videos. The averaging uses five points to get the final color. These points are located on the selected side of the texture. On the image below you can get an rough overview where these points are located (click on the image to get the full sized version of it). After averaging each channel — red, green and blue — individually we further optimize the colors by increasing the saturation of the colors. This is because our tests showed, that the blurring and the averaging of the colors often result in pale colors.     {{ :group_project:group_3:ambilight.png?direct&800 |Ambilight Computation}} ==LEDControlUSB Node== See section [[group_3#Wired Control (USB) with any Arduino]]. ==LEDControlWLAN Node== See section [[group_3#VVVV Patch|Wireless Control (WLAN) with the Arduino Yun]] ===LED Control App (Windows 8)=== One part of our concept was to improve the ambient in a room. For this reason we've created a Windows 8 App to control the lighting manually. If you actually don't use the whole system you can use this app. It provides 24 predefined colors and a custom color set function. This App uses also REST calls to communicate wireless with the LED bars. {{ :group_project:group_3:led_windows_8_app.png?direct&800 |Windows 8 Color Control App}} ===LED Control Program (Java)=== In addition to the Windows 8 app we wrote a little Java program to enable the possibility of controlling the RGB LED strip from every system which runs Java. Like the Windows 8 app the program provides a set of predefined colors and a function to set custom colors. It also uses REST calls for communication. In addition it allows to set the IP adress and the pins used of two Yuns in a setting dialog. {{:group_project:group_3:wireless_rgb_led_control.png?nolink&510|}} {{:group_project:group_3:wireless_rgb_led_control_settings.png?nolink&292|}} ---- =====Further Information===== ====Hardware==== * PC or Laptop, running Windows 7, with W-Lan * Beamer * [[http://arduino.cc/en/Main/ArduinoBoardYun?from=Products.ArduinoYUN|Arduino Yun]]((Arduino Yun Guide [[http://arduino.cc/en/Guide/ArduinoYun|(Official Page)]]))((Arduino Yun Bridge Documentation [[http://arduino.cc/en/Reference/YunBridgeLibrary|(Official Page)]])) * RGB LED-Strips e.g. [[http://www.ikea.com/us/en/catalog/products/50192365/|IKEA Dioder]] * Additional Power supply for the LEDs ====Software==== * {{:group_project:group_3:vvvv_ambilight_system.zip|VVVV Ambilight System}} * {{:group_project:group_3:wirelessrgbledcontrol.zip|Wireless RGB LED Control (Java)}} ====Presentation and Video==== ...