Electronics Need help making a momentary push button into a timed power button

Discussion in 'Modding' started by Marmotta, 23 Jul 2010.

  1. Marmotta

    Marmotta What's a Dremel?

    Joined:
    2 Jan 2008
    Posts:
    45
    Likes Received:
    0
    I'm making a portable N64 and wanted to use the start button from the controller as the power button. The first thing I need help with is actually using the momentary push button as a power button, so that the console still receives power from the batteries after the button has been released. However, I would also like to be able to retain the functionality of the button in-game, so I was also thinking about having it act as the power button only when pressed for a few seconds. I assume this would be possible using timing circuits, but although I'm willing to do a bit of trial and error work, I'm not familiar with programming at all, so I was wondering if anyone knew how to go about doing this or knows where I could find this info? I appreciate it would be a lot easier having a separate open-closed power switch, but where's the fun in that?:D

    Any help would be much appreciated
     
  2. riekmaharg2

    riekmaharg2 has completed the PowerCore scratch build

    Joined:
    22 Feb 2009
    Posts:
    1,363
    Likes Received:
    282
  3. capnPedro

    capnPedro Hacker. Maker. Engineer.

    Joined:
    11 Apr 2007
    Posts:
    4,381
    Likes Received:
    241
    Short answer: you don't want to do this.

    Long answer: A microcontroller is probably the way to go. But a PICAXE is hugely overpowered. Something like an ATtiny5 would be better suited. However, you've then got to worry about draining the batteries even when the device is switched off. Also, you'd have to learn to program microcontrollers and get an FTDI programming cable.

    A discrete solution would be over complicated (RC timer and a voltage divider fed into an Op-amp comparator, output dropped down with a zener, fed into an optocoupler which drives a D flip-flop which triggers a MOSFET should probably do it). However, it wouldn't require current even when switched off. But it would take up more space.

    Secondly, either solution (uC or discrete) would (most likely) require you replacing the (probably) membrane button with a double pole momentary which wouldn't feel the same, and would probably be a pain to fit in.

    In my opinion, you're be much better off with a nice toggle switch. Recess it slightly into the side of the case, it'll look great.

    But, there may be an easier method if the motherboard is only looking for a line to be pulled HIGH/LOW momentarily. You'd have to explain how the system works at the moment before I could tell, though.
     
  4. capnPedro

    capnPedro Hacker. Maker. Engineer.

    Joined:
    11 Apr 2007
    Posts:
    4,381
    Likes Received:
    241
    But, if you really must have this feature, and you want to know how to get started, here's what you do.

    Buy a USBtinyISP AVR Programmer Kit (some variations also available on eBay for ~£11). There are cheaper options if you want to use serial/parallel instead of USB. Alternatively, you can use an Arduino board to program other chips.

    Install WinAVR.

    Write your C.

    Use GNU make/avr-gcc to compile the .c file into a .hex file. Alternatively, you can use AVRStudio.

    Buy a breadboard if you don't have one already.

    [​IMG]
    Wire your programmer into your microcontroller (ATtiny13A is the smallest Atmel uC available as a DIP package). Check the datasheet to find out which pin is which.

    Use avrdude to burn the .hex file to the microcontroller.

    Assemble your circuit (preferably using a DIP socket which allows the uC to be removed).
    You want one input (debounced) from a momentary switch. You need one output to drive a transistor which replaces the original start button functionality. The second output needs to switch a MOSFET to power the N64 motherboard etc.
    Use interrupts rather than polling so the uC can be placed into its low power state.
    On the rising edge of the switch's interrupt, start a timer. On the falling edge, calculate the time the button was held for. If it's less than a certain time, switch output 1 (the transistor). If not, swap the state of the output pin driving the MOSFET.

    That's the basic idea, anyway.
     
    Last edited: 24 Jul 2010

Share This Page