I give up! I can't seem to figure what could be wrong with this circuit... I'm using a 16F628A to "lengthen" a contact closure for an instrument start signal. The closure lasts for 500 msec, but I've determined that it needs to be a least a second to start my other instrument. So, I created the attached circuit so that there's a 5V signal at RB0 until the contact closure occurs. When the closure occurs and RB0 goes low, I'm trying to have RB1 (and RB2) go high to drive a relay and an LED (just to give confirmation). I built this on a breadboard and used the headers on my EasyPIC4 (**broken link removed**. I used pull-down resistors on all unused ports. It worked without issue. I then put the components on this: https://www.melabs.com/downloads/pp18_06.pdf. It works intermittently (but mostly does not). I can monitor the voltage on RB0 and it's 5V, then goes low during a contact closure. All unused ports are pulled low with 1K resistors. RB1 is shown on attached circuit diagram. RB2 drives an LED. The weird thing (at least to me) is that both RB1 and RB2 are about 35 mV when tested with a multimeter. I've tried to look for "bad" connections, but don't seem to see any? The one thing I don't have is a capacitor between Vcc and Vss? Could that be the cause? I'm using an LM7805 regulator for the +5V supply. I can make this on a breadboard and it's works perfectly??? I can't figure out what to try next! Here's the programming code in case it's relevant:
Code:
void main()
{
//PORTB is all output except F0
TRISB = 0x01;
//PORTA is all outputs
TRISA = 0x00;
//PORTB starts with bit 0 high
PORTB = 0x01;
//PORTA is all low
PORTA = 0x00;
do
{
//If PORTB.F0 goes low (contact closure)
if (PORTB.F0 == 0)
{
//Make PORTB.F0 high for 1500 ms
PORTB.F1 = 1;
//Make PORTB.F1 high also to drive an LED
PORTB.F2 = 1;
Delay_ms(1500);
//Now make PORTB.FO/F1 low again
PORTB.F1 = 0;
PORTB.F2 = 0;
PORTB.F0 = 1;
}
}
//Loop forever
while(1);
}