cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 5, 3 & 1

KahHou
New Contributor

Hi, 

I am using PSoC5 LP, and I need PWM to reconstruct an analogue signal from some data.

 

My question is, how can I increase PWM's frequency and at the same time having a 16-bit resolution ?

KahHou_0-1622157150635.png

KahHou_1-1622157546662.png

KahHou_2-1622157577885.png

I have set BUS_CLOCK to 43MHz as indicated in the datasheet, for the maximum of clock frequency of 16-bit PWM.

 

As what I have understood, my PWM frequency is now 1/1.524ms = 656Hz ? which according to internet, is not sufficient, I would need it to be at least 20kHz.

I don't actually understand how does PWM function, but as what I have read from the internet, I should set PWM's frequency to the highest frequency possible and at the output of PWM I should have a low-pass filter at 10Hz to get the average value of my duty cycle.

 

I need a resolution of 16 bits because the value of the signal that I want to reconstruct varies from 0 to 65535.

 

Anyone has any idea of what I should do ? or is it just not realistic ?

0 Likes
1 Solution
Len_CONSULTRON
Honored Contributor II

KahHou,

You are correct.  With 43 MHz as the input clock to the PWM and 65535 as the period, the maximum supported frequency is 656 Hz.  (43,000,000/65536 = 656).

The PWM cannot achieve the desired 20 KHz maximum frequency.

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
2 Replies
Len_CONSULTRON
Honored Contributor II

KahHou,

You are correct.  With 43 MHz as the input clock to the PWM and 65535 as the period, the maximum supported frequency is 656 Hz.  (43,000,000/65536 = 656).

The PWM cannot achieve the desired 20 KHz maximum frequency.

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

0 Likes
odissey1
Honored Contributor II

KahHow,

One possibility  to achieve higher resolution DAC with fast response time is to use a Fractional PWM. You can find an example project using PSoC5 here:

Building a 16-bit PWM DAC out of 8-bit Fractional PWM and DeltaSigma Modulator

 

The idea behind Fractional PWM is to use 8-bit PWM, which duty cycle is being switched fast between (MSB) and (MSB+1) positions, providing averaged value. The Delta-Sigma Modulator provides fastest switching between two positions, serving the LSB for 16-bit value. Unlike 16-bits PWM, the main lobe will be at frequency  48MHz / 2^8 =  187.5 kHz, which is acceptable for some audio applications. It is also easy to filter out such high frequency using simple RC filters. Higher order filter (2-5) is recommended.

FracPWM_01c_A.png

 

As usual, PWM DAC approach has other quirks. For example, output accuracy depends on PSoC Vdd stability.  I recommend further reading about PWM DACs here:

http://www.openmusiclabs.com/learning/digital/pwm-dac.1.html 

/odissey1