Friday, September 28, 2012

The institutionalization of OSHW -- a disturbing trend

Yesterday the Open Source Hardware Summit was held at Eyebeam in New York City.  While there was a lot of awesome projects, in this post I want to write about a disturbing trend of some of the largest players.

Open Source Hardware

First, just to set the stage, as I'm sure everyone in the community knows, MakerBot is closing some of the files in the Replicator 2.  AFAIK what portions exactly were not announced until the summit, and to credit Bre (or cynically, to credit him for backpedaling), it turns out that only the plans for the steel structure and the GUI will be closed.  But once that door gets opened...

This was not the only presentation on this topic... in fact there were several talks presenting an attitude along the lines of:  "Well, 99% of our customers just change the software so as we explore business models, maybe we'll just open source that...".  For example, in the keynote speech (of all places) Chis Anderson mentioned that some of his planes' extruded parts are not open because nobody but knock-off fabricators have extruders.  Well, nobody except this guy who made a DIY extruder I guess.  And couldn't you print them in a Reprap?

Ok fine, I understand the need to discourage knock-offs.  But if you do this you are NOT 100% Open Source Hardware.  You are trading the openness of some aspects of your design for the ability to make a good profit on your work, which you use to fund more cool projects!  Its actually great in many ways.  You've rediscovered the motivation behind intellectual property.  But let's not lie about it.  Let's be honest and let the customers decide whether your product is open enough.

FCC Compliance

A bit later, a representative from Sparkfun stepped up to speak about FCC compliance.  He explained to us what he called the "good news":  its actually only about 1000 bucks to get tested (ignoring your time and effort to get it done) if you are an "unintentional radiator" (that is you don't use wireless).  If you do, I may misremember but its 10k USD.  And by the way, kits, partial products, etc are not exempt so pay up!  Also, amazingly enough if you make 5+ items for your personal use, pay up.  But 1-4 is fine.  Of course this is only for the USA.  There's a similar but different regulatory body in every other country.

A chilling effect settled over the crowd.

All of this was delivered in a happy cheery tone because as we learned, "straight from the horse's mouth" so to speak, this guy previously worked for the FCC for 5 years!

I can't resist a momentary troll:  I'm imaging this guy running around the OSHWA demo area on his mobile reporting us to his cronies in Washington.  Sorry Sparkfun, but you should not hire an ex-FCC guy to do the FCC-compliance job.  You should hire a protestor.  And not just to prove a point -- but because enthusiastic people tend to magnify their jobs.

Did you sit under that LED dome? -- turn it off -- it was made from 5 identical driver modules.  How about those fabric artists and electric ink?  Turn 'em all off.  And there was an amazing talk about testing radioactivity levels in Japan after the nuclear disaster  And not surprisingly, it was discovered that the Japanese government was not reporting these radiation levels.  If this had happened in the USA, as far as I can tell the FCC could have shut them down under the 5 unit rule.  The problem with a technicality is that it can and has been used to keep the truth from the public. 
 While clearly some small oversight to ensure reasonable electronic emissions is needed for mass consumer devices (say greater than 50k units) the 5 unit rule (and many others) is clearly obsolete.  After all, I can get 10 PCBs from Seeedstudio for about 15 bucks.

You may roll your eyes a bit, but these sort of things really do have "a chilling effect".  In other words, an effect not instantly obvious but one that is certainly dampening innovation in America.   I would imagine that the effect happens most especially in areas such as education or outreach.    People won't go the next step and bring these PCBs to a school, etc.  Why get fined 7000 bucks for volunteer work?  And of course schools are incredibly sensitive to possible litigation, since the cost comes straight from the pockets of the townspeople who hire principals.

And even if in practice nobody will see your prototypes at home, let me point out that it is a very dangerous social situation to have citizens living in a constant state of breaking the law.

USB Connectivity

Next, we got to hear about USB from DangerousPrototypes.  Ian at least presented the information mostly neutrally.  (summary: 2000 bucks to get your company registered; nope nobody can sell you an ID).  However, it is clear in his opinion that squatting on an address is for hack-ups and should only be done by raw (never sold) prototypes.

Ian, I guess you forgot about sit-ins as a method of protest.

At an OSHWA summit meeting, I would have preferred a more critical treatment.  I have done a lot of research on this, since my Lightuino 5 board uses a USB microprocessor.  Everything presented is easily discovered on the web.  But unfortunately, the key issue was not addressed and barely mentioned:

If you choose to squat (vid: 0xF055 FTW!) is there ANYTHING the USB consortium can do about it?

Currently the answer seems to be no -- they have no legal control over those particular bits in the USB protocol.  In fact there seems to be no mechanism to even gain such control (hooray!).  And history seems to prove this out; all that they have ever done is kicked companies out of the consortium (in fact one such company is still selling VID/PIDs).

But if I was invited to take up ten minutes of 450 peoples' time, I would have presented a legal opinion.

So, its getting pretty clear that the many of our most prominent OSHW members and companies are growing up.

And let's be clear, I do not blame them for following these laws -- it is important to be a productive member of the society you choose to live within.  But I blame them for following them enthusiastically.  A person's ability and proclivity to make things is literally as much a part of us as is our hands.  Similarly, economic theorists affirm that a person's right to trade goods is fundamental to any society.  Please do your part to ensure these freedoms are not taken from us.

Tuesday, September 18, 2012

A Bit on Bitcoin

Bitcoin is simultaneously an amazing and very scary technology.  It has a lot of potential, but seems to be doomed to repeat all the mistakes and scams that have been seen in traditional banking.  This guide is for people who are interested in Bitcoin but still wondering about it.

Why use Bitcoin?

In a nutshell, it is essentially internet cash.  This means:

1. It transfers value extremely efficiently worldwide.
2. It is usable for intangible goods like music or video game items.
3. If you are very careful, transactions can be anonymous.

It is quantity limited (more like a commodity then a modern currency) and stored/transferred via a peer-to-peer internet protocol.  This means:

4. It is likely a good long-term store of value.
5. Your ability to spend cannot be "frozen" or otherwise inhibited, other than by depriving you of internet access.
6. The peer to peer nature means that it will be extremely difficult to disrupt, even for large organizations.
7. It can be transferred across borders during times of strife easily since it it possible to hold the "combination" to your bitcoins in your head.

So, if you are looking for a shelter against high inflation, a mechanism to inexpensively pay for goods from China (or other locations), or just want a "rainy-day" nest-egg, then Bitcoin might be for you.

However, please note that Bitcoin is still an experimental currency, so do not purchase more then you can afford to lose!

Is it legal?

This is a strange question because in this world truly "new stuff" is assumed legal and needs to be explicitly declared illegal.  For example, it was not necessary for the Wright brothers to get a pilot's license to fly their airplane and TiVo skirted copyright issues to bring DVR technology to the world without getting a legal ruling a-priori.  

A better question is whether it is likely that Bitcoin will some day be declared illegal.

While there has been no determination of its legal status in any country (edit: looks like an official in Finland affirmed its legality in that country), it is generally considered by lawyers to be legal to hold bitcoins.  Essentially Bitcoin can either be considered a commodity, a currency, or pedantically just a bunch of (uncopyrighted) digital bits!  If a commodity, certainly it is legal to own just like you can buy a bushel of corn.  If a currency, no issue; it is legal in most countries for citizens to hold another country's currency.  And while Bitcoin is not a particular country's currency, in the USA (for example) there are ample instances of corporations issuing currencies, like the Disney Dollar or the Second Life Linden Dollars.

Is Bitcoin a deflationary currency, and does that presage disaster?

Right now, Bitcoin is in fact highly inflationary -- a lot of new coins are being created every year.  However, the inflation rate will decrease as the years go on and eventually stop altogether.

If you are like me, you have been inculcated to believe that a deflationary currency is "evil", causes recessions, and even may have caused the great depression.  Keynesian economic theory claims that a deflationary market causes people to stop consuming to the point where the economy shudders to a halt.  But the "Austrian" school of economic thought questions this gospel for many reasons:

First computer technology is massively deflationary; if you haven't noticed you can read about Moore's law which states that if you just wait a few years, you'll get a much better computer for the same price (or the same one for half price).  And I'm sure people have deferred purchases to wait for the "next great thing" (I know I did).  But did this deflationary environment hamper technology innovation?  In fact, IT technology's contribution to GDP growth in the USA has equaled the contribution of all other sectors combined.

Second, unlike what we learned in school, it is now theorized that the recessions of the 1800's that culminated in the great depression were not in fact caused by the gold standard, but by over-regulation of the currency market.  See this lecture (start a few minutes earlier then the link to get the full picture).

Finally, an argument against a deflationary currency like physical gold is that in practice it cannot represent all other economic activity.  The reason is simply because if the price of gold increased to the point where it DID represent all other economic activity, it would require an infinitesimally small amount to purchase something cheap like a piece of gum.  This amount would be too small to coin!  However, Bitcoin does not have this issue; it is divisible by 8 decimal places today, and in fact a reasonably painless protocol change could extend this by as many more decimals as needed.  Therefore even if all but one bitcoin (or .1 bitcoin, etc) were taken out of circulation, there would STILL be enough to simultaneously represent both the smallest transactions and all the economic activity in the world.

Whether you believe these arguments or not is immaterial -- you need only recognize that Bitcoin is a currency with unique properties; properties that have never been tried before.  Therefore it is not possible to look at prior deflationary currencies and conclude that Bitcoin behave similarly.

Is Bitcoin itself a ponzi or a scam?

Bitcoin has been called a ponzi scheme because a bitcoin has no inherent value (and the early adopters "mined" a lot before others jumped in).  But in fact unbacked paper money also has no inherent value, so are they a Ponzi scheme?  (actually, they often end that way...)

Additionally, while value-store commodities like gold and silver have industrial use (that is, "marginal utility"), the price of these commodities so far exceeds that justified by the intrinsic "marginal utility" value that they might as well have no inherent value.  Is investment in gold and silver a Ponzi scheme?

A Ponzi scheme or other scam is not defined simply by an unfortunate massive loss of value, but by whether the scheme provides or attempts to create any value or provide any service.  Like the Spruce Goose, if it attempts but fails it is not a ponzi or scam -- it is just a mistake.

Bitcoin in fact has tremendous "marginal utility".  It is both a "coin" and a worldwide, free, instant transfer, 10-minute confirm transaction network.  It therefore out-competes other transaction networks like Visa/Mastercard (worldwide but exclusive, 2% fees, instant, 30-60 days to confirm), bank transfer (worldwide exclusive, 25-30 USD + 1-3% currency exchange fees, 2-3 business day transfer, 30-60 day "confirm" with the never-ending low-but-non-zero chance of a "clawback"), and finally Paypal (worldwide exclusive, 2.5% + .30c + 1-3% currency exchange fees)

Additionally, Bitcoin is much easier to get started in then these other systems.  Since no credit is extended, anyone can create a Bitcoin "account" (wallet) instantly and with nobody's permission.

Finally, Bitcoin is/will be very valuable for the purchase of digital commodities like music, video game items, etc.  Traditional transaction networks essentially stop fraud with "chargebacks".  This is the ability to reverse a transaction once the theft is discovered.  The reversal passes through every step of the financial network like a hot potato and ultimately lands on the merchant.  The merchant theoretically has law enforcement follow the purchased goods to the address they are being sent to and arrests whoever picks them up.  But this technique does not work for immaterial items -- the items are not sent to a physical address!  In fact, so much fraud occurs in certain digital commodities that some traditional financial service providers (paypal, ebay) refuse to allow purchases of them.

The genesis of this unfortunate situation  -- that financial networks are forced to use the chargeback mechanism -- is because all the information needed to charge a credit card or access a bank account is passed to merchants and middlemen every single time money is spent.  Therefore many instances of fraud are not the account holders fault but actually caused by some person working in the institution that was paid. 

This is the digital equivalent of storing your money in a safe, but telling every single person you pay your combination and letting them take out the cash!

Bitcoin solves the fraud problem by NOT telling every payee the combination of the safe.  Therefore if someone steals your combination, you have only yourself to blame.  Instead of issuing chargebacks that end up costing the merchant, you must report the loss and hopefully recover your own money when the thief is caught.  Or more likely, responsibly safeguard your combination so your money is not stolen in the first place.

So Why Do I Hear About So Many Hacks and Scams?

In fact, the Bitcoin network and currency has never been "hacked".  It is secured by the same advanced cryptographic techniques that secure your normal electronic bank transfers.  However, online services that use bitcoin have been hacked.  This is equivalent to saying that people have broken into banks and stolen money, but that the money itself has never been counterfeited.  So Bitcoin is thought to be more secure then paper dollars...

But bitcoin is a fledgling currency.  Teenagers from China, hackers from England, and moonlighters in NYC have built currency exchanges.  These people perhaps were not the best choice for the public to entrust with the handling of hundreds of thousands of dollars.  Additionally, one of the features of Bitcoin is that, like cash, it can't be taken back without asking. And, also like cash, it can be used anonymously if care is taken to access the internet anonymously.

These two features are very convenient on a daily basis for legitimate use.  Yes even the "anonymous" feature.  While waiting in line at the checkout counter, have you ever suddenly grown fearful and embarrassed that your credit card would be declined for some reason?  Perhaps you were out to lunch with your boss.  But if you held cash you carry peace of mind, secure in the knowledge that you can pay.  Requiring proof-of-identity (and by extension declining payment from some identities) will always admit the uncertainty that some glitch in the system will halt a perfectly credit-worthy individual's ability to pay.

But the media amplifies the problem.  In fact, to date I've managed to avoid opening accounts with Chinese teenagers, investing in obvious Ponzi schemes, contributing to scams, or losing a single Bitcoin.  It was not hard.  It was obvious from the beginning that money should not be kept on Bitcoin exchanges like they were bank accounts due to "counterparty" risk.  These are not FDIC insured institutions and do not claim to be.  In fact, the great advantage of Bitcoin is that you can easily and safely hold your own money.  So hold it; don't hand it to someone else!

Honestly, given how obvious the scams have been, the real question in my mind is why other people are falling for them.

OK, I'm Convinced.  So How Do I Get And Hold Bitcoins?

You need to start doing your own research now.  But...

Its really easy to get a few Bitcoins in an account on your Android phone (or desktop web browser), but these should be your "spending" account -- like the cash in your wallet, if they are lost you should not be too upset.  Try for one (they also have a great Android app).  Sorry iphone users -- Apple feels Bitcoin threatens their monopoly on phone payments and so have removed all Bitcoin apps from their store.  [Personally, I think you should research this and other heavy-handed Apple tactics, realize that personal choice is more important then incremental convenience and put your iPhone up on ebay...]

Compared to buying a wallet or purse, its a lot harder to buy, take delivery of, and install a secure safe for holding valuables -- and its a lot harder to do the same for Bitcoin.  Well, actually, if you choose to trust just one service, it can be quite easy.  Please research "bitcoin paper wallet" for a primer on the subject.

An intermediate option is to download and use the original Bitcoin client.  This client is capable of storing an encrypted wallet on your computer, and you can back that wallet up.  By the way, you actually only need to back up any wallet once.  The "bitcoin wallet" is actually more accurately described as the key to a safe held on your behalf in a distributed peer to peer network.  That is, if you back up your bitcoin wallet, deposit more coins, and then restore your wallet from the backup you will NOT lose the coins you just deposited -- they are still in the safe, you just restored the file containing the safe's key.

But if you delete this wallet (this key), ALL YOUR COINS ARE LOST (so make backups)!  If you forget your password, ALL YOUR COINS ARE LOST (so don't forget it)!  This is not document "encryption" where if you ask the company that produces the software really nicely they'll crack it open for you.  This is more like if all the energy that the sun will EVER produce was used by the largest, fastest, most efficient computer theoretically possible, the sun would burn out long before it found the key to the safe containing your coins.

On the bright side, this makes it very hard to steal someone's coins.

Good luck Bitcoiner!

Tuesday, June 5, 2012

Why abstraction and open source is valuable even in small embedded programs: An example using the Arduino SPI library

  Since the object oriented "revolution", abstraction and code reuse are the bywords of modern software development even when programming in non-OO languages.  But use of these techniques has lagged in highly embedded development due to perceived inefficiencies compared to C and assembler.   Yet embedded development can be incredibly detail-oriented and time consuming.  It took a bug report discussion  and listserv conversation (you can read the originals by following the links, or just read my summary after the break) between a couple of highly experienced engineers to figure out the best solution for an 8 line chunk of code that on the surface is quite simple.  It just enables the SPI bus.

  This experience shows the power of FOSS and abstraction in microcosm.  First, judging by the discussion, any one of these engineers (including myself) working alone would likely not have figured out the best solution.  This would have meant revisiting the issue some time in the future.  And second, once this time-consuming, detail-oriented problem was solved it never needs to be solved again.  This (added to countless similar cases) creates tremendous efficiencies affecting (judging by hits to this blog) engineers across the entire world.  Neither of these effects would have taken place in classic closed-source development.

Wednesday, May 30, 2012

TLC5940, TLC5941 and Arduino

The TI TLC59xx chip family are constant current LED drivers that have some pretty impressive stats.  I'm experimenting with the TLC5941 which has 16 constant current channels, 80mA sink capability per channel, 17v maximum LED voltage and 4096 PWM intensity levels per channel.  If you want to use it, here's an Eagle schematic and footprint to get you going:

And here's a photo of 2 quad chip driver boards that I made.

Packing those features into such a small chip has created a device that has got some nasty traps that are not described in the datasheet (or hard to understand) and so it is easy for beginning hardware hackers to either fry a couple of chips or just give up in frustration.  If you are looking into using this chip, check out my experiences after the break.

Friday, May 4, 2012

If you wish to make an apple pie from scratch you must first invent the universe

I recently googled this Carl Sagan quote using the search "if you wish to make an apple pie from scratch meaning" and was pretty dismayed that the top result not only misquotes him but comes from a yahoo Q&A site with the following "best" answer:

"Sagan was merely saying all the elements of an apple pie made from scratch [reduced to the lowest common denominator] are elemental to the universe and the universe had to be there before an apple pie could be made from them.

Hardly profound, though it's often quoted."

This result probably says more about the mental acuity of the analyzer then about what is being analyzed.  Unfortunately answers are "closed" so nothing can be done about the yahoo page.  So I shall give it a shot here and if you like my response please link/forward/facebook/google+ this posting so we can collectively knock Yahoo off of the top spot!  So let me start over:


"If you wish to make an apple pie from scratch you must first invent the universe"  Carl Sagan

You can hear a clip of him saying it straight here:, but you'll probably by a lot more entertained by this remix Symphony of Science: A Glorious Dawn

Literal Meaning

Just so we are all on the same page, the simplest level of interpretation is that the baker's fundamental ingredients are not fundamental at all.  Apple trees produced the apples, wheat plants produced the flour in the crust, sugar cane produces the sugar.  And of course this idea must be recursively applied.  What made the chemicals and matter that these plants used?  The big bang and stars made them out of more fundamental particles and energy.  What made the energy the plants used to arrange the matter?

This is essentially as far as the original "answer" goes,  But this is a trivial analysis.

Let's take a Bite out of this Pie

A great way to analyze a quote is to first make your analysis, and then modify the original quote with a different one that matches your analysis.  Then compare the two and see what the original has that's missing from the new one & what the new one has that's missing from the original.  So here's what Sagan might have said if he was as smart as the author of the "best" answer:

1. God made the universe, you just rearrange it.

Here I am clearly differing by introducing "God" into the quote.  Its possible that Sagan's personal beliefs precluded this formulation (I don't know or care).  But the important point is that the omission of "God" in his quote aims it directly at humanity, at us.

So let's leave God out of the quote:

2. You can't make stuff from scratch because you're always using other stuff that's already been made.

This formulation in the negative is limiting -- but is that what Sagan wanted to say?  That you CANT make an apple pie from scratch?  His formulation is in fact enabling; "if you wish to make...".  He believes that someday we will truly make a pie from scratch and is seeking to define what that means.  By formulating the sentence positively, the quote is infused with the hope and promise of humanity's potential.

So let's reformulate in the positive, but tweak the noun:

3. If you wish to make a particle accelerator from scratch you must first invent the universe

Who is the "you" in this quote?  By choosing something as prosaic, as domestic as an apple pie he implies that the makers shall someday be, well, anybody and the making shall be an everyday occurrence.  By choosing "particle accelerator" I pretty clearly point this at a small esoteric subgroup.  He is also saying that the most common of thing are actually made up of complex ideas.

4. (and finally the misquotation) If you wish to make an apple pie from scratch you must first create the universe.

What's the difference between "creation" and "invention"?  Well, a potter can "create" a clay pot (for example) by throwing clay on a wheel.  But how can she "invent" one?  She really cannot; its already been invented.  But she can invent a new kind of pot.  With the term "invent" Sagan is clearly suggesting not the mechanical act of creation but the mental act of invention.  It is not enough for us to create the pie from fundamental particles; to truly make it "from scratch" we must invent (and therefore understand) the entire mathematical/informatic/computational underpinnings of the universe that either must have been before the first particle existed or that was forced to be by that particle's existence.

Actually, I'm still struggling with what he meant by invent.  Since the universe already exists it cannot really be invented again.  Was he suggesting the actual invention and subsequent creation of new universes by humankind?  Or was he implying that inventing the universe would allow the controlled creation of space and matter within our existing framework?   ...quantum mechanics predicts that particles and antiparticles are spontaneously created all the time...

Regardless, in this one sentence Sagan has left us with a large, tasty slice of his hopes and dreams for the future of science and humanity!

Friday, February 10, 2012

AVRez: A Simple Arduino API for other chips

The Arduino IS its software library.   As I'm sure you've seen on the web, its pretty easy to breadboard an Arduino -- and to do it for about 10 bucks -- so Arduino is not really about the hardware.  And the IDE is no Eclipse or Emacs.  While this may actually be an advantage for complete beginners :-) it cannot be the IDE that sustains the Arduino's popularity.

The true secret to the Arduino is in its software library -- which AFAIK actually came from a project called Wiring.  Here's a quick quiz to prove my point. What does this do:

Huh??? 99.9% of you will say (for .1% who get it right and don't get my drift, your next challenge is to write the equivalent of analogRead(11) without looking at the datasheet).

Well if you happen to have read the Atmel 328 processor spec, and pored through the avr-gcc io328xxx.h header file you'd know that this sets the bit corresponding to PB2 in the data direction register to high.

Make sense yet?  No?  Let me make it clearer.

pinMode(10, OUTPUT);

That's the Arduino/Wiring library version of the same code above.  And pretty much anyone who understands that pins must be designated input or output can understand that line.  You don't even have to be familiar with the Arduino/Wiring library!  Its the magic of self-documenting code. 

So when you go digging around in "AppNotes" and other example code, don't be fooled by the garbage you find.  Its not "real" embedded programmers that directly use unreadable archana like "ADMUX |= 1; ASCSRA |= _BV(ADSC); while (ADSCRA&_BV(ADSC); result=ADCL | (((uint16_t)(ADCH))*256);" (that's how you read an analog pin PB2 by the way).  Its actually just the "real bad" ones :-).  Or institutions who have a vested interested in locking you into their platform.

In fact the only real confusion with "pinMode(10,OUTPUT)" is identifying what "10" means.
This is why I've decided to make a super simple library that I call "AVRez" that provides a similar API for other chips.  You can look at it at here.  This library is intended for use with chips that are not "Arduino" compatible so a few changes had to be made made, most especially in the pin out.  However the basic API is instantly understandable to anyone whether they know the Arduino APIs or not.

With this library, for example, you can call "pinMode(pinB2, OUTPUT);".  The only visual difference between this and the Arduino library is the constant "pinB2".  Instead of making up separate names and numbers for each pin, I've chosen to use the pin names exactly as described in the datasheet.  This will make code running on "barebones" processors more understandable.

Often performance is cited as the reason registers are directly bit-banged in "main" code.  But this argument is better understood as simply a criticism of existing abstraction layers -- just because one abstraction layer is inefficient does not mean all must be!
In AVRez, for performance reasons a pin name actually expands to a complete list of all registers that are needed to manipulate the pin.  Then the macros "pinMode", "digitialWrite", etc just use the registers that they needs and the rest get dropped by the C preprocessor.  This allows the AVRez functions to be quite efficient; for example "pinMode" ultimately becomes just "DDRB |= _BV(PB2);" which is about the most efficient "C" implementation possible (but actually, technically not quite correct.  It should be "cli(); DDRB |= _BV(PB2); sei();". Can you figure out why?  In fact this issue is actually why the AVR processor has 2 special commands just for the job that are named "sbr" and "cbr".  Compare this to the implementations you see in the Arduino core library...

But one issue with this approach is that the name "pinB2" does not have a type.  So you can't store it into a variable like this:

int pin = pinB2;

But it would be quite possible to add a pin enumeration to the library and therefore fall back to something a bit less efficient.  Then you could use something like:

int pin = pinIndex(pinB2);  // Or maybe "= pinB2index;" is clearer...
pinMode(pin, OUTPUT);

One question for thought before I sign off: what is the MOST efficient way to translate a pin enumeration into code?  What we see in the Arduino library ain't it! :-)

Tuesday, January 31, 2012

Ubuntu 11.10/Gnome 3.0: Surviving the transition!

I've had significant issues with the new Ubuntu GUI and Gnome 3.0; ranging from irritations (difficulty to create launchers) to bugs (mouse stops responding).  If you are googling around I'm sure you've seen the near universal cry of dismay.  If there is one message to send Canonical (if any of you ever read this posting) it would be that while its a great idea to "dumb down" the interface so a single GUI will work between your desktop and touch machines, you can't disable the advantages available through a mouse interface!

Anyway, here is what I did to make it workable.  These are mostly culled from various web sources; they are not my original work.

Friday, January 27, 2012

Transdescending Arduino: Going cheap and small

The Arduino is great; a microController you can actually do something with for 30 bucks!  Ok, but your train layout needs 5 of them ($150), your home sensor network needs 10 + $40 xbee cards (clocking in at $700!).  Or the mere fact that your want to KEEP your projects around means that you get nailed for 30 bucks over and over again.

But wait a second... the AVR328p is a 3 dollar chip!  And the AVR ATMega48 (pin compatible but with a LOT less space) is 2 bucks (for 10)!  And if your requirements are extremely minimal, there's the ATTINY13 which comes in as little as 60 cents -- but in an inconvenient package (you'll be better off spending another 4 dimes and getting one for 1 buck).

Let's hack up a bunch of these chips so next project we'll have lots of choices...

Note: If you've figured out the hardware part and just need some software help check out this posting: AVRez -- "arduino" style APIs for other chips

Friday, January 20, 2012

DIY PCB SMT Breakout board fabrication: Results

In the last posting I described how I made a few PCBs to act as SMT breakouts.  I've discovered that this seems to be a pretty ideal job for DIY PCB work!  To mount thru-hole stuff, you need the hole -- and that means hand drilling... but a small breakout board can be done on a single side, and its possible to use .1" Right Angle headers soldered onto an oval thru-hole pad so you don't even need to drill the hole for the breakout header.

In my last posting I finished with the circuit board ironed onto the blank PCB.  It turns out that the final steps are quite easy.  First you get some etchant.  I used ferric chloride from Radio Shack, but I wish I had used muriatic acid and hydrogen peroxide as it seems slightly better for the environment.  I poured the etchant in a leftover food container (now forever dedicated to PCB etching) and left the boards in for about 30 minutes.  I used a twisted wire hanger to keep my fingers out of the etchant:

Then rinse the board in lots of water, and leave the tap running to dilute any drips of etchant solution that go down your drain.   When you're done, put the top on the container (make sure it seals!) and store for next time.

To remove the laser printer toner, I tried a few paint removers, liquid sanders, etc.  Nothing really worked.  It turns out that Acetone (nail polish remover) is required.  Its available in the paint section of hardware stores, and is absolutely amazing at the job. 2 swipes with a rag daubed in Acetone cleans the toner like wiping milk off a table!

Next I soldered the parts on to the PCBs using a toaster oven.  I was concerned that the lack of a solder mask might make the solder bridge across PCB pads because its impossible to keep the solder paste onto pads.  In fact, I don't even bother, I just paint a thin line down across all the pads in a row (see my earlier post on DIY SMT soldering techniques here).  But in fact, the solder balled up nicely as you can see here:

These are tiny SOIC-8 and SOT-23/5 parts.  I left the chip off the rightmost SOT-23/5 to see how well the solder wicked onto the pads.  Before putting it in the oven, the space between all the pads was completely covered with solder paste -- the wicking works great!

I cut some of these boards with a hobbiest bandsaw, like you can get for $200 at Home Depot.  But its even easier to cut them by scoring the front an back with a ruler and then breaking them against the edge of  table (preferably metal).  Place something hard (like a metal or hardwood block) on top, grab the protruding board with pliers and then crack it by rotating the pliers downwards quickly.

One surprise was how fine a pitch may be possible.  I had originally "designed" this board for professional fabrication and I accidentally left some tiny lettering on the board.  Amazingly, it transferred to the PCB perfectly well!  Here is a close up:

As you can see, by the ballpoint pen I put in for scale, the height of these letters is less then one millimeter!  I will need to go back to the file to check, but I'll bet that the line width is just a few mils (thousandths of an inch) wide.  Many professional PCB houses won't do less then 8mils!  Of course, they require repeatability across hundreds of large boards -- my goal is to get a single small breakout board out of a panel with a half dozen attempts.

So basically, if the transfer works without smudging or distortion you can get amazingly fine detail.  And from my limited experience it does tend to do so reliably across portions of the board that can be 2 square inches in size.  This makes me believe that it may be possible to home fabricate chip-scale BGA breakout boards -- at least for small BGA packages.  I have not discovered anyone who has tried it yet; so I think that will be my next experiment (as soon as I find a "fun" BGA chip)!

EDIT:  Here's a photo of the SOIC8 installed on a PCB.  I think that its better to put all the pins in a single row, rather then the DIP configuration because that gives you the other side of the breakout board to use to make your circuit!

Also note that no drilling is needed!  Get right angle breakaway headers and then solder them to the (undrilled) thru hole pad.

EDIT 2:  Here is a photo of a SOT-363 chip with a 2 mil circle indicating pin 1.  To get an idea of the size, the circle is indicated by the lead of a standard 1/4 watt resistor. As you can see the 2 mil line width was etched perfectly!

Friday, January 13, 2012

DIY PCB fabrication; Breakout Board Toner Transfer Experiments

Using modern components in PCB circuit board design essentially requires the use of small surface mount packages.  Testing these components can be costly and time consuming if you need to have a break-out-board professionally fabricated for every component.    It is possible to hand-solder extremely thin magnet wire to individual leads of a SMT package but that is a very painstaking process.

It would be much easier if individual PCBs could be hand-fabricated for the task.  I dug around on the web and DIY PCB fabrication for very small parts seems quite tricky; most people use home PCBs to make larger circuits out of thru-hole parts.

However, even if multi-chip SMT designs are not feasible, it would be very valuable to be able to rapidly fabricate single chip breakout boards for SMT parts (for noobies: a breakout board is a PCB that simply brings all the pins in a SMT chip to a male header that can be plugged into a solderless breadboard).  Especially small parts; if you are putting a TQFP-144 on you board there are places where you can buy breakouts.  And there are fewer footprints so you could build up a "library" of breakouts.  But there are tons of different packages for components ranging from 2 to 32 pins!

Making these small-pin count PCBs might be feasible (where large SMT designs are not) for several reasons.  First, the PCB will be quite small, allowing you to panel multiples "tries" onto a single DIY board.  You only need one success!  Second, the routing will be pretty short and simple.  If the pins are placed on either side of the chip the routes will be short and on a single side (so you can try the same circuit on both sides!).  Finally, I think that right angle .1" headers could be used in place of straight pins, so the final board would not need to be drilled.  This will save a lot of time (and painstaking work).

Here are my first attempts (ever) to use the toner transfer method to put a mask on copper PCBs.  I panelized 6 SOIC-8 and 6 SOT-23/5 breakout boards onto a space about 2x3 inches:

And the back side attempts:

The basic methodology (for people who are reading this as an instructable) is to:
1. Remove all layers of your PCB except routes, pads and vias.  Export it as an image (monochrome, 600 dpi).  Load it up in a graphics editor (gimp), reverse the color, and horizontally mirror it.

2. Next, use a laser printer to print it onto some kind of paper.  You want a paper with unique, generally undesirable properties; essentially the toner should just barely stick and it should dissolve readily in water.  Four types are commonly suggested:
  A) glossy paper ripped from a cheap magazine/catalog
  B) glossy photo paper
  C) sticker backing paper (pull the stickers off and print on the shiny side)
  D) speciality PCB toner transfer paper.

3. "clean" a blank PCB with steel wool, and then iron the toner on by placing the iron at its highest setting on the paper (which is on the PCB) for about a minute.  You can't move the paper relative to the PCB so some masking tape on the corners might help.  Also don't push down hard, and don't move the iron around much.

4. Soak the PCB in water for about 5 minutes and then rub the paper off.  You can rub quite hard; if it toner comes off then it did not transfer.

The PCB on the upper left of image 1 was made with glossy photo paper.  This paper essentially did not work for me; it would glue itself to the iron and then separate from the PCB or pick it up as well.  The toner was still melted at this point so most of it stayed with the paper.

The upper right image 1 board shows what happens when you push down too hard.  Pressure on the melted toner caused it to spread out.  So don't do that!! :-)  The bottom left of image 1 was ironed on for several minutes.  It got so hot it changed the copper color -- additionally the paper was extremely hard to remove.  Oops!  The last photo on image 1 was again done with glossy photo paper.  The paper still lifted off with the iron but amazingly it left a perfect transfer in the middle!  Unfortunately I doubt its repeatable.

I left board on photo 2 clean to show how the PCB should look after it has been rubbed by the steel wool.   The other 3 boards on the bottom image show transfers with the sticker-backing paper with ironing times of 30seconds, 1 minute, and 1:30.  I'm sure you can see which is which since they show more toner sticking.  In fact, the last image has perfect transfers of 9 out of the 12 circuits!  The only miss transfers are on the top of the PCB.  Clearly I did not get that portion hot enough (in fact, I think that it may have been under the steam holes of the iron).  Removal of the paper was pretty quick under hot water; about 5 minutes (so clearly the boards were not under the iron for too long).  But the paper did not "pill" up like other web postings suggest; it mostly peeled off.  After ironing, the paper it was a little browned in spots but not significantly.

Like any other craft there is clearly a bit of skill and practice required.  And some experimentation is required to become familiar with your particular tools.  However, so far this looks like a pretty feasible method for breakout board fabrication.  In the next installment I will attempt to etch the boards and solder the parts on!

Tuesday, January 10, 2012

Ubuntu 11.10 64bit CadSoft Eagle 6.0.0 installation pain

I think Eagle 6 was rushed to market :-).  It resists installation on the most popular Linux distros, and when you do finally get it working it pops up with an "I'm sorry, there's a nasty bug" dialog.  But Kudos to Cadsoft for admitting it!!!

Here are my notes on the installation.  I think I might be missing a step or two so if you follow these and run into issues, please post a comment!!!

These instructions should also mostly work in 32 bit Linux distros, but you won't need to install as much (remove the packages with "i386", or "32" in their names).

Step 1: Prep Ubuntu for 32 bit compilation

sudo apt-get install build-essential lib32z1-dev g++-multilib gcc-multilib ia32-libs libssl1.0.0 libssl1.0.0:i386 libjpeg8 libjpeg8:i386

Next, get and install libpng14 from source:

tar xvf libpng-1.4.8*
cd libpng-*
./configure CFLAGS=-m32 --prefix=/
make check
sudo make install

32 bit distros should remove "CFLAGS=-m32" and just use this line instead:
./configure  --prefix=/

[Troubleshooting] If you get the error: "configure: error: C compiler cannot create executables" check the config.log file.  If the problem is: "/usr/bin/ld: cannot find crt1.o: No such file or directory" then you did not install g++-multilib gcc-multilib.

If you get:  "configure: error: zlib not installed" you did not install lib32z1-dev

Now install Eagle:

chmod a+x eagle-lin*
sudo ./eagle-lin*

Good Luck and keep building OSHW!!!