MisterBill2
- Joined Jan 23, 2018
- 27,591
If the MCU package can handle analog inputs that may still be the way to go. Or possibly not. Certainly a linear analog signal will have less noise riding along.
If only my skills were that capable, I'm appreciate your for forewarning but its just a simple generator.I suspect that You are attempting to build your own Fuel-Injection-System.
You can save yourself some huge headaches by just purchasing a "Micro-Squirt" Computer.
It will also drive an Automotive-Ignition-Coil,
which is a huge bonus if you're running on Alcohol.
In the above type of application, connecting to the stock Ignition-Coil is a foolish game,
install a Hall-Effect-Sensor, or knock yourself out working-out all the bugs.
.
.
.

Yes, I done a little research, its surprising what can be done with few componentsThe circuit with the diodesand resistors is commonly called a "clamp circuit" because it clamps the signal level to between the two voltages.
The idea is to idle the engine when there's no current and knock it off if it hasn't drawn current for a while.On a Generator application You automatically have
a beautiful, and almost perfect, Sine-Wave Tach-Output from the Generator-Windings.
The next question is,
are You simply "monitoring" the Output-Frequency ?,
or are You trying to actually "control" the Output-Frequency ?
.
.
.


int pulsePin = 8;Cool! Good job!
If I'm reading that correctly (just going off the first group of 5 lines) you have a square wave or square-ish wave with on/off times measured in μS, with a duty cycle of roughly 85% and frequency of 51.68Hz, corresponding to an engine speed of ~3,100 RPM. Is that about right?
I was not aware Arduino can measure time in microseconds. I thought it is rather limited in that regard with only mS capability. Apparently I am wrong. Would you mind sharing that part of the code which you are using to get the on/off time in μS?
Thanks! I have somehow managed to never learn of pulseIn. This is very useful.int pulsePin = 8;
unsigned long pHigh;
unsigned long pLow;
unsigned long Rinterval;
void setup() {
pinMode (pulsePin, INPUT);
Serial.begin(9600);
}
void loop(){
for (int i = 0; i < 5; )
{
pHigh = pulseIn(pulsePin, HIGH);
pLow = pulseIn(pulsePin, LOW);
Rinterval = pHigh + pLow;
Serial.print("HIGH ");Serial.print(pHigh);Serial.print("\t");Serial.print("LOW ");Serial.print(pLow);
Serial.print("\t");Serial.print("INTERVAL ");Serial.println(Rinterval);
i++;
}
Serial.println(" NEXT");
}