Hi,

I built a prototype alarm system which is based around the 16F688. I also have the outputs going to a ULN2003A to turn on and off some relays. For the power supply, I have a standard 5V regulator with input and output .1uF
caps on each side. The beginning of my code looks like this:

@ DEVICE PIC16F688, INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_OFF, MCLR_OFF,
BOD_OFF,PROTECT_OFF

DEFINE OSC 4
TRISA = %00111011
TRISC = %00101110
ANSEL = %00000000
CMCON0=7
BRAKESO VAR PORTC.0 'BRAKES OUTPUT
LIGHTS VAR PORTA.2 'PARKING LIGHT OUTPUT
BUTTON1 VAR PORTC.1 'TRANSMITTER NUMBER ONE BUTTON
BUTTON2 VAR PORTC.2 'TRANSMITTER NUMBER TWO BUTTON
BUTTON3 VAR PORTC.5 'TRANSMITTER NUMBER THREE BUTTON
GENDOOR VAR PORTA.5 'GENERATOR DOOR INPUT (-)
SIDEDOOR VAR PORTA.4 'SIDE DOOR INPUT (-)
SHOCKSENS VAR PORTC.3 'SHOCK SENSOR INPUT (INTERNAL)
KEYSWITCH VAR PORTA.0 'KEY SWITCH INPUT FOR ARM/DISARM
LED VAR PORTC.4 'LED OUTPUT
NOTRIGSD VAR BYTE 'NO TRIGGER SIDE DOOR-3 TIMES MAX
NOTRIGGD VAR BYTE 'NO TRIGGER GENERATOR DOOR-3 TIMES MAX
NOTRIGSS VAR BYTE 'NO TRIGGER SHOCK SENSOR-3 TIMES MAX
SD VAR BYTE 'SIDE DOOR VARIABLE-COUNTS NUMBER OF TIMES
THE SIDE DOOR HAS BEEN SET OFF
SS VAR BYTE 'SHOCK SENSOR VARIABLE-COUNTS NUMBER OF TIMES
THE SIDE DOOR HAS BEEN SET OFF
GD VAR BYTE 'GENERATOR DOOR VARIABLE-COUNTS NUMBER OF
TIMES THE SIDE DOOR HAS BEEN SET OFF
GENDOORNT VAR BYTE 'THIS VARIABLE WILL BE SET TO ONE IF THE
GENERATOR DOOR IS OPEN WHEN SETTING THE ALARM.
SD=0 'SET SD TO 0
SS=0 'SET SS TO 0
GD=0 'SET GD TO 0
NOTRIGSD=0 'SET NOTRIGSD TO 0
NOTRIGSS=0 'SET NOTRIGSS TO 0
NOTRIGGD=0 'SET NOTRIGGD TO 0
GENDOORNT=0 'SET GENDOORNT TO 0
X VAR BYTE 'VARIABLE COUNTER USED THROUGHOUT THE PROGRAM
T VAR WORD 'TIMER VARIABLE USED TO TIME THE ALARM FUNCTION
L VAR WORD 'LED COUNTER
X=0 'VARIABLE COUNTER
T=0 'VARIABLE COUNTER
L=0 'LED TIMER
LOW LIGHTS 'SET LIGHT RELAY TO OFF
LOW BRAKESO 'SET BRAKE/SIREN RELAY TO OFF
LOW led 'ENSURE ALARM LED IS OFF
'------------------------------START OF
PROGRAM---------------------------------
PAUSE 1000
START:
IF BUTTON1=1 OR BUTTON2=1 OR BUTTON3=1 THEN GOTO ARM
IF KEYSWITCH=0 THEN GOTO ARM
GOTO START

OK, so here is my problem....The customer tells me that if he quickly
applies power and then reapplies it (less than 1 second) a bunch of times that sometimes the relays will become activated. Now, I know the worst things for electronics, other than heat, is to take power off and then reapply
it quickly so this is a concern. He also tells me that sometimes the
outputs will stay latched and he has to cycle the power a few times
or just leave it off in order to reset it.

Here are my questions. Do you think if I increase the pause at the
beginning of the program that this would solve the problem? I changed
the PWRT and WDT commands to off because sometimes the voltage sagged
below the threshold and reset the device. Do you think this has
something to do with it? The last question I have is, do you think I
should add a big output capacitor to smooth the spikes? Would this
possibly solve the problem? I currently do not have an ouput
capacitor other than the .1uF for noise.

Thanks in advance for your help.

Chris