Friday 19 July 2019

KiCad Kata

Pretty (but dumb) LED Matrix
The picture shows the result of another workout with KiCad as executed by Seeed Studio and finished by me. This looks rather prettier than the original and was considerably easier to solder, not to mention more LEDs!

However a few defects are obvious too:

  • the LED spacing is wider than on stripboard, which can make patterns harder to discern
  • the interface split between anodes and cathodes is the same as the original, for no good reason
  • it now uses 16 gpios!
The first and second of these are my fault but the last could have been mitigated by adding an LED driver, such as the MAX7221 to the design:
MAX7221 DIP package
This particular chip requires only a couple of capacitors and a single resistor to function (see the circuit here). Also it is cheap, less than €1 from China and has a mature Arduino library. It could comfortably have fit in the space occupied by the resistors on the left of the picture. On the downside, it requires a 5v supply. (The Arduino playground has a lot of information about it.)

So, it was instructive to lay out an LED matrix and write a library for it, and I'd encourage you to try it for yourself. (However I also won't blame you for simply buying one on eBay, they seem to be cheaper than the cost of parts somehow!)

Wednesday 17 July 2019

At the Margin

(Who knew that the Economics of Seinfeld was a thing? Given that it was the first link returned by Google, everyone but me I guess!)

The idea of "marginal cost" is usually in mind when I'm preparing a PCB order from Seeed Studio. That's because their product is cheap and high quality but shipping rates are high. This means that it's almost free to load up an order with small items which would not of themselves justify the total cost.

This post describes a couple of such items, which gave me practice (I'm learning KiCad) yet took no longer than a few hours to produce.

The first of these is a breakout board for the (pre-ESP8266 anyway) ubiquitous nRF24L01 radio module. Its main advantage is its low power, allowing projects using it to run off batteries. Its main disadvantage is its breadboard-hostile pinout. Enough said: see picture below.
nRF24L01 breakout
Sparkfun does something similar; however theirs is better, and more expensive! I kept mine pin-compatible though, because why not?

Next up is a breadboard-friendly development board for the attiny84. This had been on my maybe-list for a while but it was only when I discovered Spence Konde's awesome Arduino core for ATtiny that I decided to go for it. The presence of Optiboot sealed the deal for me: the pin header allows sketch upload via a standard FTDI dongle.

attiny84 devboard
Lastly, just to show that they both play nicely together, the pair wired up, and programmed with a sketch using my ATtiny port of the RF24 library (originally written by Maniacbug of course).
All together now!

Wednesday 22 May 2019

Soldering Kata

7x7 LED Matrix
When I were a lad, LEDs were a big deal, literally: £1 each. Now someone in China manages to make a living selling them for £1 for 100. With inspiration provided by an Instructable, a rainy afternoon and the need for some soldering practice I set to work.

The Instructable's, err, instructions were clear enough:

  • take a piece of protoboard (the sort with pads instead of strips)
  • solder each row of LEDs anode (longer) first to hold them in place
  • cut the cathodes to size and bend them through 90 to connect each row's together
  • test each row after soldering!
  • I then cut a piece of stripboard ("veroboard") into single strips and connected each column's anodes together in a sort of DIY dual-layer PCB arrangement, see below.

Rear view: anodes connected in columns

The last step was the only point where I deviated from the instructions. (I first attempted to fit a single piece of veroboard over all of the anodes but found this impossible: there was too much variation in their positions. Perhaps aligning each row of LEDs as it is soldered using veroboard might work?)

Next: mount vertically on breadboard, add a handful of resistors (470R) and connect to an Arduino!

I wrote an Arduino library for it, available on Github. It contains a couple of examples, the simplest can be seen running below. (The moving light makes keeping the camera focussed impossible, sorry.)




The disadvantages of this bit-banging approach to driving an LED matrix are fairly well-known:
  • it uses an excessive number of GPIOs (14 here)
  • the GPIOs themselves can't supply very much current, so the more LEDs lit, the dimmer they are
  • PWM-style dimming is not practical
  • timing is tricky: since it relies on persistence of vision to work, each refresh cycle must take no more than 40ms
For all of these reasons, using a dedicated driver chip is recommended. More when my MAX7221 (another £1) arrives on the ship from China in a couple of weeks!