Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Speaker unable to play high freq tones without distortion
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Speaker unable to play high freq tones without distortion

by arduinobaswas on Thu Aug 13, 2020 3:38 pm

Hi everyone,

I'm working on a project that requires tones of frequencies 3 to 12 kHz to play via a speaker. To this end, I'm using the tone() function on an Arduino Mega and a speaker (this one: https://www.mouser.com/ProductDetail/Visaton/FR-8-JS-8-Ohm?qs=VWNNG7jHlrJQw9chlSZlqQ%3D%3D). To be able to adjust the volume of the tones, I'm using an Adafruit amplifier (here is a link to it: https://learn.adafruit.com/adafruit-20w-stereo-audio-amplifier-class-d-max9744/overview). These are all connected via connections I found on the Adafruit amplifier webpage.

The speaker I'm using produces a low rumble or distortion for the higher frequencies I need (i.e. ~6 to 12 kHz). I have tried using different wattage speakers (more specifically, I've tried 10 W and 20 W), and I've also tried using a voltage divider to 1) attenuate A0 output and 2) attenuate output from the amplifier to the speaker, all to remove this distortion. The distortion was lower when I put a voltage divider between the amplifier and speaker, but only for low volumes. Thus, so far I haven't found a solution yet.

My question is: is the distortion likely because of the speaker, the tone() function or the amplifier? Has anyone done a similar project before, and if yes, could you please give suggestions on how to reduce the distortion?

Here is the code I'm using:

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>

// 0x4B is the default i2c address
#define MAX9744_I2CADDR 0x4B

// Setting the volume is very simple! Just write the 6-bit
// volume to the i2c bus. That's it!
boolean setvolume(int8_t v) {
  // cant be higher than 63 or lower than 0
  if (v > 63) v = 63;
  if (v < 0) v = 0;
 
  Serial.print("Setting volume to ");
  Serial.println(v);
  Wire.beginTransmission(MAX9744_I2CADDR);
  Wire.write(v);
  if (Wire.endTransmission() == 0)
    return true;
  else
    return false;
}

void setup() {
  Serial.begin(9600);
  pinMode (A0, OUTPUT);
  Wire.begin();

  while (! setvolume(23))
    Serial.println("Failed to set volume, MAX9744 not found!");
}

void loop() {
  setvolume(27); //roughly 80 dB
  tone (A0, 3000,500);
  delay(1000);

  setvolume(21); //roughly 70 dB
  tone (A0, 6000,500);
  delay(1000);

  setvolume(28); //roughly 60 dB
  tone (A0, 12000,500);
  delay(1000);

}

I have attached a rough representation of the circuit. I am a beginner at Arduino and I do not have a formal background in electronics, so please excuse the "circuit diagram". Please let me know if you need more information.

Any help will be greatly appreciated!
Attachments
Speaker_Amplifier_Arduino connections.png
Speaker_Amplifier_Arduino connections.png (740.07 KiB) Viewed 13 times

arduinobaswas
 
Posts: 1
Joined: Thu Aug 13, 2020 3:03 pm

Please be positive and constructive with your questions and comments.