I think that i have an conclusion. Maybe is not an programming problem but more an electric problem.
It's possible that is counted "false" pulses that coming from wrong electric isolation. An complete cycle open-close have about 30.000 pulses. I make some measurements and a little math and i found that on each cycle i have about 25 false pulses which is great considering how looks my assembly.
Next i will try to make some measurements using an oscilloscope to correct electrics problems.