<?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>DIY DMCole</title>
	<atom:link href="http://www.dmcole.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dmcole.net</link>
	<description>Circuits, microcontrollers, LEDs, do-it-yourself style</description>
	<lastBuildDate>Sun, 04 Sep 2011 17:25:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sawyer Star — the saga continues</title>
		<link>http://www.dmcole.net/sawyer-star-the-saga-continues/</link>
		<comments>http://www.dmcole.net/sawyer-star-the-saga-continues/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 17:25:49 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[Musing]]></category>
		<category><![CDATA[Atmel]]></category>
		<category><![CDATA[ATTiny2313]]></category>
		<category><![CDATA[DMX-512]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[Sawyer]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=207</guid>
		<description><![CDATA[This was my last take on a circuit to drive the Sawyer Star, an 8&#215;8 LED array that I have spent more than three years adapting from work from more than a dozen people — before I gave up. This schematic is basically the one drawn by Mike Ardai (N1ist) for his Color Stick project. I changed [...]]]></description>
			<content:encoded><![CDATA[<p><strong>This</strong> was my last take on a circuit to drive the <a href="http://doityourselfchristmas.com/forums/showthread.php?t=10302" target="_blank">Sawyer Star</a>, an 8&#215;8 LED array that I have spent more than three years adapting from work from more than a dozen people — before I gave up.</p>
<div id="attachment_285" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2010/07/Sawyer-v2-d.jpg"><img class="size-medium wp-image-285" title="Sawyer-v2-d" src="http://www.dmcole.net/wp-content/uploads/2010/07/Sawyer-v2-d-300x232.jpg" alt="Sawyer schematic" width="300" height="232" /></a><p class="wp-caption-text">Sawyer v2 schematic drawn in DipTrace</p></div>
<p>This schematic is basically the one drawn by Mike Ardai (N1ist) for his <a href="http://www.doityourselfchristmas.com/forums/showthread.php?t=11644" target="_blank">Color Stick</a> project. I changed only three major things:</p>
<p>&nbsp;</p>
<ul>
<li>He uses surface-mount components; I have changed this to a through-hole board.</li>
<li>I&#8217;ve added an on-board power supply.</li>
<li>Mike’s application requires three TLC5916 constant-current drivers, while in my project only one is needed. But the Star needs the addition of a 74HC595 and UDN2981 to source to the LEDs.</li>
</ul>
<p><strong>Through-hole vs. SMT:</strong> While I&#8217;m hoping to get some SMT experience in the coming months, I plan to build the first versions of this thing as through-hole because that’s where my comfort level is. From my readings in the DIY Christmas lights communities, it’s clear I’m not the only one who remains uncomfortable regarding SMT. I may redesign the PCB at some later point as SMT.</p>
<p><strong>Power supply:</strong> I’ve been thinking about the power supply for the Sawyer Star for a long time. The originator, David Thorpe, uses a nine-volt battery, which he says runs his stars throughout the holiday season without needing a change; I think that with the RS485 chip and off-board PWM, a battery probably won’t hold up adequately.</p>
<p>After seeing the on-board power supplies of <a href="http://www.diylightanimation.com/">Robert Jordan</a> and <a href="http://shop.martinxmas.com/">Robert Martin</a>, I briefly considered bringing household current onto the board, but ultimately decided this would be a bad idea. I decided a so-called wall wart (a wall-plug transformer) would be a better idea.</p>
<p>My theory here is that many people have surplus wall warts hanging around the house, which would help reduce the cost of the completed circuit.</p>
<p>In my initial design of this circuit, I used a standard LM7805 linear regulator. The problem with this component is that it doesn’t adequately handle current above one amp. In testing, I found that the LM7805 got really, really hot without a heat-sink and even with one I was concerned about it’s ability to work properly.</p>
<p>I designed a second version of the power supply using an LM317-based circuits, which while typically used for adjustable supplies, also work in fixed-voltage situations (and handle 1½-amps of current). It’s a cheap part (50-to-60-cents) and only needs a couple of resistors and a diode to complement the design.</p>
<p>Unfortunately, the LM317 is, like the LM7805, a linear regulator and dissipates the difference between voltage-in and voltage-out as heat, so the switch from the 7805 to the 317 gains me nothing.</p>
<p>Based on work done by Robert Morgan, I stumbled across the LM2576, which is a switching regulator rather than a linear regulator. As a switching regulator, it lowers the voltage by literally turning it on and off (very fast), which is a technique called <a href="http://en.wikipedia.org/wiki/Pulse-width_modulation">pulse-width modulation</a> or PWM. This technique is also used as a method for dimming DC-based components such as LEDs (see below).</p>
<p>The LM2576 works up to three amps of current but it has a problem: it has a relatively high cost ($2) and requires an inductor, which is another uncheap part (40-cents). I&#8217;m awaiting these parts (hanging head in shame: ordered the wrong versions of both the regulator and the inductor previous) and will build them up on a breadboard to make sure they work.</p>
<p>I&#8217;ve also added a 40-cent bridge rectifier to the circuit so that virtually any wall wart – from 9-volt AC or DC to 24-volt AC or DC – can be used, as long as it is at least one amp. I am using a terminal block to bring in that input voltage rather than the coax connector typically used for a wall wart for two reasons: again, so that any scrounged wall wart can be used and because in many applications the wire will need to be longer than the standard length provided by manufacturers.</p>
<p><strong>Driver chips:</strong> The choice of the ATTiny2313 means a relatively low number of pins and a certain constraint on internal memory are available (conversely, those compromises are rewarded with a relatively low chip price: ~$2). By necessity, then, the LEDs need to be handled through driver chips. I use two of those:</p>
<ul>
<li>The Texas Instruments TLC5916 is an eight-bit constant current, PWM serial sink driver with eight ports. That means it can control 256 levels (the eight-bit part) of dimming (PWM), provides the LEDs with the specific current they need (constant current), are driven by a serial signal and control the negative side of eight LED circuits. A serial signal allows you to drive a relatively unlimited number of ports with only two pins on the ATTiny2313. Multiple serial drivers can be “cascaded” together by merely taking the output of the first driver and wiring it to the input of the second.</li>
<li>The commodity 74HC595 is a serial shift register chip that sinks eight ports. Like the TLC5916, it can drive eight LED circuits via a serial signal; unlike the TLC5916, it doesn’t have constant current or a PWM. An array of LEDs doesn’t need PWM or constant current on both the positive (rows) side of the circuit as well as the negative (columns) side – as long as they exist on one side or the other, they’re fine. But the 74HC595 is also like the TLC5916 in that it sinks – or handles the negative side of the – the output circuit. Two negative controls won’t work, so the 74HC595 has to be supplemented with another chip that takes the sink port and turn it into a source port – the UDN2981.</li>
</ul>
<p>One last thought about this circuit: I drew it in <a href="http://www.diptrace.com/">DipTrace</a>, which while not the easiest program I’ve ever used, did seem to become somewhat efficient by the time I finished. After I&#8217;ve built up this circuit on a breadboard, tested it and made sure it works, then I’ll move on the the application’s printed circuit board creation ability.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/sawyer-star-the-saga-continues/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>What’s up, doc?</title>
		<link>http://www.dmcole.net/what%e2%80%99s-up-doc/</link>
		<comments>http://www.dmcole.net/what%e2%80%99s-up-doc/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 14:59:49 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[Musing]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[David Thorpe]]></category>
		<category><![CDATA[DMX-512]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Open hardware]]></category>
		<category><![CDATA[Sawyer]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=298</guid>
		<description><![CDATA[Hmm. Sixteen months. My how time flies when you aren’t posting to a blog. Life happens and my involvement in designing things that flashed LEDs wavered with my inability to get a working prototype for the Sawyer Star, a 64-LED array/matrix that is to be driven by]]></description>
			<content:encoded><![CDATA[<p><strong>Hmm</strong>. Sixteen months. My how time flies when you aren’t posting to a blog.</p>
<p>Life happens and my involvement in designing things that flashed LEDs wavered with my inability to get a working prototype for the <a href="http://doityourselfchristmas.com/forums/showthread.php?t=10302" target="_blank">Sawyer Star</a>, a 64-LED array/matrix that is to be driven by <a href="<a href=&quot;http://doityourselfchristmas.com/forums/showthread.php?t=10302&quot; target=&quot;_blank&quot;>&#8221; target=&#8221;_blank&#8221;>DMX-512</a>. Last year in the late summer it became clear that the direction in which I was head would not work and I needed to focus on getting my Christmas lights display up and running, so I abandoned LEDs and microprocessors for a while and, by extension, this blog.</p>
<p>The first half of 2011 was consumed by my real job(s) and so didn&#8217;t really have time to devote to LEDs or microprocessors, but I did do a lot of thinking. And my first real thought was that while there is a substantial community behind both Christmas-lights development and behind the Atmel chipset, neither was particularly interested in my project.</p>
<p>The basic problem was that I didn’t have the software chops to write the code to do the array display.</p>
<p>I realized that I needed to find a bigger community, one where perchance I could entice someone with some real firmware smarts to help me.</p>
<p>I decided to move the project to <a href="http://www.arduino.cc/" target="_blank">Arduino</a>. I was more than familiar in a general sense with this Open Source microprocessor platform, based on the ATMega 8 family (168s and 328s of late) and it was clear there was a huge community behind it.</p>
<p>After a few months of fiddling around with a board I had bought, I decided to investigate the <a href="http://www.seeedstudio.com/depot/rainbowduino-led-driver-paltform-atmega-328-p371.html" target="_blank">Rainbowduino</a>, a spinoff of the Arduino that is designed specifically to handle large numbers of LEDs. I bought one of those boards and played with it off and on for a few months. I finally decided that it was too powerful (and too expensive) for my needs.</p>
<p>After a wide variety of false starts on circuit designs, I went back to my inspiration for the Sawyer Star — David Thorpe’s “<a href="http://www.unusualelectronics.co.uk/projects/star.php" target="_blank">Animated Christmas Star Project</a>” — and reviewed his design. It is dead simple: an <a href="http://ww1.microchip.com/downloads/en/devicedoc/39626e.pdf" target="_blank">18F2620</a> controller PIC from Microchip Technology, some resistors, a <a href="http://www.sparkfun.com/products/312" target="_blank">ULN2803</a> Darlington transistor array and a traditional five-volt power supply.</p>
<p>Why not, I wondered, just substitute an Arduino for the PIC?</p>
<p>Which got me back on track, got me back working with microprocessors and — ultimately — interested in this blog again.</p>
<p>I had moved this web site (along with a dozen others) over to an Apple <a href="http://www.everymac.com/systems/apple/mac_mini/stats/mac-mini-core-2-duo-2.0-early-2009-nvidia-specs.html" target="_blank">Mac Mini</a> last year (another reason focus was lost here) and during the transition lost the ability for permalinks to work the right way and also lost the ability to upload images. I fixed those problems this morning.</p>
<p>Further, there was a written but unpublished post here, which I will fix up shortly and get up for you to see just how far I got down the wrong road last year.</p>
<p>You&#8217;ll be seeing more stuff here soon, I’m sure.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/what%e2%80%99s-up-doc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts on schematics and software</title>
		<link>http://www.dmcole.net/thoughts-on-schematics-and-software/</link>
		<comments>http://www.dmcole.net/thoughts-on-schematics-and-software/#comments</comments>
		<pubDate>Sat, 15 May 2010 23:15:50 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[Musing]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[DipTrace]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[McCad]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=262</guid>
		<description><![CDATA[Last July I wrote about using Adobe Illustrator to design the schematics I publish here and why I prefer it (you can read that post here). In recent weeks I&#8217;ve come to realize two things: despite a great deal of effort on my part, I can&#8217;t really design printed circuit boards with Illustrator, and I [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Last</strong> July I wrote about using Adobe Illustrator to design the schematics I publish here and why I prefer it (you can read that post <a href="http://www.dmcole.net/index.php/its-an-led-matrix/" target="_blank">here</a>). In recent weeks I&rsquo;ve come to realize two things: despite a great deal of effort on my part, I can&rsquo;t really design printed circuit boards with Illustrator, and I had completely missed that I wasn&rsquo;t drawing <em>schematics</em>; I was drawing <em>wiring diagrams</em>.</p>
<p>Let us address the second point first: I had always wondered why, in a schematics application (such as Eagle), when you placed an integrated circuit, for example, the pins were not displayed in sequence. Pins 12-18 might be, for example, in the upper-left-hand corner, while pins 1, 2, 8 and 11 might be in the lower left-hand corner, with pins  3-7, 9 and 10, might be scattered to what seemed like the wind.</p>
<p>I have lost the actual link, but somewhere recently I read a forum posting where it was patiently explained to we non-electrical engineers, that the pins are grouped by internal logical function rather than arranged physically. Also, many integrated circuits are available in a variety of formats &ndash; through-hole and surface mount and sometimes in a variety of surface-mount formats as well, where the pin numbers are not the same.</p>
<p>So, what I have been drawing have been diagrams that make it easier for me to breadboard (or perf-board) circuits. While those are beneficial, rarely can they be used for anything else.</p>
<p>My other major gripe with schematics programs (aside from the lack of choices in the Macintosh world) was the difficulty I had in making the wires actually attach. I can&rsquo;t remember any specific applications, but I definitely remember that the large part of what turned me off to schematics applications was the actual difficulty I had in making wires connect.</p>
<p>Further, I had deluded myself into believing that I could create PCB files that could be sent to board manufacturing companies (called &ldquo;Gerber files&rdquo;) by using Illustrator. I had run across a <a href="http://swannman.wordpress.com/projects/pdf2gerb/" target="_blank">set of instructions</a> for converting Illustrator files to Gerber files and believed they would work.</p>
<p>And, after extensive experimentation, I found that they did &#8230; almost. The one part that doesn&rsquo;t work is the ability to put text onto the silkscreen layer. If I were building PCBs exclusively for myself, that wouldn&rsquo;t be a problem, but I have envisioned that the DMX/LED matrix circuit I hope to one day design will be something that I can give back to the community, and for those types of boards, you really need to indicate component positions with silkscreened text.</p>
<p>So, that was out.</p>
<p>A few weeks back I stumbled across a conversation on a forum where folks were talking about a schematics and PCB application called <a href="http://www.diptrace.com/" target="_blank">DipTrace</a>. Most of the comments were positive; there were plenty of people who said it was easy to use; it had a free version for non-profit use that topped out at 300 pins (about twice what I&#8217;d need) and it created Gerber files.</p>
<p>The only downside was that it ran under Windows (patooie!), not on the Mac. I do have an old Compaq sitting here that I use to test web sites out on and to run the Christmas lights, so I thought I could actually break down and try to use DipTrace on it.</p>
<p>I was able to go through the tutorial in about an hour and had both a schematic and a Gerber file (albeit of only seven components, but nonetheless &#8230;) to show for it.</p>
<p>I&rsquo;ve recently begun work on a new matrix circuit and rather than draw it in Illustrator, I decided to use DipTrace. I&rsquo;ll post when I have something I feel comfortable showing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/thoughts-on-schematics-and-software/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More on the matrix/array</title>
		<link>http://www.dmcole.net/more-on-the-matrixarray/</link>
		<comments>http://www.dmcole.net/more-on-the-matrixarray/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 22:23:15 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[Musing]]></category>
		<category><![CDATA[Atmel]]></category>
		<category><![CDATA[DMX-512]]></category>
		<category><![CDATA[LED]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=248</guid>
		<description><![CDATA[It&#8217;s been a few months since I last posted here &#8230; I don&#8217;t think there are any constant visitors who&#8217;ve been bummed out about the lack of activity, but I apologize nonetheless. Since we last spoke I threw the LED matrix project out to the Do It Yourself Christmas community to see if I could [...]]]></description>
			<content:encoded><![CDATA[<p><strong>It&rsquo;s</strong> been a few months since I last posted here &#8230; I don&rsquo;t think there are any constant visitors who&rsquo;ve been bummed out about the lack of activity, but I apologize nonetheless.</p>
<p>Since we last spoke I threw the LED matrix project out to the <a href="http://www.doityourselfchristmas.com/forums/" target="_blank">Do It Yourself Christmas</a> community to see if I could get some others interested and willing to help.  I got a couple of bites and have spent the last few months working with them, trying to further my goal of building an LED star that has 60 lamps, three colors and can be driven by DMX-512. You can see the <a href="http://doityourselfchristmas.com/forums/showthread.php?t=10302" target="_blank">discussions</a>.</p>
<p>The current circuit is based on the Atmel ATTiny2313, two 74HC595 shift registers and a ULN2803 Darlington array to handle sink current (plus an RS485 chip to handle DMX signals and associated resistors and capacitors).</p>
<p>Unfortunately, I haven&rsquo;t been able to make as much progress as I would have liked. I have a breadboarded circuit that works, but unfortunately, it works backwards. That is, when the DMX application sends a signal to an LED to light, it is dark; when there is a DMX signal but sent to have the LED dark, it lights.</p>
<p>Big brains in the DIYC community haven&rsquo;t been able to figure this one out, so for now I remain mired in my own ignorance.</p>
<p>That&rsquo;s all I know right now. Stay tuned for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/more-on-the-matrixarray/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Christmas lights</title>
		<link>http://www.dmcole.net/christmas-lights/</link>
		<comments>http://www.dmcole.net/christmas-lights/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 00:33:00 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[Musing]]></category>
		<category><![CDATA[DMX-512]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=201</guid>
		<description><![CDATA[For those of the opinion that I fell off the face of the earth, fear not: I merely got involved in non-electronics, such as dealing with a kitchen remodel and unwell pets. That said, I also focused a bit in recent months on my Christmas lights show and have documented there a few of the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>For</strong> those of the opinion that I fell off the face of the earth, fear not: I merely got involved in non-electronics, such as dealing with a kitchen remodel and unwell pets.</p>
<p>That said, I also focused a bit in recent months on my <a href="http://www.pacificalights.info/">Christmas lights show</a> and have documented there a few of the DIY efforts not previously chronicled.</p>
<p>Take a gander at:</p>
<ul>
<li><a href="http://www.pacificalights.info/index.php/tech/17-ssr4.html" target="_new">The Lynx DMX SSR4 controller</a></li>
<li><a href="http://www.pacificalights.info/index.php/tech/21-Lynx-MR16.html" target="_new">The Lynx MR16 controller</a></li>
<li><a href="http://www.pacificalights.info/index.php/tech/19-electronic-sign.html" target="_new">The LED-Triks electronic sign</a></li>
</ul>
<p>Have a happy new year and expect to hear more from the workshop later this winter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/christmas-lights/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s an LED matrix!</title>
		<link>http://www.dmcole.net/its-an-led-matrix/</link>
		<comments>http://www.dmcole.net/its-an-led-matrix/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 01:55:49 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Atmel]]></category>
		<category><![CDATA[ATTiny13]]></category>
		<category><![CDATA[DMX-512]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[McCad]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=172</guid>
		<description><![CDATA[So, I&#8217;m going to use Henne&#8217;s transceiver for an LED matrix. You coulda probably guessed, if you&#8217;d thought about it for a minute or three. Anyway, I fell back on my &#8211; ahem &#8211; process: first, draw the circuit in Adobe Illustrator and then build it on a breadboard. (I have been asked in the [...]]]></description>
			<content:encoded><![CDATA[<p><b>So,</b> I&rsquo;m going to use Henne&rsquo;s <a href="index.php/hennes-dmx-transceiver/" target="_new">transceiver</a> for an LED matrix. You coulda probably guessed, if you&rsquo;d thought about it for a minute or three.</p>
<div id="attachment_191" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/07/Hendrik-DMX-LED-matrix-schematic-v2.pdf" target="_new"><img src="http://www.dmcole.net/wp-content/uploads/2009/07/Hendrik-DMX-LED-mtrx-schem-300x195.jpg" alt="Henne&rsquo;s DMX LED matrix schematic (click to download PDF)." title="Hendrik-DMX-LED-mtrx-schem" width="300" height="195" class="size-medium wp-image-191" /></a><p class="wp-caption-text">Henne&rsquo;s DMX LED matrix schematic (click to download PDF).</p></div>
<p>Anyway, I fell back on my &ndash; ahem &ndash; <em>process</em>: first, draw the circuit in <a href="http://www.adobe.com/products/illustrator/" target="_new">Adobe Illustrator</a> and then build it on a breadboard.</p>
<p>(I have been asked in the past why I use Illustrator and not a regular schematic-drawing application such as <a href="http://www.cadsoftusa.com/" target="_new">Eagle</a> or <a href="http://www.mccad.com/" target="_new">McCad</a>. My first line of defense is the same as when I&#8217;m asked why I use <a href="http://www.adobe.com/products/indesign/" target="_new">InDesign</a> to make slides rather than use the ubiquitous <a href="http://www.microsoft.com/mac/products/PowerPoint2008/default.mspx#/themes_templates/" target="_new">Microsoft PowerPoint</a>: I use the Adobe Creative Suite on a daily basis and am something of an expert with its components. I can create a schematic [or slideshow] faster with the Adobe product than with anything else. Secondarily, I think I get a much better, graphically pleasing, schematic from Illustrator.)</p>
<p>So, there are some changes in this version of the schematic that aren&rsquo;t electronically or function-driven: instead of the 10-position DIP switch, I have substituted a 2&#215;10 header. This will save only a few cents (around 50) on the bill of materials, but will save some space on the board as well.</p>
<p>These switches signal to the ATMega8515 the DMX start channel to use. They&rsquo;re set infrequently (probably only once a holiday season, maybe less) and the user (probably someone as unsophisticated as me) needs only to shunt the correct pairs depending upon the channel. How do you calculate the DMX start address? Just Google &ldquo;<a href="http://www.google.com/search?q=dmx+dip+switch+calculator" target="_new">DMX DIP switch calculator</a>&rdquo;.</p>
<p>Also, I eliminated a couple of superfluous components, including the potentiometer, its associated resistor and the J3, J4 and J5 headers (which are now direct connections to the shift register (74HC164).</p>
<p>The additional set of goodies that makes this an LED matrix circuit are the <a href="http://www.allaboutcircuits.com/vol_4/chpt_12/1.html" target="_new">shift register</a>, serial-in, parallel-out chip (U3 &ndash; the 74HC164), which in turn drives the <a href="http://focus.ti.com/docs/prod/folders/print/uln2803a.html" target="_new">sink chip</a> (U4 &ndash; the ULN2803A). The shift-register gets us six extra wires (taking the two serial ouput lines and turning them into eight), while the sink-chip (a Darlington transistor array) allows the current load to increase to 500mA per line.</p>
<p>Otherwise, this is the exact same circuit as the <a href="index.php/hennes-dmx-transceiver/" target="_new">transceiver</a>.</p>
<p>Because I&rsquo;m overtly ambitious, I&rsquo;m going to redraw this circuit one more time &ndash; in McCad PCB-ST, so that I can make <a href="http://en.wikipedia.org/wiki/Gerber_File" target="_new">Gerber files</a> and then, onward, to a printed circuit board.</p>
<p>Woo-hoo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/its-an-led-matrix/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Henne&#8217;s DMX transceiver</title>
		<link>http://www.dmcole.net/hennes-dmx-transceiver/</link>
		<comments>http://www.dmcole.net/hennes-dmx-transceiver/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 01:56:11 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[ATMega8515]]></category>
		<category><![CDATA[Atmel]]></category>
		<category><![CDATA[AVRDude]]></category>
		<category><![CDATA[AVRFuses]]></category>
		<category><![CDATA[DMX-512]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=151</guid>
		<description><![CDATA[If youâ€™ve visited my automated Christmas lights page, the letters DMX wonâ€™t be unfamiliar to you. For those too lazy to click, itâ€™s an electronic lighting protocol. Two wire. Used extensively in stage shows. And, in recent months, adopted by the DIY Christmas lighting community. So, I&#8217;m working on an idea (Iâ€™ll post more when [...]]]></description>
			<content:encoded><![CDATA[<p><strong>If</strong> youâ€™ve visited my automated Christmas lights <a href="http://www.pacificalights.info/" target="_new">page</a>, the letters <a href="http://en.wikipedia.org/wiki/DMX512-A" target="_new">DMX</a> wonâ€™t be unfamiliar to you. For those too lazy to click, itâ€™s an electronic lighting protocol. Two wire. Used extensively in stage shows. And, in recent months, adopted by the DIY Christmas lighting community.</p>
<div id="attachment_166" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/06/Hendrik-DMX-transceiver-schematic.pdf" target="_new"><img class="size-medium wp-image-166" title="Hendrik-DMX-xceiver-schem" src="http://www.dmcole.net/wp-content/uploads/2009/06/Hendrik-DMX-xceiver-schem-300x184.jpg" alt="Henneâ€™s DMX transceiver schematic (click to download PDF)." width="300" height="184" /></a><p class="wp-caption-text">Henneâ€™s DMX transceiver schematic (click to download PDF).</p></div>
<p>So, I&#8217;m working on an idea (Iâ€™ll post more when I get closer to the finish) that I want to add to my Christmas lights show, and it therefore needs to talk DMX. Numerous previous postings here will tell you that would mean I&#8217;d need to do this on an Atmel chip. Though there are a lot of DMX projects done on Microchips (PICs), fewer have been done on Atmels. And pretty much everyone who has done DMX on the Atmel has based some or all of their work on that of <a href="http://www.hoelscher-hi.de/hendrik/english/ressources.htm" target="_new">Hendrik HÃ¶lscher</a>.</p>
<p>Fortunately for those monolinguists among us, Hendrik â€“ who goes by â€œHenneâ€ â€“ writes in both German and English. He&#8217;s also moderately active on one of the Christmas lights forums.</p>
<p>My initial plans were to write my own code to get my idea off the ground; a few months(!) of fiddling around and I was never even able to pull off my main effect, no less receiving DMX.</p>
<p>During that fiddling, I ran across a web site in Germany that sold a bare printed circuit board for Henne&#8217;s basic DMX transceiver. It took PayPal, so I bought a couple of boards. And the next time I dropped by <a href="http://www.jameco.com/" target="_new">Jameco</a>, I took along the bill of materials for the transceiver and bought the parts.</p>
<p>Then life intervened. It wasn&#8217;t until earlier this month that I got back on track on this project, which started out with a redrawing of Henneâ€™s schematic. I then wanted to build the circuit on a breadboard. The design requires an external crystal and while I knew of the potential to â€œbrickâ€ the 8515, I didnâ€™t think said bricking would be quite so easy.</p>
<p>So easy, in fact, that I bricked two.</p>
<p>The problem (for me, anyway), was a lack of understanding of terminology. While I&#8217;d started out using <a href="http://www.bsdhome.com/avrdude/" target="_new">AVRDude</a> on the command line, I somewhere along the line stumbled across <a href="http://www.vonnieda.org/software/avrfuses/" target="_new">AVRFuses</a>, a Mac application that puts a graphical user interface on top of AVRDude.</p>
<p>Anway, AVRFuses uses the same terminology as <a href="http://www.engbedded.com/fusecalc/" target="_new">FuseCalc</a> and I find (found) both of them to be opaque. Suffice it to say, the 8MHz crystal used in Henneâ€™s design is designated as &#8220;Ext. Crystal/Resonator Medium Freq.; Start-up time: 16K CK + 4 ms; [CSEL=1101 SUT=10].&#8221;</p>
<p>So, another trip to Jameco and this new-found knowledge (thanks <a href="http://www.ladyada.net/forums/viewtopic.php?f=24&amp;t=11596" target="_new">Limor</a>) and I had a functioning 8515.</p>
<p>But not a functioning circuit. The version displayed here clearly shows a ground on Pin 5 of U2, the 75176B, as well as five-volt power to Pin 8. Well, apparently some schematic-drawing programs don&#8217;t indicate such niceties and the drawing I was basing my work off of didnâ€™t. So I sat here for almost two days, banging my head against the wall trying to figure out why the breadboarded circuit didnâ€™t work. I wonder if I would have ever figured it out without help.</p>
<p>As Henne says, this is a simple circuit, with virtually all the heavy lifting happening in the software of the 8515. Suffice to say, U2 (the 75176B), an <a href="http://en.wikipedia.org/wiki/EIA-485" target="_new">RS485</a> transceiver, receives the DMX signal and turns it into something the UART on the 8515 can read. The 8515, in turn, processes the signal and outputs it onto pins 32-39 (unless one of the many options is chosen, in which case signals can come out of the J4 Spare port as well).</p>
<p>Henne doesn&rsquo;t explain why he chose the 8515 &ndash; it&rsquo;s a big chip, taking up quite a bit of board real estate, and it&rsquo;s not inexpensive (I&rsquo;m too lazy to look it up, but I&rsquo;m pretty sure that last winter when I bought the first set of these chips at Jameco, they were $4.50+/-; last week&rsquo;s purchase they had gone down to $3.50. I just looked them up and at Mouser and Digi-Key, they&rsquo;re $5.27). But for an eight-channel project (potentially 16-channel) that has DIP-switch control of the DMX start channel (another 10 pins), this really can&rsquo;t be done in less than a 40-pin chip.</p>
<p>(Oh, and a note on the licensing: I had included my standard Creative Commons, Noncommercial Share-Alike license on the schematic and Henne asked that I remove it. In deference to the original author, I did. None of his schematics have licenses on them and he wrote, &#8220;You cannot license the schematic under cc since its based on my schematic / hw where unauthorized commercial production is prohibited. [This is necessary if some companies produce the boards in larger quantities...] I don&#8217;t want anyone to get into trouble&#8230;&#8221; Now you know what I know.)</p>
<p>Using Henne&rsquo;s &#8220;board.hex&#8221; testing software, the red LED flashes a steady beat once power is applied; turning on DIP 2 (or, as in my case, shorting Pin 22 to ground), the green LED should light if the crystal fuses are set correctly.</p>
<p>Anyway, I finally got the circuit working on Saturday. Now, to add a couple of sub-circuits and get this idea â€“ which Iâ€™ve been working since December 2007 â€“ afloat.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/hennes-dmx-transceiver/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Digital candle — Version 2</title>
		<link>http://www.dmcole.net/digital-candle-%e2%80%93-version-2/</link>
		<comments>http://www.dmcole.net/digital-candle-%e2%80%93-version-2/#comments</comments>
		<pubDate>Thu, 07 May 2009 23:22:29 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[ATTiny13]]></category>
		<category><![CDATA[Digital candle]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Fading]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[Light-emitting diodes]]></category>
		<category><![CDATA[Semiconductor devices]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=95</guid>
		<description><![CDATA[As can be seen from the dates between postings, I took an awful lot of time with this project &#8211; and yet, I never really accomplished my goal, which was to have five LEDs independently fading in and out like a candle, driven by an Atmel ATTiny13. I spent a lot of time with some [...]]]></description>
			<content:encoded><![CDATA[<p><strong>As</strong> can be seen from the dates between postings, I took an awful lot of time with this project &ndash; and yet, I never really accomplished my goal, which was to have five LEDs independently fading in and out like a candle, driven by an Atmel ATTiny13.<br />
<div id="attachment_122" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/05/digitalcandle-schematic-v2a.pdf" target="_new"><img src="http://www.dmcole.net/wp-content/uploads/2009/05/digitalcandle-schematic-v2a-300x199.jpg" alt="ATTiny13 drives 5 LEDs; programming/test circuit (click to download PDF)" title="digitalcandle-schematic-v2a" width="300" height="199" class="size-medium wp-image-122" border="0" /></a><p class="wp-caption-text">ATTiny13 drives 5 LEDs; programming/test circuit (click to download PDF)</p></div></p>
<p>I spent a lot of time with some code that had been created for a Microchip PIC12F675 but it turned out that it was merely random on-off, not fading the way a flickering candle operates. I then spent some time with a second code set, also for a PIC12F675, that did fade nicely, but which had a problem with brightness that I was never able to rectify (it is a duty-cycle issue, I know; I just don&rsquo;t know how to fix it).</p>
<p>But that <a href="http://www.geocities.com/westfw/electronics/flames.c" target="_new">second code set</a> did point me in the direction of how to control individual LEDs while within a loop, using bitwise manipulation.</p>
<p>I decided on Sunday that I had a few hours to work on this project and I wanted it finally finished. While the result is not exactly what I wanted, it will suffice.</p>
<p>What I&rsquo;ve built is a group of four LEDs that fade in and out in an inverse manner. While LED1 fades in, LED2 fades out and LED1 and LED3 work in synch, as do LED2 and LED4. So, when LED1 and LED3 fade out, LED2 and LED4 fade in and when LED2 and LED4 fade out, LED1 and LED3 fade in. It is random enough &ndash; and fast enough &ndash; that you can&rsquo;t really tell they&rsquo;re working inversely.<br />
<div id="attachment_123" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/05/digitalcandle-schematic-v2b.pdf" target="_new"><img src="http://www.dmcole.net/wp-content/uploads/2009/05/digitalcandle-schematic-v2b-300x257.jpg" alt="ATTiny13 drives 5 LEDs; production circuit (click to download PDF)" title="digitalcandle-schematic-v2b" width="300" height="257" class="size-medium wp-image-123"  border="0" /></a><p class="wp-caption-text">ATTiny13 drives 5 LEDs; production circuit (click to download PDF)</p></div></p>
<p>The fifth LED staying on all the time helps by keeping the candle from ever going completely dark. This effect would work just as well with only three LEDs, but the two extras throw off more light.</p>
<p>The finished code is at the end of this article.</p>
<p>In the prototype I&rsquo;m using 10mm warm white LEDs that are rated at 85,000 millicandles; they have a 3.3-volt forward voltage, so I&rsquo;m using 100-ohm, one-eighth watt resisters between the five pins of the microcontroller and the positive leg of the LED.</p>
<p>I have provided two circuit schematics; one is for a circuit to program and test the ATTiny13; the other is an operational circuit. I will be using this candle on my backyard railroad; you can see how I built the other flickering lights on the railroad <a href="http://www.45mm.com/lighting/flickering-big.html" target="_new">here</a> and you can assume I&rsquo;ll use a similar plastic-canistter/wood/glue/screws building technique for this.</p>
<p>These schematics don&rsquo;t detail the circuit that takes the raw Malibu 12-volt AC of my layout and turns it into filtered, five-volt DC for the microprocessor and LEDS; you can rest assured I built something eerily similar to this <a href="http://www.45mm.com/lighting/5v-DC.html" target="_new">circuit</a>.</p>
<p>I will build both circuits on a piece of RS <a href="http://www.radioshack.com/product/index.jsp?productId=2104052" target="_new">project board</a>, though I plan to attach the LEDs with one-inch long wire in order to be able to point them in various directions.</p>
<p>I&rsquo;ve provided a video of the LEDs, one scene where they&rsquo;re running on the breadboard bare and a second with a plastic canister, to give you an idea of how they will look on the layout.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/PUSlyH5_0o4&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/PUSlyH5_0o4&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p95code2'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p952"><td class="code" id="p95code2"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
* Digital candle V2
* -----------
* Use random numbers to emulate a flickering candle on five LEDs without hardware PWM 
* 
* David M. Cole &lt;dmcole at dmcole dot net&gt;
* License: 2009 Creative Commons Attribution-Noncommercial-Share Alike 3.0 U.S.
* Target: ATTiny13
* Compiler: AVR-GCC
*/</span>
&nbsp;
<span style="color: #339933;">#include &lt;avr/io.h&gt;											// Defines pins, po</span>
<span style="color: #339933;">#define led1_on PORTB |= 1 &lt;&lt; 0										// PortB0 = on</span>
<span style="color: #339933;">#define led1_off PORTB &amp;= ~(1 &lt;&lt; 0)									// PortB0 = off</span>
<span style="color: #339933;">#define led2_on PORTB |= 1 &lt;&lt; 1										// PortB1 = on</span>
<span style="color: #339933;">#define led2_off PORTB &amp;= ~(1 &lt;&lt; 1)									// PortB1 = off</span>
<span style="color: #339933;">#define led3_on PORTB |= 1 &lt;&lt; 2										// PortB2 = on</span>
<span style="color: #339933;">#define led3_off PORTB &amp;= ~(1 &lt;&lt; 2)									// PortB2 = off</span>
<span style="color: #339933;">#define led4_on PORTB |= 1 &lt;&lt; 3										// PortB3 = on</span>
<span style="color: #339933;">#define led4_off PORTB &amp;= ~(1 &lt;&lt; 3)									// PortB3 = off</span>
<span style="color: #339933;">#define led5_on PORTB |= 1 &lt;&lt; 4										// PortB4 = on</span>
<span style="color: #339933;">#define led5_off PORTB &amp;= ~(1 &lt;&lt; 4)									// PortB4 = off</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//	Declare variables</span>
<span style="color: #666666; font-style: italic;">//	==============================================</span>
	uint8_t y<span style="color: #339933;">,</span> z<span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//	==============================================</span>
&nbsp;
	<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			DDRB <span style="color: #339933;">=</span> <span style="color: #208080;">0b11111111</span><span style="color: #339933;">;</span>								<span style="color: #666666; font-style: italic;">// PortB all outputs</span>
 			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span>										<span style="color: #666666; font-style: italic;">// loop forever</span>
 				<span style="color: #009900;">&#123;</span>
					y <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						<span style="color: #666666; font-style: italic;">// bottom of first loop</span>
					z <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">63</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						<span style="color: #666666; font-style: italic;">// top of first loop</span>
					<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> z<span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>						<span style="color: #666666; font-style: italic;">// first fade loop</span>
						<span style="color: #009900;">&#123;</span> 
							led1_off<span style="color: #339933;">;</span>
							led2_on<span style="color: #339933;">;</span>
							led3_off<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// set up for first fade</span>
							led4_on<span style="color: #339933;">;</span>
							led5_on<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// led5 is always on</span>
							<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
								<span style="color: #009900;">&#123;</span>
									<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> i<span style="color: #009900;">&#41;</span>
										<span style="color: #009900;">&#123;</span>
											led1_on<span style="color: #339933;">;</span>
											led2_off<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// turn off lamps that were on</span>
											led3_on<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// turn on lamps that were off</span>
											led4_off<span style="color: #339933;">;</span>
											led5_on<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// led5 is always on</span>
										<span style="color: #009900;">&#125;</span>
								<span style="color: #009900;">&#125;</span>
							<span style="color: #009900;">&#125;</span>						<span style="color: #666666; font-style: italic;">// end first fade loop </span>
					y <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						<span style="color: #666666; font-style: italic;">// bottom of second looop</span>
					z <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">63</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>						<span style="color: #666666; font-style: italic;">// top of second looop</span>
					<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> y<span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> z<span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>						<span style="color: #666666; font-style: italic;">// second fade loop</span>
						<span style="color: #009900;">&#123;</span>
							led1_on<span style="color: #339933;">;</span>
							led2_off<span style="color: #339933;">;</span>
							led3_on<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// note lamps swap state</span>
							led4_off<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// from first loop</span>
							led5_on<span style="color: #339933;">;</span>					<span style="color: #666666; font-style: italic;">// led5 is always on</span>
							<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
								<span style="color: #009900;">&#123;</span>
									<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> i<span style="color: #009900;">&#41;</span>
										<span style="color: #009900;">&#123;</span>
											led1_off<span style="color: #339933;">;</span>
											led2_on<span style="color: #339933;">;</span>
											led3_off<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// and again, change state</span>
											led4_on<span style="color: #339933;">;</span>
											led5_on<span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// led5 is always on</span>
										<span style="color: #009900;">&#125;</span>
								<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>							<span style="color: #666666; font-style: italic;">// end second fade loop</span>
				<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/digital-candle-%e2%80%93-version-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Digital candle — Version 1</title>
		<link>http://www.dmcole.net/digital-candle-%e2%80%94-version-1/</link>
		<comments>http://www.dmcole.net/digital-candle-%e2%80%94-version-1/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 21:03:17 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[ATTiny13]]></category>
		<category><![CDATA[Digital candle]]></category>
		<category><![CDATA[Electronic engineering]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[Light-emitting diode]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=57</guid>
		<description><![CDATA[If youâ€™ve visited my web site on backyard railroad illumination, you know about my fixation with creating light that flickers as though it were a fire (either from candle or a fireplace). The first solution to that problem was to modify LED tea candles â€” readily available at crafts stores and even Walgreens â€” so [...]]]></description>
			<content:encoded><![CDATA[<p>If youâ€™ve visited my web site on <a href="http://www.45mm.com/lighting/" target="_new">backyard railroad illumination</a>, you know about my fixation with creating light that flickers as though it were a fire (either from candle or a fireplace).</p>
<div id="attachment_76" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/03/digitalcandle-schematic-v1.pdf" target="_new"><img src="http://www.dmcole.net/wp-content/uploads/2009/03/digitalcandle-schematic-v1-300x197.jpg" alt="Schematic of circuit to fade, flicker single LED (click to download PDF)" title="digitalcandle-schematic-v1" width="300" height="197" class="size-medium wp-image-76" border="0" /></a><p class="wp-caption-text">Schematic of circuit to fade, flicker single LED (click to download PDF)</p></div>
<p>The first solution to that problem was to modify LED tea candles â€” readily available at crafts stores and even Walgreens â€” so that they would work off of standard 12-volt garden lighting (aka: <a href="http://www.malibulights.com/index.php?action=subcategory&amp;pid=0&amp;did=1&amp;sid=9" target="_new">Malibu lighting</a>).</p>
<p>The dirty little secret of that method is that all the tea candles flicker at the same time. I&#8217;m not quite sure why this is so â€” perhaps the proprietary microcontroller used in those devices is time based and since they all start at the same time, they seem to work in synch? In any event, it does make looking at all the &#8220;fires&#8221; on my layout pulse at the same time.</p>
<p>So, in the back of my mind, I knew I wanted something besides tea lights to make flickering light on the layout. I kept looking around the net, and in January a reader of the backyard illumination site pointed me to an <a href="http://www.instructables.com/id/S2LGADIFN82WUKQ/" target="_new">Instructables</a> that showed a circuit to increase the current that could pass through a tea light, allowing up to four LEDs to be driven in the circuit.</p>
<p>The Instructables site provides a &#8220;related&#8221; window in the right-rail and along with the increased current circuit there were a couple of other &#8220;LED candles&#8221; that caught my fancy.</p>
<p>One, which by March seems to have been removed from the site, used the concept of the <a href="http://en.wikipedia.org/wiki/Linear_feedback_shift_register" target="_new">linear feedback shift register</a> to control the flickering. Unfortunately, it was written for a Pic12F675, not an AVR (reading the datasheets, I decided that an ATTiny13 would be the equivalent controller).</p>
<p>What I liked about this idea was that it utilized seven of the eight pins of the microcontroller â€” it drove five LEDs (which is five of the pins and one each for power and ground). There were other circuits on the â€™Net and Instructables that used just one LED, but none used all five (this was in January).</p>
<p>So, I bought a handful of ATTiny13s at <a href="http://www.jameco.com/" target="_new">Jameco</a> and set about to build the circuit and convert the code.</p>
<p>I didn&#8217;t really get anywhere. So, I started writing my own code. For the first shot, I decided to control just a single LED (crawl before walking).</p>
<p>The circuit illustrated above and the code below do that. What&#8217;s different (it turns out) from what I&#8217;ve done here and what others around the â€™Net have done is that I&#8217;m fading the LED from dark to bright in a random manner.</p>
<p>I do this without using hardware <a href="http://en.wikipedia.org/wiki/Pulse-width_modulation" target="_new">pulse width modulation</a> (PWM); I chose to skip hardware PWM because of the way the ATTiny13 is configured: the PWM pins are also the pins that are used for programming. To use hardware PWM I would have had to program the chip, power down the circuit, connect the LEDs, run the program and to debug, do the steps in the opposite order.</p>
<p>Easier to write my own PWM code, I thought <img src='http://www.dmcole.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  &#8230;</p>
<p>The code makes (to my eye, at least) a more realistic candlelight flicker. But, it is just one LED and while that might be enough for somebody else, I&#8217;ve got four more pins to use in this project and I&#8217;m going to figure out how to use them.</p>
<p>I&#8217;m working with another developer over at Ladyada forums and I hope to have a five-LED version of fading code work on an ATTiny13 shortly.</p>
<p>For now, though, here&#8217;s Version 1, the single LED fading digital candle:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p57code4'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p574"><td class="code" id="p57code4"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
* DigitalCandle -- Version 1
* -----------
* Use random numbers to emulate a flickering candle on a single LED without hardware PWM 
* 
* David M. Cole &lt;cole@dmcole.net&gt;
* License: 2009 Creative Commons Attribution-Noncommercial-Share Alike 3.0 U.S.
* Target: ATTiny13
* Compiler: AVR-GCC
*/</span>
&nbsp;
<span style="color: #339933;">#include &lt;avr/io.h&gt;														// Defines pins, po</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//	Declare variables</span>
<span style="color: #666666; font-style: italic;">//	==============================================</span>
	uint8_t x<span style="color: #339933;">,</span> y<span style="color: #339933;">,</span> z<span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//	==============================================</span>
&nbsp;
	<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			DDRB <span style="color: #339933;">=</span> <span style="color: #208080;">0b11111111</span><span style="color: #339933;">;</span>										<span style="color: #666666; font-style: italic;">// PortB all outputs</span>
 			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span>												<span style="color: #666666; font-style: italic;">// loop forever</span>
 				<span style="color: #009900;">&#123;</span>
		 			x <span style="color: #339933;">=</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span>
					y <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					z <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">63</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> z<span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>								<span style="color: #666666; font-style: italic;">// the fading in loop</span>
						<span style="color: #009900;">&#123;</span> 
							PORTB <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> x<span style="color: #339933;">;</span> 						<span style="color: #666666; font-style: italic;">// light on </span>
							<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
								<span style="color: #009900;">&#123;</span>
									<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> i<span style="color: #009900;">&#41;</span>
										<span style="color: #009900;">&#123;</span>
											PORTB <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">&lt;&lt;</span> x<span style="color: #339933;">;</span>	 		<span style="color: #666666; font-style: italic;">// light off </span>
										<span style="color: #009900;">&#125;</span>
								<span style="color: #009900;">&#125;</span>
							<span style="color: #009900;">&#125;</span>								<span style="color: #666666; font-style: italic;">// end fade in </span>
					y <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					z <span style="color: #339933;">=</span> rand<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">63</span><span style="color: #339933;">,</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> y<span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> z<span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>								<span style="color: #666666; font-style: italic;">// the fading out loop</span>
						<span style="color: #009900;">&#123;</span>
							PORTB <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> x<span style="color: #339933;">;</span>							<span style="color: #666666; font-style: italic;">// light on </span>
							<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>j<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> y<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
								<span style="color: #009900;">&#123;</span>
									<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;</span> i<span style="color: #009900;">&#41;</span>
										<span style="color: #009900;">&#123;</span>
											PORTB <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">&lt;&lt;</span> x<span style="color: #339933;">;</span>			<span style="color: #666666; font-style: italic;">// light off</span>
										<span style="color: #009900;">&#125;</span>
								<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>									<span style="color: #666666; font-style: italic;">// end fade out</span>
				<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/digital-candle-%e2%80%94-version-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Taking the ATMega8for an introductory spin</title>
		<link>http://www.dmcole.net/taking-the-atmega8-for-an-introductory-spin/</link>
		<comments>http://www.dmcole.net/taking-the-atmega8-for-an-introductory-spin/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 21:23:53 +0000</pubDate>
		<dc:creator>dmcole</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[ATMega8]]></category>
		<category><![CDATA[Atmel]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Microchip]]></category>
		<category><![CDATA[PICAXE]]></category>
		<category><![CDATA[USBtinyISP]]></category>

		<guid isPermaLink="false">http://www.dmcole.net/?p=18</guid>
		<description><![CDATA[In 2007 I played around with the PICAXE, a microprocessor sold by a non-profit in the United Kingdom that comes loaded with a BASIC-like interpreter (you can read more about it here and here). I built some lighthouse beacons and a railroad crossing light using the device. It had one drawback: I had to write [...]]]></description>
			<content:encoded><![CDATA[<p>In 2007 I played around with the PICAXE, a microprocessor sold by a non-profit in the United Kingdom that comes loaded with a BASIC-like interpreter (you can read more about it <a href="http://www.rev-ed.co.uk/picaxe/" target="_blank">here</a> and <a href="http://www.phanderson.com/picaxe/picaxe.html" target="_blank">here</a>). I built some lighthouse beacons and a railroad crossing light using the device. It had one drawback: I had to write the code and program the chip using, sigh, Windows.<br />
<div id="attachment_48" class="wp-caption alignright" style="width: 310px"><a href="http://www.dmcole.net/wp-content/uploads/2009/03/atmega8-sample-schematic.pdf" target="_new"><img src="http://www.dmcole.net/wp-content/uploads/2009/03/atmega8-sample-schematic-300x193.jpg" alt="Sample schematic to connect ATMega8 to 6-pin ISP (click to download PDF)" title="atmega8-sample-schematic" width="300" height="193" class="size-medium wp-image-48"  border="0" /></a><p class="wp-caption-text">Sample schematic to connect ATMega8 to 6-pin ISP (click to download PDF)</p></div></p>
<p>In 2008 I learned a little about Microchipâ€™s PIC series of microprocessors because that was the favored chip by most of the developers in the DIY Christmas lighting world. Though I didn&#8217;t actually program PICs, I did learn how to burn HEX code into them using an ADM programmer. These too, had a drawback: you had to write the code and program the chip using, ugh, Windows.</p>
<p>Along the way, though, I heard about the AVR series of chips from <a href="http://www.atmel.com/" target="_blank">Atmel Corp.</a>, which had a distinct advantage over PICAXEn and PICs: there was a small community of people who used Macintoshes to make them go. There was a full tool-chain for programming in C (a language I had no experience in) and there were USB devices that allowed for burning the code. Well, hello, sweetheart.</p>
<p>So, somewhere along the line in 2008 I bought myself an <a href="http://www.adafruit.com/index.php?main_page=product_info&amp;products_id=46&amp;sessid=40d5826a4b87847bc855d0f28dcbee74" target="_blank">USBtinyISP</a> programmer from Adafruit Industries; today&#8217;s price in March 2009 is $22 but I think I paid a little less for it than that. I didn&#8217;t build it after I got it; the board and components sat unworking for a couple of months while I finished the Christmas lights.</p>
<p>But once the lights were up and running, I decided to get moving on learning to program an AVR in C (maybe someday I&#8217;ll tackle assembly code, but I&#8217;m really a path-of-least-resistance guy). My first step was to set up a breadboard and get a chip in a position to program.</p>
<p>And herein I ran into a small problem: I had bought a bunch of ATMega8s to learn on and lo and behold, I couldn&#8217;t find how to connect a USBtinyISP to a Mega8.</p>
<p>Through trial-and-error and posting questions on Adafruit&#8217;s <a href="http://www.ladyada.net/forums/" target="_new">forums</a>, I worked out a method to hook them together, but thought it would be worthwhile to post here not only the method, but draw up a schematic as well.</p>
<p>I should point out that for my initial set up I used a six-pin header that I soldered to six wires, which I then plugged into the breadboard; today I would advocate buying the header adapter sold by <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8508" target="_blank">Sparkfun Electronics</a>. Though initially designed to be an interface between 10-pin and six-pin headers, it has been adapted to allow you to put a row of header pins into one side that can plug directly into a breadboard. They&#8217;re only a buck, so I was forced to buy some other stuff to justify the postage <img src='http://www.dmcole.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  &#8230;</p>
<p>The code that I wrote for the ATMega8 is pretty rudimentary (it flashes a single LED) but I reproduce it here for full disclosure.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p18code6'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p186"><td class="code" id="p18code6"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Name: main.c
 * Author: David M. Cole
 * License: 2008-2009 Creative Commons Attribution-Noncommercial-Share Alike 3.0 U.S.
 * Target: ATMega8
 * Compiler: AVR-GCC
 */</span>
&nbsp;
<span style="color: #339933;">#include &lt;avr/io.h&gt;									/* A file that defines inputs and outputs */</span>
&nbsp;
<span style="color: #993333;">void</span> delay_ms<span style="color: #009900;">&#40;</span>uint16_t x<span style="color: #009900;">&#41;</span>								<span style="color: #808080; font-style: italic;">/* Declare substitute delay function, bring in variable x */</span>
	<span style="color: #009900;">&#123;</span>
		uint8_t y<span style="color: #339933;">,</span> z<span style="color: #339933;">;</span>								<span style="color: #808080; font-style: italic;">/* Declare the variables y, z */</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">;</span> x <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">;</span> x<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>							<span style="color: #808080; font-style: italic;">/* Loop while x is less than zero; decrement */</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> y <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">;</span> y <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">90</span> <span style="color: #339933;">;</span> y<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>				<span style="color: #808080; font-style: italic;">/* Loop while y is less than 90; increment */</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> z <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">;</span> z <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">6</span> <span style="color: #339933;">;</span> z<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>		<span style="color: #808080; font-style: italic;">/* Loop while z is less than six */</span>
							<span style="color: #009900;">&#123;</span>
								asm <span style="color: #993333;">volatile</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;nop&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #808080; font-style: italic;">/* Inline assembler code: no operation performed; i.e.: do nothing */</span>
							<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>										<span style="color: #808080; font-style: italic;">/* Main function; every program has a main */</span>
	<span style="color: #009900;">&#123;</span>
		DDRD <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span>								<span style="color: #808080; font-style: italic;">/* make Pin 6 (PortD4) an output */</span>
			<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span>								<span style="color: #808080; font-style: italic;">/* Loop like forever */</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #993333;">char</span> i<span style="color: #339933;">;</span>						<span style="color: #808080; font-style: italic;">/* Define the variable i */</span>
					<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>				<span style="color: #808080; font-style: italic;">/* Loop while i is less than 10 */</span>
						<span style="color: #009900;">&#123;</span>
							delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			<span style="color: #808080; font-style: italic;">/* Hang on for a moment */</span>
						<span style="color: #009900;">&#125;</span>
					PORTD <span style="color: #339933;">^=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span>				<span style="color: #808080; font-style: italic;">/* toggle the LED; if it's off, turn it on */</span>
				<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>								<span style="color: #808080; font-style: italic;">/* never reached */</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dmcole.net/taking-the-atmega8-for-an-introductory-spin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

