cardonabits / haxo-rs

Software for the haxophone
MIT License
42 stars 10 forks source link

Startup "pop" #17

Closed gerdb closed 10 months ago

gerdb commented 11 months ago

Today I tried to understand the startup pop. For this I added delays in the initialization of the synth and you can see, that is pops at the moment, the ALSA driver is started. One solution could be (maybe) to use pulseaudio with the option module-suspend-on-idle so that the ALSA driver is always active. But I would expect at least one pop during booting.

So an other idea was to enable the headphone amplifier after haxo has started. The amplifier has a non-pop feature. I've disconnected the SD_MODE Pin (4) of the amp from +5V and connected it to GPIO4. An additional 3k3 resistor as pulldown to GND. I wanted to modify the software so that GPIO4 goes HIGH after the haxo startet. But before I could made any modifications I saw ... that it worked as it should.

I don't no why. But there are no pops anymore.

:thinking:

gerdb commented 11 months ago

Here is how I disconnected the SD pin (pin 4 of U4). My PCB: v1.0.1 how to disconnect sd First I measured if there is connection between U4 pin 4 and + of capacitor C2 using a thin needle to contact pin 4. Then I used a sharp knife and cut the copper of the PCB at the marked position. I checked if the the connection between pin4 and + is lost as it should. Then I removed ab bit of the solder mask by scratching it with the knife and soldered a thin wire.

On the other side of the PCB a soldered a 3k3 resistor between pin 7 and 9 of the rpi connector ( GPIO 4 and GND) and the wire to pin 7 (GPIO4). rpi connector

jcard0na commented 11 months ago

Oh, wow, looks like you are getting somewhere! Fantastic investigation!

You raise a valid point regarding /SD_MODE. At the moment it is fixed at +5V

image

That's because we only forward the left I2S to both L/R output. This configuration is given in this table from the datasheet.

image

If you have successfully isolated /SD_MODE and attached it to an unused GPIO, maybe it is worth prototyping leaving /SD_MODE low during power up, and only raise it at the last minute. The datasheet does mention "comprehensive click-and-pop suppression", but I cannot find details on whether it needs to be activated one way or another.

Also, keep in mind that the RPi logic high is 3.3V, not 5V. I don't think that should make a difference, given that we'd still be above the B2 trip point, but it is worth keeping an eye on that.

image

Looking forward to see what you discover!

Thanks,

PS. BTW,

I don't no why. But there are no pops anymore.

But does it still work? 😉🎷

jcard0na commented 11 months ago

Hi @gerdb,

I checked the Linux driver for the MAX98357A: apparently they do eliminate the pop by delaying the assertion of SD_MODE until after the I2C clock is started.

https://github.com/torvalds/linux/commit/cec5b01f8f1c6064037f3181e7690e3765ed995b

I think I will make the change to the schematic to connect that pin to an unused GPIO.

Cheers,

gerdb commented 11 months ago

_"delaying the assertion of SDMODE until after the I2C clock is started." I can confirm this. I've connected it to GPIO4 and do not set it. But I can see that some other service sets it to HIGH, about 5sec before haxo is started. The GPIO is configured as input during startup. I have an 3k3 pulldown and can see a voltage of some 100mV. This means that there is also some kind of weak pullup. So I would recommend to also use a pulldown.

... it's now more a hardware than a software issue ...

gerdb commented 11 months ago

Tested it without pulldown resistor: There is no audible pop. The resistor is therefore not necessary. For the first 15sec of boot the voltage at GPIO4 is 2.2V, then for 10s 0V and then for 5s 3.3V until haxo started. (RPI 3B+)

jcard0na commented 11 months ago

Thanks for testing this @gerdb!

Apparently changing /boot/config.txt as below should configure the max98357a driver to use GPIO4 to control SD_MODE

 - dtoverlay=max98357a
 + dtoverlay=max98357a,sdmode-pin=4

I've made the change to the schematic to connect SD_MODE to GPIO4, no pull-ups. I'm very reassured by reviewing the documentation and your testing that it will work. Thanks!

Links:

https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/max98357a-overlay.dts https://forums.raspberrypi.com/viewtopic.php?t=340771

jcard0na commented 11 months ago

BTW @gerdb, your contributions have been mentioned in the last crowdfunding project update post: https://www.crowdsupply.com/cardona-bits/haxophone/updates/last-days-of-the-campaign Thanks for the good work!

jcard0na commented 10 months ago

I've manufactured a board that includes this change: https://github.com/cardonabits/haxo-hw/commit/a28321d64bd03642627a374bd779182410e1912a and have confirmed that indeed it solves the startup pop.

Thanks for your help on this, @gerdb!