<?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>Keith&#039;s Electronics Blog</title>
	<atom:link href="http://www.neufeld.newton.ks.us/electronics/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.neufeld.newton.ks.us/electronics</link>
	<description></description>
	<lastBuildDate>Mon, 29 Apr 2013 00:04:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>$10 Razor E100 Scooter Project Day Two: First Battery-Charging Attempt</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1574</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1574#comments</comments>
		<pubDate>Sun, 28 Apr 2013 23:54:36 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Inside]]></category>
		<category><![CDATA[Repairs]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1574</guid>
		<description><![CDATA[I tend to assume that batteries I happen upon will not be charged. Also that lead-acid batteries I happen upon will be low on water, even so-called sealed lead-acid batteries. I wanted to start charging the batteries from my &#8220;new&#8221; scooter while working on other aspects of the project and the scooter didn&#8217;t come with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0583.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0583_mid.jpg" alt="Razor E100 battery and speed-control bucket" /></a></p>
<p>I tend to assume that batteries I happen upon will not be charged.  Also that lead-acid batteries I happen upon will be low on water, even so-called sealed lead-acid batteries.</p>
<p>I wanted to start charging the batteries <a href="?p=1572">from my &#8220;new&#8221; scooter</a> while working on other aspects of the project and the scooter didn&#8217;t come with a charger &#8212; I&#8217;ll deal with that later.  Not knowing much about the wiring circuit yet, I didn&#8217;t want to connect an external charger to the batteries while they were still in-circuit and chance damaging the speed controller, so I needed to disconnect and remove them.</p>
<p>Wiggle wiggle wiggle &lt;grunt&gt; wiggle pull &lt;grunt&gt; WIGGLE WIGGLE BEND &lt;grunt&gt;</p>
<p>Wha?</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0587.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0587_mid.jpg" alt="Soldered battery clip" /></a></p>
<p>Who does this???  When they said solder the quick-disconnect terminals, they meant <em>the wire side</em>.</p>
<p><em>Fine</em>.  <a href="?p=46">My uncle&#8217;s iron</a> and a pair of pliers solved that problem.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0589.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0589_mid.jpg" alt="Two sealed lead-acid batteries from Razor E100 scooter" /></a></p>
<p>Two batteries, extricated and not yet cleaned.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0590.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0590_mid.jpg" alt="Prying open sealed lead-acid battery cover" /></a></p>
<p>In spite of being &#8220;sealed,&#8221; you can pry off the cover (preferably after cleaning, which I did first with Goo-Gone and then with dish soap and water)</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0592.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0592_mid.jpg" alt="Sealed lead-acid battery cell caps" /></a></p>
<p>and get to the cell caps, each with a little absorbent pad in case the cell venting carries too much moisture.</p>
<p>I could see <em>no</em> water in any cell of either battery.  I borrowed a jug of distilled water from my folks (I don&#8217;t know why Mom always has some, but she does) and started filling them up &hellip; after taking measurements.</p>
<table border=1 cellspacing=0 cellpadding=5 align=center>
<tr>
<th></th>
<th>Battery 1</th>
<th>Battery 2</th>
</tr>
<tr>
<th>Initial</th>
<td>11.68 V</td>
<td>9.99 V</td>
</tr>
<tr>
<th>After adding water</th>
<td>11.62 V</td>
<td>9.92 V</td>
</tr>
</table>
<p>I filled each cell, waited for air bubbles to trickle to the top, refilled, waited, refilled, waited &hellip;  I&#8217;m guessing between the initial fill and while charging, I ended up putting at least 10 ml of water into each cell.</p>
<p>Then put battery 1 on my variable power supply with the voltage set to 13.8&nbsp;V and the current limited initially to 0.1&nbsp;A, raising the current limit to 0.3&nbsp;A as it was clear that nothing horrible was happening.  I checked on it every half-hour to hour, frequently refilling at least one cell in which I could no longer see any water.</p>
<p>After about four hours, it was up to 13.5&nbsp;V.  The water level in the cells had risen to overflow the opening and fill each reservoir.  If I watched long enough, I could see the water in a couple of cells &lt;pop&gt;, indicating they were just starting to gas and it was time for me to stop this method of charging for the day.  (More on that on a subsequent day, hopefully tomorrow.)</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/28/IMG_0601.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/28/IMG_0601_mid.jpg" alt="Charging sealed lead-acid batteries with power supply" /></a></p>
<p>While battery 1 was charging, I was also checking water levels in battery 2 and refilling low cells, just sitting on the counter.</p>
<p>Recalling that it had an initial 10&nbsp;V charge to battery 1&#8242;s 11.7&nbsp;V, noting that they had been connected in series, and knowing that the worst cell in a battery generally has a cascading failure, I expected a different charging experience from battery 2, and I was quite right.</p>
<p>I connected it to the power supply and it immediately showed 13.8&nbsp;V at a 0.1-A current draw.  Now, about an hour later, it&#8217;s at 13.5&nbsp;V and 0.3&nbsp;A and most of the cells have overflowed.  It&#8217;s nearly done charging but I haven&#8217;t put nearly as much energy into it as I was able to put into battery 1 &#8212; that is to say, it&#8217;s not &#8220;taking&#8221; as much of a charge.</p>
<table border=1 cellspacing=0 cellpadding=5 align=center>
<tr>
<th></th>
<th>Battery 1</th>
<th>Battery 2</th>
</tr>
<tr>
<th>Initial</th>
<td>11.68 V</td>
<td>9.99 V</td>
</tr>
<tr>
<th>After adding water</th>
<td>11.62 V</td>
<td>9.92 V</td>
</tr>
<tr>
<th>After charging</th>
<td>12.68 V</td>
<td>12.48 V</td>
</tr>
</table>
<p>Tomorrow, schedule willing, a load test and an attempt at desulfation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1574</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>$10 Razor E100 Scooter Project Day 1: Rear Wheel</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1572</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1572#comments</comments>
		<pubDate>Sat, 27 Apr 2013 23:17:24 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Repairs]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1572</guid>
		<description><![CDATA[This afternoon I learned of the recently- (?) opened Deja Vu thrift store in Newton and made my first purchase: a Razor E100 scooter in considerable state of disassembly. I&#8217;ve long thought that electric scooters looked like fun &#8230; All of the wires are cut, the deck is missing, the rear wheel was unattached, naturally [...]]]></description>
			<content:encoded><![CDATA[<p>This afternoon I learned of the recently- (?) opened Deja Vu thrift store in Newton and made my first purchase: a Razor E100 scooter in considerable state of disassembly.  I&#8217;ve long thought that electric scooters looked like fun &hellip;</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0581.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0581_mid.jpg" alt="Pieces of Razor E100 electric scooter" /></a></p>
<p>All of the wires are cut, the deck is missing, the rear wheel was unattached, naturally the drive belt was missing, and no charger.</p>
<p>$10.  I bought it.  Sounds like a fun project, eh?</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0583.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0583_mid.jpg" alt="Razor E100 scooter battery compartment" /></a></p>
<p>The battery and speed-control bucket could use some repair but seems at least functional.  I started working on the batteries but as soon as my brother was available redirected my attention to reattaching the rear wheel.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0593.jpg"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0593_mid.jpg" alt="Razor E100 scooter rear wheel, loose in forks" /></a></p>
<p>The rear wheel is belt-driven and needs to be positioned to align with the motor pulley but the spacers were absent and it slid freely from side to side.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0597.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0597_mid.jpg" alt="Cutting a roll pin" /></a></p>
<p>A trip to the hardware store resulted in a roll pin with ID slightly larger than the 1/4&#8243; axle diameter and length slightly greater than the two spacers needed, for $1.89.  Then my brother&#8217;s giant chop saw made short work of creating two pieces from one.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0599.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/04/27/IMG_0599_mid.jpg" alt="Razor E100 scooter rear wheel, mounted" /></a></p>
<p>Touched up a bit on the bench grinder, ends rounded over with a file, and interiors cleaned out with a round file, spacers fit perfectly and the rear wheel bolts on securely.  We &#8220;kicked&#8221; our way up and down the driveway and are eager to get the scooter powered up.</p>
<p>Next: Battery investigation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1572</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Finding a Picture That I Took Used on eBay</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1562</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1562#comments</comments>
		<pubDate>Sun, 06 Jan 2013 12:56:41 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1562</guid>
		<description><![CDATA[It is a bit surprising to follow a link from an eBay saved search and find a picture that I took. The original is in this post from 2011. I have no CC notices posted for the whole site (though I&#8217;d be happy to); but of course the Berne Convention provides for automatic copyright upon [...]]]></description>
			<content:encoded><![CDATA[<p>It is a bit surprising to follow a link from an eBay saved search and find a picture that I took.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2013/01/06/Liebert-battery-cable.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2013/01/06/Liebert-battery-cable.png" alt="Liebert UPS battery cable"></a></p>
<p>The original is in <a href="?p=1185">this post from 2011</a>.</p>
<p>I have no CC notices posted for the whole site (though I&#8217;d be happy to); but of course the Berne Convention provides for automatic copyright upon creation and publication of a work, so this is a blatant copyright violation.</p>
<p>Regardless, why is an eBay seller with only 110 feedbacks (vs one who does business on a scale of 110,000) too lazy to take their own picture of what they claim to have for sale?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1562</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Wanted: An EPROM Programmer that Works on a Mac</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1555</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1555#comments</comments>
		<pubDate>Fri, 28 Dec 2012 17:04:11 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Arcade]]></category>
		<category><![CDATA[Equipment]]></category>
		<category><![CDATA[Vintage Computing]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1555</guid>
		<description><![CDATA[And Linux. And old, high-programming-voltage EPROMs. And USB, naturally. If you know of such a thing, give me a shout in the comments &#8212; I can&#8217;t find any on Google, and I find plenty of links to other people who also couldn&#8217;t find them. 6502 Microprocessor, Apple ][, and Asteroids A couple of weeks ago, [...]]]></description>
			<content:encoded><![CDATA[<p>And Linux.  And old, high-programming-voltage EPROMs.  And USB, naturally.  If you know of such a thing, give me a shout in the comments &#8212; I can&#8217;t find any on Google, and I find plenty of links to other people who also couldn&#8217;t find them.</p>
<h3>6502 Microprocessor, Apple ][, and Asteroids</h3>
<p>A couple of weeks ago, I went to an annual holiday lunch with former coworkers and got to visit with an old friend.  He was reminiscing about 6502 assembly programming on the Apple ][ and wondered whether I'd know where he could get one.  I told him that I could probably loan him one or two; but (with a mischievous glint in my eye) that I have a couple of <a href="http://en.wikipedia.org/wiki/Asteroids_%28video_game%29">upright Asteroids arcade games</a> and they run on 6502s and I&#8217;ve always wanted to reprogram one and write my own game.</p>
<p>Bump, set, spike.  Yeah, he&#8217;s interested.</p>
<p>It&#8217;s not a completely impractical idea.  I have a large schematic set that includes the addressing of the memory-mapped I/O and some rudimentary information on the operation of the vector generator board.  There&#8217;s even a <a href="http://www.ionpool.net/arcade/astcode/asteroids_code_project.html">project to comment the disassembled ROM</a>, which would give further hints about how to interface to the hardware.</p>
<p>If one were to undertake such a project, one would really like to use a USB-attached EPROM emulator so one could dump new code into the machine frequently and rapidly for testing and development.  But at a bare minimum, one would need a stack of EPROMs and a programmer and ideally a ZIF-socket daughterboard to fit into the original EPROM socket and make it easy to swap EPROMs.  As I have no Windows machines and do my electronics development on a synchronized fleet of Mac and Linux machines, a commercial EPROM programmer that I can use is going to be a little bit hard to come by.</p>
<p>Yes, I could run Windows under virtualization on my Mac; I think I may even be able to get a legal copy through my campus&#8217;s license agreement.  But I&#8217;m not interested in going that direction unless I have to.</p>
<p>Isn&#8217;t it about time the world had a cross-platform EPROM programmer?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1555</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>72G or Larger SCSI-2 Fast/Wide Hard Drives?</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1552</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1552#comments</comments>
		<pubDate>Mon, 26 Nov 2012 23:03:07 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1552</guid>
		<description><![CDATA[Anyone know where to find new, large-capacity SCSI-2 fast/wide hard drives? A computer I supported at a hospital a long time ago has a failing hard drive and I&#8217;m happy to assist with replacement but I&#8217;m not coming up with any sources for the hardware.]]></description>
			<content:encoded><![CDATA[<p>Anyone know where to find new, large-capacity SCSI-2 fast/wide hard drives?  A computer I supported at a hospital a <em>long</em> time ago has a failing hard drive and I&#8217;m happy to assist with replacement but I&#8217;m not coming up with any sources for the hardware.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1552</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>New Arrival</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1546</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1546#comments</comments>
		<pubDate>Tue, 04 Sep 2012 00:28:56 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Vintage Computing]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1546</guid>
		<description><![CDATA[Yes, it is what it looks like. I&#8217;m the second owner. It hasn&#8217;t been powered on in 36 years. I&#8217;ll post more pictures as I share the story and test it carefully to make sure it&#8217;s safe to power on.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/09/03/DSCN0273.jpg"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/09/03/DSCN0273_mid.jpg" alt="computer" /></a></p>
<p>Yes, it is what it looks like.</p>
<p>I&#8217;m the second owner.</p>
<p>It hasn&#8217;t been powered on in 36 years.</p>
<p>I&#8217;ll post more pictures as I share the story and test it <strong>carefully</strong> to make sure it&#8217;s safe to power on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1546</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>OS X ATtiny25 Programming Walkthrough</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1539</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1539#comments</comments>
		<pubDate>Sun, 08 Jul 2012 01:18:53 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[AVR]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1539</guid>
		<description><![CDATA[A while back I bought a batch of ATtiny25 microcontrollers and today I finally put one to use and got it programmed. MIT&#8217;s High-Low Tech group has put together a really nice package for programming ATtiny45s and ATtiny85s from the Arduino IDE, but it doesn&#8217;t support ATtiny25s, presumably because the limited memory doesn&#8217;t leave enough [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I bought a batch of ATtiny25 microcontrollers and today I finally put one to use and got it programmed.  MIT&#8217;s High-Low Tech group has put together a <a href="http://hlt.media.mit.edu/?p=1695">really nice package for programming ATtiny45s and ATtiny85s from the Arduino IDE</a>, but it doesn&#8217;t support ATtiny25s, presumably because the limited memory doesn&#8217;t leave enough space after the bootloader is installed.  I had a dickens of a time trying to find instructions to walk through programming an ATtiny25, much less on OS X; but it turned out to be pretty easy after pulling together a few separate resources.  Here&#8217;s the path to blinkemness.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/07/07/IMG_1982.jpg"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/07/07/IMG_1982_mid.jpg" alt="ATtiny25 board with USBtinyISP and Saleae Logic, overhead view" /></a></p>
<p><span id="more-1539"></span></p>
<h3>Install CrossPack Development Environment</h3>
<p>First, install <a href="http://www.obdev.at/products/crosspack/index.html">CrossPack</a>, which provides &#8220;the GNU compiler suite, a C library for the AVR, the AVRDUDE uploader and several other useful tools.&#8221;  Make sure you completely close your Terminal program (if you had it running) and restart it after the installation, to pick up the location it adds to your command search path.</p>
<h3>Test the Programmer and Connectivity</h3>
<p>Once installed, connect your programmer (I have a couple of USBtinyISPs, so that&#8217;s what I used) to your computer and target board and test that the programmer is working and sees your ATtiny:</p>
<p><code>$ avrdude -c usbtiny -p attiny25<br />
avrdude: AVR device initialized and ready to accept instructions</p>
<p>Reading | ################################################## | 100% 0.01s</p>
<p>avrdude: Device signature = 0x1e9108</p>
<p>avrdude: safemode: Fuses OK</p>
<p>avrdude done.  Thank you.<br />
</code></p>
<p>If you get any other response, check the troubleshooting notes at the bottom of <a href="http://mightyohm.com/blog/tutorials/avr-toolchain-installation/mac-os-x/">Jeff Keyzer&#8217;s AVR toolchain installation page</a>.</p>
<h3>Create Blink Code</h3>
<p>The <a href="http://www.obdev.at/products/crosspack/index.html">CrossPack web page</a> includes a blinky demo project, but it&#8217;s written for a different microcontroller and requires minor adaptation to work on the ATtiny25.  Follow along both here and there for greatest insight.</p>
<p>In your Terminal window,</p>
<p><code>$ avr-project blink<br />
Using template: /usr/local/CrossPack-AVR-20120217/etc/templates/TemplateProject<br />
$ cd blink/firmware<br />
$ ls<br />
Makefile	main.c<br />
</code></p>
<p>The Crosspack example is written for an ATmega8, which has more I/O ports than the ATtiny.  The ATtiny has a single I/O port, and it&#8217;s port B (mystery of the universe why not A).  So adapting the example code, use your favorite text editor to insert into <code>main.c</code> to create the following (picking whichever pin you&#8217;d like to use for your LED):</p>
<pre>
#include &lt;avr/io.h&gt;
#include &lt;util/delay.h&gt;

#define LEDPIN (3)

int main(void) {
    DDRB = 1 &lt;&lt; LEDPIN;  //  make only the LED pin an output
    while (1) {
        char i;
        for (i = 0; i &lt; 10; ++i) {
            _delay_ms(50);
        }
        PORTB ^= 1 &lt;&lt; LEDPIN;
    }
    return 0;   /* never reached */
}
</pre>
<h3>Calculate Fuse Values and Edit the Makefile</h3>
<p>Use the <a href="http://www.engbedded.com/fusecalc/">Engbedded AVR fuse calculator</a> to calculate the command-line values to set all the ATtiny behavior flags.  Use <code>AVR part name: ATtiny25</code>, uncheck (for this example) <code>Divide clock by 8 internally</code>, and scroll down to <code>Current settings</code>.  You should see something like</p>
<p><code>-U lfuse:w:0xe2:m -U hfuse:w:0xdf:m<br />
-U efuse:w:0xff:m<br />
</code></p>
<p>Back in Terminal, edit <code>Makefile</code> .  Update the following lines:</p>
<p><code>DEVICE     = attiny25<br />
PROGRAMMER = -c usbtiny<br />
FUSES      = -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m<br />
</code></p>
<p>(using whatever programmer you have and any additional flags it needs) and save and exit the <code>Makefile</code> .</p>
<h3>Compile and Load the Program</h3>
<p>Run</p>
<p><code>$ make<br />
avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=attiny25 -c main.c -o main.o<br />
avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=attiny25 -o main.elf main.o<br />
rm -f main.hex<br />
avr-objcopy -j .text -j .data -O ihex main.elf main.hex<br />
avr-size --format=avr --mcu=attiny25 main.elf<br />
AVR Memory Usage<br />
----------------<br />
Device: attiny25</p>
<p>Program:      92 bytes (4.5% Full)<br />
(.text + .data + .bootloader)</p>
<p>Data:          0 bytes (0.0% Full)<br />
(.data + .bss + .noinit)<br />
</code></p>
<p>to build the program.  If you get errors instead, double-check <code>main.c</code> around the line the compiler indicates.</p>
<p>Run</p>
<p><code>$ make flash<br />
avrdude -c usbtiny -p attiny25 -U flash:w:main.hex:i</p>
<p>avrdude: AVR device initialized and ready to accept instructions</p>
<p>Reading | ################################################## | 100% 0.01s</p>
<p>avrdude: Device signature = 0x1e9108<br />
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed<br />
         To disable this feature, specify the -D option.<br />
avrdude: erasing chip<br />
avrdude: reading input file "main.hex"<br />
avrdude: writing flash (92 bytes):</p>
<p>Writing | ################################################## | 100% 0.08s</p>
<p>avrdude: 92 bytes of flash written<br />
avrdude: verifying flash memory against main.hex:<br />
avrdude: load data flash data from input file main.hex:<br />
avrdude: input file main.hex contains 92 bytes<br />
avrdude: reading on-chip flash data:</p>
<p>Reading | ################################################## | 100% 0.05s</p>
<p>avrdude: verifying ...<br />
avrdude: 92 bytes of flash verified</p>
<p>avrdude: safemode: Fuses OK</p>
<p>avrdude done.  Thank you.<br />
</code></p>
<p>to program the IC.  Run</p>
<p><code>$ make fuse<br />
avrdude -c usbtiny -p attiny25 -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m </p>
<p>avrdude: AVR device initialized and ready to accept instructions</p>
<p>Reading | ################################################## | 100% 0.01s</p>
<p>avrdude: Device signature = 0x1e9108<br />
avrdude: reading input file "0xe2"<br />
avrdude: writing lfuse (1 bytes):</p>
<p>Writing | ################################################## | 100% 0.00s</p>
<p>avrdude: 1 bytes of lfuse written<br />
avrdude: verifying lfuse memory against 0xe2:<br />
avrdude: load data lfuse data from input file 0xe2:<br />
avrdude: input file 0xe2 contains 1 bytes<br />
avrdude: reading on-chip lfuse data:</p>
<p>Reading | ################################################## | 100% 0.00s</p>
<p>avrdude: verifying ...<br />
avrdude: 1 bytes of lfuse verified<br />
avrdude: reading input file "0xdf"<br />
avrdude: writing hfuse (1 bytes):</p>
<p>Writing | ################################################## | 100% 0.00s</p>
<p>avrdude: 1 bytes of hfuse written<br />
avrdude: verifying hfuse memory against 0xdf:<br />
avrdude: load data hfuse data from input file 0xdf:<br />
avrdude: input file 0xdf contains 1 bytes<br />
avrdude: reading on-chip hfuse data:</p>
<p>Reading | ################################################## | 100% 0.00s</p>
<p>avrdude: verifying ...<br />
avrdude: 1 bytes of hfuse verified<br />
avrdude: reading input file "0xff"<br />
avrdude: writing efuse (1 bytes):</p>
<p>Writing | ################################################## | 100% 0.00s</p>
<p>avrdude: 1 bytes of efuse written<br />
avrdude: verifying efuse memory against 0xff:<br />
avrdude: load data efuse data from input file 0xff:<br />
avrdude: input file 0xff contains 1 bytes<br />
avrdude: reading on-chip efuse data:</p>
<p>Reading | ################################################## | 100% 0.00s</p>
<p>avrdude: verifying ...<br />
avrdude: 1 bytes of efuse verified</p>
<p>avrdude: safemode: Fuses OK</p>
<p>avrdude done.  Thank you.<br />
</code></p>
<p>to burn the fuse bits.</p>
<h3>Behold Blinky Goodness</h3>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/07/07/IMG_1989.jpg"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/07/07/IMG_1989_mid.jpg" alt="ATtiny25 board with USBtinyISP and Saleae Logic, angle" /></a></p>
<p>The board I&#8217;m developing doesn&#8217;t have an LED on it, so I clipped my logic analyzer to ground and I/O pin B3 (IC pin 2) to test for blinking.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/07/07/blink-capture.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/07/07/blink-capture_mid.png" alt="1 Hz square wave from ATtiny25 IC" /></a></p>
<p>1 Hz blinking on my I/O pin.  Fundamental programming accomplished.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1539</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hand-Soldering SOIC</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1527</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1527#comments</comments>
		<pubDate>Tue, 03 Jul 2012 03:21:48 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1527</guid>
		<description><![CDATA[I wouldn&#8217;t want to do it for a living, but it&#8217;s an enjoyable diversion once in a while, particularly as a favor for a friend. I aligned each chip&#8217;s pins by hand, clamped it to the board with a gator clamp (with heatshrinked jaws), soldered the far row of pins, rotated the board, and soldered [...]]]></description>
			<content:encoded><![CDATA[<p>I wouldn&#8217;t want to do it for a living, but it&#8217;s an enjoyable diversion once in a while, particularly as a favor for a friend.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/07/02/DSCN8950.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/07/02/DSCN8950_mid.jpg" alt="Breakout boards with SOIC" /></a></p>
<p>I aligned each chip&#8217;s pins by hand, clamped it to the board with a gator clamp (with heatshrinked jaws), soldered the far row of pins, rotated the board, and soldered the now-far row of pins.</p>
<p>Three rows I was able to do by blob-and-drag (heat the pins at the uphill end of the row, make a big solder blob, and drag it down the row at a pace slow enough to heat the pins but fast enough to keep the surface of the blob from oxidizing too badly, trusting surface tension to bring the blob with you and leave only a lovely solder fillet below each pin).  Three rows I ended up doing slop-and-wick (get solder all over the place, then use &#8220;Size: Good&#8221; solder braid to remove solder bridges from between the pins, leaving a lovely solder fillet below each pin and <strike>evidence</strike> scorched flux everywhere).</p>
<p>I&#8217;d take recommendations on a good flux remover &#8212; preferably detailed recommendations indicating whether you have to scrub or just spray, how cleanly it washes off, etc.  You can see that the rubbing alcohol I used leaves a bit of residue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1527</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>If All You Have Is a Logic Analyzer, Everything Looks Like a Timing Problem</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1519</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1519#comments</comments>
		<pubDate>Thu, 28 Jun 2012 02:44:29 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Equipment]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1519</guid>
		<description><![CDATA[I just rewrote the Arduino Playground Nokia LCD screen code to use hardware SPI instead of ShiftOut(). (More work to do before releasing the code back to the community. And I know, not everyone will want to use the hardware SPI, but it should be an option.) It looked like a trivial change, but after [...]]]></description>
			<content:encoded><![CDATA[<p>I just rewrote the <a href="http://www.arduino.cc/playground/Code/PCD8544">Arduino Playground Nokia LCD screen code</a> to use hardware SPI instead of <code>ShiftOut()</code>.  (More work to do before releasing the code back to the community.  And I know, not everyone will want to use the hardware SPI, but it should be an option.)</p>
<p>It looked like a trivial change, but after making it, the display&#8217;s screen remained blank.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/spi-bad-ss.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/spi-bad-ss_mid.png" alt="Logic analyzer capture of bad SPI communication" /></a></p>
<p>But &hellip; but &hellip; but &hellip; the slave-select line is supposed to be held low during each byte of transmission.  I know the ATmega&#8217;s SPI hardware doesn&#8217;t manage it for you, but surely the Arduino&#8217;s <code>SPI.transfer()</code> function does, right???</p>
<h3>Working Arduino SPI Transfer</h3>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/spi-manual-ss.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/spi-manual-ss_mid.png" alt="Logic analyzer capture of working SPI communication" /></a></p>
<p>No.  You have to manage it manually.</p>
<p><code>void LcdWrite(byte dc, byte data) {<br />
  digitalWrite(PIN_SS, LOW);<br />
  digitalWrite(PIN_DC, dc);<br />
  SPI.transfer(data);<br />
  digitalWrite(PIN_SS, HIGH);<br />
}</code></p>
<p>SPI support is a <em>perfect</em> candidate to be a real object-oriented class rather than a functional library in OO clothing.  Instantiate objects that know which slave-select pin is theirs, which may have different bit orders and clock rates and clock modes, and provide a <code>transfer()</code> method that sets all the registers, twiddles SS for you, and transfers your byte.</p>
<p>Sigh.</p>
<h3>Faster Arduino SPI Transfer</h3>
<p>BTW, notice on the second capture that manually bouncing SS using two <code>digitalWrite()</code>s <em>takes longer than transferring eight bits of data using the hardware SPI</em>.  Start to understand why I want to transfer data using hardware instead of bit-banging?</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/spi-faster-ss.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/spi-faster-ss_mid.png" alt="Logic analyzer capture of working SPI communication with fast SS manipulation" /></a></p>
<p>Manipulating the SS bit in the port register directly is <em>much</em> faster &hellip; at the cost of being much less clear what&#8217;s going on to non-native speakers of C.</p>
<p><code>void LcdWrite(byte dc, byte data) {<br />
  PORTB &#038;= ~ (1 << 2);<br />
  digitalWrite(PIN_DC, dc);<br />
  SPI.transfer(data);<br />
  PORTB |= (1 << 2);<br />
}</code></p>
<h3>ATmega I/O Pin Hardware Toggling for Fastest Arduino SPI Transfer (That Isn't Any Faster)</h3>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/atmega-port-toggle.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/atmega-port-toggle_mid.png" alt="ATmega I/O pin hardware toggle diagram" /></a></p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/spi-fastest-ss.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/27/spi-fastest-ss_mid.png" alt="Logic analyzer capture of working SPI communication with fast SS manipulation" /></a></p>
<p>The C-based bit manipulation code above is already fast enough that the timing constraint has moved back to the programmer-selected SPI clocking speed and the ultimate solution -- <a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1282100129">using the ATmega's hardware-based pin toggle feature</a> -- doesn't save any noticeable time, <strike>but the code sure looks cool</strike> <strike>but it's the right thing to do</strike> and it's a risky game to play to assume you always know correctly the logic level of the pin when you enter the function.</p>
<p><code>void LcdWrite(byte dc, byte data) {<br />
  PINB = _BV(PINB2);<br />
  digitalWrite(PIN_DC, dc);<br />
  SPI.transfer(data);<br />
  PINB = _BV(PINB2);<br />
}</code></p>
<p>(BTW, I had a dream recently -- which I did not know was not real -- in which the latest Arduino release added <code>digitalWrite(pin, TOGGLE)</code> to do the above.  Imagine my disappointment tonight to learn it was only a dream.  And no, I'm not the first to suggest that feature, by a long shot.  Just, maybe, the first to think it had actually happened.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1519</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino-Compatible &#8220;Practice&#8221;</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1513</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1513#comments</comments>
		<pubDate>Sun, 24 Jun 2012 21:50:27 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1513</guid>
		<description><![CDATA[I&#8217;m trying to get my LED calculator out the door this summer, and that requires embedding an Arduino-compatible &#8220;core&#8221; into my own system. Yes, yes, I could use a microcontroller without the Arduino environment; but if I actually get this thing ready to sell, I want my customers to be able to reprogram it (apply [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to get my <a href="?p=1145">LED calculator</a> out the door this summer, and that requires embedding an Arduino-compatible &#8220;core&#8221; into my own system.  Yes, yes, I could use a microcontroller without the Arduino environment; but if I actually get this thing ready to sell, I want my customers to be able to reprogram it (apply firmware upgrades <em>or</em> enhance the feature set) in a comfortable environment.  Hence an Arduino-compatible core.</p>
<p>I haven&#8217;t made an Arduino-compatible before, and the only two things I found daunting were the crystal, which I understand has to be exactly matched to its supporting capacitors or the circuit won&#8217;t resonate, so it was important to find the same one used in the Arduino; and the resettable polyfuse on the USB power lines, which doesn&#8217;t (in the Arduino circuit) specify whether 500&nbsp;mA is the hold current or the trip current.</p>
<p>I found an <a href="http://www.arduino.cc/en/Main/StandalonePartList">Arduino playground post by Tom Igoe</a> giving Digi-Key part numbers for a bare-bones breadboard Arduino-compatible and chased the out-of-stock crystal to the equivalent <a href="http://www.digikey.com/product-detail/en/9B-16.000MAAJ-B/887-1019-ND/2118703">Digi-Key catalog number 887-1019-ND</a>.  I searched far and wide for information on the polyfuse and gave up, settling on 500 mA hold current, since that&#8217;s permitted (after negotiation) by the USB spec and surely we wouldn&#8217;t want to trip at the maximum permitted current.</p>
<p>With that data in hand, I still had a healthy dose of uncertainty about my likelihood of building a working Arduino-compatible.  I prefer to develop and test modularly, so I wanted to assemble a working proof-of-concept Arduino-compatible before diving into the LED calculator project.  And as it happens, I had a perfect project waiting in the wings &#8212; an Arduino-compatible board with ground and power headers surrounding the normal I/O headers (like servo connectors), to make it easy to connect external sensors without going all-out and buying a <a href="http://arduino-info.wikispaces.com/SensorShield">sensor shield</a> (which actually has the I/O pin at the end of each connector rather than in the middle, whatever).  I want to build my own version of my friend Trevor&#8217;s <a href="http://progressiveodyssey.blogspot.com/2012/03/updated-home-temperature-system.html">household temperature-monitoring system</a>, and such an Arduino-compatible would be a great platform for terminating the three-wire temperature sensors.</p>
<p>To speed the process, I started with the EAGLE schematic of the <a href="http://www.freeduino.org/freeduino_open_designs.html">Freeduino through-hole design</a>, ripping up the board and laying it out mostly from scratch to make room for my extra header rows.  I had the board produced by BatchPCB, I received it last week, and I have now assembled it into a working Arduino-compatible.</p>
<p>But not &#8212; this is going to sound <em>soooo</em> familiar &#8212; without some snags along the way.</p>
<h3>Testing the FTDI USB-Serial</h3>
<p>The one component not available in a through-hole package was the FTDI USB-serial chip; and I planned on hand-soldering it; and that&#8217;s way easier to do without other components looming over it and getting in the way of the iron; so I attached it first.  And that led me to test it first as well, since I test as I go.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/20/DSCN8895.jpg"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/20/DSCN8895_mid.jpg" alt="Arduino-compatible with USB-serial components installed" /></a></p>
<p><span id="more-1513"></span></p>
<p>This is about the minimal set of components to test the entire operation of the FTDI chip.  Power jumper and lots of bypass capacitors, polyfuse, power LED and current-limiting resistor, transmit and receive LEDs and resistors, and &hellip; yeah, the Arduino&#8217;s digital pin 13 LED is completely unnecessary.</p>
<p>And it worked!  I powered it up first connected only to a powered external USB hub so that if anything was horribly wrong, there was no way it could smoke my computer.  The power LED came on and the transmit and receive LEDs came on and stayed on.  With only the slightest twinge of hesitation, I plugged it into my laptop.  The transmit and receive LEDs went out, ZTerm recognized a new serial port, and I could type into the receive LED to my heart&#8217;s content.</p>
<h3>ATmega and ISP Header</h3>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8913.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8913_mid.jpg" alt="Arduino-compatible with ATmega and USB-serial ICs installed" /></a></p>
<p>The next step was to install the microcontroller and try to in-system program it.  The minimum additions were the ATmega and socket, the crystal and its capacitors, the reset button and pull-up resistor, and the ISP programming header.</p>
<p>I connected my <a href="http://www.ladyada.net/make/usbtinyisp/">USBtinyISP</a>, fired up the Arduino IDE, and tried to burn the bootloader &#8212; and it didn&#8217;t work.  The USBtinyISP thought it had no chip connected.</p>
<p>It was late Wednesday evening and I had to put the board away with the problem unsolved.  I didn&#8217;t yet know whether the problem was with the microcontroller not even running, with the programming port, or somewhere else in the design.</p>
<h3>Troubleshooting In-System Programming</h3>
<p>Thursday night I had a rehearsal so didn&#8217;t get to devote much time to the problem, but I did move the ATmega from a working Arduino into this board and it worked, running the Blink sketch.  I put the ATmega from this board into the working Arduino board and in-system programmed it, and it worked, both there and when I put it back into this board.  That was a relief &#8212; it meant the fundamental design was okay and I had a problem with the programming port.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/03/Freeduino-ISP.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/03/Freeduino-ISP_mid.png" alt="Freeduino in-system programming port" /></a></p>
<p>Which is so dead simple, how can it have a problem???  It&#8217;s just traces!</p>
<p>But one of the traces is both the ISP clock line (SCK) and the Arduino-compatible&#8217;s digital pin 13, which has an LED on it, which loads down the ISP clock line &hellip;  I lifted one leg of the current-limiting resistor, but that didn&#8217;t fix it.</p>
<p>I spent Friday evening with friends making (and consuming!) pizza and ice cream, so it was Saturday before I got back to this.  By then I had examined the schematic and board layout over and over again, comparing them to multiple other references for the ISP pinout, not finding any problems; and I knew I had to get more serious.  It was time to learn to use my <a href="http://www.saleae.com/logic">Saleae logic analyzer</a>.</p>
<p>I love the product.  I find the manual not well organized and I got no response to my polite email months ago detailing many, <em>many</em> ways they could make it more clear for me &#8212; such as listing what voltage range is considered logic high.  I love the look of the user interface.  I find manipulating the view and the data clumsy.  I hate learning to use new products and systems when I&#8217;m in the middle of something hard I wish I didn&#8217;t have to do, and I learned anyway.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/23/logic-capture-factory.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/23/logic-capture-factory_mid.png" alt="Timing diagram of successful ATmega in-system programming" /></a></p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/23/logic-capture-homemade.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/23/logic-capture-homemade_mid.png" alt="Timing diagram of unsuccessful ATmega in-system programming" /></a></p>
<p>I connected the logic analyzer to every pin of the ISP port &#8212; including the 5V power pin, mainly for completeness but partly out of paranoia &#8212; of the working, real Arduino and set the analyzer to trigger on a negative-going edge of the RESET line (or assertion of /RESET, if you wanna be that way).  I captured the beginning of an ISP cycle, then moved the analyzer to the homemade Arduino-compatible and repeated the capture.  You may safely ignore the transitions on SCK before the trigger event (time 0.0) &#8212; the boards are running the Blink code until they get reset to start the programming (attempt), and that&#8217;s the LED pin.</p>
<p>I saw enough differences between these captures that I wasn&#8217;t sure where to begin, so I decided to go to the source:  Atmel&#8217;s application note <a href="www.atmel.com/Images/doc0943.pdf">AVR910P In-System Programming</a>.  I verified the ISP port pinout yet again.  I read about the functions of each pin.  And on page 4, I found this gem:</p>
<blockquote><p>When Reset is applied to the target AVR microcontroller, the MISO pin is set up to be an input with no pull up. Only after the “Programming Enable” command has been correctly transmitted to the target will the target AVR microcontroller set its MISO pin to become an output. During this first time, the In-System programmer will apply its pull up to keep the MISO line stable until it is driven by the target microcontroller.
</p></blockquote>
<p><em>Hang on</em>.  MISO is set to be an input and the ISP will apply a pull-up?  Then why, on my board, is it low the entire time?  It must be shorted to ground.</p>
<p>I grabbed the meter.  MISO was shorted to ground.</p>
<p>AWESOME!  I just have to find the solder splash &hellip; which is unlikely on a commercially-produced board with solder mask &hellip; and there&#8217;s no solder splash.</p>
<p>Okay, I just have to find the design error connecting MISO to ground.  Yeahno, EAGLE absolutely has MISO and GND as separate signals.  And BatchPCB sent me a spare copy of the board, which I checked with a meter, and which did not have MISO shorted to ground.</p>
<p>Okay, I just have to find the manufacturing error shorting MISO to ground.  Many, many minutes with a magnifying glass and I found nothing.</p>
<p>The whole time I&#8217;m thinking about how glad I am it&#8217;s a two-layer board so I don&#8217;t have to be paranoid about a short on an interior layer where I can&#8217;t see it.</p>
<p>Yesterday ended and I went to bed knowing I had a signal shorted to ground and being completely unable to find it.</p>
<p>Today I knew I had to get yet more serious.  Out came the <a href="http://midwestdevices.com/">Capacitor Wizard</a>.</p>
<p>Scoff all you want.  It has saved me countless hours testing capacitors in-circuit, but its utility doesn&#8217;t end there.  It is an exquisitely sensitive ohmmeter and can easily detect the difference in resistance between 1&#8243; and 2&#8243; of copper trace.</p>
<p>I put one probe on the ground plane and tested every point along the MISO path with the other probe.  The short to ground was quite clearly nearest the header at the top of the board.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8899.jpg"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8899_mid.jpg" alt="Copper splash across PCB isolation" /></a></p>
<p>Back to the magnifying glass, and knowing where to look, I found this.  (As always, click to see full resolution.)  It looked like a booger in the varnish, but it extended across the isolation between the ground plane and MISO, and it was in the segment of the MISO trace where the Capacitor Wizard said it should be.</p>
<p>I took the board to Ron&#8217;s to use his big magnifying glass to get the pic, and he was convinced the booger wasn&#8217;t in the copper layer and didn&#8217;t want to scratch up my pretty new board finding out, especially after knocking down the surface of the booger with a plastic scratching stick and not getting down to copper.  He even desoldered the microcontroller socket to get a closer look at its pads and the vias under the socket &hellip; finding nothing, of course.</p>
<p>So when he stepped out of the shop for a bit, I cut the MISO trace near the microcontroller to isolate which end of the trace had the short to ground &#8212; and it was the upper end.  Armed with that information, Ron couldn&#8217;t help but capitulate.  I allowed him the honor of scraping away the &#8220;hair&#8221; for me, which quickly revealed itself as copper, and he quickly revealed a few words he knew.  And the short was gone.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8909.jpg"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8909_mid.jpg" alt="Arduino-compatible with USBtinyISP" /></a></p>
<p>Ron did a gorgeous, almost invisible job of jumpering over the trace I had cut.  MISO was still not shorted.  I brought the board home and resoldered the socket and MISO was still not shorted.  I tested the ISP.  It now works fine with the digital pin 13 LED out of circuit and it doesn&#8217;t like the load with the LED in circuit.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8919.jpg"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8919_mid.jpg" alt="Socketed LED" /></a></p>
<p>No problem.  For my prototype board, I socketed the ancient, power-sucking LED so I can remove it if ever I want to in-system program the board again.  Inside my LED calculator, I probably won&#8217;t put a &#8220;Blink&#8221; LED.  If I want to make a board that does have an LED on digital pin 13, I&#8217;ll buy a modern, high-efficiency LED that I can run with a much higher series resistance, just like the real Arduino does, and not load down the SCK pin so much.</p>
<h3>Sweet, Sweet Success at Last</h3>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8922.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/06/24/DSCN8922_mid.jpg" alt="Arduino-compatible" /></a></p>
<p>A little more soldering to install the headers and the rest of the components, and that&#8217;s the rest of the story.</p>
<p>Well, almost.</p>
<p>To quote <a href="http://www.sparkfun.com/products/10909">SparkFun forum user FlorinC</a>, talking about an entirely different board,</p>
<blockquote><p>The capacitors look taller than the headers. This will be a problem when a shield is plugged in.</p></blockquote>
<p>&lt;scratches head&gt; Yup.  Ya got me there.  Good thing I built this one specifically to avoid using a shield.</p>
<p>But well noted.  I&#8217;ll use leetle capacitors should I decide to make an Arduino-compatible into which I intend to plug a shield.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1513</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
