Arduino rev counter
Moderators: User administrators, Moderators
- chewbacca
- Registered user
- Posts: 571
- Joined: 10 Jan 2015, 03:30
- 80-90 Mem No: 16186
- Location: Chesterfield (ish)
Arduino rev counter
Hi guys.
I currently have an arduino running the bus airbags, with a display on the dash.
I've been thinking about a rev counter for the bus for a while, but never found a good spot to fit one. I don't like the idea of another pod.
There's already a feed from the coil run to the dash, I needed it for the cruise control, so in theory everything is already there.
I've had a good look round the net, but not really found any great help. I'm going to need some kind of reduction on the signal I would imagine, and to be honest I can't really get my head round the code currently. I suspect I'll struggle to integrate it into my current code because of all the delays etc, but you never know.
Anyway, anyone got any ideas?
I currently have an arduino running the bus airbags, with a display on the dash.
I've been thinking about a rev counter for the bus for a while, but never found a good spot to fit one. I don't like the idea of another pod.
There's already a feed from the coil run to the dash, I needed it for the cruise control, so in theory everything is already there.
I've had a good look round the net, but not really found any great help. I'm going to need some kind of reduction on the signal I would imagine, and to be honest I can't really get my head round the code currently. I suspect I'll struggle to integrate it into my current code because of all the delays etc, but you never know.
Anyway, anyone got any ideas?
B plate 1.9 petrol bus
Re: Arduino rev counter
use interrupts instead of delays
- bigbadbob76
- Registered user
- Posts: 1733
- Joined: 07 Nov 2016, 14:41
- 80-90 Mem No: 15707
- Location: Isle of Skye
Re: Arduino rev counter
Agree you would need some pulse shaping and level shifting to get the arduino to recognise the coil pulses.
Probably need a dedicated atmega chip too, you could do all your de-bugging etc on an arduino and then flash the code to an Atmega 328.
Probably need a dedicated atmega chip too, you could do all your de-bugging etc on an arduino and then flash the code to an Atmega 328.
'86 1.9 DG, 4 spd, tintop, camper conversion.
Split case club member.
Split case club member.
- chewbacca
- Registered user
- Posts: 571
- Joined: 10 Jan 2015, 03:30
- 80-90 Mem No: 16186
- Location: Chesterfield (ish)
Re: Arduino rev counter
stigma wrote:use interrupts instead of delays
My coding is self learnt, so it'd mean a complete re-write to do that. I'm fairly sure anyone that knew what they were doing would have there head in their hands reading through it.
I actually looked at today as I wanted to program in a new pre-set. I'm glad I put a lot of notes in there, I'd forgotten most of it!
Looking through it, I was sort of put off the idea of adding it to this.
One thing I did think of though, there's a space on my clocks for an LCD. I know a lot of people have put voltmeters there. Can't help but wonder if a tacho could be added instead.... Maybe a separate mini project instead.
B plate 1.9 petrol bus
- chewbacca
- Registered user
- Posts: 571
- Joined: 10 Jan 2015, 03:30
- 80-90 Mem No: 16186
- Location: Chesterfield (ish)
Re: Arduino rev counter
bigbadbob76 wrote:Agree you would need some pulse shaping and level shifting to get the arduino to recognise the coil pulses.
Probably need a dedicated atmega chip too, you could do all your de-bugging etc on an arduino and then flash the code to an Atmega 328.
I was thinking something along the lines of a simple transistor to sort the input. Coil wire to base via a sizable resistor to switch it. Possibly a diode on the input as well to remove the negative component? Collector to the 5v rail and emitter to arduino. Just sort of thinking out loud really, but I'm tempted to try that and scope the output. Maybe tie the output to earth with a resistor as well.....
It's a long time since I was at school playing with transistors!
B plate 1.9 petrol bus
- bigbadbob76
- Registered user
- Posts: 1733
- Joined: 07 Nov 2016, 14:41
- 80-90 Mem No: 15707
- Location: Isle of Skye
Re: Arduino rev counter
Sounds like a plan, yes,I think you'll need the diode in series to block any back emf, I'd tie emitter to ground, and collector to 5v through a 10k resistor, take the output from the collector to arduino. assuming an NPN transistor. That gives you a conventional voltage follower switching circuit.
For some reason, call it a hunch, I don't feel comfortable with a current follower as you describe in this application.
You want to trigger on the voltage pulses and not draw any serious current from the cdi so 10k shoud be a good starting point for the base series resistor too, depending on your transistor of choice.
Hope that helps and doesn't hinder.
I'm sure there's some code out there you can adapt to suit, I rarely code from scratch tbh.
Happy coding. will be interesting to see how it goes.
For some reason, call it a hunch, I don't feel comfortable with a current follower as you describe in this application.
You want to trigger on the voltage pulses and not draw any serious current from the cdi so 10k shoud be a good starting point for the base series resistor too, depending on your transistor of choice.
Hope that helps and doesn't hinder.

I'm sure there's some code out there you can adapt to suit, I rarely code from scratch tbh.
Happy coding. will be interesting to see how it goes.
'86 1.9 DG, 4 spd, tintop, camper conversion.
Split case club member.
Split case club member.
- tonytech
- Registered user
- Posts: 1194
- Joined: 11 Oct 2005, 06:40
- 80-90 Mem No: 477
- Location: Liverpool
Re: Arduino rev counter
While I like the idea of a rev counter using a pulse counter I wonder if it is really the way to go.
Assuming you update the display every second
At 900 rpm (idle) you get 15pulses. At 4,500 rpm 75pulses.
Any error counting pulses, perhaps, at 900rpm the first second has 14pulses and the second has 16pulses will give a 960rpm and 840rpm reading....
I think you might be better using the pulses to attempt to charge a capacitor (through a transistor)and then read the analogue voltage (it wont be quite linear, but should be more stable)
T
Assuming you update the display every second
At 900 rpm (idle) you get 15pulses. At 4,500 rpm 75pulses.
Any error counting pulses, perhaps, at 900rpm the first second has 14pulses and the second has 16pulses will give a 960rpm and 840rpm reading....
I think you might be better using the pulses to attempt to charge a capacitor (through a transistor)and then read the analogue voltage (it wont be quite linear, but should be more stable)
T
There are 10 kinds of people. those who understand Binary and those who dont
- bigbadbob76
- Registered user
- Posts: 1733
- Joined: 07 Nov 2016, 14:41
- 80-90 Mem No: 15707
- Location: Isle of Skye
Re: Arduino rev counter
I agree you don't want to count pulses per second.
Not sure about charging a capacitor but I like your lateral thinking Tony.
I'd count milliseconds per pulse and do the maths in the arduino.
Thinking aloud here...
5k rpm = 20k pulses per min (4 cyls) = 333 pulses per second = 3ms per pulse.
then working backwards.....
4ms per pulse = 250 pulses per second = 15000 pulses per min = 3750 rpm
So it looks like you'd need to count microseconds per pulse rather than milliseconds to get any accuracy but you get the drift.
Not sure about charging a capacitor but I like your lateral thinking Tony.

I'd count milliseconds per pulse and do the maths in the arduino.
Thinking aloud here...
5k rpm = 20k pulses per min (4 cyls) = 333 pulses per second = 3ms per pulse.
then working backwards.....
4ms per pulse = 250 pulses per second = 15000 pulses per min = 3750 rpm
So it looks like you'd need to count microseconds per pulse rather than milliseconds to get any accuracy but you get the drift.
'86 1.9 DG, 4 spd, tintop, camper conversion.
Split case club member.
Split case club member.
- chewbacca
- Registered user
- Posts: 571
- Joined: 10 Jan 2015, 03:30
- 80-90 Mem No: 16186
- Location: Chesterfield (ish)
Re: Arduino rev counter
Sounds as though I need to see if I can get suitable input first, then get hold of a new arduino for playing with. Thanks for the input guys. Probably going to find myself out of my depth, but you never know.
Back for work tomorrow, so projects like this will slow down a bit now....

Back for work tomorrow, so projects like this will slow down a bit now....

B plate 1.9 petrol bus