<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Programmers&#039; Pain</title>
	<atom:link href="http://www.programmers-pain.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.programmers-pain.de</link>
	<description>Another cautionary tale about a programmers&#039; daily business</description>
	<lastBuildDate>Sat, 24 Nov 2012 15:01:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>There has been some progress&#8230;</title>
		<link>http://www.programmers-pain.de/2012/11/24/there-has-been-some-progress/</link>
		<comments>http://www.programmers-pain.de/2012/11/24/there-has-been-some-progress/#comments</comments>
		<pubDate>Sat, 24 Nov 2012 15:01:08 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[LED Coffee Table]]></category>
		<category><![CDATA[coffee table]]></category>
		<category><![CDATA[Rainbowduino]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=845</guid>
		<description><![CDATA[Eight months.. wow! Quite some time has passed since I've decided to switch my more or less working 512 RGB LED coffee table to the newer Rainbowduino V3 controllers to drive those LEDs. At this point I couldn't really anticipate that getting a working firmware for my needs up and running would be that time [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_842" class="wp-caption alignleft" style="width: 340px"><a href="http://www.programmers-pain.de/wp-content/uploads/work-in-progress-1.jpg" rel="lightbox[845]" title="A snapshot taken of the main technical compartment somewhere in the midle of getting some wiring work done"><img class="wp-image-842" title="A snapshot taken of the main technical compartment somewhere in the midle of getting some wiring work done" src="http://www.programmers-pain.de/wp-content/uploads/work-in-progress-1-1024x682.jpg" alt="A snapshot taken of the main technical compartment somewhere in the midle of getting some wiring work done" width="330" height="220" /></a><p class="wp-caption-text">A snapshot taken of the main technical compartment somewhere in the midle of getting some wiring work done</p></div>
<p>Eight months.. wow! Quite some time has passed since I've decided to switch my more or less working <a href="http://www.programmers-pain.de/category/led-coffee-table/" target="_blank">512 RGB LED coffee table</a> to the newer <a href="http://www.seeedstudio.com/wiki/Rainbowduino_v3.0" target="_blank">Rainbowduino V3 controllers</a> to drive those LEDs. At this point I couldn't really anticipate that getting a working firmware for my needs up and running would be that time consuming. Luckily I was able to <a href="http://www.programmers-pain.de/2012/09/19/finally-a-working-streaming-firmware-for-my-rainbowduino-v3-controllers/" target="_blank">solve this problem</a> nearly two month ago so that it was time again to focus on the table and get the remaining hardware tasks sorted out. If you want to find out what has happened the last two months concerning my coffee table project than feel free to continue reading this blog post <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-845"></span>Getting back to work on the table hardware itself wasn't really fun in the beginning since I had to remove quite some internals first that I've added to get my old <a href="http://www.seeedstudio.com/wiki/Rainbowduino_LED_driver_platform_-_Atmega_328" target="_blank">Rainbowduino V2 controllers</a> flying those days. That included two <a href="http://www.pjrc.com/store/teensy.html" target="_blank">Teensy controllers</a> that were used to drive four Rainbowduino V2 controllers each and all the wiring effort needed like the <a href="http://en.wikipedia.org/wiki/I%C2%B2C" target="_blank">I2C links</a> between them or the power supply of the controllers - cutting this stuff off with a wire cutter destroyed quite some hours of invested working hours. The god thing is that the whole wiring effort for the new Rainbowduino V3 controllers has been reduced to a simple USB cable plus an additional wire to be able to reset them. That's quite an improvement compared to those RX/TX, I2C, reset and power supply cables needed by the old controllers.</p>
<div id="attachment_841" class="wp-caption alignright" style="width: 340px"><a href="http://www.programmers-pain.de/wp-content/uploads/frontpanel.jpg" rel="lightbox[845]" title="The two front panels as they have been delivered to me by the Schaeffer AG"><img class="wp-image-841" title="The two front panels as they have been delivered to me by the Schaeffer AG" src="http://www.programmers-pain.de/wp-content/uploads/frontpanel-1024x593.jpg" alt="The two front panels as they have been delivered to me by the Schaeffer AG" width="330" height="191" /></a><p class="wp-caption-text">The two front panels as they have been delivered to me by the Schaeffer AG</p></div>
<p>After those leftovers were removed I continued working on the front panels that I will use to cover my two <a href="http://www.programmers-pain.de/2012/02/27/a-closer-look-at-the-rgb-led-coffe-table-internals/" target="_blank">technical compartments</a> containing the PC and the amplifiers. The easiest and probably also the cheapest way to archive that would have been to get some plywood and drill the necessary cuttings into it manually so that you wouldn't be able to touch the dangerous parts of the table internals and potentially get electrocuted any more. After drawing the first sketches I've noticed that I have quite some buttons and knobs that I want to expose to the outside. While thinking about the effort needed to drill all those holes and cuttings by myself - which includes a high chance that it'll look like crap after I'm done with it - I thought it's maybe an better idea to go for some milled aluminium front panels instead. With the <a href="http://www.schaeffer-ag.de/" target="_blank">Schaeffer AG</a> located in Berlin, Germany I've found a nice company that did helped me out. They're focused on milling individual units or small production runs and do offer a simple to use design program that is also able to show you the expected manufacturing costs while designing your front panels. I've ordered two panels for a reasonable price which saved me quite some work compared to if I would have tried to make those front panels myself. The quality of those panels was flawless and I can only recommend this company.</p>
<div id="attachment_838" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/banner1.jpg" rel="lightbox[845]" title="Some snapshots taken while milling and assembling the shielded casing for my subwoofer crossover"><img class="size-large wp-image-838" title="Some snapshots taken while milling and assembling the shielded casing for my subwoofer crossover" src="http://www.programmers-pain.de/wp-content/uploads/banner1-1024x384.jpg" alt="Some snapshots taken while milling and assembling the shielded casing for my subwoofer crossover" width="536" height="201" /></a><p class="wp-caption-text">Some snapshots taken while milling and assembling the shielded casing for my subwoofer crossover</p></div>
<p style="text-align: left;">After the front panels have arrived I've started with the panel covering the amplifiers and the subwoofer crossover. As mentioned in one of my <a href="http://www.programmers-pain.de/2011/11/08/things-you-shouldnt-do-3-cut-19-inch-amplifiers-and-subwoofer-crossovers-in-half/" target="_blank">older blog post</a> I did cut my <a href="http://www.reckhorn.com/pages/frequenzweichen/s-1-aktive-subwoofer-satellitenweiche.php" target="_blank">Reckhorn S-1 active subwoofer crossover</a> into two prices a while ago to be able to mount those knobs directly behind the front panel. Since those potentiometers are potentially prone to disturbing noises I wanted to cover then in a metal shielding casing which I originally planed to manufacture it myself out of ordinary sheet metal. Fortunately did my co-worker <a href="http://kupferwerk.org/" target="_blank">Boris</a> offered me to help me out with his milling machine so that this saved me quite some time as if I would have to build this enclosure myself - thanks again, bud!</p>
<div id="attachment_839" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/banner2.jpg" rel="lightbox[845]" title="Some different views of the front panel of the technical compartment containing all sound related hardware"><img class="size-large wp-image-839" title="Some different views of the front panel of the technical compartment containing all sound related hardware" src="http://www.programmers-pain.de/wp-content/uploads/banner2-1024x384.jpg" alt="Some different views of the front panel of the technical compartment containing all sound related hardware" width="536" height="211" /></a><p class="wp-caption-text">Some different views of the front panel of the technical compartment containing all sound related hardware</p></div>
<p style="text-align: left;">So after adding the enclosure containing the subwoofer crossover and the control elements of my two <a href="http://www.thomann.de/de/tamp_s100.htm" target="_blank">Thomann THE T.AMP S-100 2x100W Stereo 19″ PA amplifiers</a> I was able to mount the front panel inside the technical compartment that contains all sound related hardware. To make it look a bit nicer and to actually be able to see something when you open the door of this compartment I've mounted some white LEDs in the ceiling that do dim up as soon as you open the door. Those LEDs are controlled by a <a href="http://en.wikipedia.org/wiki/Reed_switch" target="_blank">reed switch</a> per compartment door that do trigger some PWM outputs of my <a href="http://arduino.cc/en/Main/ArduinoBoardMega2560" target="_blank">Arduino Mega 2560 controller</a> which are used to drive those LEDs. To not overload those outputs a transistor is used to limit the power consumption the controller has to handle.</p>
<div id="attachment_840" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/banner3.jpg" rel="lightbox[845]" title="Some different views of the PCs front panel that provides several push buttons to be able to interact with the 512 RGB LED coffee table"><img class="size-large wp-image-840" title="Some different views of the PCs front panel that provides several push buttons to be able to interact with the 512 RGB LED coffee table" src="http://www.programmers-pain.de/wp-content/uploads/banner3-1024x384.jpg" alt="Some different views of the PCs front panel that provides several push buttons to be able to interact with the 512 RGB LED coffee table" width="536" height="211" /></a><p class="wp-caption-text">Some different views of the PCs front panel that provides several push buttons to be able to interact with the 512 RGB LED coffee table</p></div>
<p style="text-align: left;">The second front panel required a bit more work to get it done since it mainly contains a bunch of push buttons to be able to interact with the coffee table. Therefore I've added some basic menu-like navigation buttons, three pairs of buttons to switch the currently shown visual, the used color palette as well as the brightness of the LEDs followed by five buttons and a matching LED per button that can be used for some sort of custom or context driven functions that I don't know about yet. Beside those buttons used to interact with the table also a bunch of technical things have been added like being able to control my <a href="http://www.elv.de/fs20-funkschaltsystem.html" target="_blank">FS20</a> sender and receiver modules as well as some buttons used to reset the different micro-controllers inside the table in case something goes wrong. The five big push buttons in the middle of the PC compartments front panel are used to trigger the main power of the table and to power on / reset the build-in PC. Also the two FS20 main power switches can be controlled using those buttons. The ATX I/O shield is exposed here too in case I want to interact with the build-in PC. However the most important part of the front panel is still the green main power switch that shuts everything down including the standby power supply of the table which is used to drive those micro-controllers that are able to power up the rest of the table.</p>
<p style="text-align: left;">Getting the PC front panel done was a bit more labour-intensive since I had to do all the wiring work need to connect those buttons and LEDs to the same Mega 2560 controller that drives the compartment lightings I did spoke earlier about. Also getting this beast mounted was a bit trickier since there isn't much space left to get all those wires to the right place - and a mounted PC including its power supply in the same compartment doesn't really make it simpler.</p>
<div id="attachment_843" class="wp-caption alignleft" style="width: 357px"><a href="http://www.programmers-pain.de/wp-content/uploads/work-in-progress-2.jpg" rel="lightbox[845]" title="The current state of the main technical compartment after all major wiring work has been done"><img class="wp-image-843" title="The current state of the main technical compartment after all major wiring work has been done" src="http://www.programmers-pain.de/wp-content/uploads/work-in-progress-2-1024x682.jpg" alt="The current state of the main technical compartment after all major wiring work has been done" width="347" height="230" /></a><p class="wp-caption-text">The current state of the main technical compartment after all major wiring work has been done</p></div>
<p style="text-align: left;">After both front panels have been put in their spot I was busy with finalizing the wiring inside the main technical compartment of my LED coffee table. The main things needed to get done there were the USB cables for the Rainbowduino controllers and modding a 10-port USB hub to be able to connect them to the PC. Mainly I had to change the power supply of that hub since I didn't want to put another 5V power supply into the table. Also the bundled power supply of the hub was only able to provide ~3A which could be a bit too less if each of the eight Rainbowduino V3 controllers can consume up to ~450mA depending if all LEDs are active or not. Therefore I've just connected the hub to the 5V line of the PCs power supply which is able to provide enough power to drive those Rainbowduino controllers.</p>
<p style="text-align: left;">So right now I'm basically done with the hardware I wanted to put into my 512 RGB LED coffee table. It's still not completely put together and actually used as a table yet since I want to get the software of the table into a state where I can test all those front panel buttons first before finally putting everything together. In the current state everything is still easily accessible so that fixing potential problems will be way easier than having the table already standing around in my living room. Still I'm very excited to put everything together but so far I've managed to hold myself off to not rush the final assembly at that point - but I have a very good feeling that it won't last too long until I can put this beast finally together <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2012/11/24/there-has-been-some-progress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Howto setup an encrypted RAID1 array using external USB 3.0 disks</title>
		<link>http://www.programmers-pain.de/2012/11/12/howto-setup-an-encrypted-raid1-array-using-external-usb-3-0-disks/</link>
		<comments>http://www.programmers-pain.de/2012/11/12/howto-setup-an-encrypted-raid1-array-using-external-usb-3-0-disks/#comments</comments>
		<pubDate>Mon, 12 Nov 2012 19:09:56 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=655</guid>
		<description><![CDATA[After one of my last blog posts dealt with modifying my two Sharkoon SATA Quickport XT USB3.0 docking stations I did spend some time figuring out how I can use them to set up multiple RAID1 volumes that should be encrypted using the LUKS environment of recent Linux distributions. Also I was searching for a [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_769" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/raid1.png" rel="lightbox[655]" title="RAID1 setup using Linux software raid and LUKS encryption"><img class="wp-image-769" title="RAID1 setup using Linux software raid and LUKS encryption" src="http://www.programmers-pain.de/wp-content/uploads/raid1.png" alt="RAID1 setup using Linux software raid and LUKS encryption" width="536" height="175" /></a><p class="wp-caption-text">RAID1 setup using Linux software raid and LUKS encryption</p></div>
<p>After one of my last <a href="http://www.programmers-pain.de/2012/07/21/offtpoic-2-sharkoon-sata-quickport-xt-usb3-0-and-its-on-off-switch/" target="_blank">blog posts</a> dealt with modifying my two <a href="http://www.sharkoon.com/?q=en/node/1736" target="_blank">Sharkoon SATA Quickport XT USB3.0 docking stations</a> I did spend some time figuring out how I can use them to set up multiple <a href="http://en.wikipedia.org/wiki/Raid1#RAID_1" target="_blank">RAID1</a> volumes that should be encrypted using the <a href="http://en.wikipedia.org/wiki/Linux_Unified_Key_Setup" target="_blank">LUKS</a> environment of recent Linux distributions. Also I was searching for a mechanism to clearly map every involved disk to an unique raid volume so that I don't end up with a generic mount point like<em> /mnt/raid1/</em> that would just show the content of the currently docked disks - instead every RAID1 volume should have it's own dedicated mount point. The solution I've came up with uses <a href="http://en.wikipedia.org/wiki/Udev" target="_blank">UDEV</a> rules to identify the disks, <a href="http://en.wikipedia.org/wiki/Mdadm" target="_blank">mdadm</a> to map two disks to a single software-RAID1 volume, <a href="http://en.wikipedia.org/wiki/Dm-crypt" target="_blank">cryptsetup</a> to encrypt the raid volume and some smaller, self-written helper scripts that do simplify the usage of those external RAID1 volumes. How it all works and how you can set up such an environment on your own Linux machine: just click <em>'continue reading'</em> <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span id="more-655"></span></p>
<h5>Defining UDEV rules to get unique symbolic links for each disk</h5>
<p>So the general idea is that each disk will have a dedicated UDEV rule which will result in a unique symlink in the <em>/dev</em> directory pointing to the actual block device the disk has been made available at by the Linux kernel. In addition to the <em>/dev/sdd</em> and <em>/dev/sde</em> mount points where my docking stations usually do show up each docked disk will have an unique symlink like <em>/dev/raid1v1d1</em> and <em>/dev/raid1v1d2</em> pointing to the actual <em>/dev/sdd</em> and <em>/dev/sde</em> block devices. <em>raid1v1d1</em> stands for: raid1, volume1, disk1 in this example to give those symlinks a meaningful name without being forced to type tons of text. With using those symlinks I can set up multiple RAID1 volumes with <em>mdadm</em> that won't collide with each other as if you would have used the <em>/dev/sdX</em> block devices directly since the real block devices will be shared by multiple disks:</p>
<p>Imagine you'd have set up two RAID1 volumes with <em>mdadm</em> that would directly use the <em>/dev/sdX</em> block devices - If you would put one disk of each RAID1 volume into the docking stations than the second disk you've inserted would be detected as an out-of-sync disk of the first disks RAID1 volume since both RAID1 volumes do share the same <em>/dev/sdX</em> block devices. The result would be that the RADI1 volume of the first docked disk will run with only one active member disk and the second disk would be handled as an out-of-sync disk although it isn't even a member of the first disks RAID1 volume. Even worse: if you would trigger a <em>resync</em> of the RAID1 volume than you'd delete the contents of the second disk if you'd skip the <em>'this disk contains metadata of another raid volume'</em> warning message! To eliminate that risk in general I'll only use those unique symlinks defined by the following example UDEV rules:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#RAID1 Volume 1</span><br />
<span style="color: #007800;">SUBSYSTEMS</span>==<span style="color: #ff0000;">&quot;usb&quot;</span>, <span style="color: #007800;">KERNEL</span>==<span style="color: #ff0000;">&quot;sd?&quot;</span>, <span style="color: #007800;">SUBSYSTEM</span>==<span style="color: #ff0000;">&quot;block&quot;</span>, ENV<span style="color: #7a0874; font-weight: bold;">&#123;</span>ID_SERIAL_SHORT<span style="color: #7a0874; font-weight: bold;">&#125;</span>==<span style="color: #ff0000;">&quot;1234511111&quot;</span>, SYMLINK+=<span style="color: #ff0000;">&quot;raid1v1d1&quot;</span><br />
<span style="color: #007800;">SUBSYSTEMS</span>==<span style="color: #ff0000;">&quot;usb&quot;</span>, <span style="color: #007800;">KERNEL</span>==<span style="color: #ff0000;">&quot;sd?&quot;</span>, <span style="color: #007800;">SUBSYSTEM</span>==<span style="color: #ff0000;">&quot;block&quot;</span>, ENV<span style="color: #7a0874; font-weight: bold;">&#123;</span>ID_SERIAL_SHORT<span style="color: #7a0874; font-weight: bold;">&#125;</span>==<span style="color: #ff0000;">&quot;1234522222&quot;</span>, SYMLINK+=<span style="color: #ff0000;">&quot;raid1v1d2&quot;</span><br />
<span style="color: #007800;">SUBSYSTEMS</span>==<span style="color: #ff0000;">&quot;usb&quot;</span>, <span style="color: #007800;">KERNEL</span>==<span style="color: #ff0000;">&quot;sd?1&quot;</span>, <span style="color: #007800;">SUBSYSTEM</span>==<span style="color: #ff0000;">&quot;block&quot;</span>, ENV<span style="color: #7a0874; font-weight: bold;">&#123;</span>ID_SERIAL_SHORT<span style="color: #7a0874; font-weight: bold;">&#125;</span>==<span style="color: #ff0000;">&quot;1234511111&quot;</span>, SYMLINK+=<span style="color: #ff0000;">&quot;raid1v1d1p1&quot;</span><br />
<span style="color: #007800;">SUBSYSTEMS</span>==<span style="color: #ff0000;">&quot;usb&quot;</span>, <span style="color: #007800;">KERNEL</span>==<span style="color: #ff0000;">&quot;sd?1&quot;</span>, <span style="color: #007800;">SUBSYSTEM</span>==<span style="color: #ff0000;">&quot;block&quot;</span>, ENV<span style="color: #7a0874; font-weight: bold;">&#123;</span>ID_SERIAL_SHORT<span style="color: #7a0874; font-weight: bold;">&#125;</span>==<span style="color: #ff0000;">&quot;1234522222&quot;</span>, SYMLINK+=<span style="color: #ff0000;">&quot;raid1v1d2p1&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;">#RAID1 Volume 2</span><br />
<span style="color: #007800;">SUBSYSTEMS</span>==<span style="color: #ff0000;">&quot;usb&quot;</span>, <span style="color: #007800;">KERNEL</span>==<span style="color: #ff0000;">&quot;sd?&quot;</span>, <span style="color: #007800;">SUBSYSTEM</span>==<span style="color: #ff0000;">&quot;block&quot;</span>, ENV<span style="color: #7a0874; font-weight: bold;">&#123;</span>ID_SERIAL_SHORT<span style="color: #7a0874; font-weight: bold;">&#125;</span>==<span style="color: #ff0000;">&quot;1234533333&quot;</span>, SYMLINK+=<span style="color: #ff0000;">&quot;raid1v2d1&quot;</span><br />
<span style="color: #007800;">SUBSYSTEMS</span>==<span style="color: #ff0000;">&quot;usb&quot;</span>, <span style="color: #007800;">KERNEL</span>==<span style="color: #ff0000;">&quot;sd?&quot;</span>, <span style="color: #007800;">SUBSYSTEM</span>==<span style="color: #ff0000;">&quot;block&quot;</span>, ENV<span style="color: #7a0874; font-weight: bold;">&#123;</span>ID_SERIAL_SHORT<span style="color: #7a0874; font-weight: bold;">&#125;</span>==<span style="color: #ff0000;">&quot;1234544444&quot;</span>, SYMLINK+=<span style="color: #ff0000;">&quot;raid1v2d2&quot;</span><br />
<span style="color: #007800;">SUBSYSTEMS</span>==<span style="color: #ff0000;">&quot;usb&quot;</span>, <span style="color: #007800;">KERNEL</span>==<span style="color: #ff0000;">&quot;sd?1&quot;</span>, <span style="color: #007800;">SUBSYSTEM</span>==<span style="color: #ff0000;">&quot;block&quot;</span>, ENV<span style="color: #7a0874; font-weight: bold;">&#123;</span>ID_SERIAL_SHORT<span style="color: #7a0874; font-weight: bold;">&#125;</span>==<span style="color: #ff0000;">&quot;1234533333&quot;</span>, SYMLINK+=<span style="color: #ff0000;">&quot;raid1v2d1p1&quot;</span><br />
<span style="color: #007800;">SUBSYSTEMS</span>==<span style="color: #ff0000;">&quot;usb&quot;</span>, <span style="color: #007800;">KERNEL</span>==<span style="color: #ff0000;">&quot;sd?1&quot;</span>, <span style="color: #007800;">SUBSYSTEM</span>==<span style="color: #ff0000;">&quot;block&quot;</span>, ENV<span style="color: #7a0874; font-weight: bold;">&#123;</span>ID_SERIAL_SHORT<span style="color: #7a0874; font-weight: bold;">&#125;</span>==<span style="color: #ff0000;">&quot;1234544444&quot;</span>, SYMLINK+=<span style="color: #ff0000;">&quot;raid1v2d2p1&quot;</span></div></td></tr></tbody></table></div>
<p>Those example UDEV rules that I do store in the <em>/etc/udev/rules.d/99-usbRaid1.rules</em> file on my Linux machine are doing multiple things:</p>
<ul>
<li>define <em>raid1v#d#</em> symlinks for in total four different disks that are identified via their serial numbers (<em>ID_SERIAL_SHORT</em> property).</li>
<li>define <em>raid1v#d#p1</em> symlinks for the first partition for each of the four disks.</li>
<li>those rules will only be considered if the the new <em>/dev/sdX</em> block device is provided by the USB subsystem of the kernel since I'm using USB3.0 docking stations.</li>
</ul>
<p>So whenever I dock one of those disks two additional symlinks (<em>/dev/raid1v#d#</em> and <em>/dev/raid1v#d#p1</em>) will be created if the new block device was provided by the USB subsystem and if the serial of the disk matches the one defined in the UDEV rules. You can use <a href="http://linux.die.net/man/8/hdparm" target="_blank">hdparm</a> the get the serial number of a disk via its block device:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">hdparm <span style="color: #660033;">-I</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdX <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;Serial Number:&quot;</span></div></td></tr></tbody></table></div>
<p>Whenever you change existing UDEV rules or add new ones than you should restart the UDEV service of your Linux distribution and call <a href="http://linux.die.net/man/8/udevadm target=">udevadm</a> to force UDEV to re-trigger all known UDEV rules for all existing block devices. As an alternative you could also re-connect your USB disks so that UDEV will consider your new rules as soon as the disk are available again.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">service udev restart<br />
udevadm trigger</div></td></tr></tbody></table></div>
<p>If you haven't set up your disks with a fresh partition table and an empty first partition yet I'd suggest to use <a href="http://www.gnu.org/software/parted/" target="_blank">parted</a>, <a href="http://gparted.sourceforge.net/" target="_blank">gparted</a> or any other disk partition tool to do so. For all of my disks I did use a <a href="http://en.wikipedia.org/wiki/GUID_Partition_Table" target="_blank">GPT</a> partition table and a primary partition without any file system type since it will be used by <em>mdadm</em> own data format anyway. After you're done with setting up the partitions and calling <em>udevadm trigger</em> once again you should find the following entries in your <em>/dev</em> directory assuming that you would have the disks with the exemplary <em>1234511111</em> and <em>1234522222</em> serial numbers up and running:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>raid1<span style="color: #000000; font-weight: bold;">*</span><br />
lrwxrwxrwx <span style="color: #000000;">1</span> root root <span style="color: #000000;">23</span> Jul <span style="color: #000000;">13</span> <span style="color: #000000;">17</span>:05 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>raid1v1d1 -<span style="color: #000000; font-weight: bold;">&gt;</span> sdd<br />
lrwxrwxrwx <span style="color: #000000;">1</span> root root <span style="color: #000000;">23</span> Jul <span style="color: #000000;">13</span> <span style="color: #000000;">17</span>:05 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>raid1v1d1p1 -<span style="color: #000000; font-weight: bold;">&gt;</span> sdd1<br />
lrwxrwxrwx <span style="color: #000000;">1</span> root root <span style="color: #000000;">23</span> Jul <span style="color: #000000;">13</span> <span style="color: #000000;">17</span>:05 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>raid1v1d2 -<span style="color: #000000; font-weight: bold;">&gt;</span> sde<br />
lrwxrwxrwx <span style="color: #000000;">1</span> root root <span style="color: #000000;">23</span> Jul <span style="color: #000000;">13</span> <span style="color: #000000;">17</span>:05 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>raid1v1d2p1 -<span style="color: #000000; font-weight: bold;">&gt;</span> sde1</div></td></tr></tbody></table></div>
<h5>Setting up RAID1 volumes using <em>mdadm</em></h5>
<p>So whenever you're done with setting up the partitions you're ready to call <em>mdadm</em> to create a new RAID1 volume using the two partitions of the two disks available via the symlinks defined by the UDEV rules:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mdadm <span style="color: #660033;">--create</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>raid1v1 <span style="color: #660033;">--level</span>=<span style="color: #000000;">1</span> <span style="color: #660033;">--raid-devices</span>=<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>raid1v1d1p1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>raid1v1d2p1<br />
mdadm: Defaulting to version <span style="color: #000000;">1.2</span> metadata<br />
mdadm: array <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>raid1v1 started.</div></td></tr></tbody></table></div>
<p>What has happened here is that we've just created a new RAID1 volume that will be available via the <em>/dev/md/raid1v1</em> block device following the same naming schema as the disk symlinks. As soon as the <em>mdadm</em> call returns to your Bash console prompt the new RAID1 volume is ready to be used. If you want to have a quick look at the current status of the new volume just have a look at the <em>/proc</em> filesystem:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>mdstat<br />
Personalities : <span style="color: #7a0874; font-weight: bold;">&#91;</span>raid1<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
md127 : active raid1 sde1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sdd1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000;">1465005888</span> blocks super <span style="color: #000000;">1.2</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>UU<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">&gt;</span>....................<span style="color: #7a0874; font-weight: bold;">&#93;</span>  resync =  <span style="color: #000000;">0.0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">183680</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1465005888</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">finish</span>=664.5min <span style="color: #007800;">speed</span>=36736K<span style="color: #000000; font-weight: bold;">/</span>sec<br />
<br />
unused devices: <span style="color: #000000; font-weight: bold;">&lt;</span>none<span style="color: #000000; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<p>The output of <em>/proc/mdstat</em> contains several interesting information that are worth to talk about in a bit more detail: The first thing you should notice is that your new <em>/dev/md/raid1v1</em> block device is again just an alias for the real <em>/dev/md127</em> block device provided by the Linux kernel. Again, we're following the same principal as we did with the disks that each RAID1 volume will have an unique symlink so that we can mount it in a dedicated location. As for the disks it's again uncritical that we reuse the real block devices like <em>/dev/sdd</em>, <em>/dev/sde</em> or <em>/dev/md127</em> since we can only mount two disks at the same time.</p>
<p>The second thing is that although we explicitly specified the symlinks we've set up with our UDEV rules the Linux software raid implementation still uses the real block devices the disks were made available by the Linux kernel. This is again not a problem since we only use those symlinks to have an unique device name per disk and raid volume. This symlink-based approach will especially show its benefits if you would get another couple of docking stations to be able to have two RAID1 volumes running at the same time or if you're thinking about mounting two disks directly into your PC: In both cases you'll just don't care which block devices the kernel will choose to give you access to your disks since you'll only use those symlinks to access your RAID1 volumes. Also <em>mdadm</em> will use the same approach to give access to those volumes via <em>/dev/md12</em>7, <em>/dev/md126</em> and so forth but all you'll care about are those <em>/dev/md/raid1v#</em> symlinks:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/*</span><br />
total <span style="color: #000000;">4</span><br />
lrwxrwxrwx  <span style="color: #000000;">1</span> root root    <span style="color: #000000;">23</span> Jul <span style="color: #000000;">15</span> <span style="color: #000000;">19</span>:<span style="color: #000000;">30</span> raid1v1 -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>md127<br />
lrwxrwxrwx  <span style="color: #000000;">1</span> root root   <span style="color: #000000;">23</span> Jul <span style="color: #000000;">15</span> <span style="color: #000000;">19</span>:<span style="color: #000000;">30</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>raid1v1p1 -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>md127p1</div></td></tr></tbody></table></div>
<p>Also notice that <em>mdadm</em> will automatically provide you with additional symlinks for every partition on your raid volume. So whenever you've used <em>gparted</em> or a similar tool to create an empty partition on the <em>/dev/md/raid1v1</em> block device you should see the same content as above in your <em>/dev/md</em> directory.</p>
<h5>Encrypting the RAID1 volume using <em>LUKS</em> / <em>cryptsetup</em></h5>
<p>As written in the introduction of this post I also want to encrypt those RAID1 volumes using <em>LUKS</em> environment and its <em>cryptsetup</em> tool. Setting up an encrypted container isn't really complicated if you're happy with using the default values:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cryptsetup <span style="color: #660033;">--verbose</span> <span style="color: #660033;">--verify-passphrase</span> luksFormat <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>raid1v1p1<br />
<br />
WARNING<span style="color: #000000; font-weight: bold;">!</span><br />
========<br />
This will overwrite data on <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>raid1v1p1 irrevocably.<br />
<br />
Are you sure? <span style="color: #7a0874; font-weight: bold;">&#40;</span>Type uppercase <span style="color: #c20cb9; font-weight: bold;">yes</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: YES<br />
Enter LUKS passphrase:<br />
Verify passphrase:<br />
Command successful.</div></td></tr></tbody></table></div>
<p>I've added the <em>--verify-passphrase</em> argument on purpose since otherwise <em>cryptsetup</em> would just create the encrypted container without validating the password you've entered via the <em>passphrase</em> prompt. To be able to use your just created <em>cryptsetup</em> container on top of the <em>mdadm</em> RAID1 volume you have to open it first so that it's unencrypted content will be available via another block device to be found in the <em>/dev/mapper</em> directory afterwards:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cryptsetup luksOpen <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>raid1v1p1 luks-raid1v1<br />
<br />
Enter passphrase <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>raidv1p1:</div></td></tr></tbody></table></div>
<p>After you've opened the encrypted container using the password you've used while setting up the container you'll find a new block device called <em>/dev/mapper/luks-raid1v1</em> that you can format as any other disk partition with your favoured file system.</p>
<p>If you've followed the instructions of this blog post so far you should have a formatted block device by now that is ready to be mounted and used. Since triggering a single <em>umount</em> call isn't enough to stop the LUKS block device and the RAID1 volume behind it you'd need to issue the following commands to stop your encrypted RAID1 volume again:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>luks-raid1v1<br />
cryptsetup luksClose luks-raid1v1<br />
mdadm <span style="color: #660033;">--stop</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>raid1v1</div></td></tr></tbody></table></div>
<p>The next time you want to use your RAID1 volume again you would have to trigger similar commands in a reversed order:</p>
<ol>
<li><em>mdadm</em> to start the RAID1 volume again</li>
<li><em>cryptsetup luksOpen</em> to provide a decrypted block device in the <em>/dev/mapper</em> directory</li>
<li><em>mount</em> to make the RAID1 volume accessible</li>
</ol>
<p>Since that's kind of boring commands to type every time you want to use one of your RAID1 volumes and since there's a chance to mess things up if you e.g. forget to stop the RAID1 volume before ejecting the disks from the docking stations I did create two simple helper scripts that can be used to automate those calls.</p>
<h5>Helper scripts to simplify (un)mounting the encrypted RAID1 volumes</h5>
<p>To be able to automated the (un)mounting process of your RAID1 volumes it makes sense to define a common base directory where each volume will be mounted using a dedicated subdirectory. I did choose the <em>/mnt/usbRaid1</em> directory for that purpose. So beside initially creating this base directory you would have to create a new subdirectory for every newly created RAID1 volume:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>usbRaid1<span style="color: #000000; font-weight: bold;">/</span>raid1v1<br />
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>usbRaid1<span style="color: #000000; font-weight: bold;">/</span>raid1v1<span style="color: #000000; font-weight: bold;">/</span>not\ mounted\<span style="color: #000000; font-weight: bold;">!</span><br />
<span style="color: #c20cb9; font-weight: bold;">chmod</span> 0444 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>usbRaid1<span style="color: #000000; font-weight: bold;">/</span>raid1v1<span style="color: #000000; font-weight: bold;">/</span>not\ mounted\<span style="color: #000000; font-weight: bold;">!</span></div></td></tr></tbody></table></div>
<p>After creating the <em>raid1v1</em> subdirectory inside the <em>/mnt/usbRaid1</em> directory you're ready to mount the RAID1 volume from this example. Before mounting it for the first time I've also created an empty <em>"not mounted!"</em> file and set its permissions to read-only so that you can instantly see if the RAID1 volume is mounted or not.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>raid1v1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>usbRaid1<span style="color: #000000; font-weight: bold;">/</span>raid1v1</div></td></tr></tbody></table></div>
<p>After mounting your RAID1 volume the <em>"not mounted!"</em> file isn't visible any more since the <em>/mnt/usbRaid1/raid1v1</em> directory now points to your encrypted RAID1 volume. At that point it's pretty easy to simplify the (un)mounting process since we did use a consistent naming schema for all device, symlink and mount point names so that providing the volume name (<em>raid1v1</em> in this example) to a Bash script is enough to trigger all actions inside the script. For that purpose I've created two Bash scripts called <em>raid_open.sh &lt;volume name&gt;</em> and <em>raid_close.sh &lt;volume name&gt;</em> that take care of opening a RAID1 volume and mounting it into the matching directory and closing the volume again:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<br />
<span style="color: #666666; font-style: italic;"># raid_open.sh &lt;raid volume&gt;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># check user the script was called with</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`whoami`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;root&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: the script has the be called with root permissions!&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #666666; font-style: italic;"># check number of given command line arguments</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #780078;">`basename $0`</span> {raid}&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">42</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #007800;">RAID</span>=<span style="color: #007800;">$1</span><br />
<span style="color: #007800;">MD_DEVICE</span>=<span style="color: #ff0000;">&quot;/dev/md/<span style="color: #007800;">$RAID</span>&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># check that the given raid volume is available and in a clean state</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">`</span>mdadm <span style="color: #660033;">--detail</span> <span style="color: #007800;">$MD_DEVICE</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;State : clean&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #000000; font-weight: bold;">`</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #666666; font-style: italic;"># open the partition on the raid volume and mount it</span><br />
&nbsp; cryptsetup luksOpen <span style="color: #800000;">${MD_DEVICE}</span>p1 luks-<span style="color: #007800;">$RAID</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>luks-<span style="color: #007800;">$RAID</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>usbRaid1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$RAID</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: cryptsetup wasn't able to open the <span style="color: #007800;">${MD_DEVICE}</span>p1 device!&quot;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; <span style="color: #666666; font-style: italic;"># give some additional detail in case the raid volume isn't in a clean state</span><br />
&nbsp; <span style="color: #007800;">MD_DEVICE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">readlink</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$MD_DEVICE</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: <span style="color: #007800;">$MD_DEVICE</span> (<span style="color: #780078;">`readlink -f $MD_DEVICE`</span>) either doesn't exists or is in an invalid state!&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;please check the output of the /proc/mdstat content:&quot;</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>mdstat<br />
<span style="color: #000000; font-weight: bold;">fi</span></div></td></tr></tbody></table></div>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<br />
<span style="color: #666666; font-style: italic;"># raid_close.sh &lt;raid volume&gt;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># check user the script was called with</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`whoami`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;root&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: the script has the be called with root permissions!&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #666666; font-style: italic;"># check number of given command line arguments</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #780078;">`basename $0`</span> {raid}&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">42</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #007800;">RAID</span>=<span style="color: #007800;">$1</span><br />
<span style="color: #007800;">MD_DEVICE</span>=<span style="color: #ff0000;">&quot;/dev/md/<span style="color: #007800;">$RAID</span>&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># check if the given raid volumne is mounted</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$RAID</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #000000; font-weight: bold;">`</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>luks-<span style="color: #007800;">$RAID</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># use cryptsetup to close the unmounted volumne</span><br />
&nbsp; &nbsp; cryptsetup luksClose luks-<span style="color: #007800;">$RAID</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># stop the underlying raid volume</span><br />
&nbsp; &nbsp; &nbsp; mdadm <span style="color: #660033;">--stop</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$RAID</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> == <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Raid volume '<span style="color: #007800;">$RAID</span>' has been unmounted and stopped!&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: mdadm wasn't able to stop the the '/dev/md/$1' raid volume!&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: check the following output of /proc/mdstat for further details!&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>mdstat&nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: cryptsetup wasn't able to close the 'luks-$1' volume!&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: unmount failed for device <span style="color: #007800;">$MD_DEVICE</span>!&quot;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: /dev/mapper/luks-<span style="color: #007800;">$RAID</span> isn't mounted!&quot;</span><br />
<span style="color: #000000; font-weight: bold;">fi</span></div></td></tr></tbody></table></div>
<p>So opening the <em>raid1v1</em> encrypted RAID1 volume from this example is as simple as calling <em>raid_open.sh raid1v1</em> which will internally call <em>cryptsetup</em> that will ask you for the password of the encrypted container. Closing an currently mounted RAID1 volume is also straight forward via calling <em>raid_close.sh raid1v1</em>. Both scripts provide an basic error handling and do print some additional information in case something goes wrong. Please not that the <em>raid_open.sh</em> script does use the example <em>/mnt/usbRaid1</em> directory used to mount the RAID1 volumes into their matching subdirectories. If you want to use a different directory you need to change the script accordingly.</p>
<p>I do use my external RAID1 volumes in the described setup for quite a while now and I'm pretty happy with the usability of that solution. As usual there's still ways to further improve this like e.g. using the <em>automount</em> daemon to trigger those scripts automatically combined with some sort of shared token for every RAID1 volume that you only have to authenticate once at e.g. the system startup so that you don't have to type the LUKS containers password every time you want to mount a RAID1 volume. But compared to the usual <em>mount</em> and <em>umount</em> commands you'd trigger for normal disks the two scripts aren't really a major drawback. Anyway, I just wanted to share my solution - maybe it's considered being useful by some other Linux users out there <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2012/11/12/howto-setup-an-encrypted-raid1-array-using-external-usb-3-0-disks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finally! A working streaming firmware for my Rainbowduino V3 controllers</title>
		<link>http://www.programmers-pain.de/2012/09/19/finally-a-working-streaming-firmware-for-my-rainbowduino-v3-controllers/</link>
		<comments>http://www.programmers-pain.de/2012/09/19/finally-a-working-streaming-firmware-for-my-rainbowduino-v3-controllers/#comments</comments>
		<pubDate>Wed, 19 Sep 2012 18:40:56 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[LED Coffee Table]]></category>
		<category><![CDATA[coffee table]]></category>
		<category><![CDATA[Rainbowduino]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=743</guid>
		<description><![CDATA[It took a while but I've finally managed to get the firmware of my new Rainbowduino V3 controllers to a state that I can use them as part of my 512 RGB LED coffee table project. I've learnt a lot of new things about interrupt handling of AVR micro controllers that I didn't want to [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_748" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2349_2.jpg" rel="lightbox[743]" title="Two Rainbowduino V3 controllers running the 'rainbowduino-v3-streaming-firmware'"><img class="wp-image-748" title="Two Rainbowduino V3 controllers running the 'rainbowduino-v3-streaming-firmware'" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2349_2-1024x414.jpg" alt="Two Rainbowduino V3 controllers running the 'rainbowduino-v3-streaming-firmware'" width="536" height="215" /></a><p class="wp-caption-text">Two Rainbowduino V3 controllers running the 'rainbowduino-v3-streaming-firmware'</p></div>
<p>It took a while but I've finally managed to get the firmware of my new <a href="http://www.seeedstudio.com/wiki/Rainbowduino_v3.0" target="_blank">Rainbowduino V3</a> controllers to a state that I can use them as part of my <a href="http://www.programmers-pain.de/category/led-coffee-table/" target="_blank">512 RGB LED coffee table project</a>. I've learnt a lot of new things about interrupt handling of AVR micro controllers that I didn't want to learn at all and I went trough quite some frustrating weeks where I was very close to just throw those controllers into the trash. But luckily I've managed to get the firmware flying at the end. If you want to find out what obstacles I had to fight with, how it all works at the end and where you can find the Rainbowduino V3 firmware including the matching Java API than feel free to continue reading this blog post <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-743"></span>The first firmware I've tried for my new Rainbowduino V3 controllers was the <a href="http://www.seeedstudio.com/wiki/Rainbowduino_v3.0#Programming" target="_blank">reference firmware</a> offered by the manufacturer (<a href="http://www.seeedstudio.com/depot/" target="_blank">seeedstudio.com</a>) of the controller. The firmware works quite nice but it targets for standalone usage of the controller without any functionality to stream 8x8 RGB frames to the controller via an I2C link or the build-in USB connector. Since I've already used the <a href="http://code.google.com/p/neorainbowduino/" target="_blank">neorainbowduino</a> firmware for my <a href="http://www.seeedstudio.com/wiki/Rainbowduino_LED_driver_platform_-_Atmega_328" target="_blank">Rainbowduino V2</a> controllers that were used for the <a href="http://www.programmers-pain.de/2012/03/01/the-first-test-assembly-of-my-512rgb-led-coffee-tabl/" target="_blank">first test assembly</a> of my coffee table I was also familiar with sending those frames with the help of an <a href="http://arduino.cc/en/Main/ArduinoBoardUno" target="_blank">Arduino Uno</a> or <a href="http://www.pjrc.com/teensy/" target="_blank">Teensy</a> controller via an I2C-link to the Rainbowduino controllers. Sadly the <em>neorainbowduino</em> firmware can't be used for V3 controllers since seeedstudio.com has change the controllers hardware quite a lot. Also I did know from my initial tests that the I2C-link approach is limited to max. four Rainbowduino controllers per Teensy controller since otherwise those controllers will act as the bottleneck preventing the Java program from sending RGB frames at ~20fps. An Arduino Uno due to his even <a href="http://neophob.com/2011/04/serial-latency-teensy-vs-arduino/" target="_blank">worse serial performance</a> isn't able to drive more than two Rainbowduino controllers at ~20fps. Therefore it was quite obvious for me to focus on the build-in USB connector of the Rainbowduino V3 controller since this would solve several problems for my use case:</p>
<div id="attachment_751" class="wp-caption alignright" style="width: 317px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2261.jpg" rel="lightbox[743]" title="The eight Rainbowduino V3 controller of my 512 RGB LED coffee table project"><img class="wp-image-751" title="The eight Rainbowduino V3 controller of my 512 RGB LED coffee table project" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2261.jpg" alt="The eight Rainbowduino V3 controller of my 512 RGB LED coffee table project" width="307" height="422" /></a><p class="wp-caption-text">The eight Rainbowduino V3 controller of my 512 RGB LED coffee table project</p></div>
<ul>
<li>Direct serial connection to every Rainbowduino V3 controller without having another controller like an Arduino Uno or Teensy in-line that will act as a bottleneck.</li>
<li>No need for an external power supply since each controller can be powered directly via the USB connection.</li>
<li>No additional wiring needed for the I2C-links or being able to upload the controllers firmware since both can be done via a single USB cable.</li>
</ul>
<p>Actually there's one drawback of using an USB connection compared to to an I2C-link: You won't be able to directly daisy-chain those controllers any more since the USB plug will be in the way. Luckily this isn't a problem for my project since I do use some <a href="http://www.programmers-pain.de/2011/09/07/soldering-512-rgb-leds-pure-fun-not/" target="_blank">self-build 34x34cm LED panels</a> so that I have enough space for an USB plug attached to each of my controllers.</p>
<p>While searching a bit for Rainbowduino V3 firmwares that claim to be able to send RGB frames via an USB connection I only found the <a href="http://code.google.com/p/rainbowdash/" target="_blank">rainbowdash</a> firmware which offers an operation mode called <a href="http://code.google.com/p/rainbowdash/wiki/DirectMode" target="_blank">DirectMode</a> that is able to send RGB frames via serial to the controllers. Sadly this only works up to a baudrate of 19200 until the firmware suffers from data corruption / data loss due to conflicting interrupts: the internal Arduino interrupt that is used to receive incoming serial data and the interrupt of the rewritten seeedstudio.com firmware used to drive the LEDs. <strong>Conclusion:</strong> I own eight new controllers but there wasn't any firmware available to stream 24bit RGB frames with 8 bit per color channel to those Rainbowduino V3 controllers via the build-in USB connector. Therefore I've decided to start my own firmware trying to combine the features of the <em>neorainbowduino</em> and the original seeedstudio.com firmware. That was end of March - or in other words - five month ago.. I had no fucking clue in what kind of trouble I'll put myself into..</p>
<p>So.. It's mid-September in the meanwhile, I've learned things I didn't want to learn, I've fought with issues I couldn't imagine five month ago and I was quite frustrated sometimes.. but I've managed to get my Rainbowduino V3 firmware including the matching Java API up and running! I've called it <em>rainbowduino-v3-streaming-firmware</em> since it's only feature is to receive RGB frames via a serial connection of the build-in USB connector. You can find it at <a href="https://code.google.com/p/rainbowduino-v3-streaming-firmware/" target="_blank">https://code.google.com/p/rainbowduino-v3-streaming-firmware/</a> if you want to use it for your own projects.</p>
<div id="attachment_759" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2275.jpg" rel="lightbox[743]" title="A Rainbowduino V3 controller attached to one of my custom build LED panels"><img class="wp-image-759" title="A Rainbowduino V3 controller attached to one of my custom build LED panels" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2275-1024x682.jpg" alt="A Rainbowduino V3 controller attached to one of my custom build LED panels" width="536" height="350" /></a><p class="wp-caption-text">A Rainbowduino V3 controller attached to one of my custom build LED panels</p></div>
<h4>How does it work?</h4>
<p>The firmware expects four frame fragments to be send to the controller to be able to show one 8x8 24bit RGB frame. Splitting up the frame into four fragments is done to avoid running into data corruption / data loss as soon as the internal buffer of the Rainbowduino V3 controller runs full. It took a while to understand that the recent <a href="http://arduino.cc/blog/2011/11/30/arduino-1-0-now-available/" target="_blank">Arduino 1.0 update</a> has reduced to buffer size from 128byte to 64byte although most of the blog and forum posts you'll find in the net are talking about a 128byte serial buffer - but that's a different story. Each frame fragment gets extended with a header and some checksums to be able to implement a reliable serial protocol including some proper error handling. Whenever a frame fragment was received an ACK reply message is send via the serial connection to the Java API. The firmware itself just holds two frames in memory: the one that is currently shown by the LEDs and the next one that is currently being received via serial. As soon as a full frame has been transferred the frame buffers do switch. Everything was held rather simple since the firmware should just accomplish a single job: Receiving 8x8 RGB frames and drive the LEDs with it.</p>
<p>The most painful problem I had to solve were those two conflicting interrupts I've mentioned earlier. In the beginning I could either decide to receive all frame fragments in a reliable way but suffering from ghosting / flickering effects at the same time since the timing while driving those RGB LEDs wasn't reliable any more. This was caused by the serial interrupt stopping the LED update routine whenever serial data was received. The other option was to keep the timing of the LED update routine evenly but dealing with data corruption / data loss whenever the controller was busy with pushing color data to those LEDs. This problem kept me busy for several month and I've tried multiple things to get around it including some frustrating moments when you have to revert all of your code changes since your new idea on how to solve this problem didn't turned out to work as expected.</p>
<p>At the end the solution to address this interrupt problem was to simply re-enable the global interrupts of the AVR micro controller <strong>inside</strong> of the just running LED update interrupt call. First this sounds like a stupid idea to allow a single threaded micro controller to again call interrupts although the currently running interrupt callback isn't done yet - this kind of smells like an interrupt calling itself over and over again which will brick your controller. In my case there's only the internal serial interrupt that is able to interrupt the LED update routine to be able to handle incoming serial data. This combined with the fact that the runtime behaviour of the LED update routine is very predictable since it only pushes one of the frame buffers to the driver ICs prevents the controller to run into interrupt loops. It took a while to figure out the best working timing and interrupt configuration but afterwards the LED update routine is only interrupted very shortly whenever the controller has to handle incoming serial data. The time between the next call of the update routine is still enough to parse the incoming serial data and store it in the frame buffer. Since the LED update routine is triggered every ~1250µs the controller also doesn't have enough time to neither receive a full frame fragment nor parsing it completely so that there's no risk to run into problems with the 64byte build-in serial buffer that would otherwise result in data corruption and data loss.</p>
<p><iframe src="http://www.youtube.com/embed/2JHB2Mo-Y74?hl=de&amp;fs=1" frameborder="0" width="550" height="320"></iframe></p>
<p>After fixing the interrupt problem the firmware is now able to run at up to 35 frames per second. Starting from ~38fps the timing between the Java API and the firmware gets wonky which results in lots of frame (fragments) being dropped by the firmware. Nevertheless 35fps should be more than enough for most usages. Also keep in mind that the internal refresh rate of the LEDs is close to ~100fps so that even if you stream frames with <em>only</em> 35fps to the controller the actual frame is pushed almost three times to the LEDs by the driver ICs. Therefore I'm currently not able to see any flickering at all while showing frames on the Rainbowduino V3 controllers. Another advantage is that this approach scales pretty good while using multiple Rainbowduino V3 controllers at the same time since even a single USB connection has more than enough speed to drive multiple controllers. I my case I even use all eight controllers directly attached to a single USB hub without any noticeable latencies of the USB connection. To not create any new bottlenecks in the Java API the <em>RainbowduinoV3.java</em> class was implemented in a thread-safe way so that more than one thread can drive multiple controllers at the same time.</p>
<p>Also I've tried to keep the Java third-party library dependencies down to a minimum so that you're not forced to use bigger frameworks like <a href="http://processing.org/" target="_blank">Processing</a> just to be able to send RGB frames to a Rainbowduino V3 controller. It only depends on the <a href="http://rxtx.qbang.org/" target="_blank">RXTX</a>, <a href="http://commons.apache.org/lang/" target="_blank">Apache Commons Lang 3</a>, and the <a href="http://www.slf4j.org/" target="_blank">Simple Logging Facade</a> libraries. If you need more technical information on how to use my <em>rainbowduino-v3-streaming-firmware</em> than please consult the technical documentation available on the <a href="http://code.google.com/p/rainbowduino-v3-streaming-firmware/" target="_blank">project homepage</a>. I've also provided two simple examples on how to use the Java API of the firmware so that you should be able to get your controller running without writing a single line of code. Those examples are also able to drive more than one Rainbowduino V3 controller at the same time.</p>
<p>For my 512 RGB LED coffee table project this means that I can focus again on finishing the remaining hardware tasks of the table itself so that I finally will able to use it as a coffee table in the near future! I'll keep you informed as soon as this happens <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2012/09/19/finally-a-working-streaming-firmware-for-my-rainbowduino-v3-controllers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Offtopic #2: Sharkoon SATA QuickPort XT USB3.0 and its on/off switch</title>
		<link>http://www.programmers-pain.de/2012/07/21/offtpoic-2-sharkoon-sata-quickport-xt-usb3-0-and-its-on-off-switch/</link>
		<comments>http://www.programmers-pain.de/2012/07/21/offtpoic-2-sharkoon-sata-quickport-xt-usb3-0-and-its-on-off-switch/#comments</comments>
		<pubDate>Sat, 21 Jul 2012 18:48:27 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Offtopic]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=526</guid>
		<description><![CDATA[While searching for an USB3.0 docking station for 3.5" SATA hard drives the SATA Quickport XT USB3.0 offered by Sharkoon got my attention at one point. It's simple, not that pricey and doesn't take up too much space. One of the things I was looking for was that it should provide an on/off switch so [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_652" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/docking_header.jpg" rel="lightbox[526]" title="Sharkoon SATA Quickport USB3.0 XT before/after moving the on/off switch from the back to the top part of the docking station"><img class="wp-image-652" title="Sharkoon SATA Quickport USB3.0 XT before/after moving the on/off switch from the back to the top part of the docking station" src="http://www.programmers-pain.de/wp-content/uploads/docking_header-1024x420.jpg" alt="Sharkoon SATA Quickport USB3.0 XT before/after moving the on/off switch from the back to the top part of the docking station" width="536" height="220" /></a><p class="wp-caption-text">Sharkoon SATA Quickport USB3.0 XT before/after moving the on/off switch from the back to the top part of the docking station</p></div>
<p>While searching for an USB3.0 docking station for 3.5" SATA hard drives the <a href="http://www.sharkoon.com/?q=en/node/1736" target="_blank">SATA Quickport XT USB3.0</a> offered by <a href="http://www.sharkoon.com/">Sharkoon</a> got my attention at one point. It's simple, not that pricey and doesn't take up too much space. One of the things I was looking for was that it should provide an on/off switch so that you don't have to rely on the operating system to suspend the disks which usually depends on how well the SATA&lt;-&gt;USB bridge inside the docking station is supported. What I don't understand is why Sharkoon places this switch on the back of the docking station so that it can't be reached easily if a disk is inserted into it - this kind of sucks if suspending the disk via the operating system doesn't work reliable. But luckily the top part of the docking station isn't used by an eject button, activity-LEDs or anything else except the imprinted Sharkoon logo - guess where I've moved the on/off switch to <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<span id="more-526"></span></p>
<div id="attachment_653" class="wp-caption alignright" style="width: 307px"><a href="http://www.programmers-pain.de/wp-content/uploads/docking_internals.jpg" rel="lightbox[526]" title="Internals of the docking station incl. the cable connection of the on/off switch"><img class="wp-image-653" title="Internals of the docking station incl. the cable connection of the on/off switch" src="http://www.programmers-pain.de/wp-content/uploads/docking_internals-843x1024.jpg" alt="Internals of the docking station incl. the cable connection of the on/off switch" width="297" height="361" /></a><p class="wp-caption-text">Internals of the docking station incl. the cable connection of the on/off switch</p></div>
<p>It's not really a tricky modification to shift the on/off switch from the back of the docking station to the top part since luckily the cable that connects the switch to the main board is long enough. Also it can be disconnected easily from the main board since it's using a 2-pin connector. Therefore it's all about mechanical work without any soldering involved. First your have to remove the four screws on the bottom of the docking station which are hidden behind the housing foots. Lift them carefully with a slot screwdriver so that you can reattach them afterwards.</p>
<p>After all four screws have been removed you should be able to lift the top cover from the bottom part of the docking station. Be careful with the front panels activity LEDs since this transparent plastic piece sits pretty tight on top of the small LED board. If you didn't mess up at that point you should be able to see the internals of the docking station as shown in the picture on the right side.</p>
<p>After disconnecting the on/off switch from the main board I again used a slot screwdriver to push down those clamps on the two sides of the switch which keeps it in position. Again be careful to not break the clamps since you'll need them to keep the switch in its new position in the top part of docking station. After you've removed the switch from its original location pick your favourite handheld power tool like <a href="http://www.proxxon.com/eng/">Proxxon</a>, <a href="http://www.dremel.de">Dremel</a>, etc to cut a hole in the top part of the docking station with the same dimensions as the original hole on the back.</p>
<div id="attachment_651" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/docking_banner.jpg" rel="lightbox[526]" title="The new hole for the on/off switch in the top part of the docking station"><img class="wp-image-651" title="The new hole for the on/off switch in the top part of the docking station" src="http://www.programmers-pain.de/wp-content/uploads/docking_banner-1024x277.jpg" alt="The new hole for the on/off switch in the top part of the docking station" width="536" height="144" /></a><p class="wp-caption-text">The new hole for the on/off switch in the top part of the docking station</p></div>
<p>If you'll pick the same location for the switch as I did as shown on the picture above you won't have any problem with the length of the cable connecting the switch to the main board. It will be a bit more tricky to reassemble the docking station since you have to be careful to not tuck the cable between the top and bottom part of the docking station. But after all it should fit quite nicely without being forced to extend the cable or anything like that. Put in the four screws on the bottom, reattach the housing foots and you're done and can enjoy an easy reachable on/off switch mounted on the top part of the docking station.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2012/07/21/offtpoic-2-sharkoon-sata-quickport-xt-usb3-0-and-its-on-off-switch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The first test assembly of my 512 RGB LED coffee table</title>
		<link>http://www.programmers-pain.de/2012/03/01/the-first-test-assembly-of-my-512rgb-led-coffee-tabl/</link>
		<comments>http://www.programmers-pain.de/2012/03/01/the-first-test-assembly-of-my-512rgb-led-coffee-tabl/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 21:15:49 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[LED Coffee Table]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[coffe table]]></category>
		<category><![CDATA[Rainbowduino]]></category>
		<category><![CDATA[Teensy]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=574</guid>
		<description><![CDATA[After being busy for almost one year with constructing my RGB LED coffee table it has finally happened: The almost complete table assembled in its full beauty! Wow! Pretty impressive to see everything together working for the first time. Okay, some hardware isn't fully done yet, the software is in an early prototype stage and [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_624" class="wp-caption alignleft" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/20120226_191318.jpg" rel="lightbox[574]" title="The 512 RGB LED coffee table after its first test assembly"><img class="size-medium wp-image-624" title="The 512 RGB LED coffee table after its first test assembly" src="http://www.programmers-pain.de/wp-content/uploads/20120226_191318-300x194.jpg" alt="The 512 RGB LED coffee table after its first test assembly" width="300" height="194" /></a><p class="wp-caption-text">The 512 RGB LED coffee table after its first test assembly</p></div>
<p>After being busy for almost one year with constructing my <a href="http://www.programmers-pain.de/category/led-coffee-table/" target="_blank">RGB LED coffee table</a> it has finally happened: The almost complete table assembled in its full beauty! Wow! Pretty impressive to see everything together working for the first time. Okay, some hardware isn't fully done yet, the software is in an early prototype stage and still some bugs have to be fixed until I'll move to table from my shop to the living room. Nevertheless I'd like to share this moment and the current state of my project with you.</p>
<p><span id="more-574"></span>With the help of a good friend (thanks again, Jan!) I was able to assemble the table for the first time including all those electronic components I've worked on for the last months. Please apologize the rather poor quality of the pictures used in this post but I only did some pictures with my mobile and forget about using a real camera - probably I was a bit too exited in that particular moment <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  So for about ~30mins the table was fully assembled and running the current state of the software. Here's a quick video taken with my mobile giving you a first impression of the RGB LED coffee table running one of the generators of the <a href="http://pixelinvaders.ch/?page_id=160" target="_blank">PixelController</a> software called <em>Plasma</em>:</p>
<p style="text-align: center;"><iframe src="http://www.youtube.com/embed/8gHPl0ZWeTo?hl=de&amp;fs=1" frameborder="0" width="550" height="320"></iframe></p>
<p>The RGB LED coffee table uses eight <a href="http://www.seeedstudio.com/wiki/Rainbowduino_LED_driver_platform_-_Atmega_328" target="_blank">Rainbowduino</a> micro controllers that each do control a <a href="http://www.programmers-pain.de/2011/09/07/soldering-512-rgb-leds-pure-fun-not/" target="_blank">8x8 RGB LED array</a>. Those controllers receive their data via an <a href="http://en.wikipedia.org/wiki/I%C2%B2C" target="_blank">I2C</a> link from a master micro controller. In the early days of the project I did use an <a href="http://arduino.cc/en/Main/ArduinoBoardUno" target="_blank">Arduino UNO</a> micro controller which turned out to suffer from a min. ~20ms delay while sending data via USB from the Mini-ITX PC via the I2C link to the eight Rainbowduino controllers. Since every to be updated Rainbowduino controller triggers another USB &lt;-&gt; Arduino UNO communication I did waste ~150ms for every to be updated frame with just waiting for the controller to pass through the data to the Rainbowduino controllers.</p>
<div id="attachment_626" class="wp-caption alignright" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/20120226_191334.jpg" rel="lightbox[574]" title="A closer look at the smoked glass with the white Polystyrene grid below it"><img class="size-medium wp-image-626" title="A closer look at the smoked glass with the white Polystyrene grid below it" src="http://www.programmers-pain.de/wp-content/uploads/20120226_191334-300x225.jpg" alt="A closer look at the smoked glass with the white Polystyrene grid below it" width="300" height="225" /></a><p class="wp-caption-text">A closer look at the smoked glass with the white Polystyrene grid below it</p></div>
<p>Since the author of the <a href="http://pixelinvaders.ch/?page_id=160" target="_blank">PixelController</a> software did suffer from the same problems he did some <a href="http://neophob.com/2011/04/serial-latency-teensy-vs-arduino/" target="_blank">measurements of the serial latency issue</a> of different micro controllers of the Arduino universe. The <a href="http://www.pjrc.com/teensy/" target="_blank">Teensy USB Development Board</a> has proven to be a practical alternative for the <a href="http://arduino.cc/en/Main/Hardware" target="_blank">official Arduino micro controllers</a> since the manufacturer also offers an <a href="http://arduino.cc/en/Main/Software" target="_blank">Arduino Software</a> extension called <a href="http://www.pjrc.com/teensy/teensyduino.html" target="_blank">Teensyduino</a> that allows you the run more or less the same sketch on the Teensy controllers using the same software used to program the official Arduino controllers. After replacing the Arduino UNO controller with a <a href="http://www.pjrc.com/store/teensy.html" target="_blank">Teensy 2.0</a> controller I was able to increase the throughput dramatically but still not as fast as I'd like to. After several performance and threading related improvements of the PixelController software I was able to almost archive ~18 fps with a single Teensy controller driving eight Rainbowduino controllers - not bad but still not as fast as I'd like to update the LED arrays.</p>
<p>The current state of the coffee table shown in the pictures does use two Teensy 2.0 controllers each driving four of the 8x8 LED arrays. This allows me to easily archive 25 fps as desired. It also allows me to update at least two of the Rainbowduino controllers in parallel so that the <a href="http://en.wikipedia.org/wiki/Screen_tearing" target="_blank">tearing effect</a> was also reduced noticeable with splitting up the Rainbowduino controllers. Still there are some things that I don't consider as ideal:</p>
<ul>
<li>Updating the Rainbowduino micro controllers with more than ~20 fps leads to some timing related drawing errors that result in some of the updated LED rows to appear brighter than the other rows on the same 8x8 LED array. So from time to time you get the impression that a single row of an 8x8 LED array does flash up for a short moment.</li>
<li>The resolution of a Rainbowduino controller is limited to 12bit. 12bit for each RGB LED means 4bit resolution per color channel which means the controller can only render 16 different red, green and blue color shades per LED. Especially if you don't want to use the full brightness of the LEDs you'll quickly notice some not so smooth color transitions.</li>
<li>Some of my controllers do suffer from another timing related problem that results in still slightly illuminated rows although all LEDs should be disabled. In the meanwhile this bug is already listed in the <a href="http://www.seeedstudio.com/wiki/Rainbowduino_LED_driver_platform_-_Atmega_328#Bug_Tracker" target="_blank">Rainbowduino documentation</a> but I wasn't able to pin this one down yet. For one of my affected controllers it turned out that this bug was temperature-dependent, for another controller I was able to fix this with replace the non lighted up LED of an affected row. But still there seems to be no pattern to handle those problems in a reliable way.</li>
<li>It's kind of painful to bring all Rainbowduinos to the same brightness level since there's only one potentiometer on each controller allowing you to regulate the current send to the LEDs. I wasn't able to measure that potentiometer value in a reliable way to get all controllers to the same current level. Also I have the feeling that the controllers are a bit temperature-sensitive depending on the pattern the controller currently sends to the LEDs and their resulting power consumption.</li>
</ul>
<div id="attachment_628" class="wp-caption alignleft" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/20120226_194333.jpg" rel="lightbox[574]" title="The table with its side board removed exposing the Polystyrene grid, the LED arrays and the technical compartment"><img class="size-medium wp-image-628" title="The table with its side board removed exposing the Polystyrene grid, the LED arrays and the technical compartment" src="http://www.programmers-pain.de/wp-content/uploads/20120226_194333-300x195.jpg" alt="The table with its side board removed exposing the Polystyrene grid, the LED arrays and the technical compartment" width="300" height="195" /></a><p class="wp-caption-text">The table with its side board removed exposing the Polystyrene grid, the LED arrays and the technical compartment</p></div>
<p>Since those problems will be very hard to fix or are even limited by the hardware used to drive the LEDs I've decided to give the new <a href="http://www.seeedstudio.com/wiki/Rainbowduino_v3.0" target="_blank">Rainbowduino V3 controllers</a> a chance. My hope is that due to the native USB interface I don't need to use an Arduino UNO or a Teensy controller to send the data out via an I2C link and rather connect all the controllers directly via USB to my Mini-ITX PC. I expect those new controllers will have the same ~20ms serial latency as the other Arduino controllers since they do use similar hardware for the USB part. Nevertheless I think that this won't be an major issue since I will be able to update all eight controllers at roughly the same time via their USB interface (if I do ignore the serial architecture of the USB bus for a second) so that those ~20ms don't pile up while sending a full frame to the controllers. Furthermore the Rainbowduino V3 controllers do use a different LED driver IC that provides a higher color resolution. I'll keep you informed with another blog post how those controllers worked out for my coffee table project.</p>
<p>Despite all the pointed out problems or possible improvements I'm still very happy with the current state of the project. The smoked glass matches the <a href="http://wikiflooring.org/North_American_Walnut" target="_blank">American Walnut</a> boards in a good looking way in my opinion. Also the satinized foil attached underneath the smoked glass works quite well and gives you the impression that you actually look at a 4x4cm illuminated square rather than actually a single RGB LED sitting on the bottom of the Polystyrene grid. I was a bit afraid of possible color distortions coming from the smoked glass but this initial assembly test did still my fears. Also the overall brightness level is more than sufficient and the <em>'cross-talk'</em> between each LED pixel through the not 100% optically opaque Polystyrene gird and the reflections of the glass is visible but not disturbing in my view. Overall I'm more than pleased with the current state and will continue to get the remaining outstanding tasks done so that I can finally move my table over to my living room.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2012/03/01/the-first-test-assembly-of-my-512rgb-led-coffee-tabl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A closer look at the RGB LED coffee table internals</title>
		<link>http://www.programmers-pain.de/2012/02/27/a-closer-look-at-the-rgb-led-coffe-table-internals/</link>
		<comments>http://www.programmers-pain.de/2012/02/27/a-closer-look-at-the-rgb-led-coffe-table-internals/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 21:10:19 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[LED Coffee Table]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[coffee table]]></category>
		<category><![CDATA[Rainbowduino]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=560</guid>
		<description><![CDATA[Since my last post about the audio system installation of my 512 RGB LED Coffee Table project I've spent my time finalizing the table internals needed to operate the eight LED arrays inside the coffee table. This includes the power supply, the micro controllers used to operate the basic table functions, the Mini-ITX PC that [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_581" class="wp-caption alignleft" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2090.jpg" rel="lightbox[560]" title="8x8 RGB LED arrays closeup"><img class="size-medium wp-image-581" title="8x8 RGB LED arrays closeup" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2090-300x217.jpg" alt="8x8 RGB LED arrays closeup" width="300" height="217" /></a><p class="wp-caption-text">8x8 RGB LED arrays closeup</p></div>
<p>Since my last post about the <a href="http://www.programmers-pain.de/2011/11/08/things-you-shouldnt-do-3-cut-19-inch-amplifiers-and-subwoofer-crossovers-in-half/" target="_blank">audio system installation</a> of my <a href="http://www.programmers-pain.de/category/led-coffee-table/" target="_blank">512 RGB LED Coffee Table project</a> I've spent my time finalizing the table internals needed to operate the eight <a href="http://www.programmers-pain.de/2011/09/07/soldering-512-rgb-leds-pure-fun-not/" target="_blank">LED arrays</a> inside the coffee table. This includes the power supply, the micro controllers used to operate the basic table functions, the Mini-ITX PC that generates and distributes the to be shown images to the eight LED arrays as well as the needed wiring between the individual components and the front panels used to operate the table.</p>
<p><span id="more-560"></span></p>
<div id="attachment_583" class="wp-caption alignright" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2068.jpg" rel="lightbox[560]" title="Overview of the RGB LED coffee table internals with all 8x8 LED arrays removed"><img class="size-medium wp-image-583" title="Overview of the RGB LED coffee table internals with all 8x8 LED arrays removed" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2068-300x183.jpg" alt="Overview of the RGB LED coffee table internals with all 8x8 LED arrays removed" width="300" height="183" /></a><p class="wp-caption-text">Overview of the RGB LED coffee table internals with all 8x8 LED arrays removed</p></div>
<p>The power supply of the coffee table divides into three sections:</p>
<ul>
<li>A small 12V standby power supply used to operate the tables micro controllers that do take care of starting up the other two parts of the tables power supply.</li>
<li>An ATX power supply that serves the Mini-ITX PC as well as the <a href="http://www.seeedstudio.com/depot/rainbowduino-led-driver-platform-atmega-328-p-371.html" target="_blank">Rainbowduino</a> micro controllers on the LED panels.</li>
<li>The internal power supplies of the <a href="http://www.thomann.de/de/tamp_s100.htm" target="_blank">stereo amplifiers</a> and a small power supply for the <a href="http://www.reckhorn.com/pages/frequenzweichen/s-1-aktive-subwoofer-satellitenweiche.php" target="_blank">active subwoofer crossover</a>.</li>
</ul>
<div id="attachment_586" class="wp-caption alignleft" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2012.jpg" rel="lightbox[560]" title="The 12V standby power supply, the PCs front panel connector and the USB hub in the background"><img class="size-medium wp-image-586" title="The 12V standby power supply, the PCs front panel connector and the USB hub in the background" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2012-300x199.jpg" alt="The 12V standby power supply, the PCs front panel connector and the USB hub in the background" width="300" height="199" /></a><p class="wp-caption-text">The 12V standby power supply, the PCs front panel connector and the USB hub in the background</p></div>
<p>The ATX power supply as well as the power supplies of the sound system can be independently controlled by two <a href="http://www.elv.de/FS20-Funkschaltsystem/x.aspx/cid_74/detail_1/detail2_1712" target="_blank">FS20</a> <a href="http://www.elv.de/FS20-SU-2-Unterputz-Funk-Schalter,-3680-VA/x.aspx/cid_74/detail_10/detail2_25126/flv_/bereich_/marke_" target="_blank">remote power switches</a>. The tables main micro controllers do use a FS20 <a href="http://www.elv.de/FS20-S8M-4-8-Kanal-Sendemodul/x.aspx/cid_74/detail_10/detail2_31220/flv_/bereich_/marke_" target="_blank">sender</a> and a <a href="http://www.elv.de/FS20-SM4-4-Kanal-Schaltmodul/x.aspx/cid_74/detail_10/detail2_25522/flv_/bereich_/marke_" target="_blank">receiver</a> module to be able to trigger and monitor the states of those power switches. One of the four channels offered by those modules is used as the main power switch of the table which triggers the micro controllers to power on the Mini-ITX PC. Therefore the micro controllers needs to be able to trigger the PCs power switch which is done via an opto-coupler so that the micro controllers don't inject any dangerous voltage levels via the power or reset signals that might harm the mainboard.</p>
<p>Beside controlling the power supplies the main micro controllers also take care of the front panel that provides several buttons to the outside world so that it's still possible to manually power on / off the individual table components. The front panel will also provide technical controls for the LED panel micro controllers so that I can flash a new firmware to them without being forced to dismantle half of the table.</p>
<div id="attachment_588" class="wp-caption alignright" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2009.jpg" rel="lightbox[560]" title="The Mini-ITX PC, the ATX power supply and the two FS20 remote power switches"><img class="size-medium wp-image-588" title="The Mini-ITX PC, the ATX power supply and the two FS20 remote power switches" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2009-300x192.jpg" alt="The Mini-ITX PC, the ATX power supply and the two FS20 remote power switches" width="300" height="192" /></a><p class="wp-caption-text">The Mini-ITX PC, the ATX power supply and the two FS20 remote power switches</p></div>
<p>The third job of the main micro controllers is to drive some additional LEDs via <a href="http://en.wikipedia.org/wiki/Pulse-width_modulation" target="_blank">PWM</a> signals that are used to lighten up the four compartments of the table triggered by <a href="http://en.wikipedia.org/wiki/Reed_switch" target="_blank">reed switches</a> hidden inside the doors of each compartment. So whenever you open one of the doors some white LEDs mounted into the ceiling of each compartment will be dimmed up. For those two technical compartments that do contain the Mini-ITX PC as well as the sound system the LEDs will only illuminate the front panel itself and not all the electronic bits and pieces hidden behind it. I've also installed eight RGB LEDs into each <a href="http://www.programmers-pain.de/2011/11/08/things-you-shouldnt-do-3-cut-19-inch-amplifiers-and-subwoofer-crossovers-in-half/" target="_blank">speaker stack</a> that are also controlled by the main micro controllers. The idea here is to have some lightning effects inside the speaker stacks that should be in sync with the just played audio signal. The hardware for doing so is ready but it still has to be implemented in software at one point.</p>
<div id="attachment_590" class="wp-caption alignleft" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2037.jpg" rel="lightbox[560]" title="The main micro controllers, the FS20 sender and receiver modules and parts of the fan control boards"><img class="size-medium wp-image-590" title="The main micro controllers, the FS20 sender and receiver modules and parts of the fan control boards" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2037-300x199.jpg" alt="The main micro controllers, the FS20 sender and receiver modules and parts of the fan control boards" width="300" height="199" /></a><p class="wp-caption-text">The main micro controllers, the FS20 sender and receiver modules and parts of the fan control boards</p></div>
<p>The fourth and last job of the tables main micro controllers is to control the four fans that are mounted into the bottom of the tables technical compartment. Two of those fans will suck cold air into the central technical compartment - the other two fans are used the get the warmed up air out of the two lower technical compartments that do contain the Mini-ITX PC as well as the sound system. Since I can't really predict the heat generation of all electrical components I've oversized the ventilation system on purpose and installed some <a href="http://www.maxim-ic.com/datasheet/index.mvp/id/2815" target="_blank">DS18S20 temperature sensors</a> in the critical parts of the table. With those sensors the main micro controllers are able to decide if all or some of the fans have to run to get the warmed up air out of the table. The warm air will be conducted through several holes in the LED panels, through the <a href="http://en.wikipedia.org/wiki/Polystyrene" target="_blank">Polystyrene</a> grid and finally through a ~1cm gap between the smoked glass and the surrounding wood panels of the table.</p>
<div id="attachment_592" class="wp-caption alignright" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/IMG_2034.jpg" rel="lightbox[560]" title="The main power distribution board containing the connectors to the eight Rainbowduino micro controllers"><img class="size-medium wp-image-592" title="The main power distribution board containing the connectors to the eight Rainbowduino micro controllers" src="http://www.programmers-pain.de/wp-content/uploads/IMG_2034-300x199.jpg" alt="The main power distribution board containing the connectors to the eight Rainbowduino micro controllers" width="300" height="199" /></a><p class="wp-caption-text">The main power distribution board containing the connectors to the eight Rainbowduino micro controllers</p></div>
<p>The next step is to bring the table to a state that all parts except the front panels have been put together so that I can get a first impression how the table will actually look close to its final state. I'm pretty sure that the initial assembly will show up some smaller - hopefully no bigger - problems until the table itself is finally done. After that there's still a lot of work need to finish the software - especially since I doubt that I'll call the software <em>'finished'</em> at any point in the near future since there's usually always something that you want to change or improve <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2012/02/27/a-closer-look-at-the-rgb-led-coffe-table-internals/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Things you shouldn’t do #3: Cut 19-inch amplifiers and subwoofer crossovers in half</title>
		<link>http://www.programmers-pain.de/2011/11/08/things-you-shouldnt-do-3-cut-19-inch-amplifiers-and-subwoofer-crossovers-in-half/</link>
		<comments>http://www.programmers-pain.de/2011/11/08/things-you-shouldnt-do-3-cut-19-inch-amplifiers-and-subwoofer-crossovers-in-half/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 18:07:44 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[LED Coffee Table]]></category>
		<category><![CDATA[Things you shouldn’t do]]></category>
		<category><![CDATA[coffee table]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=490</guid>
		<description><![CDATA[Quite some time has passed by since my last blog post about my 512 RGB LED Coffee Table project so that it's about time to give you a brief update what has happened the last ~8 weeks. Mid of September my carpenter was done with constructing the coffee table so that I could finally start [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_533" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/sound_header.jpg" rel="lightbox[490]" title="The coffee tables sound system in the original and installed state"><img class="size-large wp-image-533" title="The coffee tables sound system in the original and installed state" src="http://www.programmers-pain.de/wp-content/uploads/sound_header-1024x368.jpg" alt="The coffee tables sound system in the original and installed state" width="536" height="197" /></a><p class="wp-caption-text">The coffee tables sound system in the original and installed state</p></div>
<p>Quite some time has passed by since my last <a href="http://www.programmers-pain.de/2011/09/07/soldering-512-rgb-leds-pure-fun-not/" target="_blank">blog post</a> about my <a href="http://www.programmers-pain.de/category/led-coffee-table/" target="_blank">512 RGB LED Coffee Table project</a> so that it's about time to give you a brief update what has happened the last ~8 weeks. Mid of September my carpenter was done with constructing the coffee table so that I could finally start to integrate all the electronic components and the needed wiring into it. Thanks again to especially Gunnar Schwinn from <a href="http://www.massivholz-moebel-schreinerei.de/" target="_blank">http://www.massivholz-moebel-schreinerei.de/</a> which did a great job in bringing my ideas to life and giving valuable feedback. As soon as the coffee table arrived at my place I focused on the sound system since the installation of it is rather a standalone task beside the installation of the RGB LEDs.<br />
<span id="more-490"></span></p>
<div id="attachment_536" class="wp-caption alignleft" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/sound_amplifier.jpg" rel="lightbox[490]" title="Thomann THE T.AMP S-100 2x100W Stereo 19″ PA amplifier"><img class="size-medium wp-image-536" title="Thomann THE T.AMP S-100 2x100W Stereo 19″ PA amplifier" src="http://www.programmers-pain.de/wp-content/uploads/sound_amplifier-300x171.jpg" alt="Thomann THE T.AMP S-100 2x100W Stereo 19″ PA amplifier" width="300" height="171" /></a><p class="wp-caption-text">Thomann THE T.AMP S-100 2x100W Stereo 19″ PA amplifier</p></div>
<p>The sound system consists out of two <a href="http://www.thomann.de/de/tamp_s100.htm" target="_blank">Thomann THE T.AMP S-100 2x100W Stereo 19" PA amplifiers</a> that have been <em>'optimized'</em> to fit into the table. <em>'Optimized'</em> in that context means that I've chopped both amplifiers in half, cut the housing into several pieces that do allow me to fit the circuit boards into one of the tables 20x23cm technical compartments. The power transformers were mounted against the compartments sidewalls and the cables to the front panels providing the volume regulators have been extended to fit my installation. It's just the average modifications that makes every DIN-Standard-evaluator start to cry - instantly.</p>
<p>Each stereo amplifier will drive a <a href="http://www.esxaudio.de/pages/quantum/qx-62.htm" target="_blank">QX-62 two-way</a>- and a <a href="http://www.esxaudio.de/pages/quantum/qx-62C.htm" target="_blank">QX-6.2W kickbass</a> speaker pair from <a href="http://www.esxaudio.de/" target="_blank">ESX</a> that are meant to be installed into car hifi setups. Since I only have a stereo sound source I had to find a way how to connect both stereo amplifiers together. This is aggravated by the fact that all four speakers will be installed into relatively small compartments which will make it even harder to calibrate the speakers to deliver an acceptable sound. To do so I've installed a <a href="http://www.reckhorn.com/pages/frequenzweichen/s-1-aktive-subwoofer-satellitenweiche.php" target="_blank">Reckhorn S-1 active subwoofer crossover</a> that allows me to finetune the exact cutoff- and crossover frequencies between the two stereo amplifiers so that I can operate the kickbass speakers only in the desired frequency range and that the two-way speakers don't have to handle those the lower frequencies.</p>
<div id="attachment_538" class="wp-caption alignright" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/sound_compartments.jpg" rel="lightbox[490]" title="The four speaker compartments after they've been damped with bitumen plates"><img class="size-medium wp-image-538" title="The four speaker compartments after they've been damped with bitumen plates" src="http://www.programmers-pain.de/wp-content/uploads/sound_compartments-300x180.jpg" alt="The four speaker compartments after they've been damped with bitumen plates" width="300" height="180" /></a><p class="wp-caption-text">The four speaker compartments after they&#39;ve been damped with bitumen plates</p></div>
<p>The installation of the speakers was quite work-intensive since I first damped the speaker compartments with some bitumen plates to prevent the wood from picking up the vibrations. Afterwards I've glued them into the table so that I was able to mount the speaker chassis itself. To tighten up the sound I've also muffled each speaker compartment with a bigger piece of insulating material since especially the kickbass speakers would usually need a larger compartment volume than my ~2.5l compartments can offer. As a final step I've installed two bass reflex tubes into each compartment to give the speakers some air to do their thing. Although those two bass reflex tubes are a bit oversized for the compartments a prototype compartment with only one or none bass reflex tube wasn't able to deliver a better sound in my opinion.</p>
<div id="attachment_540" class="wp-caption alignleft" style="width: 262px"><a href="http://www.programmers-pain.de/wp-content/uploads/sound_stack.jpg" rel="lightbox[490]" title="One of the two speaker stacks with a two-way speaker on the bottom"><img class="size-medium wp-image-540" title="One of the two speaker stacks with a two-way speaker on the bottom" src="http://www.programmers-pain.de/wp-content/uploads/sound_stack-300x298.jpg" alt="One of the two speaker stacks with a two-way speaker on the bottom" width="252" height="251" /></a><p class="wp-caption-text">One of the two speaker stacks with a two-way speaker on the bottom</p></div>
<p>At the end a two-way- and a kickbass speaker have been stacked on top of each other as shown on the picture. Both speaker stacks have been installed between the bottom plate and the base plate of the tables technical compartment that does contain all the wiring needed to drive the RGB leds. To allow the sound to get out of this confined place a 45° cone between both speaker compartments does reflect the sound of the two-way speaker to the outside. Since I wanted the speaker stacks to appear as a single unit the space between the compartments will be covered with acoustic cloth to get a cleaner look.</p>
<p>The most work-intense part was for sure the modification of those PA amplifiers so that they do fit into the table at the end. Beside constructing a housing out of the original 19" enclosure I also had to extend some wiring to be able to connect the front panel controls and the power transformers to it. Also I've disassembled the subwoofer crossover and cut its circuit board in half so that I can mount the potentiometers to the front panel. The other half of the circuit board containing the power supply for the active subwoofer crossover is mounted inside the technical compartment of the coffee table.</p>
<div id="attachment_543" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/sound_internals.jpg" rel="lightbox[490]" title="Mounted amplifiers with extended front panel wiring and installed power supply"><img class="size-large wp-image-543" title="Mounted amplifiers with extended front panel wiring and installed power supply" src="http://www.programmers-pain.de/wp-content/uploads/sound_internals-1024x328.jpg" alt="Mounted amplifiers with extended front panel wiring and installed power supply" width="536" height="176" /></a><p class="wp-caption-text">Mounted amplifiers with extended front panel wiring and installed power supply</p></div>
<p>After the first tests I'm pretty satisfied with the sound of the coffee table especially since this was my first attempt to build anything like this. Of course there isn't a massive bass foundation coming out of the table but this was expected since I only used 16.5cm car hifi speakers in a very limited environment. Usually you would need a lot more space to construct an usual subwoofer compartment. Nevertheless due to the combination of a full-range two-way- and a kickbass speaker pair the table is able to deliver an more than acceptable sound from my point of view.</p>
<p>Be advised that applying those kind of modification to consumer hifi / PA devices do require a broad knowledge of electronic components in general. Please be aware that you can easily end up in a life-threatening situation since you have to deal with line voltage directly at several places while doing those kind of modifications. Therefore I have to close the post with:</p>
<h5>So, things you shouldn't do #3: Cut 19-inch amplifiers and subwoofer crossovers in half</h5>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2011/11/08/things-you-shouldnt-do-3-cut-19-inch-amplifiers-and-subwoofer-crossovers-in-half/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto upgrade PHP on CentOS 5.x</title>
		<link>http://www.programmers-pain.de/2011/10/26/howto-upgrade-php-on-centos-5/</link>
		<comments>http://www.programmers-pain.de/2011/10/26/howto-upgrade-php-on-centos-5/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 19:19:50 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=316</guid>
		<description><![CDATA[CentOS 5.x comes with PHP in version 5.1.6 which is pretty old those days. There are already quite some web applications that have dropped PHP 5.1.x support which makes it impossible to install them on a CentOS 5.x installation. With the release of CentOS 5.6 additional packages called php53, php53-common, php53-ldap, etc. have been released [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.programmers-pain.de/wp-content/uploads/php_logo.png" rel="lightbox[316]" title="PHP Logo"><img class="alignleft size-medium wp-image-385" title="PHP Logo" src="http://www.programmers-pain.de/wp-content/uploads/php_logo-300x157.png" alt="PHP Logo" width="240" height="126" /></a><a href="http://www.centos.org/" target="_blank">CentOS</a> 5.x comes with <a href="http://www.php.net/" target="_blank">PHP</a> in version 5.1.6 which is pretty old those days. There are already quite some web applications that have dropped PHP 5.1.x support which makes it impossible to install them on a CentOS 5.x installation. With the release of CentOS 5.6 additional packages called <em>php53</em>, <em>php53-common</em>, <em>php53-ldap</em>, etc. have been released which could replace the 5.1.6 default version of PHP if you don't have other RPM packages that depend on the original <em>php</em> packages. Since the <em>php</em> and the new <em>php53</em> packages do install their resources into the same directories you can't install both of them in parallel. Instead of faking empty <em>php</em> packages to be able to install all <em>php53</em> packages without conflicts and missing dependencies I decided to go for a third party PHP installation provided by <a href="http://www.atomicorp.com/" target="_blank">AtomiCorp</a>.<br />
<span id="more-316"></span></p>
<p>If you need to find out which CentOS version you're running you should have a look at the content of the following file:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>redhat-release<br />
CentOS release <span style="color: #000000;">5.6</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>Final<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>You can use <a href="www.centos.org/docs/5/html/yum/" target="_blank">yum</a> to get a list of all currently installed PHP packages so that you know which packages of the AtomiCorp PHP installation you have to install and which one you might have to install manually:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">yum list</span> installed <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> php<br />
php.x86_64 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-cli.x86_64 &nbsp; &nbsp; &nbsp; &nbsp; 5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-common.x86_64 &nbsp; &nbsp; &nbsp;5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-devel.x86_64 &nbsp; &nbsp; &nbsp; 5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-gd.x86_64 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-imap.x86_64 &nbsp; &nbsp; &nbsp; &nbsp;5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-mbstring.x86_64 &nbsp; &nbsp;5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-mysql.x86_64 &nbsp; &nbsp; &nbsp; 5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-pdo.x86_64 &nbsp; &nbsp; &nbsp; &nbsp; 5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed<br />
php-pear.noarch &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">1</span>:1.4.9-<span style="color: #000000;">6</span>.el5 &nbsp; &nbsp; &nbsp; &nbsp; installed<br />
php-pear-Date.noarch &nbsp; 1.4.7-<span style="color: #000000;">2</span>.el5.centos &nbsp; &nbsp;installed<br />
php-xml.x86_64 &nbsp; &nbsp; &nbsp; &nbsp; 5.1.6-<span style="color: #000000;">27</span>.el5_5.3 &nbsp; &nbsp; &nbsp;installed</div></td></tr></tbody></table></div>
<p>Now that you're aware of which RPMs are currently installed we can install the alternative PHP installation provided by AtomiCorp following their <a href="http://www.atomicorp.com/wiki/index.php/PHP" target="_blank">installation instructions</a>. First we have to install their repository definitions to allow <em>yum</em> to download the new RPMs:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> - http:<span style="color: #000000; font-weight: bold;">//</span>www.atomicorp.com<span style="color: #000000; font-weight: bold;">/</span>installers<span style="color: #000000; font-weight: bold;">/</span>atomic <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sh</span></div></td></tr></tbody></table></div>
<p>Since I also want to upgrade my <a href="http://www.mysql.com/" target="_blank">MySQL</a> installation from the CentOS default version 5.0 to 5.1 I added also the <em>mysql</em> package to the <em>yum update</em> command:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">yum update</span> php mysql</div></td></tr></tbody></table></div>
<p>This results in the following packages being updated or installed due to additional dependencies of the new PHP and / or MySQL versions:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Dependency Installed:<br />
&nbsp; libICE.x86_64 0:1.0.1-2.1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; libSM.x86_64 0:1.0.1-3.1<br />
&nbsp; libXaw.x86_64 0:1.0.2-8.1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; libXext.x86_64 0:1.0.1-2.1<br />
&nbsp; libXmu.x86_64 0:1.0.2-5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; libXt.x86_64 0:1.0.2-3.2.el5<br />
&nbsp; libedit.x86_64 0:3.0-2.20090923cvs.el5.art &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mysql-libs.x86_64 0:5.1.58-2.el5.art<br />
&nbsp; mysqlclient15.x86_64 0:5.0.90-1.el5.art &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t1lib.x86_64 0:5.1.2-2.el5.art<br />
Updated:<br />
&nbsp; mysql.x86_64 0:5.1.58-2.el5.art &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;php.x86_64 0:5.3.6-5.el5.art<br />
Dependency Updated:<br />
&nbsp; mysql-server.x86_64 0:5.1.58-2.el5.art &nbsp; &nbsp;php-cli.x86_64 0:5.3.6-5.el5.art &nbsp; &nbsp; &nbsp;php-common.x86_64 0:5.3.6-5.el5.art<br />
&nbsp; php-devel.x86_64 0:5.3.6-5.el5.art &nbsp; &nbsp; &nbsp; &nbsp;php-gd.x86_64 0:5.3.6-5.el5.art &nbsp; &nbsp; &nbsp; php-imap.x86_64 0:5.3.6-5.el5.art<br />
&nbsp; php-mbstring.x86_64 0:5.3.6-5.el5.art &nbsp; &nbsp; php-mysql.x86_64 0:5.3.6-5.el5.art &nbsp; &nbsp;php-pdo.x86_64 0:5.3.6-5.el5.art<br />
&nbsp; php-xml.x86_64 0:5.3.6-5.el5.art</div></td></tr></tbody></table></div>
<p>After <em>yum</em> has successfully installed the new PHP version you might want to disable the new AtomiCorp Repository to not interfere with the usual CentOS updates. To do so you have to edit the following file and set the enabled property to <em>0</em>:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>yum.repos.d<span style="color: #000000; font-weight: bold;">/</span>atomic.repo<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>atomic<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
name = CentOS <span style="color: #000000; font-weight: bold;">/</span> Red Hat Enterprise Linux <span style="color: #007800;">$releasever</span> - atomicrocketturtle.com<br />
mirrorlist = http:<span style="color: #000000; font-weight: bold;">//</span>www.atomicorp.com<span style="color: #000000; font-weight: bold;">/</span>mirrorlist<span style="color: #000000; font-weight: bold;">/</span>atomic<span style="color: #000000; font-weight: bold;">/</span>centos-<span style="color: #000000;">5</span>-<span style="color: #007800;">$basearch</span><br />
<span style="color: #666666; font-style: italic;">#mirrorlist = http://www.atomicorp.com/channels/atomic/centos/5/mirrors-atomic</span><br />
<span style="display:block;background-color:#ffff66">enabled = <span style="color: #000000;">0</span><br /></span>priority = <span style="color: #000000;">1</span><br />
protect = <span style="color: #000000;">0</span><br />
gpgkey = file:<span style="color: #000000; font-weight: bold;">///</span>etc<span style="color: #000000; font-weight: bold;">/</span>pki<span style="color: #000000; font-weight: bold;">/</span>rpm-gpg<span style="color: #000000; font-weight: bold;">/</span>RPM-GPG-KEY.art.txt<br />
gpgcheck = <span style="color: #000000;">1</span></div></td></tr></tbody></table></div>
<p>Now you should be able to call the PHP interpreter to check for the PHP version:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">php <span style="color: #660033;">--version</span><br />
<span style="display:block;background-color:#ffff66">PHP Deprecated: &nbsp;Directive <span style="color: #ff0000;">'safe_mode'</span> is deprecated <span style="color: #000000; font-weight: bold;">in</span> PHP <span style="color: #000000;">5.3</span> and greater <span style="color: #000000; font-weight: bold;">in</span> Unknown on line <span style="color: #000000;">0</span><br /></span>PHP 5.3.6 <span style="color: #7a0874; font-weight: bold;">&#40;</span>cli<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>built: Aug &nbsp;<span style="color: #000000;">3</span> <span style="color: #000000;">2011</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">13</span>:<span style="color: #000000;">41</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1997</span>-<span style="color: #000000;">2011</span> The PHP Group<br />
Zend Engine v2.3.0, Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1998</span>-<span style="color: #000000;">2011</span> Zend Technologies</div></td></tr></tbody></table></div>
<p>So version 5.3.6 is now the default PHP version of your CentOS installation. But as stated by the PHP interpreter you also have to update you <em>php.ini</em> file to fit the new PHP version:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini_backup<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini.rpmnew <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini</div></td></tr></tbody></table></div>
<p>Be sure to update all custom settings of your old <em>php.ini</em> file to the one provided by the new RPM packages. After this has been done you should be able to call the PHP interpreter without an error message complaining about deprecated configuration values:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">php <span style="color: #660033;">--version</span><br />
PHP 5.3.6 <span style="color: #7a0874; font-weight: bold;">&#40;</span>cli<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>built: Aug &nbsp;<span style="color: #000000;">3</span> <span style="color: #000000;">2011</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">13</span>:<span style="color: #000000;">41</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Copyr<span style="color: #000000; font-weight: bold;">&lt;</span>strong<span style="color: #000000; font-weight: bold;">&gt;&lt;/</span>strong<span style="color: #000000; font-weight: bold;">&gt;</span>ight <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1997</span>-<span style="color: #000000;">2011</span> The PHP Group<br />
Zend Engine v2.3.0, Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1998</span>-<span style="color: #000000;">2011</span> Zend Technologies</div></td></tr></tbody></table></div>
<p>In that context you might want to set the default timezone for all date functions which is a behaviour of PHP that has changed from version 5.1 to 5.3. To do so you have to find the line containing the <em>date.timezone</em> property and set it to your desired default timezone:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Date<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
; Defines the default timezone used by the <span style="color: #c20cb9; font-weight: bold;">date</span> functions<br />
; http:<span style="color: #000000; font-weight: bold;">//</span>www.php.net<span style="color: #000000; font-weight: bold;">/</span>manual<span style="color: #000000; font-weight: bold;">/</span>en<span style="color: #000000; font-weight: bold;">/</span>datetime.configuration.php<span style="color: #666666; font-style: italic;">#ini.date.timezone</span><br />
<span style="display:block;background-color:#ffff66">date.timezone = Europe<span style="color: #000000; font-weight: bold;">/</span>Berlin</span></div></td></tr></tbody></table></div>
<p>Since we've also updated the MySQL installation from 5.0 to 5.1 we have to upgrade our existing databases to the new MySQL version. MySQL should still be able to start up without those upgrade tasks applied to it but it will remove several errors from the MySQL logfiles. To do so you have again to backup you existing main MySQL configuration file and replace it with the new one:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>my.cnf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>my.cnf_backup<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>my.cnf.rpmnew <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>my.cnf</div></td></tr></tbody></table></div>
<p>Again make sure you adapt all old settings to the new MySQL configuration file. To upgrade your existing databases to the new MySQL version you just have to call the <em>mysql_upgrade</em> command which will than connect as the root user to your running MySQL instance to apply the needed upgrade statements. If you don't know you root password or if you don't have local root user access set up in your MySQL permissions you could just call the <a href="http://dev.mysql.com/doc/refman/5.1/en/mysqld-safe.html" target="_blank">mysqld_safe</a> script with the <em>--skip-grant-tables</em> parameter to allow full access to your MySQL instance and apply the upgrade statements afterwards:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysqld_safe <span style="color: #660033;">--skip-grant-tables</span><br />
mysql_upgrade</div></td></tr></tbody></table></div>
<p>After that you should be able to start up your upgraded databases without any errors in the MySQL log file. For my CentOS 5.6 installations I wasn't able to find any problems after upgrading PHP following this Howto. I'm still able to install any CentOS RPM that has a dependency to the original PHP version of CentOS since the names of the RPMs haven't changed. Of course you should check your currently used web applications that they are compatible with a PHP 5.3.x installation which is also the main reason that the RHEL/CentOS guys decided to provide PHP 5.3.x as additional packages since some of the provided web applications still depend on a 5.1.x PHP version. But if you're sure that you don't want to use any of those older web applications I'd say that this Howto is the easier solution to upgrade your PHP installation instead of dealing with two PHP installations at the same time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2011/10/26/howto-upgrade-php-on-centos-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Soldering 512 RGB Leds: Pure fun&#8230; Not!</title>
		<link>http://www.programmers-pain.de/2011/09/07/soldering-512-rgb-leds-pure-fun-not/</link>
		<comments>http://www.programmers-pain.de/2011/09/07/soldering-512-rgb-leds-pure-fun-not/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 19:52:36 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[LED Coffee Table]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[coffee table]]></category>
		<category><![CDATA[Rainbowduino]]></category>
		<category><![CDATA[RGB LEDs]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=408</guid>
		<description><![CDATA[Finally! After hours spend with fitting LEDs into reflectors, preparing cables, cutting shrink tubing pieces and soldering everything together to 8x8 LED arrays: It is done! And I'll never ever do it again this way. As I already stated in my first blog post about my 512 RGB LED Coffee Table project I was a [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_466" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/led1.jpg" rel="lightbox[408]" title="Eight 8x8 RGB LED arrays each driven by a Rainbowduino Controller"><img class="size-large wp-image-466" title="Eight 8x8 RGB LED arrays each driven by a Rainbowduino Controller" src="http://www.programmers-pain.de/wp-content/uploads/led1-1024x442.jpg" alt="Eight 8x8 RGB LED arrays each driven by a Rainbowduino Controller" width="536" height="230" /></a><p class="wp-caption-text">Eight 8x8 RGB LED arrays each driven by a Rainbowduino Controller</p></div>
<p>Finally! After hours spend with fitting LEDs into reflectors, preparing cables, cutting shrink tubing pieces and soldering everything together to 8x8 LED arrays: It is done! And I'll never ever do it again this way. <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  As I already stated in my first <a href="http://www.programmers-pain.de/2011/08/17/howto-waste-your-spare-time-build-a-512-rgb-led-coffee-table/" target="_blank">blog post</a> about my <a href="http://www.programmers-pain.de/category/led-coffee-table/" target="_blank">512 RGB LED Coffee Table</a> project I was a bit too optimistic in the planing phase regarding the wiring effort needed to get all LEDs working.<span id="more-408"></span></p>
<p>When I've started the first of the eight 8x8 LED arrays I wanted to wire the LEDs in a nice and isolated way. Therefore I've wired all red, green and blue LED pins with coloured cables that have been stripped on several places for about ~1cm so that I can solder a LED pin against it. After that I covered every solder joint with a piece of shrink tubing to avoid potential short circuits. The idea did sound good in the beginning. But after finishing the first LED array I realised that building one 8x8 LED array has taken me ~10h! Ouch! I didn't really expected that it will take that long but on the other hand it's quite obvious why:</p>
<ul>
<li>64 RGB LEDs with 4 pins each</li>
<li>64 reflectors</li>
<li>16m of wires cut into 64 pieces</li>
<li>256 solder joints between wires and the LED pins</li>
<li>288 pieces of shrink tubing</li>
<li>32 cables for connecting the <a href="http://www.seeedstudio.com/depot/rainbowduino-led-driver-platform-atmega-328-p-371.html" target="_blank">Rainbowduino</a> controller to the LED array</li>
<li>64 solder joints between LEDs and the Rainbowduino controller</li>
</ul>
<p>After I had finished the second LED array using the same approach I was able to reduce the overall build time to ~8h which was still to much in my eyes. At the beginning of building LED array #3 I was so sick of it all that I've tried to save the time needed to strip the wires with burning away the isolation of the cables with my soldering iron. After the probably toxic fumes made my head swim I had to stop this and come up with another way of wiring the remaining 5 1/2 LED arrays. At this point I was quite frustrated and even thought about dropping the whole idea for a short moment.</p>
<p>But instead I tried my luck with PCB stripes used to connect the red, green and blue pins of each LED in eight rows per array so that I don't need any wires and shrink tubing pieces to connect them. For the common anodes of the LEDs I used eight pieces of copper wire to connect them together. This approach really simplified the wiring effort to connect all 256 LED pins in a 8x8 matrix circuit. Therefore I only had to prepare 32 wires for connecting the PCB stripes / copper wires to the Rainbowduino controller. The overall build time did reduce to ~5h using this approach - not bad! The drawback is that the whole circuit isn't isolated any longer so that I have to be more careful to not ending up with any short circuits that might brick the controller.</p>
<div id="attachment_467" class="wp-caption aligncenter" style="width: 546px"><a href="http://www.programmers-pain.de/wp-content/uploads/led2.jpg" rel="lightbox[408]" title="LED array #1, 'The Ugly #3' and #8"><img class="size-large wp-image-467" title="LED array #1, 'The Ugly #3' and #8" src="http://www.programmers-pain.de/wp-content/uploads/led2-1024x345.jpg" alt="LED array #1, 'The Ugly #3' and #8" width="536" height="182" /></a><p class="wp-caption-text">LED array #1, &#39;The Ugly #3&#39; and #8</p></div>
<p>In the meanwhile I finished all 8 LED arrays with some help of <a href="http://www.kupferwerk.org/" target="_blank">Boris Bernhard</a> (thanks again, bud!) so that I can continue working on bringing them to life together somehow. The picture shows the LED array #1 that I've build using the old approach, LED array #3 aka. <em>'The Ugly #3'</em> since it's a mixture of the old and new approach and therefore looks really messy and LED array #8 where practice allowed me to build it in almost under ~4h. If I would have to build eight 8x8 LED arrays again than I wouldn't start with MDF boards this time. I'd rather spend some additional money to order some custom made PCB boards ready to be equipped with the LEDs providing all the needed wiring, cuttings and connectors for the Raindbowduino controller. I'm pretty sure that the money spend for those PCB boards would easily compensate the saved time to build the LED arrays like I did the last months. Lessons learned. Nevertheless here's a quick video showing one LED array running a demonstration loop based on a <a href="http://code.google.com/p/rainbowduino/" target="_blank">firmware</a> by <a href="http://www.seeedstudio.com/" target="_blank">seeedstudio.com</a> that I've extended a bit:</p>
<p style="text-align: center;"><iframe src="http://www.youtube.com/embed/iH1WQd7l_XU?hl=de&amp;fs=1" frameborder="0" width="550" height="320"></iframe></p>
<p>So my idea to bring those LED arrays to life is to use a rather simple drawing routine in every Rainbowduino which will be connected via a <a href="http://www.arduino.cc/en/Reference/Wire" target="_blank">two-wire interface</a> to a central <a href="http://www.arduino.cc/" target="_blank">Arduino</a> controller driven by some <a href="http://www.java.com" target="_blank">Java</a> code running on a small Intel Atom board. Main motivation for this approach is that I'm not too interested in programming micro controllers and rather prefer to write the actual code on a normal Linux computer using Java. It will also be much easier to integrate the whole installation into a local network, to control it with more than one frontend or to use the power of the <a href="http://www.oracle.com/technetwork/java/index-139508.html" target="_blank">Java Sound API</a> to interconnect the table with MIDI devices, etc. After searching the net a bit I've found beside mostly specialized code for specific Rainbowduino-based projects an very interesting project called <a href="http://pixelinvaders.ch/" target="_blank">PixelInvaders</a> that tries to control multiple output devices like Rainbowduino controllers or <a href="http://www.adafruit.com/datasheets/LPD6803.pdf" target="_blank">LPD6803</a>-based boards with one piece of software. The projects page also offers (prefabricated) 8x8 RGB LED panels called <a href="http://pixelinvaders.ch/?page_id=113" target="_blank">PixelInvaders Panels</a> that do use LPD6803 ICs to drive the LEDs. The program able to control those panels and all other supported output devices is called <a href="http://pixelinvaders.ch/?page_id=160" target="_blank">PixelController</a> and it follows the rough idea I had in mind to drive my eight LED arrays in a pretty similar way. Instead of reinventing the wheel once again I decided to give it a shot and to get a bit involved into this project myself. That's what the author has to say about his project:</p>
<blockquote><p><em>PixelInvaders is an open-source hardware project for artists, geeks and YOU! The PixelInvaders LED system consists of 3D RGB LED panels, that are capable of playing back real-time generated video animations or simple color changes. Multiple PixelInvader panels can be connected with each other to form a panel of any size. The panels are based on the latest LED technology - besides low heat dissipation and long life, a panel may illuminate an entire room and consume less energy than a standard lightbulb! PixelInvaders panels are perfectly used as effect lighting in clubs, bars, fairs, museums, on stage, in a lobby or in your living room. The control software "PixelController" generates the video animation in real time. This has the advantage of video animations that are synchronized to music. PixelController is released as open-source project on GitHub.</em></p></blockquote>
<p>Right now I'm busy trying to get my LED arrays to work with the PixelController software. Also the construction of the coffee table itself should be done any day so that I could start to bring everything together. Therefore stay tuned for another update of my 512 RGB LED coffee table project <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2011/09/07/soldering-512-rgb-leds-pure-fun-not/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Howto waste your spare time: Build a 512 RGB LED coffee table</title>
		<link>http://www.programmers-pain.de/2011/08/17/howto-waste-your-spare-time-build-a-512-rgb-led-coffee-table/</link>
		<comments>http://www.programmers-pain.de/2011/08/17/howto-waste-your-spare-time-build-a-512-rgb-led-coffee-table/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 20:21:30 +0000</pubDate>
		<dc:creator>Markus Lang</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[LED Coffee Table]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[coffee table]]></category>
		<category><![CDATA[Rainbowduino]]></category>
		<category><![CDATA[RGB LEDs]]></category>

		<guid isPermaLink="false">http://www.programmers-pain.de/?p=309</guid>
		<description><![CDATA["Wait.. What?! Are you serious?" "Yes, I am!" "Why do you want to do that?!" That's actually a very interesting question - and it's the usual response I do get if I explain what it's about those weird pictures I post on Facebook about prototyping loudspeakers or drilling 2,560 holes into plywood boards. Also people [...]]]></description>
				<content:encoded><![CDATA[<div id="attachment_358" class="wp-caption alignleft" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/LED-Coffee-Table-1.jpg" rel="lightbox[309]" title="512 RGB LED Coffee Table"><img class="size-medium wp-image-358" title="512 RGB LED Coffee Table" src="http://www.programmers-pain.de/wp-content/uploads/LED-Coffee-Table-1-300x137.jpg" alt="512 RGB LED Coffee Table" width="300" height="137" /></a><p class="wp-caption-text">512 RGB LED Coffee Table</p></div>
<p><em>"Wait.. What?! Are you serious?" "Yes, I am!" "Why do you want to do that?!"</em> That's actually a very interesting question - and it's the usual response I do get if I explain what it's about those weird pictures I post on Facebook about prototyping loudspeakers or drilling 2,560 holes into plywood boards. Also people don't quite understand why I've spent hours and hours with constructing a 3D model of a coffee table. This is a first attempt trying to explain myself why I'm spending my free time for this project since more than 6 months now.<span id="more-309"></span></p>
<p>During 2009 / 2010 several projects got popular in the Internet where guys used various micro-controllers to drive (RGB) LEDs installed in some sort of coffee table. A lot of those guys seems to be inspired by <a href="http://en.wikipedia.org/wiki/Daft_Punk" target="_blank">Daft Punk</a> since they did use the patterns shown by those <a href="http://www.youtube.com/watch?v=1lVsKcuUapA" target="_blank">tables</a> during their live performances. A German example of such a project is <a title="64 RGB-LED Couchtisch" href="http://www.freeduino.de/blogs/charlos/64-rgb-led-couchtisch" rel="bookmark">64 RGB-LED Couchtisch</a> that did use <a href="http://focus.ti.com/docs/prod/folders/print/tlc5940.html" target="_blank">TLC5940</a> ICs to drive 64 RGB LEDs from a micro-controller. Those TLC5940 are a quite easy way to drive multiple LEDs using a serial connection that can also be daisy chained. Also the <em>Arduino</em> platform does offer a <a href="http://www.arduino.cc/playground/Learning/TLC5940" target="_blank">library</a> for this IC. Sadly the number of TLC5940 that can be dasiy chained is limited by the time the micro-controller needs to update all ICs via the serial interface. For a 64 RGB LED installation it's a suitable solution since you 'only' need 12 TLC5940 ICs to drive those 64 RGB LEDs but I wouldn't use this approach for bigger setups. That was one of the main reasons for me to not following up the idea to build such a table on my own those days.</p>
<p>Than in late 2010 I've stumbled upon a piece of electronics offered by <a href="http://www.seeedstudio.com/">www.seeedstudio.com</a>: An <em><a href="http://www.arduino.cc/" target="_blank">Arduino</a></em> based board able to drive 64 RGB LEDs with all the comfort of the <em>Arduino</em> platform and without the need of any external wiring? I for sure had to get my hands on this controller called <em><a href="http://www.seeedstudio.com/depot/rainbowduino-led-driver-platform-atmega-328-p-371.html" target="_blank">Rainbowduino</a></em>. After reading the basic <a href="http://garden.seeedstudio.com/index.php?title=Rainbowduino_LED_driver_platform_-_Atmega_328#Resources" target="_blank">documentation</a> I was pretty confident that this piece of hardware is suitable for driving larger numbers of LED arrays since the <em>Arduino</em> platform allows you to easily interconnect multiple controllers - for example with a 2-wire serial protocol offered by the <a href="http://www.arduino.cc/en/Reference/Wire" target="_blank">Wire</a> library as one of the many available <em>Arduino</em> libraries. This sounds like the perfect playground for someone like me which isn't really interested in low-level micro-controller programming and is more excited about programming fancy animations and patterns in a high-level programming language. So while having some days off after Christmas 2010 it was unavoidable that I had to continue developing my idea of building a coffee table that uses RGB LEDs to illuminate it's glass top.</p>
<p>Since I wanted to go bigger than 64 RGB LEDs I thought about doubling the number of LEDs which lead to a 16x16 LED setup resulting in 256 LEDs in total organized in four 64 RGB LED groups each driven by a <em>Rainbowduino</em> controller. As I didn't wanted to build a quadratic table I added another set of 256 LEDs to it which end up in 512 LEDs in total driven by eight <em>Rainbowduinos</em>. Wow, that's quite something - and I didn't realized those days how huge the wiring effort will be for this setup. Based on that idea I've started constructing a coffee table around it. Each RGB LED should light up a 4x4cm area on the glass top which lead to the overall dimension of ~140x70cm. Since the needed electronics to get this table running also takes up a bit of space I decided to start constructing a 3D model of the coffee table. This model made it for sure easier to find potential problems I haven't thought about so far and it helped a lot to get an overall impression on how the table will look like.</p>
<div id="attachment_354" class="wp-caption alignright" style="width: 310px"><a href="http://www.programmers-pain.de/wp-content/uploads/LED-Coffee-Table-2.jpg" rel="lightbox[309]" title="512 RGB LED Coffee Table Internals"><img class="size-medium wp-image-354" title="512 RGB LED Coffee Table Internals" src="http://www.programmers-pain.de/wp-content/uploads/LED-Coffee-Table-2-300x194.jpg" alt="512 RGB LED Coffee Table Internals" width="300" height="194" /></a><p class="wp-caption-text">512 RGB LED Coffee Table Internals</p></div>
<p>So here's a quick tour through the latest model of my still to be build RGB LED coffee table: The first picture of this post gives you an overall impression on how the table will look like. After checking out a lot of wood board samples I decided to go with <a href="http://wikiflooring.org/North_American_Walnut" target="_blank">North American Walnut</a> boards for constructing the main table out of it. The table will be covered by a smoked glass which will have a satinized foil attached underneath it so that you can't see the tables internals. The foil also helps to diffuse the light emitted by the LEDs. The main table seats on two floor units that mainly will store all the needed electronics. So that the table wouldn't look like an upside down 'U' I've connected both floor units with a central bottom panel. The two square pillars that are barely visible in the picture between the bottom panel and the main table will contain loudspeakers so that you can play some music while the table shows your newest psychedelic music visualisation pattern. The second picture shows another shot of the table where you can see some of it's internals with the glass top partly removed. Below the smoked glass you'll see a grid constructed form 3mm <a href="http://en.wikipedia.org/wiki/Polystyrene" target="_blank">Polystyrene</a> panels which separates every RGB LED in it's own 4x4x15cm compartment. Below this grid eight ~35x35cm <a href="http://en.wikipedia.org/wiki/Medium-density_fiberboard" target="_blank">MDF</a> boards will be installed where every board will hold 64 RGB LEDs. Below those eight LED boards a technical compartment will contain all the needed wiring and micro-controllers to operate the table.</p>
<p>The current status is that the table is being constructed by my favourite local carpenter <a href="http://www.massivholz-moebel-schreinerei.de" target="_blank">www.massivholz-moebel-schreinerei.de</a> specialized on solid wood cabinetry. I didn't try to build the table on my own since I wouldn't be able to build it in a way that it doesn't fall apart at the end or that it doesn't look like the work of a bungler. The last months I was quite busy with soldering the LED boards and prototyping the other remaining circuits. I haven't really started yet to work on the needed software for the <em>Arduino</em> controllers - I only have some demonstration code to test the LEDs on each LED board and I have a prototype running that instructs a <em>Rainbowduino</em> micro-controller via the <em>Wire</em> library from another <em>Arduino</em> controller. So there's still a lot of work to do and I will continue to report about my plan to build a 512 RGB LED coffee table.</p>
<p>...and coming back to the question from the beginning: <em>"Why do you want to do that?!"</em> I still don't know yet.. but stay tuned for a potential answer in the near future <img src='http://www.programmers-pain.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.programmers-pain.de/2011/08/17/howto-waste-your-spare-time-build-a-512-rgb-led-coffee-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
