Hello I would like to calculate the RPM's on engine.
Since it is difficult to screw an encoder on the alternator, I thought of measuring the ac voltage (of generator) through a 10k voltage divider and measuring the peak voltage phase time , or using the pulseIn command.
Or using interrupt Rising or Falling.
Is that a good approach ? Should I use another approach, ie measuring the phase time from an optoisolator ?
When sensing any analog waveform like this you either need to read it with the ADC and
do digital signal processing, or you'll need a conditioning circuit to convert it to a clean
Slowing varying voltage is no good to connect to a logic input, it might see 1 transition or
1000 transistions - logic input voltage slew-rate is expected to be in the 100's to 1000's of
V/us range for reliable operation.
The normal way to handle a messy analog waveform is first level convert/clip to the
logic supply range, filter out as much noise as possible, then put the signal through
a schmitt-trigger circuit (a logic gate with lots of hysteresis - these will reliably register
on a slowly-changing input voltage because of the internal positive feedback).
For instance the 74HC14 is commonly used, it has 6 schmitt-trigger inverters.