I'm currently working on a nano project to run an EDIS 4 ignition module.
If you don't know a ford edis module sorts out all the hard parts of reading and processing a flywheel sensor and sorting the sparks out . All you have to do is tell it how far to advance the sparks.
Problem is the signal from the EDIS can get quite noisy even with shielding and filters so I have done this small bit of code to see if I can reduce false readings
The pulse from the edis is up to around 200hz square wave and I need to know when the pulse is falling . So to make sure I get the correct wave and not an oddball spike i've looked for 3 high readings and then counted the output on the next fall ( the rpmcount) . I'm hoping that the checks at 3 separate times will ensure i'm on the top of the square wave and not a random spike.
Is this going to work? , please note my code skills are pretty poor at the moment as i'm learning this for the first time.
{
int reading = digitalRead(PIP_Pin); // read the state of the pip-pin into a local variable:
if (reading != HIGH)
{delayMicroseconds(150); int reading = digitalRead(PIP_Pin);int z=1;} // delay to check definate pulse
if (reading != HIGH)
{delayMicroseconds(150); int reading = digitalRead(PIP_Pin);int z=z+1;} // delay to check definate pulse
if (reading != HIGH)
{delayMicroseconds(150); int reading = digitalRead(PIP_Pin);int z=z+1;} // delay to check definate pulse
if (int z=3) // adds up all 3 definate pulses to eliminate chance of noise giving false pulse
{rpmcount++;}
int z=0;
}