Saturday 21 September 2013

Use an ATTiny45 to auto-boot a NAS200 on power up

I make no guarantees for the information contained herein, I also cannot be held responsible for data loss as a result of your actions, we make our own decisions.

I needed a way of booting the Linksys NAS200 automatically when powered up. As standard from Linksys the NAS200 just stays off when powered up. The Power button on the back left hand side when looking at the rear of the NAS200 needs to be pressed to start the NAS. I often found that when I tried to connect to the NAS it was powered off usually due to a power outage that occurred through the night. I would then have to go upstairs to power it on and wait for it's disk check to finish before I could actually use it. So I set out to fix this inconvenient feature of the NAS200.  First power off and disconnect the power supply then remove the hard drives so they don't get damaged. I numbered the drives 1 and 2 to match the bay they came out of before removal just to be sure they went back into the correct drive bay.  I proceeded to open up the case of the NAS. This involved removing the silver painted base cover using a screwdriver to lift the plastic sprung pillars out and then slide the cover to the front of the NAS. Four screws included one covered by a warranty sticker ( only proceed if you are happy having no warranty and only if you are confident of success ) are removed. This allowed removal of drive bay 2, be careful of the power wires to PCB and SATA connector. Another four screws are removed to remove drive bay 1, again be careful of SATA and power cables. This will allow the main PCB to be accessed. Four screws are removed and this allows the PCB to be removed. An 8 pin socket was procured, pin 4 was soldered to the rear of one of the PCB mounted USB socket, pin 8 was connected to the 5V pin on the LM7805 voltage regulator see the picture below.

NAS200 ATTiny45 in Socket

Pin 5 is connected to the conductor of the power push button at the rear of the PCB via a flexible insulated wire, I soldered it to the top of the push button.

The ATTiny45 was programmed using an Arduino Uno programmed with the ISP Sketch, it's in the Arduino IDE examples, remember to choose the correct board and serial port in the IDE. See my previous post on how to program the ATTiny45 with the Arduino Uno Board.

The AutoPowerON.ino sketch basically sets up the port pins we are using as inputs this gives us the high impedance state so the pins don't affect the NAS200 power up or switch off function using the button. After 10 seconds (just to be sure the power has settled) from power being applied the pins on the ATTiny45 being used are set as outputs and PB0 PB1 go low and high respectively for half a second. They then return to high impedance state, the NAS200 has begun booting. After this the program in the ATTiny45 is then caught in an infinite loop, this ensures the pins are only pulsed once for each power cycle.
Note* I only use pin 5 this is the active low output, pin 6 can be used for circuits that may need an active high 5V pulse.
Code I used is pasted below I saved it as AutoPowerON.ino :-

/*
 NOTE* This Sketch will pulse a Pin low on the ATiny45
 This is to auto power up a NAS box to ensure it
 is available after a power cut. It normally has to be
 turned on by pressing the power button.
 If using an Arduino to program these devices you need to 
 program the ISP Sketch found in the IDE onto the Arduino 
 first. 
 
 So the circuit will pulse a pin low after a
 predetermined amount of time say 10 Seconds
 
 This pin will be connected the same part of
 the NAS box's push button circuit to simulate
 a button press.
 We only want to do this procedure once on every power up.
 hence the capture while loop at the end of the loop function.
 
  +5V---------------------+
                       Vcc|
                     +----------+
                 PB2 |    8     |PB4
               +-----|7        3|----+
                 PB1 | ATTiny45 |PB3               
               +-----|6        2|----+             
TO               PB0 |          |PB5             
Push Button    +-----|5        1|----+          
                     |    4     |    
                     +----------+  
                       GND|          
   Ground-----------------+                          

(Wiring Diagram for Auto Power On Circuit)
 
 By Jim Park jim (dot) buzz (at) gmail (dot) com
 Coded :- 18/09/13
 
 */
 
int PowerPin = 0;          // Pin 5 to power up the NAS if it's active Low  
int PowerPinInv = 1;       // Pin 6 to power up the NAS if it's active High

void setup() {
// declare pins as O/P's or I/P's
  pinMode(PowerPin, INPUT);           // HI-Z pin
  pinMode(PowerPinInv, INPUT);        // HI-Z pin
}

void loop() {
// Now delay for 10 Seconds
  delay(10000);                       // 10 second delay to be sure power is stable
  pinMode(PowerPin, OUTPUT);          // Remove HI-Z state from pin
  pinMode(PowerPinInv, OUTPUT);       // Remove HI-Z state from pin
  digitalWrite(PowerPin, LOW);        // Active Low on Pin 5
  digitalWrite(PowerPinInv, HIGH);    // Active High on Pin 6
  delay(500);                         // Half a second delay
  pinMode(PowerPin, INPUT);           // Back into HI-Z state
  pinMode(PowerPinInv, INPUT);        // Back into HI-Z state
  while(true){}       // Capture for ever......and..ever.........
}


The programmed ATTiny45 is inserted into the socket carefully ensuring that pin 1 on the ATTiny45 goes into pin 1 on the Socket ( see the photo above ). The unit was tested by plugging in the power to the NAS, after 10 seconds the familiar boot beep with the flashing leds occurred. After the full boot the NAS was available on the network all without having to press the power button. :)

11 comments:

  1. Negligible power difference when connected to the wall, but why while(1) instead of sleeping?

    ReplyDelete
    Replies
    1. Because power saving isn't in my priority list. And sleep isn't one of the functions available in the ATTiny45 using arduino sketches see the link http://hlt.media.mit.edu/?p=1229
      The link details the functions available:-
      Reference

      The following Arduino commands should be supported:

      pinMode()
      digitalWrite()
      digitalRead()
      analogRead()
      analogWrite()
      shiftOut()
      pulseIn()
      millis()
      micros()
      delay()
      delayMicroseconds()

      No Sleep unfortunately................

      Delete
  2. Ever heard of a UPS? A small 350VA one runs under $40, and it would prevent the NAS from having to do a file system check every time it restarts.

    ReplyDelete
    Replies
    1. UPS is only good for so long. If you're experiencing a power outage greater than 10-30 minutes, a cheap UPS won't cut it, and he may already have it on a UPS for all we know. Once the power is back on, the UPS will power up but his NAS won't.

      Delete
    2. UPS for home based file storage, I don't get that many power outages. However the hassle of climbing all those stairs just to press a power button, I thought the Arduino would do it. And at least the system would be available for use after an outage without human intervention. Sorted.

      Delete
  3. Did you try to put 15 micro farad capacitor? I've used this method on old ATX boards and it worked just fine.

    ReplyDelete
    Replies
    1. I was just being lazy and couldn't be bothered tracing out how the power switch was wired.

      Delete
    2. It might work on your ATX board but not on the NAS200. I even installed a Microchip MCP120 3 pin supervisory chip without success. There has to be settle period before the reset is applied.

      Delete
  4. jimbuzz: This is amazing. My NAS200 is in an outbuilding and its such a pain, sometimes at 2am crossing the wet grass then standing on a step ladder to press the reset. Having recently used an ATTiny for another project I decided I would try one for this purpose as an MCP120 mod 2 years ago did not work. Started looking around for alternative solutions (found none) and came across this post which is exactly what I was I was planning to do, plus some. You've done all the hard bits for me, thanks so much.

    ReplyDelete
  5. Thanks again Jim. I've just installed this mod in my NAS200 and it works great.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete

Defender 300tdi Lucas 10AS Alarm Immobiliser (Spider) Problems

We have a 1997 Landrover Defender 300tdi that has given immobiliser problems intermittently. I had initially fixed the fuel solenoid as we w...