Showing posts with label ISP. Show all posts
Showing posts with label ISP. Show all posts

Monday, 13 July 2015

Teensy 3.1 programmer for ATtiny85 chips - going permanent, part 3

This is a continuation of my previous post Teensy 3.1 programmer for ATtiny85 chips - going permanent, part 2 and the last part of the tutorial. After a couple of months of a break, this time, I'm going to connect indicator LEDs and the socket. The board does not look as clean and neat as initially thought it would, but it's my first one afterall.

I took my time finishing the board as after wiring everything up and soldering it together, I introduced a hardware bug and couldn't figure out where it was. After a couple of days of scratching my head I put my unfinished board on the shelf and decided I would get back to it at some stage. I looked at it almost every day for a couple of months saying to myself: "I will fix you some day" and finally, last weekend I decided that this just has to end. I took my trusty yellow multimeter and started debugging.

Finding hardware problems is not as easy as debugging a high level program. There's no IDE, no debugger, no stack trace. There is just your board and your multimeter. And a short circuit somewhere. Debugging a physical circuit is not as easy as "stepping into" your code or whatever term you use (if you've ever debugger a program, that is!). It is a tedious set of checks, one wire after another. One after another, and again and again... Even if you find a bug (minimal or infinitely large resistance), it is not immediately obvious what causes it. It wasn't any different in my case.

I found two short circuits and I had no idea what could have caused them. I almost gave up a couple of times, but after hours and hours of probing, I finally found my mistake. And when I finally did, I was far from happy with what caused it! As it turns out, when you drill a hole in the copper strip to break the connection, you have to be very careful not to leave any residue copper touching the neighbouring strips. Zero, null. If you do (and you might not even see it!), you, my friend, are up for a treat - hours of tedious tests and misery.

Thankfully all ended well and I finally fixed the board. Let me show you the process step by step.

  1. Indicator LEDs connected and working (I decided to stir thing up a bit and assign the red LED to WRITE signal):
  2. Socket connected:
  3. RESET and GND lines connected:
  4. Remaining lines connected:
  5. And finally, the board gets cut:

This is the final part of the tutorial.

A piece of advice for keen fans of electronics: think twice before you buy a stripboard like mine. If you're a beginner, just like me, it will most definitely cost you hours of head-scratching if you make a tiniest mistake. And after it's finished, it will not look pretty.

However, finding a bug and fixing it does give some sort of feeling of accomplishment, so it wasn't all that bad :)

Thanks for reading and happy hardware hacking!

Saturday, 14 March 2015

Teensy 3.1 programmer for ATtiny85 chips - going permanent, part 2

This is a continuation of my previous post Teensy 3.1 programmer for ATtiny85 chips - going permanent, part 1. This time, I'm going to list all components needed to make a permanent Teensy 3.1 programmer for ATtiny85 chips.

I have all components ready, here's what I'm going to use:
  1. Shrouded box header (2x3):
  2. 8 Pin DIL IC Socket:
  3. 2 x 14 pin header socket:
  4. 6-Conductor Ribbon Cable with IDC Connectors 6:
  5. and obviously, a stripboard:
Now, since I have all components, let's prepare a compact prototype on a breadboard. If you remember from my previous post, I wanted to change the default Arduino ISP layout slightly to make my board look better.

Update:

After an hour or so of experimentation, I realised that changing that pin 13 to 9 would be more complicated than I initially thought, so I decided to leave the ISP code as it is now and move on to soldering. Expect an update soon!

Sunday, 1 March 2015

Teensy 3.1 programmer for ATtiny85 chips - going permanent, part 1

Breadboard prototypes are handy. You can assemble them quickly, check if your concept works and your work is done - the tool you wanted to build can be used immediately (see my Teensy 3.1 programmer design here). However, after a while, those flimsy cables and fragile design make you want to build something more permanent. I don't mean anything like a printed, fancy board, but just a simple, soldered solution on a stripboard. As I have one of those stripboards somewhere in my "electronics" drawer (thankfully, it's still only one drawer), I decided that it's the highest time to try to make my ATtiny85 programmer more robust and move from plastic to copper.

Stripboard.jpg
"Stripboard" by Alexander Jones - Own work. Licensed under Public Domain via Wikimedia Commons.

Before I start soldering, let me gather all requirements in one place so the design is as polished as possible.
  1. Ideally, only one side of Teensy's pins should be used - right now, most of the programmer's pins are located on just one side of the Teensy board. There are two pins on the other side, though:
    • 3.3V
    • PIN 13
    While I don't think I can relocate the 3.3V pin, PIN 13 should be easy to replace by one from the the other side of the Teensy board. This should keep the design compact and understandable but will require some changes to the Arduino ISP code.
  2. Microcontroller socket should be a part of the programmer board - in case the device doesn't have the programmer interface (programming is done by removing the chip), it should be possible to connect programmed chips directly on top of the programmer board.
  3. The board should have the ATtiny85 programming interface - 6 pins will be enough.
  4. The board should be as compact as possible - that goes without saying.
I think that's a complete list of my requirements. Now, let me prepare all required components. Please expect an update soon!

Sunday, 24 August 2014

Teensy 3.1 ISP - program an ATtiny85 with your Teensy!

A couple of weeks ago I had this brilliant idea of building an intervalometer for my canon 450D. As I already had my Teensy 3.1 at that stage, it was an obvious choice for me. I implemented a *very* simple Arduino code, uploaded it to my Teensy, hooked up some wires together and had a blast shooting some time lapse videos (see here for example).

However, I quickly realised that I want my intervalometer to be smaller, more portable and battery powered (no USB cable required). I started googling and discovered that people use their Arduinos as In-System Programmers (ISP, see here) to program smaller AVR chips like ATtiny85. What a brilliant idea! I quickly ordered some ATtinys and started building. Here are my results - who knows, maybe somebody will find them useful?

  1. First of all, you'll need to have the Teensy 3.1 configured and working with the Arduino IDE. To make sure everything is working as it should, please follow PJRC's tutorial. If you have already set up your Teensy 3.1, you can obviously skip this step.
  2. Open the Arduino IDE (I'm using version 1.0.5-r2). You should already see the ArduinoISP sketch in the Examples section (File -> Examples -> ArduinoISP).
    Select it and take a quick look at the source code. You should see a section where RESET, LED_HB, LED_ERR, etc. macros are defined. Since RESET's original value is SS, let's change it to 10. Additionally, make sure that the function start_pmode() calls spi_init() before anything else. Save the sketch and upload it to your Teensy 3.1.
  3. Now, let's wire the programmer's LEDs up. They will give you an indication of what your ISP is currently doing. And if it's not doing anything, you can always rely on the heartbeat LED. There are 3 LEDs I'm using:
    • Heartbeat (YELLOW, LED_HB, pin 9)
    • Error (RED, LED_ERR, pin 8)
    • Write (GREEN, LED_PMODE, pin 7)
  4. Now, the next step is to install the ATtiny85 definition in your Arduino IDE. David A. Mellis was kind enough to prepare ATtiny support libraries for the Arduino IDE and share it on GitHub (you can get the zip directly here).

    Once you download the zip, extract it and you should see a folder called attiny inside the package (attiny-master -> attiny). Copy the attiny folder to your Arduino's sketchbook folder's hardware subfolder (it should go like this: Arduino -> hardware -> attiny). Start or restart your Arduino IDE. You should see a list of newly added ATtiny definitions in the Board menu (Tools -> Board -> ATtiny...)

  5. Make sure your Teensy acts as a programmer from now on by choosing appropriate Programmer option (Tools -> Programmer -> Arduino as ISP):

    Select the basic Blink example and choose your board from the new list. I'm working with ATtiny85, so my choice is ATtiny85 (internal 1MHz clock) (I don't want it to consume too much energy, as it's going to be battery powered).

    The last thing before connecting the ATtiny is to make sure we are using correct pin number to drive the LED. ATtiny doesn't have pin 13 (otherwise it wouldn't be so tiny!), so let's change the value of the led variable to 0 (which, funnily enough, is ATtiny's pin number 5).

  6. Now, let's connect the ATtiny. Disconnect the Teensy and stick the ATtiny on a breadboard. Look closely at the top surface of the chip, you should see a small circular shape indicating where the RESET pin is. It will look like this:

    Connect the pins as follows:

    ATtiny85 Teensy 3.1
    RESET (1) 10
    VCC (8) 3.3V
    GND (4) GND
    7 13
    6 12
    5 11

    using the ATtiny's pinout sheet as a reference:

    Your connections should look like this:

  7. Now you are ready to program your ATtiny85. Connect your Teensy 3.1 again and, having the Blink example in front of you, simply upload it. If you connected everything correctly, avrdude should upload the Blink code with no problems reporting something like this:

    ...
    ...
    ...
    avrdude: verifying ...
    avrdude: 836 bytes of flash verified
    avrdude: Send: Q [51] [20]
    avrdude: Recv: . [14]
    avrdude: Recv: . [10]

    avrdude done. Thank you.

  8. Now your ATtiny85 is programmed and you can test it:
I had a couple of problems in the process, but it was mostly due to wrong connections. If avrdude complains about invalid ATtiny's signature (whether it's 0x000000 or 0xFFFFFF), double check the wires and try to connect everything again. I hope this is useful and I encourage you to let me know if it worked in for you.

Thanks and happy hacking!