# Clock pulse multiplier - HOW would i do this?

#### OLDmarty

##### Senior Member
Hi All,

I was asked by a friend if i can build him a clock multiplier circuit for his euro-modular synthesis stuff.

I said "sure, it shouldn't be too hard"....and that was the beginning of my failure lol ;-)

On the commercial multiplier modules, they accept an input clock anywhere from 0.1hz to maybe 10 or 20 hz, then they multiply that input clock by a factor chosen by the front panel switch, e.g. multiply by 2,4,8,16 etc.....some of them even multiply by 1,2,3,4,5,6,7,8....

So,if the multiplier switch is set to "8", then the 1hz clock input would now provide a burst of 8 output pulses (8 hz) that occur within the original 1hz(1 sec) time period.
(NOT to be mistaken with 8x 1hz output clocks).

I started thinking about reading/measuring the input clock period and doing some math to calculate the new frequency required, but that calculation worked (on paper) only for a known frequency.

Would reading the input frequency/period interrupt the timing of the output clock? maybe there's a better way to read the incoming clock pulse?

If an odd input clock of say 57.3 hz arrived, i'm not too sure how to re-calculate the multiplier output.
For the example of 1 hz input and an 8 hz burst output, would i do something like reading the input clock period and maybe multiply it by 10 to give me a larger number to then divide into the 8 smaller periods, then use that answer as the new clock period to send out of the picaxe?

In fact, i think i need to dive the number by 16, to give me 8 equal sized pulses with 8 equal sized spaces in between each pulse.

My friend has shown me one of these multiplier devices and it's all done with a PIC18F2550 with a couple of transistors to buffer the clock input/output signals to the required logic levels and 8 leds to indicate which of the 8 multipliers are selected and that's about all that is in this module

How does one achieve such black magic? I'm a bit lost now lol ;-)

#### oracacle

##### Senior Member
I would be tempted to look at using an ADC. It would require some rersearch, but there should be some relationship between the ADC reading for frequency. Not sure this would work for lower frequencies though as it only takes a few ms at most to read an ADC.
have you got a link to the PIC based one, we maybe able to reverse engineer it and understand how it works

#### OLDmarty

##### Senior Member
I would be tempted to look at using an ADC. It would require some rersearch, but there should be some relationship between the ADC reading for frequency. Not sure this would work for lower frequencies though as it only takes a few ms at most to read an ADC.
have you got a link to the PIC based one, we maybe able to reverse engineer it and understand how it works
The PIC based unit is made by Doepfer in Germany, they make a whole range of euro synth modular stuff.
The item in question is the A160-5 (or A-160-5) clock multiplier/Ratchet controller.

There are no schematics (they never provide them), but there's nothing complex about the minimal components on the board, PIC, LEDs, resistors, transistors, voltage reg etc.
The wiring is the easy bit, It's the black magic inside the PIC that eludes me.

#### oracacle

##### Senior Member
So is the circuit an RC filter, RF filter, which pins are the I/Os connected to, do those I/Os have a function that is specific to that pin.
The other thing that I think might be happening is the transitorsare there for signal conditioning, then the pulses are timed possibly using the main system clock runningat which ever frequency they thought best to use then just multiplying that by the value needed.

You could use an X2 and timer3, when the picaxe detects a pulse record the value of timer 3, when the next pulse is detected record it again. detuct the first reading from the second and you have the time between pulses, do some maths based on your chosen prescaler.
You may also be able to settimer in a similar manner.

#### OLDmarty

##### Senior Member
So is the circuit an RC filter, RF filter, which pins are the I/Os connected to, do those I/Os have a function that is specific to that pin.
The other thing that I think might be happening is the transitorsare there for signal conditioning, then the pulses are timed possibly using the main system clock runningat which ever frequency they thought best to use then just multiplying that by the value needed.

You could use an X2 and timer3, when the picaxe detects a pulse record the value of timer 3, when the next pulse is detected record it again. detuct the first reading from the second and you have the time between pulses, do some maths based on your chosen prescaler.
You may also be able to settimer in a similar manner.
The module is purely a clock modifier, it's got no audio processing/filtering or otherwise.
One pulse in and several pulses out...

The transistors in this brand of module are typically just the clock/signal in/out buffers to ensure that control volts and gates/clocks are a decent 0-5v level, although some other brands use 0-12v which is the ongoing battle for interfacing all those different modules together.
(i've lost count at how many level convertor boards i've made for my friends rig in recent years).

I'll have to borrow the module from him sometime and trace out whatever specific pins that i can.
All i know at the moment is it's a PIC18F2550 with a 20Mhz crystal and 8 leds on the front panel.

I found some user-level details on the manufacturers site:

#### AllyCat

##### Senior Member
Hi,

AFAIK, the principle to use would be a (software-implemented) "Phase-Locked Loop" (PLL). This starts with a high(er) frequency Variable-Frequency Oscillator (VFO), usually voltage-controlled, which is divided by the required ratio and compared with a reference point (e.g. the rising edge) of the input waveform. If the (hardware/software determines that the) Input Reference point is "early" then the VFO is increased, if it is "late" then the frequency is reduced. A key part of the design is a Low-Pass filter, which might be implemented in either hardware or software (e.g. Resistor-Capacitor or Memory/Storage).

In principle, such a system can be implemented entirely by "hardware", or entirely by software (e.g. in a microcontroller), or a combination of both, depending on the frequency(s) involved. In the case of a PICaxe, the "higher" frequency might be derived by dividing the clock frequency itself and/or by using the CALIBFREQ command, or from another external or internal oscillator, for example designed around an internal comparator (available in all current PICaxes) or perhaps even using the "Touch" sensor oscillator.

A description of the actual application might determine whether a PICaxe can be used, or if "Assembler" type speeds or methods are required. Tip: for mid-frequencies, a zener diode can make quite a good "Varicap" (variable capacitance) diode.

Cheers, Alan.

#### hippy

##### Technical Support
Staff member
How does one achieve such black magic? I'm a bit lost now lol ;-)
I was thinking about this and it seemed rather hard but there is that simple way; just generate however many pulses are needed on the rising edge of an input, that "burst" as described ...
Code:
``````         _____________               _____________
Input  _|             |_____________|             |_
_   _   _                   _   _   _
Output _| |_| |_| |_________________| |_| |_| |_____``````
In this case, regardless of what the input frequency is the output will be three times that..

That meets the specification of frequency multiplier but doesn't keep the mark-space ratio. If one wanted a square wave output -
Code:
``````         _____________               _____________
Input  _|             |_____________|             |_
____       ____       _____       ____
Output _|    |_____|    |_____|     |_____|    |____``````
That could be much harder and I don't know how it would be done. One would have to determine what the frequency is before generating a multiple of that, and that would have some latency when the input frequency changes.

Probably the simplest thing to do is to measure the frequency, then generate at N time that frequency. Or sample the pulse high and low time and then work out how long output highs and lows should be for N times that. For example 50Hz has 10ms high plus 10ms low, 20ms total. Four times would be 200Hz and we could determine that with 20ms/4 = 5ms, 2.5ms high and 2.5ms low.