I had some PIC micro and I built a simple LED tachometer for my car with a 16 led linear scale.
The circuit with a frequency/voltage converter and a LM3914 is better, but using a PIC and the A/D converter integrated is simpler!
There's wire in my car where voltage grows proportionally with engine revolutions, from 0V to 12V.
I connected this wire to PIC A/D, through a conditioning unit to reduce the 12V to 5V, and used 2 PIC ports to drive the leds.
This is the pin diagram and...

this is the program, compiled with MPASMWIN and flashed with a PROPIC II programmer:
;16f877 a/d test routine
;
;TEST CIRCUIT:
;pin 11 & 32 = 5VDC
;pin 12 & 31 = 0VDC
;pin 1 = 5VDC
;pin 2 = 0 - 5 VDC analog input (center tap on 20k variable resistor)
;pin 13 & 14 = 4MHz crystal with 18pF capacitors to 0VDC
;pin 15,16,17,18,23,24,25,26 PORTC outputs each to 330 ohm resistor
;pin 19,20,21,22,27,28,29,30 PORTD outputs each to 330 ohm resistor
; in series with LED to 0VDC
__config _LVP_OFF & _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF & _BODEN_OFF & _DEBUG_OFF
processor 16f877
include "p16f877.inc"
REG1 equ 0x020
org 0x000 ; Start at the reset vector
goto Start
org 0x004
;Interrupt
retfie
Start
bsf STATUS,RP0 ;bank 1
bcf STATUS,RP1
movlw H'00'
movwf TRISC ;portc [7-0] outputs
movwf TRISD ;portd [7-0] outputs
clrf ADCON1 ;left justified, all inputs a/d
bcf STATUS,RP0 ;bank 0
movlw B'01000001' ;Fosc/8 [7-6], A/D ch0 [5-3], a/d on [0]
movwf ADCON0
Main
call conv
call shift
call output
goto Main
conv ;wait for acquision time (20uS)
bsf ADCON0,GO ;Start A/D conversion
Wait
btfsc ADCON0,GO ;Wait for conversion to complete
goto Wait
movf ADRESH,W
movwf REG1
return
shift
rrf REG1
rrf REG1
rrf REG1
bcf REG1,7
bcf REG1,6
bcf REG1,5
return
output
movf REG1,W ;se reg > 00001 salta
sublw 1
btfss STATUS,C
goto salto1
clrf PORTC
clrf PORTD ;dc 00000000 00000000
return
salto1
movf REG1,W ;se reg > 00011 salta
sublw 0x003 ;00000011B
btfss STATUS,C
goto salto2
movlw 0x001
movwf PORTC
clrf PORTD ;dc 00000000 00000001
return
salto2
movf REG1,W
sublw 0x005 ;00000101B
btfss STATUS,C
goto salto3
movlw 0x003
movwf PORTC
clrf PORTD ;dc 00000000 00000011
return
salto3
movf REG1,W
sublw 0x007 ;00000111B
btfss STATUS,C
goto salto4
movlw 0x007
movwf PORTC
clrf PORTD ;dc 00000000 00000111
return
salto4
movf REG1,W
sublw 0x009 ;00001001B
btfss STATUS,C
goto salto5
movlw 0x00f
movwf PORTC
clrf PORTD ;dc 00000000 00001111
return
salto5
movf REG1,W
sublw 0x00b ;00001011B
btfss STATUS,C
goto salto6
movlw 0x01f
movwf PORTC
clrf PORTD ;00000000 00011111
return
salto6
movf REG1,W
sublw 0x00d ;00001101B
btfss STATUS,C
goto salto7
movlw 0x03f
movwf PORTC
clrf PORTD ;00000000 00111111
return
salto7
movf REG1,W
sublw 0x00f ;00001111B
btfss STATUS,C
goto salto8
movlw 0x07f
movwf PORTC
clrf PORTD ;00000000 01111111
return
salto8
movf REG1,W
sublw 0x011 ;00010001B
btfss STATUS,C
goto salto9
movlw 0x0ff
movwf PORTC
clrf PORTD ;00000000 11111111
return
salto9
movf REG1,W
sublw 0x013 ;00010011B
btfss STATUS,C
goto salto10
movlw 0x0ff
movwf PORTC
movlw 0x001
movwf PORTD ;00000001 11111111
return
salto10
movf REG1,W
sublw 0x015 ;00010101B
btfss STATUS,C
goto salto11
movlw 0x0ff
movwf PORTC
movlw 0x003
movwf PORTD ;00000011 11111111
return
salto11
movf REG1,W
sublw 0x017 ;00010111B
btfss STATUS,C
goto salto12
movlw 0x0ff
movwf PORTC
movlw 0x007
movwf PORTD ;00000111 11111111
return
salto12
movf REG1,W
sublw 0x019 ;00011001B
btfss STATUS,C
goto salto13
movlw 0x0ff
movwf PORTC
movlw 0x00f
movwf PORTD ;00001111 11111111
return
salto13
movf REG1,W
sublw 0x01b ;00011011B
btfss STATUS,C
goto salto14
movlw 0x0ff
movwf PORTC
movlw 0x01f
movwf PORTD ;00011111 11111111
return
salto14
movf REG1,W
sublw 0x01d ;00011101B
btfss STATUS,C
goto salto15
movlw 0x0ff
movwf PORTC
movlw 0x03f
movwf PORTD ;00111111 11111111
return
salto15
movf REG1,W
sublw 0x01e ;00011110B
btfss STATUS,C
goto salto16
movlw 0x0ff
movwf PORTC
movlw 0x07f
movwf PORTD ;01111111 11111111
return
salto16
movlw 0x0ff
movwf PORTC
movwf PORTD ;11111111 11111111
return
end
Comments
Schematic
Could you post a schematic, please?
Expecially of the conditioning unit
Re: Schematic
This is a little schematics without power supply stadium. It can be realized with a LM7805 voltage regulator.

Important: the 10k trimmer must be set to avoid voltage from car sensor above 5V
Schematic
Thank you very much! I'll try this!
is it safe to only use
is it safe to only use 10(20)K pot.are you sure no more conditioning is required for the input signal side?
and does this circuit switch on the LEDs with respect to the input voltage at pin no2,or it converts frequency to voltage and power the LEDs.
can u clear my doubt
i have this circuit in my mind.i tried to built it,don't know why it never worked.
http://www.walktronics.de/html/led-drehzahlmesser.html
The circuit is made
The circuit is made thinking to my car, a Vauxhall-Opel Corsa B. In this case there is a sensor that give us a voltage proportional to the engine revolutions. In this case, it is possible to connect the sensor output to a pot and drive the circuit.
A better way is to clamp the signal into the PIC port with some diodes, to avoid its peaks up to 5v, and optionally a capacitor in series to filter the high frequencies.
This circuit drive the leds respect to the voltage, not the frequency.
"Never worked" means never run the program, never turn on leds or never sow right the engine revs?
thanks a lot
this is a amazing project.
thanks a lot for providing it in such amazing and simple way.
i have a doubt.i saw lot of circuits of tach's,which do lot of conditioning.i mean using capacitors,resistor.but i see only a single resistor(pot) in your circuit.is it safe?
and i see the circuit diagram you posted using current source method for LED's,how can i reverse it.i mean sink method?
and does this circuit handle the job of both LM2917,LM3914 ?
The conditioning is simple
The conditioning is simple because this circuit is tinked to running connected to a gears sensor, that provides a voltage proportional to the engine revolutions. The large cond. units are expecially in the parts of the circuit that work with middle-high frequency, but my circuit are before that.
The PIC micro can provide up to 25mA IN and OUT the I/O ports, changing the code you can immediateli switch the circuit in "sink configuration".
The LM3914 yes, it made a similar job, but it don't requires a program. It is simpler but fewer flexible. I'm sorry but I doesn't know the 2917..
maths
can you explain the maths in the code thanks
Re: maths
if (reg <= 1)
leds: 00000000 00000000
else if (reg <= 3)
leds: 00000000 00000001
else if (reg <= 5)
leds: 00000000 00000011
else if (reg <= 7)
leds: 00000000 00000111
else if (reg <= 9)
leds: 00000000 00001111
else if (reg <= 11)
leds: 00000000 00011111
else if (reg <= 13)
leds: 00000000 00111111
else if (reg <= 15)
leds: 00000000 01111111
else if (reg <= 17)
leds: 0000000 11111111
else if (reg <= 19)
leds: 00000001 11111111
else if (reg <= 21)
leds: 00000011 11111111
else if (reg <= 23)
leds: 00000111 11111111
else if (reg <= 25)
leds: 00001111 11111111
else if (reg <= 27)
leds: 00011111 11111111
else if (reg <= 29)
leds: 00111111 11111111
else if (reg <= 31)
leds: 01111111 11111111
else
leds: 11111111 11111111