10 years, 6 months ago.

Using PWM output for stable accurate clock source for other components

I have a voltage to frequency device I want to use that requires a clock input. The more accurate and stable the clock source the more accurate the device is. The faster the clock source the faster the read time. The limit is 32kh (not recommended) to 1mhz which is more ideal. I was having trouble finding a cost effective crystal frequencies close to 1mhz but had trouble. I figured that I could use the PWM output of one of the MBED devices (LPC1769, LPC11U24 or LPC812) with a frequency close to 1mhz based on the default clock to keep it as stable and accurate as possible.

I realize that there is the FastPWM and the HighPWM libraries that should help with getting quick PWM speeds. My concern is the stability and accuracy of the frequencies at those speeds. I saw a note that the accuracy should be within 1% if the frequencies are the correct multiples of the system frequencies.

I realize that I might have to mess with the clock that the PWM uses to get the best results.

http://mbed.org/users/jocis/code/HighPWM/ http://mbed.org/users/Sissors/code/FastPWM/

My main questions is if I should consider the PWM good enough for this application? Second question would be if anybody has some suggestion or resources to start me off on the right foot?

2 Answers

10 years, 6 months ago.

Hi Travis,

You could go the PWM way, filtering with a resistor and capacitor. This will work, and probably nicely!
Or you could get a MCP4822 SPI DAC (12-bit), which is stable, no jitter, and affordable.

Lerche

When I look up the part it is about $2.27 US in qty100 which is more than makes sense to use the device. In this case I would just use a SPI ADC. I will look further into the using the PWM which reduces parts and also utilizes the very nice micro controllers at the same time.

Thanks!

posted by Travis Travelstead 10 Oct 2013
10 years, 6 months ago.

There are two parts to your question. First is the accuracy of the output frequency.

When using PWM this pretty much completely depends on the accuracy of the reference crystal of mbed. In the schematic you can probably find on how many ppm it is specified. That should be quite accurate, and certainly more accurate than 1% (I think that 1% also came from the way it was measured).

Then we have stability, that can be seen in two ways: Changing of frequency vs for example temperature is the first one. That is again related on the reference crystal used on the mbed board. Or they can mean jitter/phase noise. And that is harder because it also depends on the PLL for example.

If the PWM output of an mbed is suitable depends probably mainly on the requirements of your application.

That is what I expected. If the 12mhz crystal (in most cases) is both accurate and stable then the PWM output appropriate frequencies will be accurate and stable.

To make sure, the ideal frequencies for the PWM is multiples of 12, correct? For example 960khz would be a good frequency that is also close to 1mhz and is a multiple of 12.

Thanks for the help

posted by Travis Travelstead 10 Oct 2013

You can make any integer divisions of half the clock frequency (since you have a high and a low period) at 50% duty cycle. If duty cycle may very you can make any integer division of the clock frequency.

What that means is that there is no problem with making 1MHz exactly: assuming you have the LPC1768 that is the clock frequency divided by 96, or half the clock frequency by 48. So that is a nice integer number.

posted by Erik - 10 Oct 2013