Update: True Bypass kits now available for sale here.
I have used Arduino over the last twelve months or so for a couple of projects and I have been looking for an excuse to go to play with the AVR ATTiny embedded microcontroller range. I came across on Jack Orman’s true bypass project and initially thought that controlling a relay with a microcontroller was a little over-the-top. Whilst researching another project I came across Jack Gannsle’s excellent article on switch debouncing where it becomes clear that custom chips for debouncing switches are basically non-existent and if you’re going to debounce a momentary switch and drive a bipolar (latching) relay, you’re going to end up with quite a few components. So maybe using a microcontroller is not such a bad idea. Let’s try it!
Here’s the schematic:
As you can see, once you get the voltage regulator out of the way, the whole thing is only five components. ATTiny outputs can sink or source 40mA and the relay coil requires about 20mA so that’s OK. When we power up PB3 and PB4 are made low. To set the relay, we make PB3 high for a few milliseconds then low again. To reset the relay, we make PB4 high for a few ms then low again. Thus the power consumption of the circuit is very low (a continuous 1mA instead of 20mA if we used a non-latching relay). I used an LP2950-5 in lieu of the 78L05 shown on the schematic to reduce quiescent current from around 4mA to 1mA ( see below).
Here’s the finished item:
The PCB dimensions are 30mm x 25mm. Here’s another picture with the development board and a couple of half-finished PCB’s:
The software is interrupt-driven and uses Dr Marty’s best-switch-debounce-routine-ever… and it works very well. I toyed with using a jumper to determine whether the unit should power-up with the effect active or bypassed but I decided there was no downside to detecting if the stomp switch was pressed at the time the unit powers up and, if so, toggling the power up status. The power-up status is held in EEPROM.
Whilst the 78L05 is less expensive than the LP2950-5 (about half price) neither are going to break the bank. Furthermore, looking at the specs, the 78L05 has a quiescent current of 3mA and a minimum load current of 1mA whereas the LP2950 has a quiescent current of 0.1mA and a minimum load current of 0.1mA to maintain regulation. So it seems like a no-brainer to choose the LP2950-5 and get much better battery life. The ATTiny is currently running at a clock frequency of 9.6MHz and if I rewrote the software to run it at 128kHZ the power consumption of the ATTiny13A would fall further but as the idle current is already less than 1mA, I may not get a round tuit.
All in all, an interesting my-first-ATTiny project.
p.s. for those interested in such things, I used the following setup:
- ADAFruit USBtinyISP from oomlout
- Eclipse IDE for C/C++ developers
- AVR-Eclipse Plugin
- WinAVR – AVR-GCC toolchain including AVR-libc and AVRdude