Author Topic: Fractional frequency dividers.  (Read 2700 times)

0 Members and 1 Guest are viewing this topic.

Offline firewalkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2450
  • Country: gr
Fractional frequency dividers.
« on: June 29, 2018, 12:53:29 pm »
What is the best way to implement a fractional frequency (<1 kHz) divider with a microcontroller (preferably an AVR). The fraction is 5/4.

Alexander.
« Last Edit: June 29, 2018, 04:36:29 pm by firewalker »
Become a realist, stay a dreamer.

 

Offline vealmike

  • Regular Contributor
  • *
  • Posts: 192
  • Country: gb
Re: Fractional frequency dividers.
« Reply #1 on: June 29, 2018, 01:44:59 pm »
Write software.

Do you really mean 5/4ths? So the output is 1.25* higher in frequency that the original. Do you want to feed a square wave in, and get a square wave out at a different frequency, or is there more that you haven't told us.

Just one method would be to choose a micro with a much higher clock rate than the desired frequency. Measure the period of one (ore more) cycles of the input waveform. Use the measurement to adjust the timing of a software generated output waveform.
 

Offline firewalkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2450
  • Country: gr
Re: Fractional frequency dividers.
« Reply #2 on: June 29, 2018, 02:02:49 pm »
Everything is 0-5 volts square pulses. The divider is 1.25. The output frequency will be Input/1.25.

I was thinking a simple frequency counter (counter with external clock and a .1 sec gate time) and a simple delay pin toggle.  Does it sound sane?

The application is for the conversion for the RPM pulses of 5 cylinder engine to an RPM meter of a 4 cylinder engine.

Alexander.
Become a realist, stay a dreamer.

 

Offline agehall

  • Frequent Contributor
  • **
  • Posts: 383
  • Country: se
Re: Fractional frequency dividers.
« Reply #3 on: June 29, 2018, 02:15:48 pm »
Does the number of cylinders affect how RPM is measured? Not sure I understand how this is done...
 

Offline firewalkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2450
  • Country: gr
Re: Fractional frequency dividers.
« Reply #4 on: June 29, 2018, 02:25:19 pm »
Yes. It is an engine with a distributer for the high voltage. The PCM counts ignition coil pulses per revolution and feeds that info to the RPG gauge. The ignition coil pulses depends on the number of cylinders.

Alexander.
Become a realist, stay a dreamer.

 
The following users thanked this post: agehall

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3146
  • Country: ca
Re: Fractional frequency dividers.
« Reply #5 on: June 29, 2018, 02:42:30 pm »
Yes. It is an engine with a distributer for the high voltage. The PCM counts ignition coil pulses per revolution and feeds that info to the RPG gauge. The ignition coil pulses depends on the number of cylinders.

You can simply pass all the pulses through, but block every 5-th pulse.
 
The following users thanked this post: firewalker, JPortici

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: Fractional frequency dividers.
« Reply #6 on: June 29, 2018, 03:39:00 pm »
The simple way is pulse skipping. So leave out 1 out of 5 pulses.
The better, but more difficult way is a PLL to get 4 times the frequency and than divide by 2. One may be able to do this with logic ICs like an 4046 PLL and 2 dividers (e.g. HC74 + 4017). It is also possible to do the PLL in software, though it starts to get tricky at 10 kHz for an AVR.
 
The following users thanked this post: firewalker

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: Fractional frequency dividers.
« Reply #7 on: June 29, 2018, 04:25:00 pm »
pulse skipping is the best, easies solution.
otherwise acquire the frequency and generate the new pulse with software DDS / Timers
at 9600 RPM, or 160 Hz, it's going to be 800Hz pulses in, 640Hz pulses out. Almost trivial.

I am doing a simillar thing with a PIC18 for airflow sensors. Using one timer i acquire the input frequency, using another timer i re-create the signal.
I have to compensate the reading for the interrupt routine entry latency, but once calibrated with a fixed value i can get to up to 8kHz with < 25Hz error, less if use different values for different frequency ranges (use the last acquisition to decide which compensation value to use). If the MCU wasn't doind a lot of other stuff i could probably get to > 10kHz but that's already outside the range of interest
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3146
  • Country: ca
Re: Fractional frequency dividers.
« Reply #8 on: June 29, 2018, 04:27:15 pm »
The better, but more difficult way is a PLL to get 4 times the frequency and than divide by 2.

PLL will not work when the input frequency is constantly changing (as the motor goes slower or faster).
 
The following users thanked this post: firewalker

Offline firewalkerTopic starter

  • Super Contributor
  • ***
  • Posts: 2450
  • Country: gr
Re: Fractional frequency dividers.
« Reply #9 on: June 29, 2018, 04:36:12 pm »
My bad. The frequency is less than 1 kHZ. I accidentally added a 0 to the first post.

Alexander.
Become a realist, stay a dreamer.

 

Offline MT

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: aq
Re: Fractional frequency dividers.
« Reply #10 on: June 29, 2018, 06:49:58 pm »
Use a Ghz clocked regular counter and pretend the resolution of that at 1Khz is sufficient to hit  close to your
fractional frequency. There are MCU's with these sort of things.
« Last Edit: June 29, 2018, 06:51:38 pm by MT »
 
The following users thanked this post: firewalker, Nitrousoxide

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3353
  • Country: nl
Re: Fractional frequency dividers.
« Reply #11 on: June 29, 2018, 07:32:01 pm »
Use a variant of the Bresenham line algorithm.
 
The following users thanked this post: firewalker

Offline lukewren

  • Contributor
  • Posts: 11
  • Country: gb
Re: Fractional frequency dividers.
« Reply #12 on: July 15, 2018, 12:25:56 am »
My bad. The frequency is less than 1 kHZ. I accidentally added a 0 to the first post.

Alexander.

At sub 1 kHz you should be able to do pulse swallowing (pulse deletion) in software!

Sit in a loop, and for every pulse you see on your input, generate a corresponding pulse on the output -- except for every 5th pulse, where you generate nothing.

There is a general form (not just 5/4) where you accumulate a count of the fractional amount of pulses which should have been swallowed, and swallow a whole pulse when this accumulator goes above 1. This is the "variant of Bresenham's" an earlier poster mentioned.
 
The following users thanked this post: firewalker

Online nfmax

  • Super Contributor
  • ***
  • Posts: 1560
  • Country: gb
Re: Fractional frequency dividers.
« Reply #13 on: July 15, 2018, 07:07:09 am »
What is the best way to implement a fractional frequency (<1 kHz) divider with a microcontroller (preferably an AVR). The fraction is 5/4
We came up with a neat approach to this back in the 80's - https://patentimages.storage.googleapis.com/pdfs/e8707a5e10f639ed9f01/EP0236108B1.pdf

AFAIK all the patents will have expired by now.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: Fractional frequency dividers.
« Reply #14 on: July 15, 2018, 09:55:58 am »
If the frequency does not change too fast a PLL can follow changes in the frequency. It is just that the loop filter must be fast enough and may thus not give you a very stable frequency. A mechanical system with a motor can not instantly change speed anyway. However it can get a little tricky if the frequency range is very large and may include a stand still.

Pulse skipping is definitely easy done with a µC at this low frequency. It is also possible to do a kind of PLL in software.
 

Online nfmax

  • Super Contributor
  • ***
  • Posts: 1560
  • Country: gb
Re: Fractional frequency dividers.
« Reply #15 on: July 15, 2018, 10:14:27 am »
Pulse skipping is definitely easy done with a µC at this low frequency. It is also possible to do a kind of PLL in software.

Our invention was a sort of feed-forward PLL. You measure the input period, and calculate the required frequency for an NCO to bring the accumulated phase error to zero, at the end of the next input period, if it is the same as the previous. The trick is in keeping track of all the sources of error so that they do not accumulate over multiple cycles. It can handle essentially arbitrary variations in input frequency, though it may take a while to bring the error back to zero.
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Fractional frequency dividers.
« Reply #16 on: July 15, 2018, 01:49:47 pm »
Time the period between 2 input pulses, multiply it by 1.25, and use that as the period for the out pulses.
16 bit counts and 2us timing would do for ~8Hz to 1kHz+.
.  That took much longer than I thought it would.
 
The following users thanked this post: firewalker

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5870
  • Country: de
Re: Fractional frequency dividers.
« Reply #17 on: July 16, 2018, 10:14:30 pm »
A 4-bit counter with decoded outputs can give you the following pulse pattern:

     11010010110100101101001011010010

Note that for 20 input clock pulses (black + red), you get 8 output pulses. Not equally, but regularly spaced, meaning you have a signal that's periodic and does not have DC bias.

Now we just need to double the input clock frequency and your 5/4 division is done. The simplest way is an XOR gate with a delay on one input.



For the counter? Well there are a lot of 4-bit counters around, but output decoding can be tedious. Personally, I'd cascade two 4022 Johnson counters and simply connect the outputs to a diode matrix (8 diodes needed).

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf