I have a nas that I shut down when I go to sleep. But I noticed that it was still drawing a lot off power even in standby so I decided to build a stand-by killer. If this circuit detects that the nas draws less then a pre-set power then it shuts the output off. To eliminate measuring faults it checks during 5 seconds, if the power is low enough during these 5 seconds then it will shut down.
I did not like that the 220 Ohm resistor in the power supply got so hot and that there was lost to much power there. So I replaced the old power supply with a small transformer.
The box mounted and connected:
The code in the pic:
Device 12F629 Config INTRC_OSC_NOCLKOUT, WDT_OFF, PWRTE_ON, BODEN_OFF, MCLRE_OFF ALL_DIGITAL TRUE Symbol GPIF = INTCON.0 Symbol GPIE = INTCON.3 Symbol GIE = INTCON.7 Symbol stroom = GPIO.5 Symbol druk = GPIO.3 Symbol ssr = GPIO.2 Symbol LED1 = GPIO.1 Symbol LED2 = GPIO.0 Dim index As Byte ; 76543210 GPIO = %00000000 TRISIO = %11111000 IOC = %00101000 GIE = 0 ;Global Interrupt Enable uitschakelen(!) GPIE = 1 ;GPIO Port change Interrupt Enable inschakelen Clear begin: While 1 = 1 GPIF = 0 Sleep If druk = 0 Then GoTo aan EndIf Wend aan: While 1 = 1 High ssr High LED2 GPIF = 0 Sleep If stroom = 0 Then GoTo uit EndIf If druk = 0 Then GoTo af EndIf Wend uit: While 1 = 1 LED1 = 0 For index = 0 To 5 Toggle LED1 DelayMS 500 If stroom = 1 Then LED1 = 0 GoTo aan EndIf Next Low ssr Low LED2 GoTo begin Wend af: While 1 = 1 LED1 = 0 For index = 0 To 5 Toggle LED1 DelayMS 500 If druk = 1 Then LED1 = 0 GoTo aan EndIf Next Low ssr Low LED2 While druk = 0: Wend DelayMS 2000 GoTo begin Wend End