Qustion about sensor output

Hello,
I am trying to read a tachometer signal from a MSD box. Here is the instructions that came with the box.

The part that I'm curious about is this snippet.

TACHOMETERS
The MSD Ignition features a Tach Output Terminal on the side of the unit. This terminal provides a trigger signal for tachometers, a shift light or other add-on rpm activated devices. The Tach Output Terminal produces a 12 volt square wave signal with a 20% duty cycle.
Some vehicles with factory tachometers may require a Tach Adapter to operate with the MSD.

So I was thinking about using a voltage divider to drop the signal down to 5v logic. Would that be the way to go?

But I have no idea how to read the signal coming from the box. I thought about using the pulseIn() function? I wish the instructions were not so vague.

Anyways, any help would be greatly appreciated.

Thanks, and sorry I'm a noob
lance

you could use a voltage divider with a zener diode to catch any stray pulses, or you could use an lm339 comparator, either one should work. since it sounds like the duty cycle is fixed, i'd say its the number of pulses per second that determines the rpm. a six cylinder engine would have 6 pulses per revolution, so measure for a second, divide by six, and bam.

wouldn't a high impedance connection like that be very susceptible to noise, especially in an automotive environment?

So how would I count the pulses in code?
I need it to be fast so i can measure all the other sensors in this project as quickly as possible.

Thanks again.
Lance

Atmega chips (on which the Arduino is built) feature built-in protection diodes in both directions.

Sorry Richard this is one of those pieces of miss information you get on the net. All ICs have clamping diodes around the rails but these are not designed to be used for input protection at all. There main use is in protecting against low level static discharge caused by normal handling. They should not be used as protection against deliberate over voltage because not only do they have a small voltage and current rating the doping density in the silicon is such that if you use them continuously they can get denuded of free carriers.

For voltage protection you should ALWAYS use external clamping diodes if you want to protect your arduino.

wouldn't a high impedance connection like that be very susceptible to noise, especially in an automotive environment?

Yes high impedances inputs will pick up more noise than low impedance ones.

so would something like this work?

int GetRPM()
{
  unsigned long startTime = millis()+ 100;
  int pulseCnt = 0;
  
  while(startTime <= millis())
  {
    if(digitalRead(tachPin) == HIGH)
    {
      pulseCnt ++;
    }
  }
  
  return (pulseCnt * 600)/8;
}

and use a voltage divider with a 5.1v Zener diode to protect the digital pin?
I also have a bunch of optoisolators laying around or would that be overkill?

Thanks
lance

while(startTime <= millis())
  {
    if(digitalRead(tachPin) == HIGH)
    {
      pulseCnt ++;
    }
  }

Don't you want to measure the number of times the line goes high in your 100ms sample period, not the amount of time it is high?

I assume that pulseIn() would be a better function to use. That makes sense incase the loop hits twice or more on the same wave.

so

int GetRPM()
{
  unsigned long startTime = millis()+ 100;
  int pulseCnt = 0;
  
  while(startTime <= millis())
  {
    pulseIn(tachPin,HIGH);
    pulseCnt ++;
  }
  
  return (pulseCnt * 600)/8;
}

can someone put together a schematic using a lm339 comparator with a 12v SQ Wave tach signal input.

One other related quesiton, trying to learn here, i'm a SW Engineer, not a hardware one. My commercial Data Acquistion system came with several "sensors" to hook up to the tach. OF course i found one that works with my car, but one of the others confuses me. Its basically a solid core wire which one wraps around the spark plug wier. I believe this is an inductance loop (there is some small circuit board under a bunch of potting so I can't disect it), but there is not path to ground for this loop (i have an hour meter on my dirt bike that does the same thing, wraps around the spark plug wire). I guess this is similar to how a timing light works.

Can anyone
a) explain why this works
b) help me create such an animal myself (my project is my own data acquisition system, gps, accelerometer, tach, AFR, ignition advance (my ignition box has a nice 0-1v output which is degrees of advance (eg. 0.13v == 13 degrees). I;m looking for this for 2 reasons. 1) to give flexiblity for those who don't have a tach out signal that they can use, and 2) with my ECU (megasquirt), commercial daq, and the dash tach all connected to the same signal, the dash tach is erratic (the ecu and the daq both show correctly as compared to a timing light)

one other thing.. only the ECU and dash tach share the tach signal from the Ignition controller... so i think that my erratic dash tach is because of the ECU (it was fine with this setup before adding the mega squirt. it would be nice if i could take the tach from the ignition box and "split" it into 2 signals so that both devices get driven equally.. apologies for poor terminology here.