Calculating frequency in BASIC

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
hgboy
Posts: 25
Joined: Wed Aug 13, 2008 9:35 pm
Location: Dayton, OH

Calculating frequency in BASIC

Post by hgboy » Wed Oct 08, 2008 7:14 pm

I am working on an led shift light project based on a pic18f4550 chip. The basic goal of this project is to light a series of leds depending on a few different rpm ranges, the higher the rpm, the more leds are lit. I am using the tach input signal wire from inside the dash of my car. It is a 12 volt signal, which I have dropped down to 5 volts with a voltage divider, and put in parallel with a 5.1V zener diode incase of any spikes in the signal. What i need help with is using the pic to calculate the frequency of this signal to determine rpm. The accuracy doesnt need to be incredibly close, as a faster refreshing display would be more beneficial than accuracy. I am new to pics, so any advice or sample code would be great. (I am using the internal oscillator if that matters)

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Wed Oct 08, 2008 8:43 pm

Hello hgboy(what is your real name?!?)

A simple method that will work very well is to treat the RPM signal as if it were an AC supply and rectify it then feed it into a C/R filter and voltage divider.
What you will get is a dc voltage that varies with the frequency, measure the voltage and you can flash you leds to your hearts content.

hgboy
Posts: 25
Joined: Wed Aug 13, 2008 9:35 pm
Location: Dayton, OH

Post by hgboy » Thu Oct 09, 2008 2:06 am

Real name is Austin. Would you happen to have an example of a circuit that would do that? I know how to set up a voltage divider, but don't really know what the other things are.

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Thu Oct 09, 2008 3:06 pm

Hello Austin, I have made a shematic but this site does not have an attatchment function, my email is on my profile if you want me to send it as a jpg.

Post Reply