Do you have a delay on /mclr so that Vcc comes up first ? Might be that the unplugging of the mains causes a pulse that gets through to /mclr and that's what starts the program -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist