0

What is the speaker on the Circuit Playground Express?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

What is the speaker on the Circuit Playground Express?

by kevinjwalters on Fri Apr 12, 2019 12:11 pm

What is the 7.5mm square, speaker/buzzer on the Circuit Playground and Circuit Playground Express? It looks a little like the CUI CMT-7525S-SMT?

kevinjwalters
 
Posts: 963
Joined: Sun Oct 01, 2017 3:15 pm

Re: What is the speaker on the Circuit Playground Express?

by kevinjwalters on Sun Apr 14, 2019 4:39 pm

I was curious about this because of the harsh noise that occurs around 2300 Hz for square waves. It can be heard with this CircuitPython code (on CircuitPython 4.0.0-beta.5):

Code: Select all | TOGGLE FULL SIZE
import time, board, array, digitalio, audioio
speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.direction = digitalio.Direction.OUTPUT
speaker_enable.value = True
dac = audioio.AudioOut(board.SPEAKER)
freqs = list(range(1800, 2900, 100))
sq = audioio.RawSample(array.array("h", [-20000, -20000, 20000, 20000]))

for freq in freqs:
    print("square wave Hz is", freq)
    sq.sample_rate = round(freq * 4)
    dac.play(sq, loop=True) ; time.sleep(0.5) ; dac.stop()


It sounds reasonable until 2100 Hz which is a little noisy, 2200-2400 are very harsh, 2500 is a bit noisy, after that it's fine. I've got a toy audio spectrum analyser on an Android tablet and that shows a lot of noise spread around the fundamental and 3x and 5x harmonics and possibly higher but I had it cropped. I thought originally this was a physical resonance issue with the speaker but perhaps it's the amplifier or some combination of effects/components? Both of the CPX I have do this.

This is powered off the USB from a desktop computer. I've noticed in the past that's not particularly clean. I've not tried it with battery power yet...

kevinjwalters
 
Posts: 963
Joined: Sun Oct 01, 2017 3:15 pm

Re: What is the speaker on the Circuit Playground Express?

by adafruit_support_mike on Mon Apr 15, 2019 2:43 am

The speaker does have some buzz. I'll check to see if that's the part number, or if we're using something equivalent.

adafruit_support_mike
 
Posts: 63052
Joined: Thu Feb 11, 2010 2:51 pm

Re: What is the speaker on the Circuit Playground Express?

by adafruit2 on Mon Apr 15, 2019 10:06 am

thats the equiv part, and we drive it very hard, with a class D so its about 6Vpp instead of the spec'd 3V. This means it can play WAV files and they come out not too bad, but square waves make it rattle! solution? drive it with a sine wave :)

adafruit2
Site Admin
 
Posts: 20094
Joined: Fri Mar 11, 2005 7:36 pm

Re: What is the speaker on the Circuit Playground Express?

by kevinjwalters on Mon Apr 15, 2019 1:14 pm

The discussion started with sine waves on CircuitPython's equivalent of MakeCode's increase volume? where the difference in perceived volume between MakeCode and CircuitPython was questioned.

I just tried it under MakeCode (https://makecode.com/_K3T0exHmuFcg) and the plot thickens. The 3x and 5x harmonics from the real CPX suggest play tone uses a low amplitude square wave but it's both quieter and noisier with the noise more perceptable in the full 1800-2800Hz range.

For reference, here's the response curve (dbA?) from the datasheet which does show the device is at its peak around 2400Hz so is likely to be over excited in so many senses of the word with big square waves:

CUI-CMT-7525S-SMT-frequency-response.png
CUI CMT-7525S-SMT frequency response curve
CUI-CMT-7525S-SMT-frequency-response.png (61.55 KiB) Viewed 153 times


[Added later] Playing a 96 sample sine wave with max amplitude +/- 10000, I see a lot of audible harmonics at 2x, 3x, 4x, 5x and a lot of noise fixed at around 3k but perhaps this is just what the PAM8301 does.

kevinjwalters
 
Posts: 963
Joined: Sun Oct 01, 2017 3:15 pm

Re: What is the speaker on the Circuit Playground Express?

by kevinjwalters on Thu May 16, 2019 6:36 pm

I note there's now a video with a simple explanation of how speakers work featuring the CPX and Shawn Hymel: Microsoft MakeCode: Behind the MakeCode Hardware - Speaker on the Circuit Playground Express (YouTube).

kevinjwalters
 
Posts: 963
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.