Reading Motorcycle RPM

Hi forums!

I'm trying to read engine RPM by sensing a pulse.

The pulse i was taken from Tachometer i took 1 wire that sending pulse to Tachometer
( i've tested attaching led )

So the goals is to receive that pulse signal into arduino, i can't just connect it directly to arduino since the pulse is using working with different voltage , so I'm using optocoupler to sending the pulse to arduino.

I'm using
attach interrupt() function to calculate the rpm

The program works but the reading is not accurate, i assume there's still a noise signal ? Since the optocoupler operated from engine power supply ?

No, i don't have any oscilloscope so i can't figure out.

I was wondering is there any shield isolated shield available for arduino? So each IO input is isolated

Edit :

The Tachometer is digital, the engine itself has 12 pulse per rotation, how do I know ? Because the engine has 12 magnet for pulse pickup for the ECU

I'm using optocoupler module that already has resistor to operate from 12v

So why do you assume it is a noise signal?

If you want help from the forum, read the forum guide in the sticky post, and follow the advice there.

From what you have posted so far, no one can give you any reliable help or advice, only guesses.

In what way is it "not accurate"? For several readings of the tachometer, what does the tachometer ay nd what does the Arduino say?

Thank you for the info, i apologize I'm still new on the forum

An oscilloscope would certainly be helpful, but absent that, I would try just capturing the pulse train from the optoisolator using "digitalRead()", writing that to the serial port, and looking at it with the Arduino Serial Plotter from the IDE. In essence using the Arduino as a single channel logic analyzer.

This is based on a hypothesis that the tachometer pulse is noisy and you'll see multiple pulses in groups rather than evenly spaced pulses while the engine is held at nominally constant RPM. It could, of course be something else, but we confirm or rule out one thing at a time.

Is the tachometer a mechanical device or electronic? How many cylinders on the motorcycle? What type of ignition system does the machine have?

For example the Tachometer is showing 2k rpm but arduino showing 3k rpm

The Tachometer is digital, from the spec the factory using 12 of magnet on pulser, so i assume there's 12 pulse for 1rpm, I've adjust the pulse per rotation on the sketch, but the higher i set the pulse per rotation, the inaccurate it gets, so i assume there's something wrong with reading pulse signal ,

Have you considered that there may be one or possibly two MISSING pulses per RPM?

For one time yes, i think theres was missing pulse,

So basically i connect the optocoupler to the engine pulse , in logic the optocoupler is on and of following the pulse from wire signal

I connect 3.3v from Arduino to collector and the emitter to pin interrupt

I'm still beginner in electronics, correct me if I'm wrong, is the optocoupler can't handle fast on off?

You did not mention a current limiting resistor for the optocoupler LED.

Sorry to not mention it , but the optocoupler itself it's board module, it already have resistor , so there's should be no problem operating the optocoupler

Probably right. But, are you beginning to see why you need test equipment if you intend to continue with this project and ones to follow?

Don't count pulses. Measure the period between pulses.

Assuming 12 pulses per rotation and a max revs of, say 10,000 RPM, then thats 120,000 pulses / minute. Dividing by 60 gives 2000 pulses per sec or ~2kHz or 500uS minimum between pulses. Plenty of time for interrupt driven code to keep up.

Using the period between pulses, you can either compute, or look up the instantaneous RPM at each pulse. This, versus counting pulses for an interval, which reduces the response rate by the number of pulses averaged.

Now if you're updating any kind of display at 2kHz it'll be a blur and unreadable. A bargraph is usually better than numbers for rapidly updating data.

I still:haven’t seen any code. in code tags

Seems an unusual arrangement to have 12 pulses per revolution.

Normally one is enough.

make sure all directly interfaced circuits can handle 50V spikes, there can be alot of noise because of ignition
automotive electronics are usually above consumer grade, at least the power supply and opto sensing circuit, on the LED side, need to be rock solid for the tacho

you wouldn't want your motor stalling/death in a corner because of dodgy tacho, keep it in mind...

read the opto datasheet, convert max RPM to frequency, compare, you will have a clear picture then if its fast enough XD

also 1 pulse on any motor is probably enough, on old school motors the pulse is used to excite the ignition, and tacho is just rigged on it , 12 pulses kind of seem like 12 cylinders lol, or noise,newer have it on the ECU, it can even be a coded binary, then you need to know the baud rate...

Btw if its realy 12 per rpm, if you want to start from say, pulse 6... there will still be 11 before that one arrives again. So initial wait for one of them, then every 12, maybe its a failsafe of some sort, shouldn't matter where you start as long as you are sure of the number, perhaps they are bundeled, and there is a longer gap between 2 that the original tacho detects to count the pulses...

at least post what vehicle is it, and what equipment you are using, this way we got almost no info

also correct way to connect it is to have a large (100k) resistor connected from arduino Vcc to collector, and emmiter to ground, then you connect collector to arduino, and the pulse is inverted logic (FALLING edge), if it is npn opto, idk what you have tho, but you need either a pullup or a pulldown resistor to keep the pin from floating.

Arduino has internal pullups too, but the connection should be pin-collector, emmiter-ground then, and you need to digital write the input pin high to engage it... I dont like to rely on them... and there exist 5 legged opto flip-flops that have pnp-npn pair, but I highly doubt you have that

1 Like

There are lot of Internet material around various implementations. Surely one or more have resolved the noise issue(s).

arduino tachometer from old tach signal - Search (bing.com)

I would guess EXTRA pulses is more likely, that is multiple pulses detected due to some ringing on the line. On my 90s vintage Kawasaki the tachometer input is the switched side of the ignition coil primary and I expect it's a really lousy realization of a binary signal. It fires once per revolution.

I don't know what to make of the "12 pulses per revolution" statement above. It would be really helpful if that sort of thing were backed by reference to the documentation.

These sorts of threads are frustrating when key details aren't presented. We don't know the particular motorcycle, so can't look for a wiring diagram, we don't know the specifics of the detection circuit, we haven't seen code, etc, etc, etc.

Wondering if the OP's machine uses something like the multi-fire ignition on the 1978 International Scout I owned. 4 cylinder engine with Chrysler Corp's multifire ignition. Fired plugs several times instead of a single time. Worked fine, but drove the emission testing people crazy trying to relate the ignition pulses to the RPM.