Making tools #2

      No Comments on Making tools #2

Some time ago, I wrote about how I’d hacked together a board to program and experiment with AVR ATMEGA328P microcontrollers. Well, now I’ve stepped things up a bit.

Mk.II

The key features of the old board were a ‘zero insertion force’ (ZIF) socket for the microcontroller chip and a 2×3 HE10 socket to take the ISP cable from my programmer of choice, the Atmel-ICE. Just plug in a chip, plug in the programmer and burn the program into the microcontroller. Easy.

But I’d found a couple of limitations. There was no reset button (although the chip’s reset line, on pin PC6) was pulled high with a resistor. Also, there was no power switch, so resetting the chip or cycling power (as you have to, for example, when going into debugging mode) meant unplugging and replugging the power cable.

The Mk.II board in use.

I fixed both of those on the Mk.II version. I also made the crystal removeable so that I can experiment with different external clock speeds, or no external clock at all. As it turns out, my solution isn’t perfect because the XTAL1 and XTAL2 pins, (aka PB6 and PB7) have 22pF capacitors connecting them to GND. These are soldered in so I can’t choose specific capacitor values to match the crystal. This is sub-optimal and I learned that this might be an issue only after I’d made the board. Oh well, something to consider for Mk.III.

The original board had a tactile button and an LED attached to two of the pins (they could be deselected if I wanted to use the pins for other things). The idea was to have these permanently available for experimental purposes. But I hardly ever used them. So on this version I employed the space to add a second ZIF socket, a 14-pin one, so that I can use the same board to program ATTiny84 microcontrollers. As with the socket for the bigger chip, all the I/O pins are broken out to male headers. There’s no reset button for the ATTiny socket (although there’s room to add one if I find I need it) and no provision for an external clock.

I also added a whole bunch of headers on the GND rails to help when probing with the oscilloscope. Power is supplied via a barrel jack (standard 2.1/5.5mm type) with onboard regulation down to 5V. I usually power it with a 9V 2A wall-wart PSU.

As before, the programmer board is mounted on an acrylic base alongside a permanently glued breadboard. It’s a handy, self-contained unit that allows me to prototype all my AVR-based projects. Or, at least, it did…

Going SMD

For my DottyMatrix serial-to-parellal adapter project I decided to go SMD. Surface-mount components have the advantage of bringing down the overall size of the PCB. So I selected the ATMEGA328PB version of my favourite microcontroller in the TQFP package (it’s also available in a VQFN package, but not as a through-hole PDIP).

It was only after I’d put the order in with Mouser that I thought, “How am I going to program and prototype with this thing?”. Doh!

A quick search on AliExpress revealed the availability of ZIF sockets for TQFP packages. They’re not cheap – mine cost me $16 – but what choice did I have?

The socket came soldered to a breakout board with header pins on the underside. I’d hoped I could solder this into a piece of stripboard, but it wasn’t to be that easy. The pin pitch was wrong. Fortunately, the device also came with a couple of adapter boards that fixed the problem, if in a rather ungainly way.

As before, I broke out the I/O pins to male Dupont headers. This involved some creative routing with cables underneath the stripboard because, while the ATMEGA328PB makes some attempt to group pins belonging to the same port together, it doesn’t always succeed. For example, PE0 and PE1 are on one side of the chip while PE2 and PE3 are on the opposite side. I wanted to group port pins, hence lots of flying wires.

One thing that nearly tripped me up was how the connections are broken out by the ZIF socket board. It routes the connections to two rows of pins, one down each side of the board. These are handily labelled 1-16 on one side and 17-32 on the other. But these are not the pin numbers of the IC package. Pin 1 of the IC is actually routed to pin 29 of the board. Pin 1 on the board is connected to pin 5 of the IC. Everything else is in sequence, just off by four pins.

Things get a little messy underneath. But hey, it works…

This is odd but (and maybe this is the reason) it has the effect – with the ATMEGA328PB, at least, and maybe other TQFP packages – of putting the GND and VCC pins at the tops of the rows. Anyway, I used a permanent marker to note that pin 1 is actually pin 5 and did a lot of counting when working out what connects to where.

I added an HE10 2×3 header to plug in the Atmel-ICE, connected to VCC, GND, MOSI, MISO, SCK and /RESET. I pulled the /RESET pin (PC6) high with a resistor. I also added a socket for an external crystal and 22pF capacitors (to GND) on the XTAL1 and XTAL2 pins as before. But I experienced some problems that will be the subject of a future post. For the time being, I’m running the microcontrollers with the internal clock, typically at 8MHz because clock accuracy isn’t an issue for my current projects.

I also added a reset button.

There really wasn’t space for a power connector, so this time I’m powering the board from its accompanying breadboard. Into the latter, I’ve plugged a handy power supply doohickey that has selectable 3V3/5V outputs that plug into the breadboard’s power rails. It also has a power switch.

And so there you have it – I can program ATMEGA328PB TQFP chips before soldering them to PCBs. I intend to put ISP header connections on all PCBs that use this chip so that the microcontroller can be programmed after soldering. But this new breakout board allows me to prototype and experiment.

Right now, I’m having fun working on DottyMatrix, of which more soon…

Never miss a post

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.