Output devices
Speaker, amplifier

Introdcution

The homework of this week is aimed at controlling actuators to output something, including stepper motors, servo motors, speakers, and so on.

I will focus on the speaker and its digital amplifier this time, it’s the second step that continues from last week’s input devices assignment, where I struggled to get sound input from a digital microphone. This design is for the AI astronomical knowledge answer machine, and it can be installed on my smart stargazing chair (final project idea). To achieve that, I still need to connect these input devices and output devices to the OpenAI API, which is the target for networking and connection week in the future.

The MAX98357A I2S Amplifier breakout

This week, I’m going to use the commercial MAX98357A breakout board from (Adafruit), and a 0.5 W/ 8Ω speaker. All these parts are in stock from the CBA lab. For the I2S breakout, since I learned the I2S working principle last week, the pinout from it has become easier to understand:

Pinouts instruction

LRC: Select the Left and right channels (for the MCU to identify the channels)

BCLK: The clock reference from the MCU to the amplifier

DIN: The digital sound signal that’s going to speak

GAIN: Connect to GND to output 12dB gain (default 9 dB when it’s not connected to anything)

SD: When it’s connected to GND, the GAIN will be closed. So I need to leave it hanging.

GND/VIN: power input. Notice that this amplifier needs a 5V input, but not similar to the microphone’s 3.3V input

The new AI chatbot board design

The PCB I used last week for the microphone is just for general Raspberry Pi testing purposes. To let both the microphone and speaker work together easily without jumping lines, I decided to redesign a new PCB board just for the sound input/output function. Considering it will be used for astronomical purposes, I also added the ports for the GPS module. All the out pinouts are now modified to female style, so the soldering can be easier on the other side of the board (pins passing through the holes).

I named this AI astronomical chatbot “IRIS”, because it’s a palindrome of Apple’s smart assistant “SIRI”, and IRIS is the name of a nebula. The PCB sketch and traces look like this:

9-1

(Download: Final PCB trace PNG)

(Download: Final PCB edge PNG)

(Download: Final PCB KiCAD original design files)

The finished board with all devices soldered on it:w9-2

It’s not necessary to use a two-sided coated copper board. I use it just because the one-sided board was out of stock.

The debugging of a digital speaker

I first tested the digital amplifier and speaker with the old development board. It worked well with the modified Neil’s example code: academy.cba.mit.edu/classes/output_devices/I2S/hello.MAX98357A.RP2040.ino

However, when I randomly touched the working board with strong static electricity on my finger, the speaker began to output noisy sounds. There must be something that was punctured by static electricity. I tried a new amplifier, a new speaker, but it still can’t work well. Then the only possible broken thing is the MCU or the board.

I opened the multimeter and then tried to measure the voltage of different pins when it’s not normally working. Pin 1 (Clock, BCLK) was measured as 1.65V, while pin 2 (Frame, LRC) was measured as 3.27 V. Pin 4 (DIN) was jumping voltage, which means it’s outputting the different tones normally.

Pin1 and Pin2 should all be clocks with different functions, so they should jump between high/low levels quickly and be measured as the average voltage in the middle (1.65V, for example). As a result, the 3.27 V pin always seems to be outputting a high level, which doesn’t make sense.

To prove my hypothesis, I got a new Raspberry Pi Pico W MCU and uploaded the same code, measured the voltages of different pins again, and the new Pin2 was outputting 1.65V now! This proved my idea that 3.27 V pin was broken so it can only output high level signal instead of clock signal.

This is another reason why I want to redesign the PCB. The new one uses the new MCU and this bug is disolved.