Go Down

Topic: One wire RPM pickup (Read 1 time) previous topic - next topic


Hello guys,

I have built a one wire rpm pick up that uses a wire wrapped around the spark plug.  The circuit consists of a zener diode, a rectifier, a couple resistors, and a cap.  I hooked it up to an O scope, and it works as expected.  The frequency veries with RPM very consistantly. 

I hook it up to the Arduino, but the output is not consistant.  the RPM goes up after the a few minutes.  Its not just the engine warming up either.  I believe it has to be the code.  I hooked up a tiny tach to it, and it does the same thing. 

My tach puts out an AC wave, and the tiny tach is digital I believe.  If anyone could point me into the right direction I would really appreciate it.  Here is the code.
Code: [Select]
int iTestPin=13;                                   //Pin which generates test pulses, this is not needed when actual pulse is available for measurement
int iPulsePin = 2;                                //Pin serving as external interrupt (pin 2) to count the pulses
static float siPulseCounter=0;                       //Variable keeping track of pulse counts
static float siSecondCount=0;                        //Variable keeping track no. of seconds in the timer1 block
float rpm;
void SetupTimer1()                                //Setting up timer1 with appropriate register values

      TCCR1A = 0;                                 // No PWM is used.So set this to zero.
      TCCR1B = 1<<CS12 | 0<<CS11 | 0<<CS10;       // Input clock is set to F(cpu)/256
      TIMSK1 = 1<<TOIE1;                          // Enable timer interrupt to detect overflow
      Set the timer count to overflow to in 1 second.
      My board has a 16MHz oscillator.
      Reload Timer Value  = ((2 ^ Bits) - 1) - ((Input Frequency / Prescale) / Target Frequency)
                          = 65535 - ((16 x 10 ^6 Hz)/256)/1 Hz
                          = 65535 - 62500
                          = 3035
      TCNT1=0x0bdb;                               //3035 in hex

ISR(TIMER1_OVF_vect)                             // Timer1 ISR when it overflows
    TCNT1=0x0bdb;                                //Reset Timer1 to count another second     
    siSecondCount++;                             //Increase second count
    if(siSecondCount>=1)                        //If 1 Seconds are attained Print the Pulse count to serial port.
        rpm = siPulseCounter*16.54;     //Multiplier has to do with Reference Voltage this is at 5v ref.
        Serial.print("RPM is ");
        Serial.println(rpm);  //Print as decimal value
        siPulseCounter=0;                       //Reset counter values for next minute cycle

void setup(void)
      pinMode(iPulsePin, INPUT);                  // Set Pulsepin to accept inputs
      digitalWrite(iPulsePin, LOW); 
      pinMode(iTestPin, OUTPUT);                  // Test signal generator pin as output. Can be ignored if the actual digital signal is available
      attachInterrupt(0, count, RISING);          // Caputres external interrupt 0  at iPulsepin at rising edge and calls funtion count defined below
      Serial.begin(115200);                         // Begin Serial communication at baudrate 9600 bps
      SetupTimer1();                              // Call Setuptimer1 function
      Serial.println(" Initialising, Please wait...");

void loop(void)
  /*** Following 4 lines just generate pulses for testing purposes.
    All the 4 lines Can be ignored if the actual digital signal is available ***/
      digitalWrite(iTestPin, HIGH);             // sets the iTestPin ON
      delay(6.89);                              // waits for a second
      digitalWrite(iTestPin, LOW);              // sets the iTestPin off
      delay(2);                              // waits for a second

void count()                                    // Function called by AttachInterrupt at interrupt at int 0
      siPulseCounter++;                        //increment the pulse count


Post a schematic and the scope trace.  What output do you get from your code and from the mini-tach.


I hooked up the scope today.  My circuit looks like it is picking up emf.  I dont have it potted or anything so this is a huge problem.

The tiny tach is a perfect digital signal 0-5v.  I didnt have a chance to take a pic, but like i said its a perfect square wave.  Any thoughts on why the code doesn't work?  I'll just use the tiny tach for now.

Does anyone have an idea to protect it from the emf?

Go Up