Introduction

The following design can convert a PWM signal from one known constant frequency to another constant frequency while retaining the duty cycle.  This can be useful in cases where we want transmit the information contained in the duty cycle of a signal, over a carrier of different frequency. An example application is PWM control to analog output by means of RC filter - a low-frequency PWM needs a very large RC filter, but by converting the PWM to a higher frequency, a smaller RC filter can be used, along with advantages of smaller ripple and faster response.

Below we described steps needed to understand how the PWM frequency converter has been programmed. However, if you just want to get the result of programming, download GreenPAK software to view the already completed GreenPAK Design File. Plug the GreenPAK Development Kit to your computer and hit the program to design the device.

How does it work?

Let’s see how it works. When PIN#3 (signal input) goes HIGH, FSM1 is reset by the rising edge and starts to count UP, thus measuring the pulse width. Then, when PIN#3 goes LOW, FSM1 stops and the falling edge at PIN#3 through inverter 2-L4 writes FSM1 counter value into SPI buffer. This operation is repeated each period.

At the same time, CNT2 output sets the output frequency, i.e. the frequency at “OUT” is equal to output frequency of CNT2.  The PWM of the output is generated as the counter value of CNT2 is constantly compared with SPI buffer’s value by DCMP1.  To change the “OUT” frequency, the setting of CNT2 as well as any element in the clock source chain (CNT1, osc divider, type) can be changed. The clock source can also be taken directly from OSC or an external oscillator if desired.

The input frequency of FSM1 (FSM1 CLK) should be selected using the following formula:
FSM1 CLK = “IN” frequency × (CNT2 Counter data + 1)
“IN” frequency – frequency at PIN#3
If CNT0 counter data is 255, the formula can be written as:
FSM1 CLK = 256 × “IN” frequency

To change the FSM1 CLK, CNT0 counter data can be changed, oscillator divider can be changed, type of OSC can be changed, also CNT2 counter data can be changed.

Below are shown several scope shots of the design’s functionality.

Channel 1 (yellow/top line) – PIN#3 (IN)

Channel 2 (light blue/2nd line) – PIN#11 (OUT)

Conclusions

This design can be used in many projects where there is a need to change a PWM constant input frequency without changing the duty cycle, for example, LED backlight, motor controller, voltage regulator etc.