Hi AJB
I tried your suggestions, namely
I made R13 100k
I left the capacitor off to test (in case I wanted count the pulses to work out roughly what the frequency is)
I then put 2 x 150k 1/4 watt in series, and got a decent waveform on the scope.
I even went and put 4 x 150k 1/4 watts in series (now 600k 1/4w) and my waveform was still decent (see attached pic)
Strange thing is it does not look like the voltage is going all the way to zero [it looks like it goes from 5v down to 1.2v (remember I do not have the capacitor in),
Maybe the PIC micro has some capacitance on that pin (or my scope is just not seeing it right),
any comments on this??
Also, now that I am using 6k, that means that at the current line voltage, I have
350v/600000 = 0.58mA (or half a miliamp...)
And current through the resistors then is 0.134w
Is that fine, or am I pushing the lower limit there.
Maybe I should have 2 x 150r in series, so that I can have it at 1.2mA
and then the current through the resistors would then be 0.26w, and I can then use 1 watt resistors (or should I rather go 2 watts, just to be safe)
Again this is just to detect when the Mains is no longer present, and when the Generator is giving output (and possibly frequency, if I can figure out why the waveform does not go to zero??? If I can sort that, then I can count frequency.
My thinking is this:
Mains phase etc doesn't really matter, if it drops substantially (basically to zero volts), then the PIC must acknowledge it.
If the pic is cranking the generator, it needs to see as soon as the generators alternator is giving off mains, and stop cranking.
A nice feature I saw on another generator controller is that it monitors the frequency the generator is giving out. If it is -15%<Nominal>+15% then it must shut down and give an indication of what went wrong. It also stops the cranking (releases the starter motor) as soon as it sees the output frequency of the genset is >40hz.. That is why I am thinking of leaving the caps off, and counting the cycles...
I'd make R13 50-100K to start, and C10 something like 10nF. ...., so you can aim to hit your target current at something like Vpeak/2, or around 175V for 250Vrms. That means you need 175V/0.001A = 175K, and the resistor will dissipate only 250Vrms2/175000 = .357W under normal conditions. You also have only 2mA peak through the LED, giving you margin for a 30X line voltage transient before you hit absolute max current.