Detect and restore RPM counter switch state in a circuit where counter switch at ON state produce garbled PWM packages due to original and unfortunately unchangeable design. PWM packages are acquired over AC input optocoupler and debounced to 3.3V logic voltage level for further use.
In simulation garbage PWM packets are made by a circuit with two 555 timers. See the circuit and full description here: https://everycircuit.com/circuit/5344919044227072. Garbage packet debouncing are done by a circuit at bottom right side. Current to current source with the NPN transistor partially emulate the AC input optocoupler where real implementation use PC814, EL814 or LTV-814. When RPM counter switch is ON, voltage in debouncing output raise till 3.3V or 5V logic "1" level. This allows to pass the signal from debouncing output directly to the MCU ADC/GPIO pin. Or refine it further via MOSFET switch, op-amp based comparator, logic buffer etc.