1

I tried to create a tachometer for my motorcycle using an Arduino Uno.
I am trying to measure the voltage of the ignition coil (stepped down to not destroy the Arduino).

I am trying to determine the time between two explosions (one ignition coil high voltage).

I tried to use the pulseIn command in the following way:

unsigned pin=8;
float t;

unsigned long rpm;

void setup() {
    Serial.begin(9600);
    pinMode(pin,INPUT);
}

void loop() {

    rpm=pulseIn(pin,LOW);

    Serial.println(rpm/60);
}

The problem with it is that it won't display stable values. It will go all crazy. With an open circuit it still displays random values.

gre_gor
  • 1,669
  • 4
  • 18
  • 28
  • Are you sure that pulse is not shorter than 10ms? – Divisadero Mar 08 '17 at 15:14
  • i tested both pulseIn(pin,LOW) and pulseIn(pin,high) and neither worked. At most, my bike does 14.000 rpm, meaning 14.000/60 (233) rps. 233 rps ..... 1000 ms x rps............1 ms x=233/1000. I guess it is less than 10 ms. Is that the problem? – Andrei Grigore Mar 08 '17 at 15:19
  • https://www.arduino.cc/en/Reference/pulseIn - under 10ms it wont work right – Divisadero Mar 08 '17 at 15:29
  • but if you have tested it with smaller speed, the problem will be somewhere else – Divisadero Mar 08 '17 at 15:29
  • I am curious, how do you get to incorporate ignition coil into your circuit? – Divisadero Mar 08 '17 at 15:31
  • 3
    I suspect that it is already too late for that Arduino. How are you safely stepping the voltage down in such a way that it doesn't a) kill the Arduino, and b) kill you? – Majenko Mar 08 '17 at 15:40
  • btw: http://arduino.stackexchange.com/questions/318/how-precise-is-the-timing-of-pulsein?rq=1 – Divisadero Mar 08 '17 at 16:12
  • pulseIn works for values less than 10ms, it returns time in 'micro Seconds'. Try Serial.println(pulseIn(pin,LOW)); – Sniper Mar 08 '17 at 16:54
  • I did not use the high voltage terminal. I took the minus from the coil primary minus (the 12v terminal) and the plus from the battery, since the ground is the one that continuously varies in an ignition coil. I used a voltage divider to step the voltage down to acceptable levels. – Andrei Grigore Mar 08 '17 at 20:29

2 Answers2

2

No one mentioned that there is back EMF from primary coil when switch (or points) becomes open. This means that there is 200-300V applied backwards to your voltage divider while you think there is only 0-12V.

Alex Y
  • 21
  • 2
0

I can't tell you why that isn't working, but I can give you a working alternative.

unsigned int pin=8;

void setup() {
    Serial.begin(9600);
    pinMode(pin,INPUT);
}

void loop() {
    unsigned float rpm = 0;

    while (digitalRead(pin) == FALSE) {
        rpm++;
        delayMicroseconds(1);
    }

    Serial.println(rpm/60);
}

I might've forgotten something, but that should work.

Edit: the comments may be right, are you stepping down your input voltage?

Carrot M
  • 86
  • 1
  • 6