Lifelong Learning Knowledge should be uncompromisingly sought after and freely given away.

6Oct/090

Saving Power With an AVR

I've been consumed lately with saving power with my designs and I decided to focus my obsession on my new "FakeFireLEDDriver" design I got inspired to build from this example. I knew that I wanted to hand out Halloween gifts, in this case Jack-O-Lantern fake fire boards to my family who always pacify my obsessions du-jour. I knew that the first version worked and worked quite well, but I couldn't stand the thought that it was definitely a battery hog. Much could be done to improve upon it's energy consumption. Knowing that AVRs are known for their power saving design, I set out to figure out how to squeeze out more efficiency from this design. What is attached below is my first attempt at power savings with the "FakeFireLEDDriver" design. I've basically implemented a WDT (Watchdog Timer) to tell the system to wake up (if the system is asleep) every ~8 seconds and check the photocell, if it's dark, flicker away, if not, go back to sleep. This simple change in logic should save considerable energy. My next step is to only give power to the photocell during that check, which is about as much energy as I can see saving with this design. Check out the attached code and as always, feedback is most welcomed!

AVR Power Saving Example
Title: FakeFireDriver1.2 (816 clicks)
Caption: AVR Power Saving Example
Filename: fakefiredriver1-2.zip
Size: 2 KB

AVR Power Saving Example
Title: FakeFireDriver1.2 (816 clicks)
Caption: AVR Power Saving Example
Filename: fakefiredriver1-2.zip
Size: 2 KB

Tagged as: No Comments
30Sep/090

ATTINY13A Automated Dog Stairs

ATTINY13A Motion Dectector Dog Stairs 

So I finally got my next shipment of PCB boards from BatchPCB.com. The boards were perfect, not one mfg issue (I suspect this is mostly thanks to what I learned from SparkFun.com). It's fantastically rewarding to see your ideas come to life, I posted here originally about the Arduino controlled dog stairs I had built but I wasn't satisfied. I wanted to free up the Arduino, it's not what a development board is for anyhow. I have since crossed the hurdle of building my own code in C using AVRStudio. I decided upon the ATTINY13A chip because it was small and really had just enough functionality to make this project work as I had wanted it to. The Arduino was overkill; an ATMEGA328 is WAY overkill for this project. I've learned so much about AVR programming I can't even believe how far I've come. I've posted the AVR source code, high resolution pictures and the eagle files so you can build your own. I figure I've got no more than $10 invested in this not including the stairs!

ATTINY13A Dog Stairs

And here are the boards I got from BatchPCB.com the other day.

BatchPCB.com Boards

Images and AVR Code
Title: AVRDogStairsSmall (935 clicks)
Caption: Images and AVR Code
Filename: avrdogstairssmall.zip
Size: 220 KB

Images and AVR Code
Title: AVRDogStairsSmall (935 clicks)
Caption: Images and AVR Code
Filename: avrdogstairssmall.zip
Size: 220 KB

Tagged as: No Comments
12Sep/090

Arduino Powered Dog Stairs!

Arduino Powered Dog Stairs

Yes, you read that right! I've talked briefly about my dog stairs project in my first post and finally got around to taking lots of high resolution pictures and thought I'd share the project with everyone. You can find all the pictures and code in the attached ZIP file. Here's basically what I did:

1. I purchased a Parallax PIR motion detector from Radio Shack.

2. A photo cell I had lying around, it doesn't matter what resistance, just modify the value in the code to reflect your photocell's darkness value.

3. Project box (enclosure) from Radio Shack.

4. Two white 20ma LEDs.

5. Wire, plenty of wire (you'll see in the pictures, I used a bit much)!

I've hooked up the photocell to the analog pin 0 of the Arduino. The code loops checking for the pre-configured value for darkness, when the value is read from the photocell and it's at or below that value we increment a counter and delay 1 second. We repeat this process until the counter equals the number of seconds of darkness required to activate the PIR. We do this to prevent momentary darkness/lightness from switching the state of the PIR. We of course perform the exact opposite logic for light (this helps if for example you flip on the light and then flip it back off).

Once the state has changed and the PIR is activated we enable power on Arduino pin 7 and give the PIR a pre-configured 30 seconds to calibrate. This is per the datasheet. Once calibration is over we monitor pin 3 on the Arduino for motion (which is triggered by a logical HIGH on pin 3). When motion is detected we turn on the LEDs by setting pin 13 to logical HIGH for the pre-configured 15 seconds. This motion detection sequence repeats until it's light outside and we shut down the PIR. I power the whole thing with a 9V 500MA wall wart.

Simple huh? This project went together quite nicely and fairly quickly. If you have questions or comments, please feel free to ask.

DogStairs
Title: DogStairs (1127 clicks)
Caption:
Filename: dogstairs.zip
Size: 8 MB

DogStairs
Title: DogStairs (1127 clicks)
Caption:
Filename: dogstairs.zip
Size: 8 MB

Tagged as: No Comments