{"id":23,"date":"2012-04-21T13:07:14","date_gmt":"2012-04-21T18:07:14","guid":{"rendered":"http:\/\/monopoly.foxtailsoftware.com\/?p=23"},"modified":"2013-07-14T16:26:51","modified_gmt":"2013-07-14T21:26:51","slug":"control-freak","status":"publish","type":"post","link":"http:\/\/monopoly.furdaze.com\/?p=23","title":{"rendered":"Control Freak"},"content":{"rendered":"<p>Controlling one LED with a Netduino or other microcontroller is easy.\u00a0 Controlling two, three, four, likewise simple.\u00a0 How about controlling 143?\u00a0 That&#8217;s about how many I&#8217;ll need for this project, and that&#8217;s a lot more digital outputs than any microcontroller I know of can handle.\u00a0 So, what can we do?\u00a0 Obviously other projects have controlled large quantities of LEDs, so we need to figure out what they&#8217;re doing and whether it will help.<\/p>\n<p>After discussing the problem with coworkers, we discovered the joy of RGB LED cubes.\u00a0 If you haven&#8217;t seen them, use your Google skills and be impressed.\u00a0 The short version is that one microcontroller is managing a 6 x 6 x 6 (or whatever size) cube of LEDs, putting up all sorts of cool patterns.\u00a0 This is typically accomplished through a bit of electronic trickery, where the microcontroller is only actually controlling one slice of the LEDs at a time.\u00a0 Because humans experience a phenomenon known as &#8220;persistence of vision&#8221;, it appears that all the LEDs are lit simultaneously, even though only a fraction are actually on at any given time.\u00a0 The same trick was used back in the days of CRT monitors and TVs, where a single point of light was all that was actually illuminated at one time; your brain (and some slow-fading phosphors) did the rest.<\/p>\n<p>For this project, though, I wasn&#8217;t quite sure relying on persistence of vision would get me where I wanted to be.\u00a0 I&#8217;m trying to illuminate plastic with these LEDs, which means the overall light is getting dispersed and diminished.\u00a0 For that, I want to keep as much full power, full time brightness as possible, so I want every LED to be on full time if I want it on.\u00a0 Some further links and research turned up a class of ICs called LED drivers, which (as the name implies) drive LEDs.\u00a0 You tell the chip &#8220;turn on LEDs 1, 5, 8, and 12&#8221;, and it&#8217;ll keep those lit until you tell it otherwise.<\/p>\n<p>After looking around, I found the TLC5490 (and TLC 5491) chips seemed like good candidates with <a href=\"http:\/\/forums.netduino.com\/index.php?\/topic\/2689-tlc5940-pwm-driver\/\">existing Netduino support<\/a>.\u00a0 Each of them can handle 16 LEDs, and since I need to run 143 (remembering that the red, green, and blue channels are all independent) I sent out an order for 10 of them.\u00a0 (Nine would be okay, but who doesn&#8217;t order at least one spare?)\u00a0 A big benefit of the chip is that it supports built in Pulse Width Modulation (PWM), which lets you adjust the brightness of the LEDs.\u00a0 This is actually a technique that goes back to the persistence of vision thing, so that if I want the LED to be 50% brightness, the chip will handle having it be on 50% of the time and off 50% of the time.\u00a0 It&#8217;s not perfect, since the human eye only begins to detect dimming at a lower percentage, but it&#8217;ll work for what I want. (Also, you can daisy chain these guys together, which means I can run all nine or ten of them from one set of control lines. Sweet!)<\/p>\n<p>The chip also requires an external grayscale clock signal.\u00a0 I could run that from the microcontroller, but that seems like unnecessary work, so we&#8217;re going to try running it from an external chip.\u00a0 One annoying thing about the TLC5940\/1 is that it has a fundamental cycle of 4096 pulses on the grayscale clock.\u00a0 After it&#8217;s run through its cycle, you actually have to send the chip a blank command, release it, and let it start on a fresh count of 4096.\u00a0 To handle this, I went to our local electronics supplier, <a href=\"http:\/\/www.intertexelectronics.com\/\">Intertex<\/a>, and grabbed some 4060 binary counter chips.\u00a0 I found out later that they have a built-in oscillator circuit, so theoretically all I need to do is hook up a resistor and capacitor to it, and I should be able to generate my grayscale clock straight out of the chip.<\/p>\n<p>(Foreshadowing:\u00a0 That last bit didn&#8217;t work to my satisfaction.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Controlling one LED with a Netduino or other microcontroller is easy.\u00a0 Controlling two, three, four, likewise simple.\u00a0 How about controlling 143?\u00a0 That&#8217;s about how many I&#8217;ll need for this project, and that&#8217;s a lot more digital outputs than any microcontroller I know of can handle.\u00a0 So, what can we do?\u00a0 Obviously other projects have controlled [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-electronics"],"_links":{"self":[{"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=23"}],"version-history":[{"count":1,"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":142,"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions\/142"}],"wp:attachment":[{"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/monopoly.furdaze.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}