as1x752    20th Apr 2014   

I had been thinking of what I wanted to do as my very first project and learning experience with electronics.

I was pretty hell-bent on getting my feet wet with some hardware hacking, but I didn't know where to start. For my very first project, I decided to make something using one of the ATTiny45 samples that I had received from Atmel. These, of course, were recommended by Fidel, so I figured why not give it a shot, right?

So the very first step was to figure out what I wanted to do with the project, and typically these ideas spawn out of necessity. I thought about what I could really use, and the idea dawned on me that my network storage device had been acting up one me as of late. Nothing to severe, but it is quite annoying having to power-cycle the damn thing every time I try to access my music files -- so, that was what I decided to base my project around. Nothing too flashy -- I really just wanted to control a brushless DC motor to perhaps push a rod out and auto-magically power-cycle my NAS at the push of a button.

Planning is of utmost importance when building a project -- something I seldom do. I'm rather impulsive and tend to jump into stuff without any real direction most of the time. This was pretty much one of those times.

Trying to use only what I had laying around, I grabbed one of my Arduino Uno boards and quickly set it up for use as an ISP for the ATTiny45. I grabbed a small perf board and got to work soldering all of the leads to some jumpers so that I could hook up to the Arduino pins following a small diagram I picked up off google.

In order to test it out, I used the blinky example sketch to test and verify that the ATTiny was indeed hooked up to the Arduino properly. Once I confirmed the blinky sketch was good to go, I quickly hooked up the lead from the DC motor to see if it was still in working condition.

I must admit that the thrill of seeing that motor spinning was quite exciting, considering this is my very first project, anyway.

So once I verified that the I could control the motor, albeit in one direction, I went into brainstorm mode to figure out what the next step was to getting the motor to spin the opposite direction. I felt it easy to consult with Fidel, who recommended I put the PWM pins to good use, but I wanted more. It seemed a bit too easy to use the PWM pins for this project. On top of that, I also wasn't all that sure on how to implement the pulse width modulation pins into this project.

After researching a bit and stumbling upon a great video on how to construct an H bridge with 4 transistors and two momentary switches, I started formulating an idea of how I may be able to implement the ATTiny into this to act as either switch and then I just might be able to get my project rolling.Luckily, I had some transistors lying around just collecting dust. After emulating and modifying the schematic for the H bridge, I got to work popping all the pieces into my breadboard for testing.

After a few hours of head-scratching and rebuilding, I finally got everything plugged up the way it needed to be. The one thing that I needed to do was modify the sketch to make sure that I could control the ATTiny pins with a momentary switch to trigger them high.

I soon realized that the motor was not doing what I expected -- in fact, it wasn't doing anything at all. Why was this? Was my schematic flawed -- or perhaps the leads on the breadboard? I immediately grabbed up my multimeter to start testing.

Some more head-scratching and over-analysing and I finally figured out what was going on. The VCC from the Arduino was indeed feeding near 5 volts to the collector pin of the first transistor, but the current was dropping drastically on the output from the emitter pin. By drastically, I mean the current was being reduced to less than half a volt! What's worse is it was dropped to nearly nothing after passing through the second transistor!

After giving it a few days rest and realizing the project was nothing but a complete failure, I decided to poke at it a bit anyway. I started reading up a little more and I decided to give the PWM pins a try. Well, let's just say the easy route was the safest route in this case.

All in all I did learn a few things about the ATTiny and what an H bridge is. I also learned how to use transistors and the difference between NPN and PNP. I don't consider the project to be a complete loss since I did learn, and that was the main goal of this experiment.

I may just start tinkering a bit more with my ATTiny45 MCUs and see what else I can cook up, but for now, I will leave it at that. I look forward to adding another page to my journey in hardware tinkering!

Tweet This!

Social Media