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.

Distortion/Warping of DAC output?

Status
Not open for further replies.
Hello there,

Recently, out of boredom, I managed to construct myself a simple programmable tone-generator with a microcontroller, and a R-2R DAC is hooked on it. The output is then, of course, amplified.

I started out with a 440Hz sine wave tone with a decay envelope generator inside, without the amplifier. It sounds like a chime. It's just as it is intended.

However, hooking this up with an amplifier (LM386, or the one-quarter of LM324 opamp) give a warped and/or distorted tone, with the decay element not heard anymore, and the tone has been a bit off-key.

By the way, I programmed the system to give out samples every each 31.25µ-seconds, or 32KHz sampling rate to the DAC.

What could be the problem? Must I use a full chip-based DAC, or must I use an amplifier that can accept higher frequencies?

Thanks.
 
Here is the diagram. I've even tried a simple non-inverting op-amp configuration, but still it went warping like mad. Putting an LM386 instead makes things worse.

Could I need any band-pass filters between the system? The DAC contains 330Ohms resistors. R is 330 || 330 Ohms, and 2R is 330 Ohms.

Btw, the supply voltages are all +5V.**broken link removed**
 
Last edited:
Your attachment is not working.
 
Your op amp can't drive a low Z speaker load. Perhaps, have the op amp drive your LM386 then speaker.
 
So you're feeding 5V p-p to an opamp (ignoring the speaker, which won't work) and amplifying it by ten. How do you expect the opamp to output 50V p-p? - no wonder it's clipping and distorted.

That also isn't a circuit diagram, more a rough block diagram, so it's difficult to know exactly what's going on, but you can't drive a speaker, or have a gain of ten in the opamp.
 
So you're feeding 5V p-p to an opamp (ignoring the speaker, which won't work) and amplifying it by ten. How do you expect the opamp to output 50V p-p? - no wonder it's clipping and distorted.

That also isn't a circuit diagram, more a rough block diagram, so it's difficult to know exactly what's going on, but you can't drive a speaker, or have a gain of ten in the opamp.

I apologize for the diagram being hastily written and I will recheck the analog front-end again. Right now I might draw this full circuit up in Eagle and post it up tomorrow as I have work to do. I used the R-2R because I don't have any DAC chips around and my construction is a bit shoddy.

By the way, I drove the output using just non-inverting buffer and it still sounded warped, twisted, distorted and... unholy!
 
An LM386 power amplifier has an output of only 0.25W into an 8 ohm speaker. A cheap clock radio is louder.
The LM386 power amplifier IC already has its inputs biased at 0V and has negative feedback for a voltage gain of 20.

An opamp can drive 2000 ohms, not 8 ohms.
 
I apologize for the diagram being hastily written and I will recheck the analog front-end again. Right now I might draw this full circuit up in Eagle and post it up tomorrow as I have work to do. I used the R-2R because I don't have any DAC chips around and my construction is a bit shoddy.

By the way, I drove the output using just non-inverting buffer and it still sounded warped, twisted, distorted and... unholy!

As we don't have any circuit, we've no idea what you're doing wrong - but from what you did post, it doesn't look like it's anything close to what's needed.

R2R ladders are perfectly fine, jusr as good as anything else.
 
As we don't have any circuit, we've no idea what you're doing wrong - but from what you did post, it doesn't look like it's anything close to what's needed.

R2R ladders are perfectly fine, jusr as good as anything else.

Here is the circuit.

In the diagrams, the resistors in the R-2R are all 330Ohms. A 330 || 330 parallel has been made to form it's half, which is 165Ohms.

The first diagram showing a DAC with just an LM358 (edit: I accidently wrote LM324 inside the diagram - ignore it) non-inverting buffer to see whether it comes out the same output or not. However, it isn't.
edit: Oops! The 7th pin of the LM358 connected to the supply, which I hadn't draw it in! The supply is +5V.

**broken link removed**

Uploaded with ImageShack.us

The 2nd diagram showing a DAC with the LM386. Needless to say, it is louder, but sounds really off-tune and unholy.

**broken link removed**

Uploaded with ImageShack.us

Without connecting amplifiers whatsoever, I manage to hear a normal 440Hz chime on it as it is intended. But it is not loud enough, I have to put the speakers near my ear to hear it.
 
Last edited:
Many of the required parts are missing - for a start you MUST have a capacitor from the DAC to remove it's DC offset, plus there's a distinct lack of capacitors overall. You also need to consider the buffering, an R2R ladder requires a decent buffer after it to work properly.
 
Many of the required parts are missing - for a start you MUST have a capacitor from the DAC to remove it's DC offset, plus there's a distinct lack of capacitors overall. You also need to consider the buffering, an R2R ladder requires a decent buffer after it to work properly.

I see. So must I put a normal 1uF capacitor in between the DAC and the buffer to remove the DC offset?

I've seen some projects with a R-2R DAC and only an op-amp and it has amplified sound. Strangely mine doesn't work. I think I need to put those caps as you mentioned. :D
 
I see. So must I put a normal 1uF capacitor in between the DAC and the buffer to remove the DC offset?

I've seen some projects with a R-2R DAC and only an op-amp and it has amplified sound. Strangely mine doesn't work. I think I need to put those caps as you mentioned. :D

You're trying to run an opamp off a single 5V supply, and feeding it from an input that varies from close to 0V to close to 5V, it's difficult to find an opamp that will do that.
 
If you check my analogue PIC tutorial, I use a charge pump IC so the opamp gets +/-5V, and I use a 2.5V precision reference, so it easily (and perfectly) accepts from true 0V to whatever +ve voltage the input attenuator is designed for.

There are a number of R2R ladder applications on the MicroChip website, which give examples of doing it.
 
If you check my analogue PIC tutorial, I use a charge pump IC so the opamp gets +/-5V, and I use a 2.5V precision reference, so it easily (and perfectly) accepts from true 0V to whatever +ve voltage the input attenuator is designed for.

There are a number of R2R ladder applications on the MicroChip website, which give examples of doing it.

Many thanks for the suggestion. I will look into it. :D
 
In your first schematic you have an opamp trying to drive a speaker. You forgot to say what is the impedance of the speaker but if it is 8 ohms then an opamp can barely drive it with extremely low power before severe distortion occurs. A lousy old LM358 dual opamp has crossover distortion anyway and has trouble with frequencies above only 2kHz.

In your second schematic the LM386 power amplifier has a supply of only 5V. Its output at clipping into an 8 ohm speaker (if its input has a coupling capacitor to block any DC from the R2R ladder) (and if it has a supply bypass capacitor) is only 0.11W. A cheap clock radio has at least 5 times more power.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top