Henrik,

Unfortunately the duty cycle of the source is not a perfectly symmetrical square wave although I believe it to be of a constant duty cycle.

I have done some research on Darryl Taylors routines and am trying to fit this into what I am learning. Thank you for sending me in that direction.

1 us is more than enough resolution one update per input cycle would be great. However, I am more concerned in the lag time in the propagation at such low frequencies. In the back of my mind I am thinking that it will be horrific with a 10Hz input. Will the PIC really be able to propagate in one cycle with a 10Hz and lower signal? If so, it would be better than I ever imagined possible. In the past I have built a crude frequency doubler with a couple of flip flops and the jitter was unacceptable. This setup also taught me that I Need to stray slightly from the !:2 ratio. I really don't know what I will need in terms of numerical specification but I have a test setup that I can run real time tests and see the result. The system is for a motorbike fuel injection system which I can monitor with a diagnostic scope on a dyno.

And I thank you again! Jim.


Quote Originally Posted by HenrikOlsson View Post
Hi,
That can be done but I don't think I'd use 12F675. Instead I'd look for a PIC with a CCP-module (which I'd use to measure the frequency) and then an additional timer to generate the "doubled" frequency. I took a quick look and the 12F615/617 could work.

If the dutycycle of the input signal is 50% you only need to measure half a period (positive or negative) which is easy to do, if it's not 50% it gets a little bit trickier but still very much doable with the CCP module. Get the captured value from the CCP-module, apply your math and load the 'other' timers register with the correct value so that it overflows and generates an interrupt at the correct interval. In the timers inerrupt service routine reload the timer and "step" your pattern.

I'd definitley use Darrel Taylor's Instant Interrupt routines (because I suck at ASM).

What kind of resolution are we talking about? The timer used for the CCP module is 16 bits wide, at 4MHz that means it can "measure" up to ~65.5ms (with 1us resolution) which is enough if the duty cycle if the inout signal is 50%. If not you need to use the prescaler which "extends" the measurable time but decreases the resoultion by the same ratio.

With that said there are always more than one way. Does the frequency need to be updated "immediately" or is it OK to only update it once per "cycle"? One way to do it with the '675 might be to use one of timers to "manually" measure the input frequency (polling the input, starting and stopping the timer manually) and the other to genereate the "new" frequency.

/Henrik.