Archive for the ‘Arduino’ Category

LED Puck: Tilt Prototype

Thursday, December 27th, 2007

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.

LED Puck: Tilt Menu Demo

Sunday, December 16th, 2007

I have a working prototype of the tilt menu system for the LED puck, albeit square instead of round, and missing the select button.

It started a couple of weekends ago at Cort’s house, where we made some breakout boards for two Analog Devices ADXL202 MEMS accelerometers I have. Sparkfun used to have a great-looking breakout board for them, but it had the filter capacitors on board and I really wanted them off-board for easier prototyping and testing different signal bandwidths.

ADXL202 breakout board, etched

We did iron-on toner transfer etch resist, using Cort’s heat press. We also did toner transfer for the silkscreen-layer labels.

ADXL202 breakout boards

The boards came out very nicely, although the straightness of my hacksaw job leaves something to be desired. Besides indicating the positive directions of the X and Y axes, the silkscreen layer also had labels for the individual header pins; but they didn’t stick at all well going up and down the edges of the copper traces, so I scraped ‘em off. Ditto the pin-1 indicator for the LCC chip.

ADXL202 breakout board, top view

Here’s the board I’ve assembled, with header pins hand-labelled.

ADXL202 breakout board, LCC soldering

I used the Sparkfun SMT soldering method — slop solder on and wick off as much as you can. It leaves enough between the chip and the traces to make good contact, while eliminating solder bridges.

This was a bit interesting to position while soldering. Because it’s an accelerometer / tilt-sensing chip, I wanted its orientation as closely aligned as possible with the orientation of the carrier board. Absolute position doesn’t matter; but if it were rotated relative to the board, its readings wouldn’t align with the tilt of the project it was part of.

I knew I wanted to hold it securely in place while soldering, rather than tacking down a corner and hoping it was rotated about right while soldering the remaining pins. I thought about using a hemostat, but Cort’s was way too strong and would have crushed the chip. I ended up using a needlenose vise-grip, backing it off far enough to just barely grip the chip. I still worried about crushing it; but I was careful enough, as the accelerometer still works.

Tilt Menu Software and Prototype

The whole idea of tilt-menu-based control comes from reader Kevin Reid‘s suggestion:

Accelerometer-based control!

1. Press single control button.
2. Tilt puck such that the LED indicating the relevant function is lit.
3. Release button.

I don’t know whether that’s the exact mechanism (press/release) I’d like to use, but I love the overall idea. To clarify one point, the top of the puck will be rounded/domed, so tilting the puck will light the LED that’s “on top,” like an air bubble floating inside a liquid-filled dome.

With the accelerometer breakout board completed, I was able to prototype the system.

Tilt menu prototype

The Arduino at the bottom is the brains. The accelerometer is at the left end of the breadboard with fairly large signal-filtering capacitors — I sized them for about 50 discrete readings per second, which I think should be more than enough (and is still far fewer than the device is capable of). Note that I’m using the accelerometer’s analog outputs and the Arduino’s A/D inputs; I didn’t feel like measuring pulse length from the ADXL’s digital outputs.

The LED matrix at the right end of the breadboard is kind of ugly, at least to implement on a breadboard (as well as hard to see in this picture). I intend to use an Allegro MicroSystems A6276 16-bit serial-in, parallel-out, constant-current LED driver for the real thing . . . but I can’t find where I put mine, so I just hacked together a row/column drive straight out of the Arduino.

The Arduino code is nothing special, but here it is:

tilt_menu_demo.pde

It reads the analog inputs to get the X/Y tilt, translates from the scale of the A/D converters into the size of the LED matrix, and drives the row/column outputs. I added hysteresis that (although simple) does a fantastic job of keeping the LEDs from flicking back and forth when you’re on the fence between two adjacent ones. And I used tristating on the LED matrix drive because it made more sense to me to float unused lines than to flip them to the opposite value.

Tilt menu demo, flat

Here’s what it looks like sitting on a flat surface. One of the four center LEDs is lit — it turns out to be always the same one, as I haven’t calibrated the accelerometer readings for perfect level yet and it lists a bit to one corner. Note that one of the envisioned modes for the puck is a bubble level; and in that mode, I think I’d flash the four center LEDs to indicate when the puck is perfectly level.

Tilt menu demo, upper right

Tilted a little bit, a different LED is “uppermost” and lights.

Tilt menu demo, far upper right

Tilted dramatically, the corner LED is “uppermost” and lights. Note that the amount of tilt required is set by the TILT_MIN and TILT_MAX values, so it’s easily adjustable for dome shape and/or user preference.

Not Really a Square Matrix

I indicated early on that I pictured LEDs around the perimeter of the puck angled slightly out for good dispersion, so the square matrix I made this weekend was just for a quick demo. I’m actually thinking of twelve LEDs around the perimeter (analog clock mode!) and four in a square surrounding the center, totalling the 16-LED capacity of the A6276 driver chip. I’m working up some very simple drawings of what it might look like, which I hope to post soon.

Arduino First Impressions

Sunday, August 12th, 2007

I’m back to working on my CNC machine and wanted to hook some joysticks up to a microcontroller to run the motors back and forth during development, before I have the whole thing running under computer control. I realized that the PIC18F232 (LogoChip) has only two PWM outputs and I have three motors to control, so the LogoChip isn’t going to be ideal for this.

The Atmel has scads of PWM outputs, so I finally busted out the Arduino I bought a year ago from SparkFun Electronics. The Arduino is, to snip from their own description, an open-source prototyping platform based on a couple of Atmel microcontrollers.

Arduino with joystick, LED, and stepper controller attached

The Arduino folks really shined up their Macintosh dev system install procedures since the last time I looked — I downloaded a zip file, double-clicked a USB driver installer and rebooted, double-clicked the IDE icon, and I was in.

I played with the Arduino Friday night. It’s really, REALLY nice to be programming in C again. I had come to the conclusion earlier from looking at the language that it was C with some microcontroller-specific libraries provided, and that’s exactly what it is. The documentation even mentions that it’s using avr-gcc underneath.

Here are my first impressions:

  • The early Arduino board I have requires you to press the reset button each time you want to download code. This is a huge pain. The newest boards have reset magic built into the USB circuit.
  • It waits about seven seconds after power-up or reset to see if you’re going to download new code to it before it starts running your program. That’s a long delay waiting for something to happen, especially if you’re not even connected to it. I expect that could be shortened by tweaking the bootloader, but I suspect you’d need a real Atmega programmer for that.
  • Taking power from the USB port is really cool, particularly during the development phase when you’re constantly tethered anyway.
  • I don’t like the GUI-based text editor in the integrated environment — but then I never do. I understand there’s a way to do all this stuff from the command-line (so advanced developers could edit with vi or emacs), but I haven’t looked up how to do that yet. (Remember, first impressions.)
  • PWM frequency is fixed by the firmware. There’s example code to change it, but the frequency is probably controlled directly by a hardware timer, and I don’t know if there are enough timers to run three PWMs at different frequencies. So the Arduino may not be any better for this application than the LogoChip was. :-)

So overall, it’s super easy and fun for geeks with programming experience. Proooobably not a good introduction to microcontrollers for visual arts students, though.

Arduino Circuits and Tutorial

Sunday, October 15th, 2006

Tod Kurt is posting lecture notes from an Arduino class on his blog. It’s Halloween themed, and the two sets of notes posted so far look like a really nice introduction to electronics and the Arduino. Go, Tod!