Thinking Too Much

This is how things get out of hand...

I was making a clone of my hard drive to keep at my sister's place. (I do this in case my ex-wife ever decides to come by and burn my house down.) As I'm sitting there doing other things, I notice the computer reboot while there's still two minutes to go on the cloning countdown timer.

"That's weird.", I thought, "That's probably not a good thing."

Sure enough, trying to boot from either drive produced an "OS not found" error. Everything was still on the drives, they just wouldn't boot. So I tried the standard things: Windows recovery disk, rebuild the MBR, rebuild the boot sector, etc. Eventually the cloned drive started to boot, but I wasn't real comfortable with that since the cloning hadn't entirely completed. And the original drive still wouldn't boot.

Since I'd been using Windows XP, I figured this was a sign to finally upgrade to Windows 7. I knew I would have some compatibility problems - particularly with my Strobe XP200 scanner that I use to scan my business records - but I was going to have to do it eventually so it might as well be now.

I got Windows 7 up and running and transferred all my files. Sure enough, the Strobe gave me a problem: the hardware worked fine, but the PaperPort version 9 software that organizes all the scanned images wouldn't work. I decided not to buy the newest version from Nuance for $200 since I already knew they had removed some of the more useful features (to me) of the software. Instead, I booted from my cloned drive and used my old version of PaperPort to translate all their proprietary .max scan files into PDFs. Then I brought the PDFs over to Windows 7 and used the Windows Explorer thumbnail view and file preview features to replicate 90% of the features I used in PaperPort. After that, I figured I had all my Windows 7 issues resolved.

So I was happy until I started the Microchip MPLAB IDE, recompiled my source for the XuDL data logging board, and then found I couldn't flash the PIC chip because my ICD 2 programmer wasn't being detected.

"That's weird.", I thought, "That's probably not a good thing."

An upgrade to the newest software didn't help, so I went looking on forums for compatibility problems between Windows 7 and MPLAB. That's where I found out that only the ICD 2 with a part number of P/N 10-00397 supports 64-bit drivers. I turned over my ICD 2 and saw P/N 10-00319. Doh!

Now, I could have solved this problem (as well as the PaperPort problem) by running the program on Windows XP inside of VirtualPC. But VirtualPC takes a bit of time to come up and the whole point of having a Windows 7 machine with 8 GB of memory is to do things fast. So I decided to upgrade my Microchip programmer. I looked at a newer ICD 2 or ICD 3, but they were nearly $200. I settled on a PICkit 3 for $45 and an RJ-11-to-ICSP adapter for $10. Hopefully, those will replace the functionality of my old ICD 2.

While I was on the Mouser site ordering the PICkit 3, I decided I needed to purchase a variety of 0603 resistors. (I might as well amortize my shipping costs over as many items as possible.) I have a lot of the larger 0805 resistors, but my new designs are using the smaller 0603 and I don't have many around for when I'm prototyping. But there are 168 different resistor values, so which ones should I get to have a reasonable assortment for most of my needs? By soldering resistors on top of each other, could I use a small set of resistance values in parallel to synthesize values in the entire set? If so, what are the best resistances to use that will get me closest to each of the standard resistances?

I fiddled around with the problem by hand for a while, hoping that a closed-form solution would pop out. No such luck. But I did have one insight: whatever the best resistors were for a given decade range of resistance, they would be scaled by a power of ten in every other decade range. So if a 160Ω resistor is built with a parallel combination of a 240Ω, 620Ω and 2.4KΩ resistors, then a 1.6KΩ resistor would be built with 2.4KΩ, 6.2KΩ and 24KΩ resistors. (I figured that I wouldn't want to solder more than three resistors on top of each other.)  I came up with a Python program to compute the best resistor values as follows:

  1. Select three values from the 24 root resistor values and replicate these in each of the seven decade ranges of resistance. For example, if 1.2Ω, 6.8Ω and 8.2Ω were selected, then 21 resistor values would be generated: 1.2Ω, 6.8Ω, 8.2Ω, 12Ω, 68Ω, 82Ω, 120Ω, 680Ω, 820Ω, ... , 1.2MΩ, 6.8MΩ, 8.2MΩ.
  2. Synthesize all possible resistance values that can be created by paralleling up to three of the 21 resistance values.
  3. For each of the 168 standard resistance values, find its closest match in the list of synthesized resistances, calculate the percentage of the mismatch, square it, and add it to the total error for the entire set.
  4. Repeat the preceding steps for every possible combination of three root resistor values. Then select the combination that has the lowest total error.

After running the Python program for a few minutes, the best resistor values that popped out were 2.4Ω, 6.2Ω, 9.1Ω, ..., 2.4MΩ, 6.2MΩ and 9.1MΩ. Here's a graph of the percentage errors for all the standard resistor values w.r.t. their closest, synthesized values:

The synthesized values are all within ±4% of the standard values until you get into the megaohm range. Then things get a bit hinky because there aren't any larger resistances that can be used to trim down the synthesized values. Still, it's not bad: using only 21 resistor values I can synthesize 159 of the 168 standard values to within ±4%. A strip of 100 Panasonic 1% 0603 resistors costs $1, so the total cost is $21.

So, did I buy them? No way! You can buy kits with a wide range of resistors for as little as $40. It just isn't worth the effort of stacking and soldering resistors to save $20.

So why did I waste a bunch of time doing this academic exercise? Because once I'd asked the question, I couldn't unask it. It's like seeing a hole in the ground and then digging all the dirt out of it even though you know the rabbit has long since left the vicinity. Because I just had to know.

Comments

Nice analysis, even if it's not worth the effort of actually using the data :-).

I know what you mean about not being able to unask the question. I'm a very inquiry-driven person myself; the problem is aligning the questions I pursue with my larger goals...

 

Yeah, that's the trick. You need to stay on your path, but still find a way to take deviations from it. 

How can the net amount of entropy of the universe be massively decreased?

Hah! Now try un-asking that one! MultiVac couldn't even do it!

You said, "I was making a clone of my hard drive to keep at my sister's place. (I do this in case my ex-wife ever decides to come by and burn my house down.)" You nit-wit, now your ex-wife will burn down both your's and your sister's house!

Doh!

In real-world applications this would tend to improve the overall tolerance of the final resistance values. 5% and 10% resistors, for example, are typically manufactured together and then tested to determine which tolerence band they fit into. Thus, a pack of 10% resistors won't have any resistors within 5% of the marked value. When you serialize or parallize them the tolerances either sum (i.e. stay within the tolerance range for the final value) or cancel each other out (which is better), depending on which side of the 5% exclusion band they fall into. If I were you I'd take this into account when generating your table, any time you encounter a value that can be achieved in two or more different ways then choose the combination that has resistors of most similar value to increase the chance of a tolerance match.

This is a great idea...I'm just not sure about the numbers of resistors.  How many different values would be needed if I wanted a maximum of 2 stacked resistors with +-5% coverage for all the standard values?

Right now I am using 64-drawer cabinets to hold my resistors...mostly through-hole stuff.  I have filled two of the cabinets...about 90 drawers are standard value +-5% resistors, while the rest are +-1% resistors in the more common values.

I want to get a good selection of 0805 and 0603 resistors, but I don't have room for another pair of cabinetts.  I figure that I can easily split the drawers so that I can put 0805 and 0603 resistors of the same value into the same drawer.  I have about 40 free drawers right now...could your python program be used to find me a solution?

If you only want to parallel two resistors, then using the values 2.0, 2.7, 6.2 and 9.1 will get you within +/-6% until you get into the MOhm range. If you use the values 1.3, 3.0, 4.7, 6.2 and 8.2, then it's just a tiny bit better (+4% / -6%).

Why do you square the percentage mismatch? just to get rid of the sign ? or?

Yes, to get rid of the sign. You could also use the absolute value.