2
\$\begingroup\$

I am working on a sound synthesizer using an ATmega328. My synthesizer works for now, and has two voices. Of course I want these voices to be mixed and though I'd use an opamp for that. I have the following circuit now (with a little bit of help from Gemini).

enter image description here

Rail voltage of the opamps is 0 and +5 V (the whole thing needs to be powered with 5 V).

My question now, is if this design makes any sense, or is it AI hallucinations? For what I can find online and offline, this should work and give me a combined audio signal, with a 1.79 V offset.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ why not combine them in software? \$\endgroup\$ Commented Nov 9 at 16:44
  • \$\begingroup\$ @jsotola, if it's hardware-generated PWM then switching from that to software PWM generation to combine them is a lot of work on the CPU just to save a cheap small op-amp circuit. If it was a PLD then fair enough. \$\endgroup\$ Commented Nov 9 at 17:20
  • \$\begingroup\$ 1. what's the benefit of U7A? op-amp inputs take negligible current so R9/R10 can just go straight into the + input of the next op amp; 2. choose a RRIO op amp (with adequate current capability for your speaker) \$\endgroup\$ Commented Nov 9 at 17:28
  • 1
    \$\begingroup\$ @PeteW No benefit except that a dual opamp needs to have the unused opamp connected properly anyway, so might as well wire it. \$\endgroup\$ Commented Nov 9 at 19:54
  • \$\begingroup\$ @jsotola I use the internal timer/counters of the Atmega328 at 16MHz to generate the PWM signals. I had a pure software solution before, but that didn't work very well. \$\endgroup\$ Commented Nov 10 at 11:23

5 Answers 5

3
\$\begingroup\$

U7A is surplus to requirements. Note that R9/10 could just as easily go to U1B's +ve input as U7A's.

A capacitor in series with the loudspeaker would be useful, to eliminate the DC bias on it, and so reduce the current required from U1B.

\$\endgroup\$
3
\$\begingroup\$

In principle, the diagram has all the bits and pieces in block diagram kind of level and it might even work in practice to output something that resembles audio.

The actual implementation is just very poor and is missing a couple of obvious things it should have, so it might be low in volume and have poor audio quality, at least if compared to what it could be with a proper design.

First of all, at high level, the op-amp isn't strong enough to drive the speaker, and the DC bias is passed on to speaker, which needs to be AC coupled. Technically there should be an amplifier capable of driving the speaker.

Then the actual op-amp and component values to bias the op-amp and the gain it has may not be very suitable for the old LM324. At 5V supply, it will have input voltage range between 0V and 3V only, so bias should be 1.5V. On the other hand, at any appreciable level of current, the output range will be between 1V and 3.25V, so DC bias should be about 2.125V.

Summing two 5V signals together at 1x gain means the output will clip.

It is not meaningful to calculate why the values are not very good, as they need to be recalculated anyway, so it may make sense to just recalculate the values appropriately from scratch, and then check if what AI told you makes sense or not.

As said it will make also sense to AC couple the input, but frankly, the LM324 is so weak that even the MCU PWM pins might drive the speaker with more current, and mixing the audio could be done by just wiring the PWM outputs together with resistors. It may make sense to exchange the LM324 to something newer as well.

There are some weird things such as one opamp used as buffer for reference voltage, but as the reference voltage goes only to one high impedance node, the input of second op-amp, the first op-amp can be removed without any functional difference.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Hmm, the question mentions AI (Gemini) was used to help generate the schematic. Guess that the issues pointed out in this answer are the result of using AI for circuit design. \$\endgroup\$ Commented Nov 9 at 19:24
  • \$\begingroup\$ The gain for each channel (below the cut-off frequency) is 0.5 and not x1 because the input resistance is 2x 10 kohm. \$\endgroup\$ Commented Nov 10 at 11:06
  • \$\begingroup\$ Thanks, this is a lot of info that I can use. If I would ditch the speaker and work towards a signal that I can use in any audio-input (e.g. audio in of a amplifier, or even the microphone in of a PC), would that be helpful. I guess the signal being between 1 and 3,25V shouldn't be a big problem there? (My choice of the LM324 by the way, is because I have those lying around). \$\endgroup\$ Commented Nov 10 at 11:21
2
\$\begingroup\$

You need to add a blocking capacitor in series with U18's (-) input, otherwise the 1.8V bias volage will be amplified by a factor of 1 to 2, depending upon how many inputs are connected.
A value of 1µF will give a low frequency rolloff below 20Hz.

\$\endgroup\$
2
\$\begingroup\$

Have you considered the effect of the low pass filters (R4 and C6, R7 and C7) on your audio?

The given values (10k and 4.7nF) give a cutoff of about 3.4kHz.

  • Is that high enough to pass the audio you are generating?
  • Is that low enough to filter out the PWM signal?
\$\endgroup\$
1
  • \$\begingroup\$ You have miscalculated the cut-off frequency; due to the virtual ground, the resistance is effectively 5k ohms and not 10k. This means that the cut-off frequency is double what you say. \$\endgroup\$ Commented Nov 10 at 11:03
2
\$\begingroup\$

It should work if you have input coupling capacitors to remove any residual DC level that might swamp the op-amp output. However you won't have much output headroom with an LM324 on 5 volts. It looks like the output should be centred (around 1.8 volts) between the clipping points (0 volts and 3.5 volts) so, if you can live with that then no problem.

Connecting a speaker to the output is a big mistake.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.