Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:43 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite: driving a small speaker

     Page 5 of 14    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 10:12pm 27 Mar 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  Looks ok, I think.


Thanks Mick.

  Mixtel90 said  If you find that the volume control is a bit touchy then try adding a resistor in series with C2. That should reduce the gain of the amp, I think. Try anything up to 120k - the higher the value the less gain you should get.


Now you have "confirmed" that I haven't done anything stupid (EDIT: or maybe I have, see below) I need to turn the scope on it again. It was sort of working except for excessive noise (including pulses from the heartbeat LED and when I was using XMODEM to send files to the Pico).

  Mixtel90 said  The power supply looks ok.


That's good, though I was hoping for a smoking gun because when I tested at the weekend I was getting a strange issue where when running off the battery the sound is basically completely cut off except for short loud pulses of noise, running off the USB it didn't have the same issue. I'll make a recording later in the week after some more testing.

  Mixtel90 said  If you only want one USB socket exposed you can get a 5V supply to the charger module from VBUS. Just connect it to In+ on the charger.


Presumably that would mean that if you wanted to charge the battery then the device would also be running ?

On a related matter I think I read somewhere that you don't want to be charging the battery and running a load off the battery at the same time - do you know if that is a thing ?

  Mixtel90 said  Note that battery -ve does not go to GND, it has to go to B- on the charger.


Hmm, I had that correct originally, but looking at the physical prototype again that looks like it's got f**ked up at some point and has been tied to ground ... I wonder how long it has been running like that, and it has been running. I need to have a proper look when I'm not so tired, but thanks Mick that may be the smoking gun I was looking for .

Best wishes,

Tom
Edited 2023-03-28 08:15 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 10:44pm 27 Mar 2023
Copy link to clipboard 
Print this post

  thwill said  I'm like a dog with a bone

And you call me a terrier?

Looks mostly OK to me.

As I said earlier, I wouldn't connect the spare PWM to the amplifier because it has the potential to add more noise. Unless you have plans to include extra sounds from that PWM.

If the amplifier does have too much gain (or not enough) you can simply change the ratio of the two 2k2 resistors after the filter. You could temporarily replace them with a 5k pot and adjust that to find the desired ratio and them replace it with two resistors of roughly the same value as the two halves of the pot.

Bill
Keep safe. Live long and prosper.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2140
Posted: 10:50pm 27 Mar 2023
Copy link to clipboard 
Print this post

If that doesn't fix it another possibility is the 10R in series with the supply to the module may be a bit high for 3v operation.

Try 2R2 to 4R7, or better still if you have a spare inductor with a DC resistance less than 3R give that a shot.
If you have more than one to choose from use the highest inductance that has the required resistance.

Edit
To drive an 8 ohm speaker 10R WILL be too high. At high volume the module voltage may drop below 2V. Even 4R7 may be too much, 1R might be better.
Edited 2023-03-28 09:00 by phil99
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 11:43pm 27 Mar 2023
Copy link to clipboard 
Print this post

All good points, Phil. It depends to a degree on how hard Tom needs to drive the speaker. It may be a case of suck it and see. It's easy enough to tack resistors in parallel with the 10R while testing if needed.

I think I forgot to say that the capacitors should be a close as possible to the device that they are bypassing, particularly the 0.1uF ones.

Bill
Keep safe. Live long and prosper.
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 03:58am 28 Mar 2023
Copy link to clipboard 
Print this post

  Quote   I think I read somewhere that you don't want to be charging the battery and running a load off the battery at the same time

I see no problem with that. We all use our phone while it's charging. Even if it's just on it's still taking power from the battery. Your car is charging the battery while you are driving - it is still supplying the car's electrics.

It won't charge as fast and if you are taking out more that you are putting in then you will still eventually flatten the battery.

Bill
Keep safe. Live long and prosper.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6808
Posted: 07:19am 28 Mar 2023
Copy link to clipboard 
Print this post

On Page 21 of the Raspberry Pi Pico Datasheet there is a circuit using a MOSFET to switch the charger between charging the battery or powering the Pico. The other alternative is to feed OUT+ into VSYS via a schottky diode to prevent a back feed. If you do that the charger can end up powering the Pico and charging at the same time, and it can be putting up to 1A into the battery unless you have changed the charge rate programming resistor.

Whether you put 5V directly into the charger or whether you get the charger feed from VBUS doesn't really matter. What decides whether the Pico is running is whether it's switched on or not. :) If VSYS is getting voltage by any means then it'll be running.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
mozzie
Regular Member

Joined: 15/06/2020
Location: Australia
Posts: 68
Posted: 09:04am 28 Mar 2023
Copy link to clipboard 
Print this post

G'day Tom,
Just supplying ideas for you to tinker with as I tinker with them as well  

Move forward at whatever pace is comfortable and with a bit of luck the PAM amp will suit your needs, if not try something else  

May I suggest, if you are having issues powering the amp module, to hook it up to 2 or 3 "AA" batteries directly, couple the battery and Pico earth together and get the sound output working before going further. This will isolate problems with the power supply.

The last amp circuit I posted is built on breadboard and now have had the first tune in your program stuck in my head for 3 days...  

Hope this helps

Regards,
Lyle.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 08:46pm 30 Mar 2023
Copy link to clipboard 
Print this post

Hi folks,

Still on the PAM circuit posted previously, but with the 10R on the amplifier power supply replaced by 2.2R - the too high resistance seems to have been the cause of the erratic sound when powering by battery - thanks @phil99.

It turns out I had completely c**ked up installing the battery charger module even though I knew what I was doing; I had charged the battery originally offline and not checked in the device itself - stupid . When on battery the Pico was effectively hooked directly to the battery (though through the Schotky) and bypassing the charger module. Even after fixing that, the charger wouldn't charge the battery and turned out to have a tiny solder bridge on it. All resolved now, but thanks to @Mixtel90 for suggesting it might be an issue.

Current situation running b30 of the firmware:

With USB power to the Pico (4.8V at the amplifier) and the volume pot at ~6.5K the sound is quiet and has borderline acceptable noise.

With Battery power to the Pico (3.3V at the amplifier) and the volume pot at ~6.5K there is a noticeable whine of noise that pulses with the heartbeat LED.

Next steps:

1. Test an independent 5V power supply to the amplifier as suggested by @mozzie.
2. Build/test the inductor version of the filter from the PicoMite manual.

  mozzie said  ... and now have had the first tune in your program stuck in my head for 3 days...


Sorry about that, uncomment lines 54-55 to get it to play Vivaldi's "Spring" instead.

Best wishes,

Tom
Edited 2023-03-31 06:56 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 11:36pm 30 Mar 2023
Copy link to clipboard 
Print this post

  Quote  With USB power to the Pico (4.8V at the amplifier) and the volume pot at ~6.5K the sound is quiet and has borderline acceptable noise.

With Battery power to the Pico (3.3V at the amplifier) and the volume pot at ~6.5K there is a noticeable whine of noise that pulses with the heartbeat LED.


Tom, the offending noise is coming from one of two possible sources (maybe both), the amplifier or the Pico itself. From that quote above: I would suspect the Pico.

While under battery power: Does turning down the volume control to zero eliminate the noise or at least reduce it to a level that does not bother you? If it does then the amplifier is OK, no need to mess with it.

If the noise level varies with the volume control then the noise is coming from the Pico via the filter, probably superimposed on the PWM signal because of the noisy Pico power supply.

The filter in your schematic has a corner frequency of around 3.4kHz, that is adequate for your needs. Changing the filter to one that has a wider frequency response will only increase the noise level.

Disconnect the unused PWM output that will increase the noise level.

Somebody else can help here: Because the Pico is running from a battery, should the internal (noisy) regulator be disabled? It is possibly the source of the whine.

If the noise is coming from the Pico via the filter then one way to reduce that has already been suggested. Use a switching transistor between the PWM output and the filter circuit. The supply for this switching circuit MUST be decoupled. Using the power supply for the amplifier will be OK. Any transistor 10k base resistor 1k collector resistor connected to the amplifier's decoupled supply, collector output to the filter.

Hope this helps. That last bit about the switching transistor may be all you need.

Bill
Keep safe. Live long and prosper.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2140
Posted: 12:46am 31 Mar 2023
Copy link to clipboard 
Print this post

" Any transistor 10k base resistor 1k collector resistor connected to the amplifier's decoupled supply, collector output to the filter."

That is the proper way to do it, though a LED (any colour except blue or white) or string of 3 series diodes (cathode to Gnd.) across C1 to clip the top off the PWM signal might also work.
As the top of the PWM signal is at Vcc it will be carrying any noise produced by the 3V3 regulator or from the Pico itself.

The layout of the ground connections may also add some noise. Connecting all the grounds from the amp, filter and clipper directly to the charger Gnd. and not to the Pico could be worth a try.
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 01:05am 31 Mar 2023
Copy link to clipboard 
Print this post

  Quote  a LED (any colour except blue or white) or string of 3 series diodes (cathode to Gnd.) across C1 to clip the top off the PWM signal might also work.

Good idea! Simple to try, may reduce the volume a little, the LED will act like a low voltage zener diode.

  Quote  As the top of the PWM signal is at Vcc it will be carrying any noise produced by the 3V3 regulator or from the Pico itself.

That was my reasoning.

  Quote  The layout of the ground connections may also add some noise. Connecting all the grounds from the amp, filter and clipper directly to the charger Gnd. and not to the Pico could be worth a try.

Using heavier wire, making more interconnections between earths (creating a sort of grid) may also help.

I like the LED idea, that would be the first thing I would try.


Bill
Keep safe. Live long and prosper.
 
mozzie
Regular Member

Joined: 15/06/2020
Location: Australia
Posts: 68
Posted: 05:52am 31 Mar 2023
Copy link to clipboard 
Print this post

G'day Tom,
Going back over this thread and perhaps there is a (rather small) "Elephant in the room"



If you are still using this 27mm driver open like this, it might be a great idea to try hooking up a bigger speaker temporarily to see what you get, a hint would be to turn the volume down first  

I realize the eventual design is intended to fit in the TomBoy but this is meant to prove the filter and amp are working first, hopefully you have a hifi with separate speakers.

The only real way to get the low frequencies in your music files out of a small speaker like this is to overdrive them pretty hard, and the PAM8403 like most class "D" amps doesn't like being overdriven, makes some pretty horrid noises  
The small (unhoused) speaker also does a great job of accentuating the broadband hiss and noise from the PSU and Pico.

I have rigged up a PAM8403 and filter etc similar to the circuit you posted earlier and it works ok so hopefully its either a wiring issue or the speaker.

Regards,
Lyle.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6808
Posted: 07:00am 31 Mar 2023
Copy link to clipboard 
Print this post

I've just seen this.

Grounding 3V3_EN shuts off the on-board switching power supply. Normally that would be done to get lower noise on audio, but it's not practical when running from batteries. This is because the battery supply can drop to less than 3V3 (to get a longer running time) and will be stepped up to 3V3 because the switcher is a buck-boost type.

I've not tried this, but putting a ferrite bead on the signal from the PWM capacitor might reduce the carrier and any clicks even further. Putting one on the supply wire to the amp might also help, but probably to a lesser extent if there is filtering. Something to experiment with. :)

Those tiny speakers won't sound as bad once they are on any sort of baffle. Try pushing one into a "friction fit" hole in a bit of cardboard about 2" square.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4253
Posted: 07:20am 31 Mar 2023
Copy link to clipboard 
Print this post

  phil99 said  " though a LED (any colour except blue or white) or string of 3 series diodes (cathode to Gnd.) across C1 to clip the top off the PWM signal might also work.
As the top of the PWM signal is at Vcc it will be carrying any noise produced by the 3V3 regulator or from the Pico itself.


Not sure that works phil99. You shoudl clip the 44kHz PWM signal. At C1 there is a residual of the 44kHz signal (first stage of low pass filter) combined with the demodulated signal. There is severe risk you also clip away part of the modulation, causing severe distortion.

As I understand how it works you should

PWM --- clip ----low pass filter ---volum control --- PAM8403 --- tiny speaker

I ordered som of Toms speakers, and just go the message that they are out of stock (German supplier). I'll experiment with differen speakers, I have laying around. Although I think we (as a community) are already 90% on the way solving Tom's issue...

Good work...

Volhout
PicomiteVGA PETSCII ROBOTS
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 08:02am 31 Mar 2023
Copy link to clipboard 
Print this post

Volhout, I understand what you say. Maybe use 220R, LED, 820R then C1. It will reduce the volume a little more but that may be OK.

The transistor approach will still give the best results providing the noise is coming from the Pico. I am becoming more convinced of that but turning the volume down to zero should prove it.

I don't want Tom to be pulled from pillar to post by suggestions of 'try this, try that' using fault finding logic is the way to go.

Bill

Edit: Volhout said "PWM --- clip ----low pass filter ---volume control --- PAM8403 --- tiny speaker". Sorry I think I said the same thing after re-reading your post.
Edited 2023-03-31 18:06 by Turbo46
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 09:24am 31 Mar 2023
Copy link to clipboard 
Print this post

Good morning Bill, et al.,

  Turbo46 said  While under battery power: Does turning down the volume control to zero eliminate the noise or at least reduce it to a level that does not bother you? If it does then the amplifier is OK, no need to mess with it.

If the noise level varies with the volume control then the noise is coming from the Pico via the filter, probably superimposed on the PWM signal because of the noisy Pico power supply.


After a quick test I can reveal that turning the volume control reduces the volume of the noise and sound in proportion. The noise is still barely audible (ear next to speaker) and pulsing with the LED when the pot is at the full 10K

  Turbo46 said  Disconnect the unused PWM output that will increase the noise level.


It's not "unused", it's playing the same signal (i.e. Left & Right are the same). Disconnecting very slightly reduces the noise.

  Quote  Use a switching transistor between the PWM output and the filter circuit. The supply for this switching circuit MUST be decoupled. Using the power supply for the amplifier will be OK. Any transistor 10k base resistor 1k collector resistor connected to the amplifier's decoupled supply, collector output to the filter.


I think I know what you want me to try, but could I suggest a snippet of schematic in case I don't .

As I understand it the switching transistor is the better alternative to adding an LED across C1 so I'll ignore the latter suggestion for the moment.

I also have a 2", 8R, 0.5W speaker that I will try later; currently it doesn't have any leads soldered to it so I couldn't just plug it in over breakfast.

Thanks again folks,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 10:24am 31 Mar 2023
Copy link to clipboard 
Print this post

Hi Tom, this is the best I can come up with for now. My ability to draw a proper schematic is limited for now.



It's part of a schematic posted by mozzie. R1, C1 and C2 are the existing filter for the amplifier and don't need to be duplicated.

The transistor will be switching from a relatively quiet supply unlike the 'noisy' Pico supply so the resultant PWM should be relatively noise free.

Bill
Keep safe. Live long and prosper.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9133
Posted: 10:29am 31 Mar 2023
Copy link to clipboard 
Print this post

There is of course an easy solution to the switching noise - buy one of the Pico clones that use a linear regulator (the black Chinese ones)
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 10:32am 31 Mar 2023
Copy link to clipboard 
Print this post

  Quote  I also have a 2", 8R, 0.5W speaker that I will try later

Try whatever speaker you like, the sound quality and volume may vary but it is not the source on any noise. That's another side track you can go down later.

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 10:33am 31 Mar 2023
Copy link to clipboard 
Print this post

  matherp said  There is of course an easy solution to the switching noise - buy one of the Pico clones that use a linear regulator (the black Chinese ones)


Ultimately I'd like to build from the official device, but I don't mind adding another uC to my box if you could point me at a listing.

Thanks,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 5 of 14    
Print this page
© JAQ Software 2024