Frequency Scaling - remapping
Peter Betts email (remove spam text)
I'm Pete and I'm a recent convert to the PIC chip.
I am trying to build a project at home which measures the frequency of a
digital signal, modifies the frequency value and uses this to generate a new
e.g. 1kHz in gets scaled by 2/3 say and frequency output is 666.66Hz
Firstly I wanted to just get the reading of the frequency working (exact
frequency is not important just the relative scaling)
So I set up a timer at a rate of approx 3.9ms which I used to call an
interrupt routine. The interrupt routine then tested/checked the input
signal level (hi or lo) and then incremented a counter. This gave me a
resolution from 1Hz to 256Hz using a 5MHz XTAL. (Just using a single 8 bit
The counter was used to count the time between successive high pulses (this
was to ensure if I had an input which was not a 50:50 duty cycle I could
still scale it and generate a 50:50 duty cycle output.) The counter value/2
was the hi or lo period respectively.
First: Does anybody have a better way of measuring the period of an
incomming signal in order to generate a scaled frequency output.
Second: My output signal seems to gitter quite a bit and I don't know why.
Third: (and finally) I ideally want to remap the input so I guess I could
use a 256 element look up table and for every frequency input value I can
look up a new output value so I can have my own user defined mapping. Good
I have a basic system working but it doesn't look at all elegant so I would
appreciate new ideas.
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the