As with many of my projects, this one deserves more of a write-up than I have time to give it right now. I wanted to get it up on GitHub so that anyone else looking for an example of using the timer interrupts / ISRs on the ATtiny461 can find it.

The algorithm is basically:

  • If the power is off, turn it on when the button is pressed.
  • If the power is on, don’t turn off on a single press.
  • If the power is on and the button is held for 6 seconds, turn the power off.
  • If the button is held after the power has been turned off, don’t turn on until it’s released first.

Hopefully the code is commented enough to be useful: set up the prescaler and the ports, then enable interrupts and do everything else in the ISR.

The Makefile is from Markus Conrad’s project, and was invaluable for getting things up and running. I used a BusPirate for programming, though I’ve gotten a real AVR programmer in the mean time, so I’d like to revisit and finish this.


30th June 2016

Okay, there was some progress. Due to programming woes, I ended up switching to using the ATtiny84..

The work is now the default branch on GitHub for this project. I’ve retrofitted Boo-the-Power-Supply to use this program, here’s the first test:

https://youtu.be/JctCwt6r1HY

ATX power supplies have a stand-by (5VSB) which provides 5V even when the computer is off. This is so that the motherboard, running something pretty similar to my code above, can have enough power to check if it needs to turn the full PSU on. That may be because of a button press, or an interrupt, or a timer - whatever.

I’ve wired VCC on the tiny to 5VSB. Ground to ground, which is also where the negative terminal of the lamp in the button is wired and to C terminal of the push button switch.

The NO (normally open) terminal of the switch goes to PB3, and PB4 connects to the green wire of the ATX connector (PSON) - it has the internal pull-ups enabled and will pull down when the conditions for enabling the PSU are met.

Inside