1
\$\begingroup\$

In the datasheet of a PAM8302A, which is a class-D amplifier, the recommended circuit is as follows:

PAM8302A circuit

I have seen many people also use a variable resistor (potentiometer) at the input. I do not understand the role of the variable resistor as the signal is just on-off and not analog.

Can I connect IN- to the ground and get IN+ right from a PWM GPIO pin of a STM32 microcontroller (3.3 V) without any resistor and capacitor?

Clarification:

I am using PWM pin from the microcontroller to control the speaker signal via its duty cycle. I do not use analog output from my microcontroller, so the input to the PAM8302A is an ON/OFF signal rather than the wave form of the sound.

\$\endgroup\$
22
  • \$\begingroup\$ What do you mean when you write "a class-D op-amp"? I can find no reference to such a thing in the datasheet, nor do I see any mention of the inputs expecting a on-off signal. It's a normal analog amplifier. \$\endgroup\$
    – pipe
    Mar 28, 2023 at 5:04
  • 2
    \$\begingroup\$ you generally need these input caps on most types of amplifier. They are called coupling capacitors and they stop the DC offset of the preceding stage from either upsetting the bias of the following stage, or from being amplified by it. Doesn't really matter about the class of the amplifier that much. \$\endgroup\$
    – danmcb
    Mar 28, 2023 at 5:53
  • 2
    \$\begingroup\$ The input would be a normal analogue audio signal. Any PWM stuff is happening within the class D circuitry and has nothing to do with the input. You ARE planning to use it as an audio amp, right? \$\endgroup\$
    – danmcb
    Mar 28, 2023 at 6:10
  • 1
    \$\begingroup\$ this is a class D AUDIO amp. It so happens that class D amps use something like PWM to work, but generally they take an analogue audio input signal. MAYBE you could use it in other ways, but as you haven't told us what you are really doing here we can't help you. Now I am not going to answer any more questions in chat. I suggest to take the time to completely explain your problem if you want further assistance. \$\endgroup\$
    – danmcb
    Mar 28, 2023 at 6:24
  • 1
    \$\begingroup\$ @ar2015 Sad to hear, that this chip will disappear. Yes, a full bridge with enable is useful here. You need a late enable until the PWM is active or you have DC at the speaker during boot. However, many full bridge chips are too slow for audio PWM frequencies. So sometimes I abuse strong dual 5 V gate drivers in this context. \$\endgroup\$
    – Jens
    Apr 1, 2023 at 22:24

3 Answers 3

3
\$\begingroup\$

The PAM8302A expects an analog signal at its inputs; it converts this signal to PWM, and amplifies that. All the "on-off signal" stuff happens inside the IC and at the output, but as far as the input is concerned, it is just an audio amplifier for an analog signal.

If you want to amplify a PWM signal coming from an ESP32, this is not the right way to do it; again, this IC is an audio amplifier.

You can, of course, convert the PWM audio from the ESP32 to an analog audio signal with a filter, and then feed that to the class-D amplifier, but that seems a roundabout way of handling this.

As the PAM8302A's input is supposed to be an analog signal, you can use a potentiometer at the input to attenuate the input signal; this functions as a volume control.

The two capacitors are there to get rid of the DC component of the input signal; two are used to make the input fully differential. You can tie the IN- pin to ground if you don't need differential inputs, but you stil need a capacitor to get rid of the DC component of the input signal. For calculations, see datasheet.

\$\endgroup\$
3
  • \$\begingroup\$ Thank you very much. Do you recommend me using any other amplifier? \$\endgroup\$
    – ar2015
    Mar 28, 2023 at 6:37
  • \$\begingroup\$ @ar2015 If you are already outputting PWM then aren't you already doing the first half of class D - converting audio into PWM - yourself? You only need the last part that amplifies the power to the speaker. I don't know my class-D amplifiers but the internet tells me this is done with a push-pull stage (normal and inverted signal, two transistors) and an LC filter (inductor+capacitor) \$\endgroup\$
    – user253751
    Mar 28, 2023 at 8:12
  • 1
    \$\begingroup\$ @user253751. Thanks. You are correct.. However, as I am not an electronic expert, I am a bit refraining from circuits rather than dedicated IC. If I get the self confidence, using a transistor can do that too but have complications about additional capacitors and maybe diodes. If any mistake happens, I should pay for re-manufacturing. \$\endgroup\$
    – ar2015
    Mar 28, 2023 at 8:16
0
\$\begingroup\$

Judging by the schematic in the datasheet, I think the unused input will bias correctly if you connect to to GND via the shown capacitor (i.e. AC-ground it).

\$\endgroup\$
0
\$\begingroup\$

No, you can't.

Even if you do only want to output a 3.3V digital logic PWM signal and amplify it.

The amplifier input requires a certain DC bias which comes from the input, so the capacitor between signal source and input is necessary to allow the amplifier to set the DC bias.

The amplifier input stage is such that a resistor on input sets the amplification gain. The data sheet says maximum gain is 24dB which requires a 10k resistor in series. So having no resistor would result in too much gain.

Even sending a 3.3V PWM signal has too much signal voltage for 24dB gain so the gain must be set low enough so that the amplifier can take in the 3.3V signal and drive a speaker with it. Depending on supply voltage and volume yoi want, you likely need to attenuate the signal for it to be at a suitable level, so the resistor required could be in the order of 100k or more.

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.