Making tools #1

      No Comments on Making tools #1

Sometimes, before you can make a thing you have to make the tools to make the thing. Or to put it another way … while having a bunch of breadboards tenuously connected by a rats nest of inscrutably coloured wires might be impressive (when it doesn’t look like a bomb), on occasion it’s good to have a tool that simplifies certain bits of work and makes it repeatable.

So this is the first post is what’s going to be an ad hoc series about the tools I’ve made, and will make in the future, as I explore the world of electronics, robotics and retro computing.

Let’s start with AVR chips, because that’s my current obsession.

I’ve been playing around with Arduinos for quite some time now, but I decided to get all hairy-chested and try my hand at bog-standard AVR microprocessors. It’s been quite an eye-opener. There are many, many challenges involved in getting down to that level if you’re not an electronics engineer and not a programmer. Know anyone like that? (Sticks hand in air.)

(By the way, you can expect another occasional series on programming AVRs, too.)

The first hurdle is getting your program from your computer on to the chip. I’ve started off with the ATMEGA328P and, as hard as I tried, I could not get the USB cable to plug into it.

Next stop – breadboard.

I treated myself to the Atmel-ICE programmer which terminates, via the ISP port, at a little six-pin plug. So I made up a connector for this using an HE10 2×3 socket, a tiny bit of stripboard and some header pins. This way I can easily plug the programmer into a breadboard.

Connecting to the chip at that point is a simply matter of running four jumper cables (MOSI, MISO, SCK and RESET) and providing power. So that was easy.

However, the breadboard setup has some disadvantages. It’s fine for programming the chip and maybe connecting up a few extras bits and bobs to experiment with. But I find that constantly plugging in and extracting chips runs the risk of bent little legs. And wiring up each time is time-consuming and cumbersome. I wanted something a little more permanent, more capable of allowing me to set up test circuits, but where I could easily remove the chip once programmed so that I could transfer it to the final project.

This was my first attempt. I say ‘first’ because I’ve now recognised some drawbacks and am planning a Mk.II.

The prototyping board mimics a breadboard in terms of size and the way the connections run. You can get similar boards from Adafruit but this one is from … somewhere else. This model has the advantage that the positive and negative rails down the side are connected via traces across the board, so you need only provide power to one side.

I soldered in my little adapter for the Atmel-ICE (it’s at the right-had end in the photo). For some reason I provided a switch to either connect it to or isolate it from the board’s +5V supply. I can’t remember why I did that. No doubt it’ll come back to me.

At the other end of the board I put a barrel jack socket for power, connected to the power rails via a 5V regulator and a couple of smoothing capacitors. I also added a power-on LED. I neglected to include a power switch – something I’ll correct on the next version.

The AVR chip itself sits in a zero insertion force (ZIF) socket. That makes it easy to swap chips in and out. I can bung in a chip, test and debug the code for it, then easily move it to its final resting place in the project for which it’s being programmed.

Most of the GPIO pins are brought out to header pins. But there are some exceptions and additions.

I added an external 16MHz crystal. With an ATMEGA328P the whole setup then emulates an Arduino Uno. That means I lose two GPIO pins – PB6 and PB7. In retrospect, that wasn’t necessarily my best decision.

And for another reason, too. Originally I thought, ‘bung in a fast clock and it’ll zip along nicely’. But I’ve since learned more about clock speeds – for example, how you need to choose them carefully if you’re doing stuff like using the USART for serial communications. Some speeds give a better range of reliable baud rates than others, and 16MHz isn’t one of the best. So, on the next iteration of the board, I’ll make using an external crystal optional and the crystals themselves interchangeable.

I also lost PC6 because I tied the RESET pin permanently high using a resistor. Again, this is something I might want to make optional via a switch.

Two additions I made were a pushbutton and an LED. (The LED is nearly invisible in the photo. It’s between the push button and the DIP switches.) These are just handy things to have when you’re experimenting with code. They are connected to pins PB1 and PB2. But this time I was smart and put DIP switches inline so that I can use those GPIOs either with the LED and/or button or via the header pin.

I mounted the board and a breadboard on a piece of acrylic, so I have a self-contained prototyping system. In the photo, the LEDs on the breadboard are remnants of various experiments. The 4-digit, 7-segment display being driven via a shift register is part of a prototype for another tool – a hex display for a 6502 microcomputer I plan to build. But more of that another day… suffice to say that, here, I’m using a tool to build a tool.

And it’s worked great. I’ve taught myself a lot of AVR coding with this setup. But it does have its limitations. It works only with AVR chips that are pin-compatible with the ATMEGA328. I’m stuck with one clock speed. And I’ve lost access to three of the GPIOs. My next version will sort all of those.

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.