How about the following- Put a low power rectifier on the same ac which supplies your main rectifier. (ie the low voltage side of the transformer. Put a low value cap across it's o/p to smooth it. Then connect this voltage via a resistor to the diode of a cheap opto isolator. The o/p transistor of the opto is on when you have power. when the power is turned off the opto will be turned off long before your main regulator. (The time will be determined by the value of the cap you use at the input of the opto. If you don't use this cap you will get the opto switching at 2 * the AC freq). Connect the collecter of the opto to the interrupt of the PIC and do your data saving in the interrupt. If the component count is a problem you might consider saving the data to e2prom at every change of data. The e2prom endurance might be a problem here though. This is how I solved a similar problem. (I tried the first solution but I had 12 bytes to save and found that some pics worked ok while others did not I assume it was variations in the write time that got me) I figured that I could accept that eventually the chips would have to be replaced, but that until that day they would be superior to the stuff they were replacing reliability wise (can't say too much about what that was - sorry) Does anyone know how the e2prom fails if wou continously write to the same bytes? Do the bytes being written to not work any more or is the entire e2prom wrecked? Joe