can run off 2 CR2032 batteries
on-board SMD 8Ohm 1W speaker
when it is battery powered, the voltage drops on the MCU momentarily from ~5V to around 2.6V
Because it is an Atmega328pb, I am running off a 20MHz crystal.
Quick observation: no Vcc decoupling on the Atmega power supply pins? Put 100nF X7R 16V close to the chip from Vcc to Gnd (one at each power pin). See if that improves things.
Be careful when you have series inductors followed by capacitors and throw an AC signal.
It's really easy to accidently make a voltage boost circuit and overvolt things. Which might be what's crashing your mcu
Because it is an Atmega328pb, I am running off a 20MHz crystal.
I had to go by the schematics, that you seemed to supply. Which don't seem to show any crystals.
Here:
https://www.eevblog.com/forum/projects/atmega328pb-unstable-outputting-amplified-audio-over-pwm-into-a-speaker/msg5570493/#msg5570493
I posted it in the reply here https://www.eevblog.com/forum/projects/atmega328pb-unstable-outputting-amplified-audio-over-pwm-into-a-speaker/msg5570511/#msg5570511
Sorry if I wasn't clear. Thank you.
I posted it in the reply here https://www.eevblog.com/forum/projects/atmega328pb-unstable-outputting-amplified-audio-over-pwm-into-a-speaker/msg5570511/#msg5570511
Sorry if I wasn't clear. Thank you.
You did.
But that is afterwards (after my initial comment, about the crystal appearing to be missing).
The point I was trying to make, is that if we only get bits and pieces of your overall complete and full schematic(s). It makes it very difficult for other people to try and see what is going on, and comment on possible mistakes or missing things.
In some cases, even the exact PCB layout, can cause issues.
You need to decide and way up between releasing the full or a fuller schematic, versus how able and willing, we are going to be, to help spot possible issues.
I might be onto something.
I plugged my jack to bare wire cable and added 2 330Ohm resistors on the differential audio lines and plugged my 8Ohm 1W speaker after that and it works fine (albeit very quiet). I think the ferrite beads that I picked on those lines have very low resistance (300 mOhm, 600 Ohm@100Mhz). The datasheet mentioned picking very low Z at low frequency, which probably makes sense for externally powered speakers, but for the on-board speaker and headphones it might be too low. The Adafruit board doesn't mention the Ferrite bead impedance. I am thinking this was the issue and adding resistors in series solved things. Thoughts?
Also, what resistances would make sense in this case? any best practices?
Thank you.
It is definitely not the beads. I think I needed a fixed large resistor on the PWM line before the amp. I think the amp is overloaded when it gets a 5V input and is driving a load. This doesn't seem to be a problem with a powered speaker, but the volume at which it overloads changes if I decrease the duty cycle of the output to reduce the voltage. If anyone has a good explanation for me I would be grateful.
Some parts of your (full) schematics, don't look 100% right to me. I was hoping others would chime in, and help sort it out, as necessary. Such as the combined battery voltage, being above 5 volts.
I'm not convinced by the way, you have grounded (after the 100 Ohm resistor and 1 Microfarad capacitor), the IN_N input. Because the Adafruit schematic, seems to leave it floating (as in, connected to the pot, but NOT connected to the actual GND), but connected to the pot.
See here:
https://cdn-learn.adafruit.com/assets/assets/000/112/257/original/components_schem.png?1654276084
You might have done it correctly, depending on if you mean the common GND to everything or one of the 3 pot terminals, but it not otherwise connected to the common ground.
It still could be ok, but it might not be.
Found this project, a morse code tutor, that uses the PAM8302: http://w8bh.net/PocketTutor4.pdf
The schematic on the last page is almost exactly the one Adafruit has except for an additional 100k Ohm resistor on the output.
Still doesn't explain the mystery of the Adafruit board not crashing though.
Found this project, a morse code tutor, that uses the PAM8302: http://w8bh.net/PocketTutor4.pdf
The schematic on the last page is almost exactly the one Adafruit has except for an additional 100k Ohm resistor on the output.
Still doesn't explain the mystery of the Adafruit board not crashing though.
The 100k R13, seems to be limiting the input, to around 10%, even at full potentiometer volume at max, of the incoming voltage level.
Which makes sense, to stop possibly saturating the input to the amplifier (i.e. overloading the input).
The A-Star board has a 4.7uF decoupling capacitor - would that make that much of a difference?
The A-Star board has a 4.7uF decoupling capacitor - would that make that much of a difference?
If you mean C3 4.7 μF and R2 (1 Ω), then they are probably a requirement of the specific LDO datasheet (I can't see the LDO part number), as it specifies (I suspect) a minimum ESR (equivalent series resistance, some types of capacitor can have a value, which is too low, to work well), for that capacitor, to ensure it damps down oscillations (for stability).
So, it shouldn't matter, as you are not using an LDO.
In your PCB layout. Are things like the crystal, its supporting (load) capacitors and the decoupling capacitors, very, very close to the IC pin(s), that need them?
Did you source all your parts from reliable sources?
I.e. Not from AliExpress/Ebay Chinese sellers, with x10 .. x50 parts for $0.25 total, for things that normally cost at least $2 each, everywhere else?
(Because of possible, fakes, rejected components, substandard-clones, reused components, faulty parts, etc).