Fixing a Kids’ Educational Toy

January 13th, 2008 by Keith Neufeld

Alphabet training toy

A while back, my wife got this alphabet-training toy for one of our nephews. When they opened it and tried it, it “didn’t work and the batteries got hot.” Sounded like a short to me, so I figured I’d take a look.

Alphabet training toy, interior

The inside was interesting — I wasn’t expecting a bunch of little pushbutton circuit boards and a ton of fly wires (bundled together with cellophane tape), but I guess it makes sense. In China skilled labor is cheaper than automation, so a bunch of little boards with hand-soldered wires probably cost less than one big board made by a machine.

Alphabet training toy main circuit board

I put my meter across the terminals of the (empty) battery compartment and measured 0Ω — a dead short. I visually inspected every connection on the main PCB, assuming I’d find a solder bridge, but I didn’t. I desoldered the battery and power LED ground wires from the PCB (outlined in the white rectangle) so I could start isolating the short, and the short went away.

Let me say that again: I measured across the battery terminals (with the ground wire disconnected from the circuit) and got no short, as expected. I measured across the LED and got no short. I measured from the ground pad on the PCB to the positive terminal and got no short. I reattached the ground wires, still had no short, and the toy powered on and worked.

I’m quite certain I didn’t fix a solder bridge at the ground pad. My best guess is that while I was moving all the other wires to make room to work, I pulled apart something that was making contact and shouldn’t have been. But it’s quite a mystery what I really did that fixed it.

Except for the Batteries

Except for the batteries, which weren’t making reliable contact.

Kids' toy battery compartment

The shoulders of the cell compartments were too thick for the positive ends of several different brands of AA cells to make contact with their . .  uh, contacts. So I sharpened up my best $3 wood chisel (the one that I use to pry up leads on circuit boards I want to desolder) and shaved them down, and now the batteries make great contact.

But It’s Too Late

My wife says the nephew has outgrown the toy, so it won’t go to him. We have a couple of nieces about the right age, so one of them might get it, or she might take it to a thrift store.

Where to Salvage Electronic Parts

January 9th, 2008 by Keith Neufeld

A reader recently asked me where he should stock up on miscellaneous electronic parts, and asked about buying grab-bags from various surplus stores. What follows is spurred by my reply to him.

I have so much stuff that I’ve taken apart and that’s waiting to be taken apart that I hardly ever buy components, at least not common components for breadboarding and prototyping. I’ve never been that interested in buying grab-bags, because I can do just as well taking stuff apart for free.

Is it really economical to salvage parts for “free” that you can buy for pennies? It depends on your perspective, but for me there are two main factors:

  • Having a wider assortment of parts on hand, ready to grab when I’m in the middle of a project, than I would choose to order and stock up from a catalog
  • A sense of responsibility to save perfectly reusable components from going into the landfill

Criteria

So with the goal of getting through-hole parts that are easy to experiment with on a breadboard, let’s look at a few common items and what you can salvage from them. All of this is stuff you should be able to get for free by letting friends and coworkers know that you’re willing to haul it away for them. Everything here is completely salvageable even after it’s broken, so there’s no point in shopping even garage sales when you get can dead ones for nothing.

Other places will tell you how to salvage cassette players for motors, but I’ll leave that for the BEAM electronics guys. I’m talking about stocking up on the basics that you’ll use in every circuit you breadboard, particularly resistors, capacitors, and diodes.

Of course you can salvage anything you get your hands on — digital clocks, cordless telephones, car stereos — but this is what you specifically want to look for to stock your parts bin.

Whatever you salvage, please set out the metal frames and plastic cases for recycling, if your community has facilities available.

Good Stuff for Salvage

My best suggestion, based on how easy they are to come by, is dead CRT computer monitors. They have mostly through-hole components, including a lot of resistors and small-signal diodes, a fair number of capacitors, a few pots and pushbutton switches, and a handful of TO-92 transistors that you can use for basic switching if you have a transistor checker to identify the pins.

CRT monitor main board

Be sure to discharge the anode cap to the frame at least twice with a couple of big screwdrivers before disconnecting it. Also short large capacitors in the power supply — whatever broke in the monitor may have left no path for the caps to drain.

Dot-matrix impact printers have lots of resistors, maybe a couple of stepper driver chips if you’re lucky, and most likely a bunch of high-power (5A) FETs that ran the printhead, maybe with TTL-compatible FET driver chips. Also one or two large electrolytic capacitors in the power supply, if you’re into that kind of thing.

The printhead carriage rods and slides are great for DIY CNC drill/mill machines . . .

Dead PC power supplies have a couple of good bridge rectifiers, some other rectifier diodes, a few medium-sized electrolytic capacitors, and a bunch of one-foot pieces of really nice 18-gauge stranded wire in a miscellany of colors.

PC power supply

They also have power transistors that you won’t be able to find datasheets for (but they have great heat sinks for TO-220 packages) and toroids that you won’t let yourself throw away but will never actually use.

Live PC power supplies, particularly AT and older, make great bench power supplies, as has been noted many other places. Ignore the bit about soldering in a resistor as a dummy load and just strap an old hard drive on top (plugged in, of course).

If you can find external modems the size of a hardback book and kind of boxy, you’ll get a bunch of resistors and capacitors, a handful of indicator LEDs, and a couple of RS-232 line driver/receiver pairs.

External modem circuit boards

Save the RJ-45 jacks before throwing away dead network cards.

PC network card

Old computer terminals have a bunch of discrete digital logic chips and probably some .1″ headers that are great for terminating fly-cables to plug sensors into your breadboard.

If you’re interested in dabbling in surface-mount work, watch for rackmount network hubs, 10M switches, and 10M fiber media converters. They’ll be old enough that the SMT components are large enough to see and the resistor values large enough to read. They may also have SMT discrete digital logic, PALs and GALs that can be reprogrammed, and SRAMs.

Fiber to copper media converter

Bad Stuff for Salvage

TVs, VCRs, and stereos are going to disappoint you with monolithic ICs and surface-mount components. An old enough stereo may get you a handful of resistors and capacitors, and save the phono jacks if you’re at all interested in tinkering with audio or video.

VCR main PC board

Inkjet printers have a couple of motors — maybe stepper, maybe DC — that are fairly strong for their size. All the electronics will be surface-mount, though. Save the wall wart and salvage the corresponding jack if it’s easily removed.

Computer motherboards have been nearly all SMT for quite a while. The battery holder or supercap that preserves the BIOS settings is worth pulling out, and there may be headers/jumpers you can save. If you have a good magnifying glass and room to store the board, set it aside for when you need to find a particular value of SMT resistor.

Computer motherboard

Dead CD-ROM and hard drives are full of fascinating things, but not that great for basic electronic parts, since they’re all SMT. CD drives have nice geared/pulleyed DC motors for the tray and tiny limit switches nearby to detect when the tray is in or out, plus tiny DC or stepper motors to move the read head sled.

CD-ROM drive mechanical components and main PC board

Parallax Motion Sensor from Radio Shack

January 5th, 2008 by Keith Neufeld

The back cover of Servo Magazine is always an ad from Parallax, and the December issue featured several sensors that will now be distributed through Radio Shack, including a motion sensor for $10.

John and I are getting ready for this spring’s Technology: Art and Sound by Design class; and although I think John will be doing most of the teaching this year, I’m always on the lookout for sensors that would be good for students’ interactive sculptures.

Jason at work suggested that the LED puck could have a motion-sensing mode, to serve as a sort of intrusion alarm.

When two separate events occur simultaneously pertaining to the same object of inquiry, we must always pay strict attention. Or, ah, three events.

Two Parallax / Radio Shack motion sensor kits

I picked up a couple of the sensors last week to try out. The clerk said when they got them, he had thought they’d never sell any. Why am I always the guy buying the weird stuff?

How Motion Sensors Work

The heart of common motion detectors is a pyroelectric sensor, which is essentially a FET with a window in the case opening onto an infrared-sensitive gate. Changes in the level of IR light with a wavelength corresponding to body heat cause changes in the drain-source resistance, which the circuit monitors.

Parallax pyroelectric sensor

The real trick is that the sensor is then placed behind a multifaceted lens that (loosely speaking) “chops up” the view of the world into smaller cones of heightened visibility and intervening areas of lessened visibility. Think of a stage polka-dotted with multiple spotlights, only actually seeing that way rather than merely illuminating that way.

A body moving from an area of reduced visibility into an area of increased visibility causes a rapid change in the amount of IR (body heat) shining on the sensor, hence a rapid change in its drain-source resistance. The motion detector circuit watches for these rapid changes, and when detected, triggers the alarm. This is why Robert Redford has to move slowly while retrieving the MacGuffin from Cosmo’s office in Sneakers.

A brief note about the multifaceted lens: It is usually a Fresnel lens, but being a Fresnel lens is a red herring. That simply makes the lens thin and easy to mold out of plastic; it is really the multifaceted nature of the lens that’s important. Closer examination of a motion sensor lens easily reveals that it comprises multiple adjacent Fresnel lenses.

The Fresnel dome of this sensor, by the way, is too large to fit into the LED puck (as, most likely, is the PCB). However, it’s not out of the question to purchase a separate PIR element and mill a multifaceted lens pattern into the puck enclosure above it. It would be an interesting challenge, perhaps for a later version.

The Parallax Sensor

The sensor comes with an absolutely minimal connection diagram, and refers to the Parallax web site for full documentation. The module has a three-pin connector (bottom) for ground/V+/output, and a two-position jumper (upper left) for retriggering mode.

Parallax motion sensor, component side

The power/output header is annoyingly the same height as the other components on the back side of the board, so the sensor cannot be plugged directly into a breadboard for prototyping; it requires an extension. Parallax recommends a servo extension cable; I soldered a three-pin header to a three-pin header socket to make a rigid extension for breadboarding.

The module’s output is active-high. The Parallax documentation indicates that the jumper selects retriggering mode. With the jumper in the L position, the module triggers the output upon detecting motion and then goes low again. With the jumper in the H position, the module is supposed to keep the output high as long as motion continues, but mine does not.

The datasheet indicates that the module needs a “warmup” period of about a minute, during which time it’s adapting to ambient conditions and may trigger randomly. My experience was similar, so anyone using this module needs to be prepared to accept random triggering for a while after startup.

The package and datasheet indicate a detection range of about 20′. I didn’t have room to test this, but I’m willing to believe it until I learn otherwise. Apart from the minor annoyances above, the sensor really is very easy to use, particularly for our class. It seems quite responsive to motion, and certainly responsive enough to pick up gallery visitors not specifically trying to sneak up on it. Output is a very clean 5V, so it’ll be easy for students to interface to the Arduino.

Sensitivity is fixed. It’d be nice to have a trim pot to adjust sensitivity/range, particularly for use in interactive sculpture projects. A Halloween prop-maker going by the name “Scary Terry” has written a nice review of the motion sensor, and includes pictures of mounting it inside PVC pipe to control its angle of sensitivity. I guess with care, the sensor could be angled toward the ground in such a way that it would be triggered only when feet entered a designated area.

Hacking the Sensor

I suspect that most students using this sensor either would trigger a long sequence of actions when motion is first detected, or would like to get a continuous (retriggered) signal the entire time motion is detected. I’m somewhat interested, though, in a much finer-grained notion of “the entire time motion is detected” than that.

By my rough count, the sensor triggers for about two and a half seconds each time it detects motion. It then locks out briefly (didn’t time it — say another couple of seconds?) during which time it’s insensitive before it can detect motion again.

I’d like to be able to get a series of much shorter spikes and much shorter recovery time. I don’t know exactly why; it just seems useful to me.

Let’s go back to that component view:

Parallax motion sensor, component side

The IC doing all the work is a BISS0001. The only datasheet I can find for it is in Chinese, yay, don’t read that, sorry. The chip has a bunch of comparators, some logic, a logic section labelled in Chinese, and two timers labelled in Chinese. It looks like it’s probably made specifically for motion-sensing applications.

Fortunately the pinouts and component values are labelled in English, so I was able to make enough sense of the datasheet to understand how to set the timing constants. From the sample application circuit, pin 2 is obviously the master output; and on the pinouts, pin 2 is labelled VO.

On the timing diagrams, VO goes high for a period labelled TX and low for a period labelled Ti. Just above that, we have the equation TX ≈ 49152R1C1 leaping out at me from a wad of impenetrable Chinese. On the functional diagram, R1 and C1 stack from pin 3 to 4 to ground.

Parallax motion sensor, pulse timing components

Okay! On the PCB, pin 3 goes to a resistor that said “204.” (Ignore the 473 in the picture.) The resistor and the IC’s pin 4 go to a capacitor, which goes to ground. We’re in business!

The resistor is labelled as a 200KΩ, and my meter confirms that. The capacitor is unlabelled; in-circuit, my meter tests it at about 470pF. Doing the math:

49152 R1 C1 = 49152 * 200KΩ * 470pF ≈ 4.6 seconds

Hm, that’s a little off from the 2.6 seconds I was counting, but same order of magnitude. For a capacitor value that small, I’m willing to believe that I’m getting extra capacitance from my meter probes and from measuring it in-circuit. I think we’re in the ballpark.

The easiest way to shorten the on-period (TX) seems to me to be replacing the resistor. To take the period down an order of magnitude, I should use about a 20KΩ resistor. After looking at the SMT resistors on a dead PC motherboard, I found a 473 (47KΩ) and figured it was enough smaller to make my point.

I desoldered it by wrapping a piece of heavier wire around it and heating the wire, like Josh suggested, and it worked great. Then out of laziness and because the new resistor was larger than the existing resistor and might not fit the pads well, I just soldered it on top of the resistor that was already there, in parallel. Makes it a 38KΩ resistor instead of a 47KΩ, so we’re even going in the right direction.

I powered up the motion sensor again, waited a minute for it to settle down, and started timing its response. On-time after sensing motion (TX) is now in the half-second range. The absolute numbers still don’t match what the equation says I should get, but the relative values are right on — a resistor with 1/5 the value reduced TX to 1/5 of its former value.

Parallax motion sensor, lockout timing components

Pretty slick! Now I can pick whatever TX I want, be it short or long. I haven’t tried it yet, but the lockout time between motion detection (Ti) is set by R2 and C2 on pins 5 and 6, and they’re easily accessible as well, so I should be able to change that too.

And About that Datasheet . . .

Don’t get me wrong about the Chinese datasheet. Sure I would have been disappointed if I couldn’t read it, but I was actually really pleased that sections of it were in English. I’m aware that people throughout the rest of the world have to learn English in order to do a lot of technical things, and do so with ease and proficiency much greater than that of the few Americans who bother to learn languages other than English.

Bunnie Huang has an interesting blog post that touches in passing on certain types of devices using chips of Chinese manufacture that can’t be found, or can scarcely be found, by searching Google in English:

Just try searching for USB mass storage controller ASICs, or digital picture frame SoCs on Google in English, and then go and open up one of these devices and compare your findings. I bet you’ll find that the chips most frequently used in these popular devices are best searched for in Chinese.

It’s a competitive world out there, and those of us in the west have had it awfully easy for an awfully long time. I know as a mere hobbyist, the technology I use is far behind the leading edge, and I’m not yet impacted in nearly the way of engineers developing new products for market. But the world is changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Merry Christmas to Me!

January 4th, 2008 by Keith Neufeld

When I thought up the LED puck idea, I went shopping for some bright LEDs to put into it. I don’t like the blue+yellow color of “white” LEDs, and I thought it’d be fun to have green illumination, so I found some green LEDs from a Hong Kong [correction: Chinese] eBay seller and bought ‘em. Since I’m pretty sure it costs about the same to ship a package from Hong Kong China if it has a few more items of negligible weight in it, I kind of went crazy and treated myself to an LED assortment.

I won’t mention the specific eBay seller, because I have mixed feelings about them. On the one hand, their prices were very good and their LEDs seem okay. On the other hand, I’m pretty sure it cost them next to nothing extra to ship my whole package than just my first LEDs; but even after requesting and receiving an additional additional shipping discount, I still paid $30 shipping for $35 of LEDs. And on the gripping hand, I paid on December 9 and didn’t receive my package until December 24. It made a nice Christmas present to me, but it made me feel like I was paying shipping by the day instead of by the pound.

Square 5mm LED

Grumbling aside, the LEDs I was shopping for turned out to be not at all what I was expecting, and probably better in every way. This is because I wasn’t paying enough attention to see that they have four legs (I thought they were two-legged LEDs with a square base), but four legs gives better heat dissipation and allows higher current; and I didn’t realize how squat they are, which makes them fit better into a puck; and I saw that they were 1500 mCd but didn’t realize they had a 120-140° viewing angle, which means they output a whopping 4.7-6.2 lumen each. In contrast, my 10,000 mCd 20° blue LEDs only output .95 lumen.

The other stuff I got was a handful of 1W and 3W Luxeon knockoffs, because, y’know, why not; and a constant-current driver board, which I thought would come in handy while testing.

Here are eight of the 5mm LEDs on a breadboard with 100Ω resistors, for about 15mA at 5V or 85mA at 10V (~3V drop). Remember, that’s maybe 5 lumen each or 40 lumen total.

Square 5mm LEDs on breadboard

Let’s see how they fare against the 3W, 70 lumen beast of the apocalypse, wired to the 1W driver without thinking about how that means it’s not running at full power and brightness.

LED driver and 3W green LED

Here’s my desk with about 200W of fluorescent light from the ceiling fixture and the swing-arm lamp.

Desk lit with fluorescent lights

Same scene with the eight 5mm LEDs fed at 10V, and the camera locked to the same aperture and shutter speed:

Eight green LEDs

Same scene with THE BEAST:

3W green LED

Assessment:

The LEDs don’t provide nearly as much illumination as normal room lighting. But then, nobody thought they were going to.

Each set of LEDs does provide enough light to read by, pretty comfortably, even with the light in the same plane as the paper’s surface (i.e. indirect lighting).

According to the camera, half the LEDs for the puck make less light than a single 3W faux-Luxeon driven at 1W. Crap, I should just make a Luxeon throwie and call it a puck. Nah, that’s not really the fun part of the puck idea.

According to my eyes, and my wife’s as well, there’s much less subjective difference in the brightness between the eight 5mm LEDs and the single 3W LED than what the camera appears to show. The math seems to back this up as well (maybe 40 lumen versus some fraction of 70 lumen), so I can’t explain what’s going on in the pictures.

And, oh yeah, LEDs ARE COOL!!!

LED Puck: Blender Modeling

January 3rd, 2008 by Keith Neufeld

Joel is setting up EMC2 so we can use his CNC machine for milling (DanCAM could mill, but we’d probably have to use DanCAD so we’ve just used the machine for drilling), and I’ve been working on modeling the puck enclosure in Blender.

First, I’d like a better visualization than my crude line drawings; and second, Blender has a plugin to output STL (stereolithography) code, which FreeMill is supposed to be able to convert to g-code, which EMC2 (and everything else in the world) can mill. So at the same time, I get a visual idea of what I’m designing and a CAM file to produce it. Almost like using CAD software. :-)

I am completely new to Blender, which is obvious both by how long it took me to build a satisfactory model and by the amateur appearance of the result. At the end of this post is a plea for education, if anyone wants to teach me how to do it better.

Here’s a view of the draft enclosure from slightly above, rendered translucent (plexi or lexan):

LED puck case modeled in Blender, translucent, from above

The hole through the top will host a waterproofed plunger for the pushbutton switch, but the plunger is absent because I’m only drawing the case for now.

Same draft viewed from below:

LED puck case modeled in Blender, translucent, from below

There’s a shallow recess for mounting a plate to seal the bottom, then a deeper recess for the PCB and battery.

Same case in Blender’s default material (scrith?):

LED puck case modeled in Blender, default material, from above

And from below, which is way too dark but may show a little more detail of the nested recesses:

LED puck case modeled in Blender, default material, from below

Below, detailed information on how I made this in Blender, for anyone interested, or willing to offer advice.

Read the rest of this entry »

Arduino USB Auto-Reset Hack

December 31st, 2007 by Keith Neufeld

Older Arduino boards like mine have two annoyances associated with uploading software to them. First, you have to press the reset button (physically) to trigger the bootloader to expect new software from the host computer. Second, the Arduino waits allegedly 6-8 seconds (actually about 10 on mine) on every boot before starting your program, in case you might want to be uploading new software to it.

Small annoyances, to be sure, but they add up quickly when you’re trying to tweak a timing constant in a program and uploading software repeatedly. Thus in designing the latest Arduino, the Diecimila, the team addressed these two issues.

On the Diecimila board, they added a capacitor between the USB-serial chip’s DTR line (active-low) and the microcontroller’s reset line, so that the host computer can trigger DTR and pull down the reset for a moment, relieving you of pressing the button. In the new version (10) of the IDE, they added code to support that new functionality. And in the bootloader burned into the ATmega168 microcontroller, they shortened the boot wait time to a second or less.

All of that comes prepackaged for Diecimila owners; but owners of older Arduinos are resourceful and found how to adapt their own boards as well. The NG can be hacked by soldering a capacitor across two adjacent pads that appear to have been put there for that purpose. The Arduino serial can be hacked by stringing a capacitor between the serial connector and the reset line.

Arduino USB hacked for auto-reset, top side

But I have an Arduino USB, the first version to support USB and not yet a “next generation,” and I haven’t been able to find instructions on modifying it. It doesn’t have the pads already broken out like the NG; in fact, it doesn’t even have the same package USB-serial chip. So I muddled through, found the right pins, and did it myself. Works (mostly) great!

Finding the Right Pins

The page for the NG hack simply shows you physically where to put the capacitor on the NG board and doesn’t describe what it’s connecting electrically, which didn’t help me, as I needed to figure out where to put it on the physically different USB board. Fortunately, the page for the Arduino serial hack gives the critical information:

The retrofitting process consists on soldering a 0.1uF disc capacitor between the DTR pin [of the serial port or USB-serial chip] and the Reset signal [of the microcontroller].

Good enough!

I got the datasheet for the FTDI FT232BL USB-serial chip, and for a moment got my hopes up higher than I should have. The DTR line is in the row toward the top of the Arduino board, and it looked as though it might already be broken out into the unpopulated, .1″-spacing X3 header. Nope, nope, it’s about the only line on that side that’s not already broken out. I was going to have to solder directly to the chip.

Given that it’s a 7mm-square LQFP with .8mm (.03″) lead spacing, I should perhaps have set it out with a thimbleful of Special Sheep Liniment to entice the Nac Mac Feegle to solder for me. But I have no dearth of hubris, and soldered it myself. Twice, in fact, the second time after cutting the other end of the wire too short to reach the capacitor.

top-side zoom

One side of the capacitor connects to the DTR line of the USB-serial chip, the fourth pin from the left on the upper edge. The other side connects to the reset line, which appears to be available only on the microprocessor, the ISP header, and the reset button. I chose the reset button on the underside of the board.

I could have used a capacitor with long leads, sleeved them, and connected them directly to the pins at both ends as in the serial board hack; but I thought it looked better to use wire-wrap wire.

bottom side

I laced the (insulated) wire-wrap wire through open vias in the board to keep things tidy and the capacitor snugged down. A few dots of glue would have done the same had I wanted to keep all the wires top-side, but this felt a little more artful to me. Plus it seemed easier to solder to the underside of the reset switch rather than the top, so I was feeding a wire to the back side of the board anyway.

IDE and Auto-Reset

I upgraded the integrated development environment to version 10, which adds the DTR-triggering, and tried it out. The host computer does indeed now reset the Arduino, and I can upload software to it without pressing the button! Hooray!

But there’s still about a 10-second delay after a boot, reset, or upload before the software starts running. Boooo!

Bootloader and USBtinyISP

One of the hacking guides suggested that the Arduino bootloader would need to be upgraded in order to reduce the reset delay, which makes sense. The IDE includes the ability to burn a new bootloader, for which the bootloader web page gives instructions. Burning the bootloader, unfortunately, can’t be done through the Arduino’s serial interface; it requires a separate AVR programmer.

Thus it was time to assemble my USBtinyISP kit from LadyAda.

USBtinyISP PCB

I bought it a while back in order to be prepared for programming ATmegas outside of the Arduino board. It’s an Atmel ATtiny chip interfacing directly between a USB connector and two cables for in-system programming. The board is nicely made, the instructions are clear enough for absolute beginners, and it was a joy to solder.

USBtinyISP

Fully assembled, it lives in a shell that makes me think of old serial line drivers; but the shell is somewhat customized to fit the USBtinyISP board (and vice-versa).

I read recently and have since forgotten the name of the little “columns” built into plastic enclosures (like toys) to hold PCBs in place; but no matter, since my point is that this case doesn’t have them. The USB end of the board had a lot of room to move and was a bit wibbly-wobbly, but I took the foam that the chip shipped in and packed it between the USB connector and the top of the case, which secured the whole thing nicely.


The term is mounting bosses, seen at Near Future Laboratory.


That done, I unplugged the Arduino’s USB connector, plugged the USBtinyISP into the Arduino’s ISP header and into my iBook’s USB, and burned a new bootloader. I went to the Arduino IDE’s Tools / Board menu and selected Arduino NG or older w/ ATmeta8, then Tools / Burn Bootloader / w/ USBtinyISP. The USBtinyISP’s programming light went on and IDE told me it was burning and would take a minute. Twiddle twiddle.

Finished. Disconnected the USBtinyISP and reconnected the Arduino. It didn’t seem to have my program on it any more, which I guess makes sense that doing low-level AVR programming would wipe the whole memory. I uploaded my code again; and when the upload finished, it took about 10 seconds to start the code. Hrm. Pressed reset, and it took about 10 seconds. HRM.

Arduino Bootloaders and ATmega8

My Arduino is so old that it has the ATmega8 instead of the ATmega168. I don’t know whether that’s true of all Arduino USB boards, but it’s certainly true of mine.

It would appear that the ATmega8 bootloader image has not been updated for the auto-reset. Poo.

The bootloader source code is available online, but the ATmega8 code looks unusable. By that I mean that large sections of code are commented out, including the part that makes timeout after n seconds. (Yes, I’m saying it appears that it would wait forever for a software upload before starting your program.)

It looks to me like it’s been half-***ed patched with updates that have been made to the ATmega168 bootloader, but that parts that would have taken any effort to fix have been commented out rather than updated. Yes, I’m bitter.


See the comment from David Mellis, a developer of the Arduino, below. The timeout value is still present; I just didn’t look carefully enough. The ATmega8 bootloader code probably is what’s in the IDE, and it should be possible to recompile it with a shorter timeout. I’ll provide a further update once I get that worked out.


Interestingly, the ATmega168 bootloader code includes conditional compilation for many different ATmega chips, including the ATmega8. It seems likely that I could build it for the ATmega8 and get it to work. However, the bootloader web page says that the ATmega8 bootloader is only 1k rather than the newer bootloader’s 2k, an important savings given the ATmega8′s mere 8k of FLASH.

Fix the abandoned ATmega8 bootloader code myself? Sacrifice an extra 1k of program space by using the newer bootloader? Sigh.

Another option would be to buy Lady Ada’s preprogrammed ATmeta168 microcontroller. Of course I’d check first, but I think the ATmega8 and ATmega168 are pin-compatible. If that’s the case, I could pop in a 168 (preprogrammed from her, or straight from the factory and program it myself with the USBtinyISP) and be done with this. But it really grates on me to replace hardware when a software fix is perfectly viable.

And of course I could just try lying to my IDE about what chip I have and burning the ATmega168 bootloader into my ATmega8. But looking at the source code, there are enough differences between the ATmega168 and ATmega8 sections that I’m leery of doing this. I wouldn’t mind if it simply didn’t work, but I don’t know enough to be sure it wouldn’t damage the chip somehow. I’d rather live with the delay (for now) than destroy the only chip I have (for now).

To Sum Up

The capacitor-reset hack was easily adapted to the Arduino USB, if you don’t mind a little fine-pitch soldering. Yay! That plus an upgrade to v10 of the Arduino IDE allow the host computer to reset the Arduino when uploading new software, relieving you of pressing the reset button each time. Yay! But I don’t yet have a solution to reduce the reset delay on a board using the ATmega8 microcontroller. Boo!

LED Puck: Tilt Prototype

December 27th, 2007 by Keith Neufeld

My wife isn’t interested in electronics. She doesn’t do electronics, she doesn’t understand electronics, and she really doesn’t want to hear me ramble on at length about electronics. (I say this all in a very good-natured way, of course. Identical interests were not a prerequisite for our marriage.)

So when my wife asks my why I keep soldering chips onto boards in the wrong direction, I know I have a problem.

Oh, and the ADXL202 is a hardy little sucker.

Prototype Puck I/O Board

Over the weekend, I laid out and built a prototype of the I/O for the puck — just the LEDs, their driver, an accelerometer chip, and a pushbutton. I expect to use the Freeduino circuit for the microcontroller and will still need to add it to the board (as well as battery-charging circuit and all that other good stuff); but I wanted to get started programming the actual LEDs and tilt system.

LED puck I/O prototype PCB, cleaned and cut

I laid out the board in EAGLE; and believe me, it’s a bit of a challenge routing nice curves as traces. The V+ circle around the edge wasn’t too bad; but I wanted to route the LED drive traces as concentric arcs and just couldn’t find a way to do it.

I had a few SMT A6276 LED driver chips around, so I was able to make most of the board SMT already. The A6276 will want to be on the underside of the board (shown here) so its pins are in the same order as the LEDs it drives. I’m not sure where the other chips should be, but it was easy to make a single-sided board for this prototype.

I worried that I was packing the traces too closely together; but they came out well enough (iron-on toner transfer), I think I could have made them smaller. And having to run to headers to go off-board to the Arduino complicated the routing; if the microcontroller were on the other side of the board, each of those signals could have gone through on a via wherever it was convenient rather than having to converge to the two headers at the top and center.

Tinnit

I tried plating the board with Tinnit, because I had such good results last time — that board was incredibly easy to solder. Alas, five-month-old eighteen-year-old Tinnit apparently doesn’t work very well. After forty minutes at 110°F with no plating appearing on my traces at all, I gave up, washed the board clean, and dumped the rest of the Tinnit.

I still think it’s great stuff and I intend to use it again. I just need to be sure I’ll be making enough boards for it to be worthwhile.

I did learn something else, though. After cleaning the board, it sat out for a few hours, and I noticed that it was already oxidizing — the copper was considerably less shiny than when it was fresh. Before soldering, I polished it with wet 600-grit sandpaper, and it took solder beautifully — completely unlike untinned boards I’m used to soldering.

Lesson: If a copper board has been exposed to air for even a few hours, polish it with wet, fine sandpaper before soldering.

Assembly

I soldered on all the SMT components first. I was pleased that I was actually able to find all the resistors and capacitors I needed in my salvage bin. I’ve desoldered a number of SMT boards (heat with heat gun, then bang on the bench vise and the components come flying off; or pluck them off with tweezers for a more orderly approach), and I think these came from a dead Cabletron hub.

LED puck I/O prototype, SMT components soldered

The resistors were all labeled, so they were easy to search for the right values (if you call picking through a bag of grains of rice easy). The capacitors were a bit more challenging — they were completely unlabelled, so I had to dump them out on the workbench and use the meter (tweezer-style) to find the values I needed.

LED puck I/O prototype, copper side

I placed all the LEDs with their cathodes facing clockwise (as viewed from the top) for simplicity — so I wouldn’t have to think about which way each one goes. Although parts of the puck are obviously asymmetric, I prefer to think of the puck as a whole having at least rotational symmetry, and I wanted the LED orientation to reflect that as well.

LED puck I/O prototype, LED side

The jumper wires are a bit scabby, particularly the one running halfway across the board at an odd angle; but again, they’re at least partly due to routing challenges with not yet having the microcontroller on board, as I mentioned earlier.

I should stop to add that laying out an SMT board is really refreshing, in that you can fill both sides of the board with components and traces, and not worry about through-holes impacting the routing on the other side of the board. As long as you don’t need to hop to the other side and back to cross one trace over another, each side can be completely independent of the other.

That’s not illustrated well by my single-sided SMT board; but I mention it because I’m really looking forward to laying out the microcontroller (probably on the top side) and cleaning up some of these traces and jumpers.

Two Mistakes on the Accelerometer

First: absent-mindedly running the resistor that sets the PWM output period to the self-test pin by mistake. Second: soldering the accelerometer to the board 180° from its proper orientation.

When I first powered up the board, I was most interested in testing the LED driver, since I had already tested the accelerometer on the breadboard. The lights didn’t come up (I had forgotten to manipulate the output enable line in my program), but I also smelled hot electronics. I fixed the program, the LEDs worked, the accelerometer didn’t, and I realized my mistake.

On the EAGLE PCB layout, I had a marking for the accelerometer orientation, of course. But the marking was on the silkscreen layer, and I didn’t make a silkscreen layer when I etched the board at home. Then because the components are on the bottom side, I got myself confused about which end of the accelerometer was which.

Lesson: Copy IC orientation markings to the copper layer for homebrew boards.

Rework

Last night I waved my soldering wand and cast a spell of devious reparo on the accelerometer chip; but apparently it backfired, because it ended up looking like this.

Closeup of LCC and stacked SMT capacitors

I actually used solder wick to remove the errant PWM period resistor — it did a nice job of sucking up solder, heating both ends at the same time, and then scooting the resistor off its pads so it wouldn’t stick back down when the solder cooled.

I used solder wick to suck up all the solder I could from around the accelerometer; but I didn’t have a way to heat the whole thing at once, so I couldn’t scoot it away. I need a hot-air pencil and looked at several DIY designs, but didn’t want to take the time out to build one. There was little enough solder left, I was able to twist the chip off the board with a pair of pliers.

I lost a couple of pads in the process; but when I soldered it back down, one was NC and the other I was able to bridge with solder. Then I needed to move one of the resistor traces from the left pin to the middle . . . and the easiest way to do it was to solder one end of the resistor directly to the chip.

Yes, I’ll fix it right in EAGLE for the next board.

BTW, notice the stacked SMT capacitors on the right. I couldn’t find anything in the .1uF – .2uF range in my bag, so I paralleled a couple of 75nF. Nasty!!! :-)

Proto-Puck

The upshot of all this, if I can finally get to the point, is that I have a working proto-puck.

Arduino and puck

I have ribbon cables connecting it to the Arduino for power, LED output, and tilt input. The LED driver works perfectly, and (miraculously) the accelerometer works now that I’ve reoriented it. And that means I’ve been able to start writing code.

This isn’t much yet — it only detects whether the tilt is inner or outer, and which quadrant it’s in — but I think it gives a flavor of things to come.

Project Idea: Household Pager

December 23rd, 2007 by Keith Neufeld

When we’re doing several other things at the same time as baking, it’s easy to forget to check the oven, and things get burned. When we’re watching a movie and the phone rings, it’s annoying to have to go to the phone to check the caller ID to see whether it’s worth interrupting for.

I want a household pager that vibrates and has a single-line alpha display. Range limited to my house, and integrated with everything.

Set the oven timer; when it goes off, the pager says “Oven timer.”

Incoming phone call, pager shows the caller ID. Doorbell could show “Doorbell,” in case we were upstairs where we can’t hear it.

Washing machine, dryer, or dishwasher finishes running, pager lets you know.

Integrated with everything in the house, I think it could be incredibly handy. Sensor modules could be serial-numbered, so you assign text to functions in the base station rather than at each sensor. Of course, the trick is integrating with everything in the house.

LED Puck: Tilt Video

December 21st, 2007 by Keith Neufeld

Many thanks to John Harrison for showing me how easy iMovie is to use.

YouTube must by default pick the middle frame of the whole video for the thumbnail screen? I’ve updated it to use a different frame, but they say it can take six hours to take effect. Meanwhile, here’s a great video apparently about hysteresis!

YouTube has synced my change for which frame gets used for the video still, so the joke about the hysteresis video doesn’t work any more.

LED Puck: Need an Inexpensive Accelerometer

December 19th, 2007 by Keith Neufeld

I thought I’d seen an accelerometer chip recently that retailed for $3-5, but the cheapest I can find on Digi-Key is $7-9. I’m really worried about the puck price climbing out of control. Anyone know of cheap accelerometers?