This is all a bit analog for me but looks clever.
So now you are getting pulses at some frequency that are in bursts of about 1/2 sec on/off. Like this ?
it usually only has 2 cycles HIGH
Why is it only > 500 for 2 samples? Is the frequency that fast? (or are you sampling that slow?)
What's you current code?
I'm having trouble working remotely and without any proper test equipment I have to say. This really needs a scope so we can see what's going on.
OTOH if you are getting reliable results maybe that's all we need for a one-off home job.