Tag Archives: ATtiny

PWM Based LED Driver

** Updated code for better performance and stability [26 Feb 2015, rev.3]

It has been quite some time since my last post – as often happens, life intervenes and this time just a bit too much hospital time both for myself and one of my kids. Things are good now and normal can resume…

Black-Decker-FSL18FL-Firestorm-18-volt-FlashlightFor years I have had this Black&Decker FireStorm FSL18 flashlight, but hardly ever used it due to its anemic light quality. The fixture is powered with an 18v battery pack and uses a KPR18v0.3A bulb putting out 7 candlepower when running at 18 volts. 1 candlepower = 1 lumen. Compared with the brightness of the 12v power LEDs I have been working with lately, the brightness from this incandescent bulb is not much better than a glassed candle.

The trigger for upgrading this flashlight came one day when the wife complained an LED lightbulb had failed in her workshop. I replaced the bulb, but rather than throw it away, I took it down to my workshop to disassemble and identify what had broken. Continue reading

ATtiny Programming Jig – Part 2

It has been quite a while since my last update. My wife messed up her knee two weeks ago, so between being Mr. Mom and working for The Man, there was no time to tinker. My hat is off to all of you single parents and caretakers who find time to tinker!

Anyway, finally got around to finishing my ATtiny Programming Jig. In Part 1, I covered the functionality of the Jig using a breadboarded solution. Now in Part 2, I take it one step further and develop the schematic into an Arduino shield. Creating a shield greatly simplifies the Jig’s use, as no jumper wires are needed. The shield snaps onto the Arduino in the correct position and is immediately ready for use, as in the image below.

Photo on 2-15-14 at 9.08 PM

Getting there was the hard part. It took me about three tries to get the toner transfer correct. Rather than using the popular glossy photo paper method, I chose to scavenge a few of the wife’s gossip magazines. The results kept coming out rather weak until I found all of the correct print settings for my Mac. The key was to set High Quality and Transparency. For etching, the choice was simple. We have a large swimming pool behind the house, so I reached into my pool supplies shelf and used some of the Muriatic Acid I have. Strong stuff. Within 10 minutes in the freezing garage (it was 25F/-4C today) the board was ready. A bit of milling and drilling got me ready to go.

Photo on 2-15-14 at 7.41 PM

I placed the parts, soldered and plugged it in for testing…

Photo on 2-15-14 at 9.07 PM

Green light on, good! Picked a random bit of code I had written for the ATtiny and avrdude came back complaining the processor does not look right. Ouch! All that effort and it does not work? Started tracing all of the paths on the board until I found the problem. For some reason I had forgotten to map the Arduino pin 12 to the MISO bus. Not sure how that happened, as the schematic is correct. For some reason I must have missed that connection in Eagle when mapping the traces. Once the problem was found, a quick soldered wire solved the problem.

Photo on 2-15-14 at 9.10 PM

Once the new wire was soldered into place, I reconnected the shield to the Arduino and tried to upload again. SUCCESS!!

Photo on 2-15-14 at 9.08 PM #2I will have to go back into Eagle and update the board with the new trace, but that is for another day. I will post an update when I have the board fixed and will publish the Eagle layout. Then onto my next project – animating an ancient backup tape!!

Edit: The revised board layout is available here: ATTiny Programmer.brd

ATtiny Programming Jig – Part 1

Lately I have been making a few projects with the ATtiny84/85 micro controllers. The pumpkin light controller I presented a few months ago, as well as a brushless motor controller I have been playing with (amongst others) have been built with these controllers. I use the Arduino IDE to write and compile the code and an Arduino programmed with the ArduinoISP sketch to write the code into the chips.

At first, I wired up a small breadboard, which worked fine until I needed the breadboard to test something else. Arrrgh. Need to make it more permanent. Rather than make one board for each of the controller types I have, I built it for all three – ATtiny84/85/861. So far, I have tested it with the 84 and 85 with perfect results.Photo on 1-15-14 at 10.15 PM

I always like to put a cheat sheet on the underside of my boards. Not only does that help in remembering which pin connects where, but it also serves as an insulator. I cover both sides of the paper in clear packing tape (poor man’s lamination), punch a few screw holes and attach it with some risers and screws. Keeps the solder side out of the inevitable clipped wire strands and soda-pop condensate puddles.

Photo on 1-15-14 at 10.16 PM #2

The jig includes the Arduino reset override capacitor and LED indicators referenced in the ArduinoISP code. The lights sure look nice when blinking, but about the only thing they really show is whether code is being written to the ATtiny or not.

This jig has worked well over the past few months, but is also wearing out its welcome. I am currently working on an Arduino shield version, which will make it much easier to disconnect and reconnect the jig, without taking my glasses off to see if I connected the jumper to the right hole or not. More info to follow.

Meanwhile, here is a draft schematic of the board, for those who are interested: attiny programmer.sch

 

Using an Oscilloscope to Select a Transistor for a PWM Project

Recently saw some discussion online (I think hackaday.com) regarding the merits of an oscilloscope in the modern hacker’s lab.
As I was working on an DC motor control driver using Pulse Width Modulation (PWM), I was getting odd behavior from the circuit when approaching full power output. In the attached video, I discuss the role an oscilloscope played in helping select an appropriate transistor for the PWM circuit. Specifically, I show how two different transistors behave in the same circuit.

Haloween Pumpkin Light Project

Every year we make a pumpkin to decorate the front porch for Halloween. My daughter, the artist in the family, traces the design on the pumpkin, I cut it out, we add a generic pumpkin light and wala! a pumpkin is ready.

This year I thought I would do something different. I had a few strips of red/blue/white 12v LEDs my Dad once gave me (and is impatiently waiting for me to do something with them!), and I decided to make a mood light based red/blue LED driver with the white LEDs flashing to create a sparking effect.

Rather than use a full Arduino for this project, I decided to try my hand at using the smaller format ATtiny84 on a custom board. I had recently bought some for tinkering and this seemed like the perfect first project. Much easier than I thought. Installed the AVRisp software on my Ruggeduino, connected the leads as required and added a few LEDs for testing. Works!

Ruggeduino as AVRisp

Ruggeduino as AVRisp

Why Ruggeduino, you ask? EZ. I have already blown up used up all of my ATmega328 chips on other projects and I have yet to find a way to destroy the Ruggeduino. Wish I could say that about my UNO you see in the background of the pic above… but that is for another story.

With the ATtiny programming issues sorted out, time to figure out how to drive the 12v LED strips from the ATtiny. Despite using high gain A63 Darlington NPN transistors, I was not able to get the LEDs to full brightness with a single transistor. I found that if I use a 2n2222 to pull the base to ground, I could get the desired light output.

Prototyping the Pumpkin LED driver

Prototyping the Pumpkin LED driver

The software is a mashup of a moodlight sketch and a firelight sketch I had laying around. I added some potentiometer control to limit the brightness of the flashing white light. This would make the board more universal for other seasons. Once I was satisfied the design works, I put it all together on a piece of Radio Shack protoboard I had laying about. I wrapped short LED strips around a cardboard tube and dangled it from the top of the pumpkin.

LED controller board ready for use

LED controller board ready for use

2013-11-02_18-40-01_6522013-11-02_18-38-56_372

A more visual representation of the project can be seen in a short video I uploaded to YouTube earlier today.

Oh… do you think any of the kids noticed the cool pumpkin by the door? sigh… damn candy…

2013-11-02_18-38-33_346

Happy Halloween!