Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Digital to Analogue Conversions via Pulse Width Modulation

Status
Not open for further replies.

gramo

New Member
There's a billion (well not quite) circuits out there for Digital to Analogue Conversions (DAC) via Pulse Width Modulation (PWM), but how many of them show you real life results? Consider the most popular that I used to stumble upon; a variation of the below;
**broken link removed**

If you pumped a 50% duty cycle into this circuit, sure it will filter it, but here's what you'll end up with;
**broken link removed**

A rather poor DAC interpretation of the PWM signal. When creating a project for a friend, I ran into this issue and had to find a resolve. There were quite a few considerations, but here's the end result;

**broken link removed**
note the PIC's power supply/OSC are not shown

For great performance, the low-pass filter was designed as a two pole, providing an attenuation of 40 db / decade past its cut-off frequency. The higher PWM frequencies are filtered out by the low-pass filter, thereby reducing the noise in the DAC output. I could ramble on all day with the findings, or simply provide you, the end user, a method that simply works, so lets get started..

**broken link removed**, optimized for 36Khz (so that its out of the audio freq range)

Here's some real life results;
variable-20pwm-20duty-20cycle-gif.25610


It's a little hard to judge quality from that, so here's some other real life results;

a) Switching from 0% to 100% duty instantly (with short pause in between);
max-20and-20min-20duty-20cycle-gif.25611


b) Closer look a the Time Constant charge time (image displays a ramp from 0% to 100% duty on a 400uS time base);
img45-jpg.25612


c) The only noise left over is the slight ring from the PIC's PWM signal, extremely clean outside of that (note; the this is a DAC output signal from a 50% duty cycle @ 36Khz. The time base on this test is 100nS)
img46-jpg.25613


As per usual, all of the source code and information can be found on the site **broken link removed**


Final Note:
Single-supply operational amplifiers with low offset voltage and input bias current specifications are
preferred for driving loads. For cost-effective solutions, however, the operational amplifier can be eliminated, with the
precaution that the load is at least 10 times the combined value of the filter resistors R1 + R2 (in this case, 20*2K = 20K


:eek:
 
Last edited:
Really useful post

Hola Gramo,

Thast's the kind of post that I appreciate.

I was just considering the use of PWM instead of a 10 bits to generate different values of V. This is a good push in the right direction.

Good.
 
Good post. Look into CLASS D audio systems for more reading.
 
The above circuit filter shown has a -3dB roll-off of 60Hz, yet your scope photo shows a rise-time (1 time-constant) of about 400µs, which corresponds to a -3dB point of about 400Hz. Don't understand the discrepancy.

In either case it might be noted that the circuit is designed for a DC or low frequency output, not audio.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top