converting PWM to DC voltages using RC

Status
Not open for further replies.

ikalogic

Member
Hello,

I am trying to build a circuit to convert a PWM signal into a DC voltage that correspond to the duty cycle of the PWM signal.

I am not sure how to chose the optimal values for R and C depending on the frequency. is there a relation i can use to approximately find suitable values for R and C

I found this page on wiki, i think my answer may reside inside.. but i can't find it! maybe you can :

https://en.wikipedia.org/wiki/RC_circuit#Time_domain_considerations

or maybe you can provide me with the info i need.. that would be very kind of you guys! a smal explanation would be a plus!

thx a lot

EDIT: After further readings on the web, maybe the right question to ask is: Do i have to build my RC circuit so that it's central frequency match the one of the PWM signal?

EDIT 2: No i think i am wrong, accoding to this page https://ontrak.net/pwm.htm the frequency of the PWM is much more important than the banpass frequency of the filter....
 
Last edited:
Higher frequency will allow you to use smaller caps and still get good filtering. Common frequencies are 20khz-100khz. If you use too large of a resistor/cap combination the repsonce will be slugish when the duty cycle changes. You want to find the best value that will provide a low rippple but enough responce so you can change the signal at your desired rate.
 

That's exactly what i want!

now is there a way to calculate it rather than finding it by trial an error?
 
ikalogic said:
That's exactly what i want!

now is there a way to calculate it rather than finding it by trial an error?

I suspect it requires some analysis as well as calculation to pick the best values. The impedence of the L/C filter will load the PWM output pin so it has to be high enought to not load down the PWM output. The lowest frequency of the PWM will be the determing value such that the low-pass filter corner frequency is a smaller value.

Just as important is the load impedence of the circuit that is going to measure or see the output of the L/C low pass filter, it needs to be a much higher impedenace to not effect the true DC value. OP amp buffer stages are often used in that application.

Lefty
 
Check the MicroChip application notes, if I recall correctly, there are two explaining just what you want!.
 
Attached is a circuit I designed and built for a friend some years ago. The purpose and circuit description are included in the attachment.

It includes a PWM to DC conversion, see Figure 2. It works at the mains frequency (50 Hz) but it could be altered for other frequencies.

Signals A & B are PWM signals whose mark/space ratios are proportional to the phase differences. These signals are converted to "DC" by the averaging circuits around IC6a & IC6b.

See the description for more detail.
 

Attachments

  • Three Phase Meter.pdf
    107.2 KB · Views: 1,608
hello.. it's me again..

after reading the pdf proposed by Nigel Goodwin, i understood how to chose the right frequency for my PWM signals with regard to the bandwidth of my orriginal signal... however i dont quite understand why...

Let me put it this way: according to that PDF by microchip, i have to design the RC filter with a cut-off frequency equal to the frequency of the orriginal signal. i guess this is the way to get the best response/filtering ratio, right?

Then, what i really don't get, the PWM signal is chosen to have 5 times the frequency of the orriginal signal, why? how pwm signals having a frequency 5 times higher than the cut-off frequency pass through the filter??

can anyone explain it to me in a simple way?
 
The PWM frequency doesn't pass through the filter, that's the whole point!, the filter is there to remove it.
 
Nigel Goodwin said:
The PWM frequency doesn't pass through the filter, that's the whole point!, the filter is there to remove it.

ok so instead of passing throught the filter the average voltage will appear. ok.. i think i'll fully understand this when i'll have built this circuit and ran some oscilloscope readings around some points...


thanks again Nigel.
 
The word 'filter' might cause a bit of confusion. A filter that we might use in a water line traps the particles and at some point the particles are discarded with the filter cartridge (or flushed) - the important thing is that they do not reappear in any form downstream.

A simplification that might help to clear things up: some or all of the components of a filter, such as capacitors and inductors, serve to store energy. In the case of the RC filter the 'C' stores energy that is returned to the output. In the case of the PWM the 'C' fills in the off time - so unlike the water filter example the energy that is trapped, in a manner of speaking, does appear downstream at a slightly different time. Current flow thru the 'R' does dissapate some energy so it's not returned.
 
Nigel - not sure, it all depends on where the original poster is at. What I described helped me sort some things out with a young man who is now my mentor (for electronics anyway). As a mechanical engineer I was visualizing a PWM signal on the input - with even more gaps or holes on the output because I was stuck on the idea that the filter only removed energy as a mechanical filter would remove particles. From my point of view the filter, in the PWM case, serves to move the energy around over time rather than just trapping and discarding.
 
don't worry guys it does not confuse me i am familiar with the energy storing/dissipation of electronic components. i was trying to connect theory and practice..

by the way here is another question. still in the application note provided by microship, the authr chose to use a pwm frequency 5 times higher than the one of the orriginal signal.. could i use a frequency 20 times higher? or more? on what basis do we chose the frequency of the PWM signals ?

As far as i understand, the higher the better.. right?

thx
 
It really depends what you're wanting to do?, if you're only wanting a DC voltage, without any fast changes, you can have a cutoff frequency MUCH lower than 1/5th of your PWM frequency. But assuming you're using PWM for an amplifier, and you're wanting the filtered output to have a good frequency response (say 20KHz for audio), then using 100KHz for the PWM makes sense, as running it higher may require more expensive transistors, more complicated circuitry, and bigger heatsinks (higher frequency, higher losses).

But if the filter is entirely removing the PWM frequency, then increasing the PWM frequency won't have any helpful effect.
 
The accuracy of the output signal will be dependent upon the speed at which the original signal is sampled. A sampling rate 5x that of the original signal frequency will yield good results on the output. If there is any higher frequency content in the original signal, then this information will likely be lost.

Just out of curiosity, what is the purpose of using pwm to recreate the signal? Is this a buffer of some type? If so, then for low power, an op-amp would easily suffice and have low output impedance. If you're taking a signal and looking to significantly boost the power of the signal, then you may want to look into an LC filter to recreate the original signal from the pwm version.

Using an RC filter will require that the output be tied to a high impedance block so that the output impedance is not altered.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…