Quote Originally Posted by The Master View Post
I wasnt gonna use interrupts for this. I need 3 inputs and i dont think this PIC has 3 interrupt pins. I would still have the same problem of needing to reset the interrupt after a certain length of time. Using the cap/resistor method should make it really easy though
Since an input pin is a high impedance input, it won't draw any current (well, very very little current), so, if you're dealing with 50Hz, half-wave, it's almost a simple matter of figuring out what R/C time constant you want depending on values of parts you have on hand, keeping in mind that generally 5 R/C time constants is considered a full 'charge' or 'discharge'...so...
1ohm @ 1f = 1 second, 1ohm @ 1uF = 1us, 100ohm @ 1uf = 100us...and so on and so on...
50hz = 20ms per pulse, 5x = 100ms, so...just thinking in general here...
Put the signal into your PIC, tie a 10uF capacitor into that line with a 10K resistor hanging off the other end of the capacitor going to ground.
10000ohm x 10uf = 100ms
IF my figuring is right, it should work like a champ and 'hold' your signal there for the PIC to see. The only 'problem' is that it'll take the cap (and therefore the PIC pin) about 100ms to bleed off completely and your PIC might think power is still on for a few ms after it's actually off.