Tuesday, May 22, 2012

Cousin of HexOut

Inspired by Quinn Dunki's HexOut, I decided to build my own.  This wasn't completely on a whim -- I'll need to use it to debug my register board, which has been sitting there, all wired up, waiting for me to play with it.

I don't (yet) have the space/patience needed to make my own PCBs, and I think I'm a bit more space-constrained than Quinn is, so I decided to make a smaller version.  Not so small that I venture into the wild and wooly world of SMD, mind you, but small enough.

Here's the completed project:

The basic setup is the same as Quinn's -- '165 input latches feeding an ATTiny, which in turn controls '595s which feed four 7-segment displays.  A few changes, though, in no particular order:

  1. I opted to use an ATTiny85V instead of the ATTiny13 Quinn used.  Primarily this was because I happened to have '85Vs on hand.  At the same time, though, the '13 has 1K Flash and 64 bytes of SRAM, whereas the '85V has 8K Flash and 512 bytes of SRAM, so the extra headroom was nice.  I haven't a clue whether my program would fit on a '13.  It probably would've, but I just didn't want to have to even think about whether I was about to run the chip out of SRAM.
  2. My first time using resistor networks -- I have them acting as pull-downs for the inputs, just before the '165 latch.  I don't know whether that makes a difference in practice, but I've been burned by floating inputs before, and didn't want to repeat the experience.
  3. I really didn't want to have to remove the ATTiny to reprogram it, so I added a 6-pin ISP header. Adding in-system programming was an adventure in itself, which began on the breadboard.  I learned that I can't just slap a Bread Head (another Blondihacks invention) onto the microprocessor and expect it to start working.  In my case, the signals sent from the ISP to the ATTiny were causing the circuit to change the state the ATTiny pin I was using for serial input.  The circuit signals on that pin fought the ISP signals on that pin, and thus programmer no worky.  I solved (hacked?) that by adding a jumper for that input pin.  If you want to program the ATTiny, you remove the jumper.  If you want normal operation, you install the jumper.
  4. To reduce part count, I'm only using one resistor on each 7-segment display.  They're CA displays, wired so that the '595s talk directly to the cathodes, without any resistors.  The anodes are tied together, with each display connected to Vcc via a single 150 ohm resistor.  The downside of doing this is that the display is marginally brighter or dimmer depending on the number of segments illuminated, but I'm willing to put up with that to save 24 resistors.
Lessons learned:
  1. The 7-segment displays (Vishay TDSO 1150L's) have a staggered pin pattern.  In one direction they're on 0.1" centers, but in the other they're on 0.05" centers.  Turns out you can bend the middle pins out such that all pins end up on 0.1" centers around the perimeter of the device.  I did that to make a breakout board with a standard Radio Shack proto board, and for some reason chose to make the Eagle part that way as well.  Bending the pins out again for assembly of the real board was pointless, and the new pad layout complicated routing.  I should've just used the standard pad layout for the board.
  2. When I created the custom Eagle part for the 7-segment displays, I didn't check the drill hole diameters for the pins.  It's a really tight fit, which is even more annoying when your pins are hand-bent and could really do with some margin for error (see above).  Memo to self: check drill hole diameters.
  3. The mounting holes may be too close to the components.  This may or may not turn out to be a problem.
The boards arrived in very short order, thanks to Laen's excellent Dorkbot PCB service.  The boards are excellent quality, as always.  With the exception of the 7-segment displays (my fault), everything went together smoothly, and now I have my very own working HexOut.


Board layout:


  1. Maybe I'm misunderstanding, but couldn't you just use an ATtiny24 for each of the digits? Those have 14 pins, and leaving 3 for ground, VCC and RESET gives you 11 pins, which is just enough for 4 bit inputs and 7 segment outputs. That way you'd avoid the whole shift register mess.

    (Of course, (re)programming them all would be a hassle)

    1. There are indeed a number of ways to implement this circuit. I considered versions which used larger microcontrollers (but only one of them) so as to eliminate some of the shift registers. For example, I could've used a multiplexed 4-digit 7-segment display, an ATMega168, and had enough input pins left over to read the input lines directly.

      I confess I never considered doing what you've suggested -- using four microcontrollers. Had that occurred to me, I probably would've dismissed it for two irrational reasons. First, the idea of throwing multiple microcontrollers at the problem, "wasting" tons of processing capability for something like this would've bugged me. I know I should just go on cost, but it is what it is. Second, as you mentioned, reprogramming the microcontrollers would be a hassle. I don't know that I'll ever need to, as I proved out the software with the breadboard version, and I don't anticipate changing it, but I still like to have the option without having to remove the chip(s).

      The (bonus) third reason is that I'm lazy. This circuit was more of a means to an end (creating a diagnostic tool for my register board), and I didn't want to invest the time in getting the very smallest, most cost-effective circuit I could. I was happy to stick with the Blondihacks version, which seemed to get the job done at a reasonable expense.

      All that said, if I ever make a v2 of this thing, I'll probably try to see just how small I can make it, just to keep things interesting. Your suggestion will be one of the first things I try.