Car RPM switch

Hello. I tried to make Car rpm switch, but it won't work in action. It works well with squarewave generator turning on and off led on testing table, but not in car with all other components, relays, transistor etc.

Arduino switch DO10 HIGH when DI8 gets over 100Hz and DO10 LOW when under 100Hz

The problem is the arduino won't react to frequency changes with the relays and other stuff connected.

This is the car connection in car with relays and transistor

This is how arduino works fine with PWM generator. Used USB port to power supply arduino

With squarewave generator

What is wrong with car assebly? I think its something with groundings, that makes arduino blind to frequency changes?

int input=8;
int output=10;
int high_time;
int low_time;
float time_period;
float frequency;
float RPM;
void setup(){

pinMode(input,INPUT);
pinMode(output,OUTPUT);
}

void loop()
{
high_time=pulseIn(input,HIGH);
low_time=pulseIn(input,LOW);

time_period=high_time+low_time;
time_period=time_period/1000;
frequency=1000/time_period;
RPM=frequency*2*60/4;           
delay(100);                    
RPM = constrain (RPM, 0, 8000); 
 if (RPM==8000){RPM=0;} 
  

if ((RPM) > 3000)  
  {
    digitalWrite(10, HIGH);
    delay(500);
  }
  else
  {
    digitalWrite(10, LOW);
    delay(500);
}
}

Edit: and the car running the voltage is 14V, so ignore the 12V from picture.

Hi, Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum". OR http://forum.arduino.cc/index.php/topic,148850.0.html.

Have you googled arduino tachometer car

The usual method is to us an Interrupt and count pulses.

Tom... :)

Hi,
OPs circuit;

Tom… :slight_smile:

Yes, i have googled that. I don't find the problem from my circuit when i compare mine to other rpm switches.

I tried to take rpm signal from car IGN- wire. Normally tachometers work with that. Not my arduino.

One thing is for sure ,the signal from your car contains a lot of spikes and harmonics ,so you have to clean up that signal to make it work. Use filters ,TVS diodes etc...

Hmm.. If i add 2.2Uf non polarized capasitor between 150ohm reistor and ground, that would make low pass filter for signal cable, with f.3db =328Hz? Could this help for cleaning signal?

|500x213

Answer to myself: that wouldn't work because the signal voltage raises back to almost 12v. Digital input can not handle that.

Here is my latest thoughts for signal. Falstad link

Copyed the idea from some other arduino project. I just need to buy SFH618A-2 optocoupler. It seems to work very well on simulation.

Arlutpe: Here is my latest thoughts for signal.

Copyed the idea from some other arduino project. I just need to buy SFH618A-2 optocoupler. It seems to work very well on simulation.

Using a common ground on an opto isolator defeats the purpose of trying to isolate noise.

Okay, if i add low pass filter with 50ohm resistor and 10uF capacitor, before optocoupler, that would clean the signal and gave nice square wave to arduino? Falstad link

Or is there better options ?

Does the car have spark plug cables? A Hall Switch should be able to read the spark pulses even through the cable shield (it's there to stop radio interference).