Driving a RPM gauge.

I'm just beginning my journey into the wonderful world of arduino's,
i have an arduino mega 1280, and my goal for it is to use it as the interface between a bus simulator and real gauges and lights on a dashboard i'm building.

I have a couple of gauges, a rev counter and a fuel and water temp gauge, they are all air core gauges, but the rev counter has it's associated control board on it, so it just needs feeding with + 12 volts, earth and a pulsed signal,

The fuel and water gauges have 3 pins connected to the coils, 2 pins have a resistor across them, and you feed them 12 volts to one pin, earth to the 3rd pin, then a variable resistance to earth to the other resistor connected pin to get the needle to move,

I have got the fuel and water gauges to move under arduino control with the led dimmer sketch, so they are pretty simple,

The rev counter is proving harder,
i have tried the basic led blink sketch, brought the on and off time down to 1Ms, and i can get it to show 1000 rpm, but i can't seem to get higher than that on the needle, i can get lower by varying the on and off times.

i have been looking for rpm or speedo gauge driver sketches, but can't seem to find what i need, other than most gauges want a 1 to 300Hz square wave signal, at 50% duty cycle,

it seems i need to use a transistor on the output of the arduino to the gauge, as it'll be producing a 5volt signal, and the gauge wants a 12 volt signal, so that's another thing i have to learn (tried the way shown on some sites, npn tranny, 2 resistors, 12 volts to collector, arduino signal to base, output to gauge to emitter, but i am getting the signal feeding through it even with the collector power removed, so i've not even managed to do that right)

Can someone point me to a sketch i can copy and paste into the arduino which will make it output the 1-300Hz square wave signal at 50% duty cycle, i can then study it and figure out how it's working,
i have some 10k and 22k pots, so can use them to vary the frequency.. but would really like to use the computer to vary it, or a sketch that sweeps from 1 to 300Hz and back again,

just so i can prove the gauge works fully, and i can see i'm beginning to get somewhere, and move onto the next part which is getting the data from the simulator to the arduino.

Can you provide a link to this/an "RPM gauge"?
You describe it as a freq meter, but I wonder that it's not just a milliammeter.

In another subject, there's a guy asking questions along the lines of yours and I demo'd my understanding (my take on the matter.)

More information would help.

the tachometer is from an iveco turbodaily van, about 1997 vintage,

the meter is an air core, with pins on the back for the coils, BUT only 3 pins are connected to the circuit board on the back of the gauge,
the board has a chip on it that reads 'ELEX 14308D 3027A 1595' a few resistors, 2 transistors and a few capacitors, and a component im not sure waht it is, circular case like an electrolytic cap, blue-ish silver covering, and PH 036, F3 K0 F3' written on it... it's in the +12 volts in section of the circuit.

It's from a diesel vehicle too... but the trigger in the vehicle is a hall effect sensor, magnet on the flywheel, sensor picks up the pulses, tacho shows the revs on the needle,

12 volts into one pin on the cicruit board, earth to another and the signal pin from the sensor (which i do not have)

i have fed it with a tone signal, and from 50 to around 120Hz the needle will sit at 1000 rpm, when i take the frequency up the needle moves down, about 200Hz gives me 0 revs, and going up in frequency causes the needle to bang against the stop, it's like it's being driven backwards.

but this is the 5 volt signal from the arduino, measuring the frequency on my multimeter, and it shows the duty at around 50% throughout the range.

i'm using the TonePitchFollower sketch to feed the tacho, i've replaced the photoresistor with a pot, and adjusted the numbers in the sketch to give me a 50 to 400Hz output over the range of the pot travel.

You described a circuit, in your first post, that leads me to understand that you used the emitter as the output and wired to your tachometer_in. The output of such would be < 5V.
I don’t know how much current your gauge requires.
Try the attached circuit.
The output will switch 12V/0V.
Start with a high value for the collector resistor (and reduce it as may be necessary.)

*** The GND there is common to the transistor, the arduino, and the gauge/ckt. ***


brilliant, thanks for that, i'll give it a go later on tonight,

A lot of this is all new to me, i've built plenty of circuits from kits before, but never had to investigate what goes on when and why, which is why i'm loving the arduino, as i'm learning tons as i go along,

yes i did mention using the transistor in a different way to how you've shown it, i found a few diagrams on the net that showed the transistor being used like a relay... 12 volts into the collector, 5volt signal from the arduino through a 1k resistor to the base, and the supposedly now 12 volt arduino signal to the tacho from the emitter,

i guess i was just using the transistor as a diode that way.

well, i'm stumped,

i've done the circuit with the transistor as shown, i've tried a BC547, a 2N5557 and a 2N3904 transistor, all do the same,

The transistor is working, i put 5 volts on the base, get almost zero volts on the emitter, remove 5 volts i get 11.07 volts on the emitter, my psu is outputting 11.10 volts, i know this rev counter will work down to 6 volts as the one in my motorhome which is the exact same type worked when the battery was dead and alternator had become disconnected once.

When connected to the arduino producing the 50 to 400Hz signal, i'm getting the same frequency out from the transistor as before the transistor, and measuring voltage, i am putting 2.46v in, getting 5.52 out... this is with it being pulsed at 122Hz, so deffo getting an increase in the voltage of the output.

But the rev counter behaves exactly the same as when fed a 5 volt signal, 50 Hz is 900 rpm, 120 Hz is 1000 rpm, then 190Hz is 800 rpm, 220Hz is zero, and going up in frequency drives the needle into the stop.

So i wonder if i need to invert the signal?... but the transistor is doing that isnt it?

The rev counter responds to a + signal, not a - one it seems, as if i take a wire with + 12volts on it and stroke it over the bolt serrations that is the input terminal, the needle will react, do the same with an earthed wire and needle dosent react.

Maybe i should just feed the air core of the gauge directly, and ignore the pulse counter circuitry on the back of the rev counter.

So i wonder if i need to invert the signal?... but the transistor is doing that isnt it?

Yes, when the arduino output is +5 then the collector is "0" (the transistor is on), and when the arduino output is "0" then the collector is +12 (the transistor is off).

50 Hz is 900 rpm,
120 Hz is 1000 rpm,
190Hz is 800 rpm,
220Hz is zero
going up in freq drives the needle into the stop.

That's kind of whacky isn't it? It goes up from 50-120, down from 120-190, and then down to 0 as freq increases to 220?
Have you tried keeping the on-time fixed and varying off-time? That's FM. The time of an ignition spark is the same (pulse width) at low revs as high revs, they just occur more often at higher revs (the freq increases).
Try a loop of 5ms on, 15ms off for several (100?) reps; then a loop of 5ms on & 10ms off; then a loop of 5ms on & 5ms off.

*** Then try it the other way round, too, let's wring this out. [15ms on, 5ms off; 10ms on, 5ms off...] OK? ***

Sorry i havent had time to try this out yet,

Been running round like a blue ar*ed fly recently... trying to sort an insurance claim, not fun, especialy today as i went to see the vehicle and get any personal effects that survived, not much re-useable, looks so much worse in daylight.

anyway, will give the code a go tommorow, i have a H bridge that people use to drive the air cores directly now, but that feels like cheating, when this thing must be fed with pulses that vary in frequency as the engine speeds up and slows down,

unfortunately i can't measure the output of the sensor, as the rev counter is the same one as used in my motorhome, which went up in smoke on valentines day,


5 on 15 off = 750rpm, 49.93Hz, 74.9% duty

5 on 10 off = 850rpm, 66.56Hz, 66.6% duty

5 on 5 off = 900rpm, 99.78Hz, 49.9% duty

10 on 5 off = 850rpm, 66.56Hz, 33.3% duty

15 on 5 off = 750rpm, 49.93Hz, 25.0% duty

i'm more confused than ever over this thing now,
i get the same needle swing and readings if it's a 5 volt signal straight from the arduino, or via a transistor (2N3904), 2k between base and arduino pwm pin 9, and i've tried from 410ohm to 4.1K from 12 volts and collector. makes no difference to the readings.

Maybe this gauge is borked,
i wish i could find infor out about the chip on it... the ELEX 14308D, 3027A 1595, but all i can find is people in china selling them but not giving any data sheets or info about what it is (appart from one that claims it's a high output led)

the gauge is made by Veglia Borletti, it's italian so that may be a good or bad thing (i know the van it came from being italian the electrics were not it's strong point.

im no pro at this stuff but i know there is a difrence in the way it reads if you have a4 6 or 8 cly motor and this could be your problem ... its not counting singel pules it could be counting 2 4 or 8 ? so maybe you can dubble them ? i may have read the info you guys gave wrong but it seems like it could be a simple fix...

like 4 pules wire tired to the sig lead .. and with diodes and pules them all real close in freq.

hey gazz,
The data look encouraging to me.
5 on 15 off = 750rpm, 49.93Hz, 74.9% duty
5 on 10 off = 850rpm, 66.56Hz, 66.6% duty
5 on 5 off = 900rpm, 99.78Hz, 49.9% duty
That’s a definite trend if not “highly” conclusive, it bottoms out at 50% where it goes back up the same way.
How about going the extra mile here with 5 on/20 off and 5 on/25 off?

Try it with a shorter on time and varying off times (1 on/1 off, 1 on/2 off, 1 on/5 off, …), too.

Don’t Give Up the Ship!


there was a break in the track from the chip to one of the sine/co-sine coils, so i was only getting half the coils working, hence the weird behaviour, i guess 1000 rpm is where it switches to the next coil... i had found that if i flick the needle right round, it'd display in the last segment... which led me to check the connections to the air-core.

BTW, this is a factory gauge from an iveco turbodialy, which are only available with diesel engines, so no changes for cylinder count, as it uses a sensor on the flywheel to count actual rpm's, not count sparks and divide by cylinders... but thanks for pointing it out,
i once read about someone with a million dollar twin engined race boat, fitted a new dash panel with 2 aftermarket rpm gauges, one engine showed low rpms, engine out, re-built, same fault, both engines out, re-built, same problem, then someone checked the back of the gauges and saw one was set to 6 cyl the other 4cyl!!

Anyway, right now i have the tone follower sketch running on the arduino, adjusting the frequency with a pot,

at 50Hz i get zero on the gauge (needle will drop down further, but i hope to use that feature to show when the simulated vehicles ignition is off or on, i.e. read 0 rpm when ignition on, needle off the bottom of the scale when ign off)

383Hz is 5k rpm... the max on this gauge, 433Hz is against the end stop, 218Hz is 2500rpm,

Now to work out how to interface this with the bus simulator i want to have real gauges working on,

Hopefully a tachograph will be a similar arangment, feed it a varying frequency signal to get the needle to move, and then vary the frequency according to the data out from the simulator.

thanks for all the help runaway_pancake,
i'm off to twiddle me know to make the needle move about for a bit now :slight_smile: