Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

ATtiny45 low-side switching, unwise?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ATtiny45 low-side switching, unwise?

by efh on Tue Oct 12, 2010 11:18 am

Greetings all,

I purchased several kits from Adafruit Industries this past year as I had some time to learn new things when I was stuck in Kuwait. The soldering, general assembly, and the Arduino programming kept me fairly well occupied. Now I'm starting to take projects from Arduino prototyping of the logic to the Tiny AVRs. I have my USBtiny working well for me. I am using Eclipse AVR for my IDE. I have successfully programmed my ATtiny45 to do my bidding and have run into some issues.

I would like my ATtiny45 to be powered off much of the time. I have an external circuit that switches the beasty off. Well it is supposed to. My external circuit terminates in a NPN transistor as a low side switch to the ground of the ATtiny45. The ATtiny45 has an output pin passed through a resistor to the base of another NPN transistor. (Here is where I hope many of you are smiling and shaking your head at the silly mistake I have made and already know what I will describe next.) As there is still Vcc at pin 8, the current finds a new place to go. The path through my output pin, resistor, base NPN pin, NPN emitter is now the ground. As such the transistor is 'ON' and the LED it was switching is now constantly on, though low. If I restore the ground to the ATtiny45 all works fine.

Need I high-side switch the AVR? Am I missing something elementary to the extreme?

I've been RTFMing a fair bit, but I've yet to go cover to cover. I've also wandered around the 'net on this issue a bit, but have yet to find any insight. Inexpensive references most welcomed. Anecdotal solutions as well.

Thank you for your time,

efh
 
Posts: 19
Joined: Tue Oct 12, 2010 11:04 am

Re: ATtiny45 low-side switching, unwise?

by zener on Tue Oct 12, 2010 1:52 pm

So you have a control line that goes high when you want the Tiny on, and low when you want it off. Instead of running your NPN switch with this line, how about just connect it to the reset line? Would need to be open collector, or run through a resistor so your normal reset switch would still work, if you have one.

zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: ATtiny45 low-side switching, unwise?

by Entropy on Tue Oct 12, 2010 7:33 pm

Why do you want it powered off most of the time? If you put it into deep sleep its current draw will be almost negligible, and you should be able to wake it up with a pin change interrupt.
Entropy
 
Posts: 472
Joined: Tue Jan 08, 2008 12:43 am
Location: Owego, NY USA

Re: ATtiny45 low-side switching, unwise?

by efh on Tue Oct 12, 2010 11:32 pm

After my post I realized, as suggested above, that I could more efficiently use the other pins and programming to take the place of the switching circuit. The problem a newb has when mashing circuits together. I miss the obvious. I will work on making the device power efficient by its programming and the utilization of interrupts and sleep modes. It will take me longer to do the first time than an external switch, but would certainly be a more proper way to do things in the uController realm!!!

Thank you,

efh
 
Posts: 19
Joined: Tue Oct 12, 2010 11:04 am

Re: ATtiny45 low-side switching, unwise?

by chatham on Wed Oct 13, 2010 3:33 am

Congratulations on having such a can-do attitude about using your uC properly! It will really keep you in good stead to build good habits. It really is amazing how little power modern devices can take, though, and a ton of sensors also have sleep modes, so if you can get used to working with them, you'll be well-equipped to build things that will do some pretty crazy stuff running on a watch battery, for like 2 months straight. It's a good time to be getting into this hobby, since interesting things are getting dirt cheap - like accelerometers are now like a buck or two each. Crazy!
OpenChord.org - Open Source kits to let you play Guitar Hero with a real guitar, or build your own Wii/PS3/USB controllers.

chatham
 
Posts: 144
Joined: Thu Feb 04, 2010 2:30 am

Re: ATtiny45 low-side switching, unwise?

by efh on Wed Oct 13, 2010 7:47 am

The costs, or really lack thereof have really blown my mind. Now the temptation to order in huge lots still keeps the expenses up there if one lacks discipline. The next price cut always seems just a few more items away and the thoughts run along the lines "I will certainly use them eventually". Now if I can just get organized so as not to lose all the extra little bits I keep buying.

Now, back to the topic on hand. I've yet to do the proper research this evening after work to see how I work the interrupts to wake the device as needed from a sensor that is giving pretty much constant input. Would it be safe to assume that a periodic waking to check the status would be a reasonable method. Say a check of the sensor status every second or so?

efh
 
Posts: 19
Joined: Tue Oct 12, 2010 11:04 am

Re: ATtiny45 low-side switching, unwise?

by efh on Wed Oct 13, 2010 4:38 pm

It seems the Watchdog Timer will be my friend. I'll just need to make an initialization and shut down routine that is run at the beginning and end of each interrupt generated by the WDT. Where, should the interrupt test for a condition it would initiate sleep again on false and on true it simply allows main() to do its thing again.

Time to fiddle and fail a few times, til I garner some modicum of a clue!

efh
 
Posts: 19
Joined: Tue Oct 12, 2010 11:04 am

Re: ATtiny45 low-side switching, unwise?

by efh on Wed Oct 13, 2010 9:00 pm

OK. Say I have the device sleeping and the WDT wakes it and checks for a true condition from time to time. To return to 'normal' function that operates off of timer0 overflows, do i simply restart timer0 and not reset the WDT flag?

efh
 
Posts: 19
Joined: Tue Oct 12, 2010 11:04 am

Please be positive and constructive with your questions and comments.