Headphone jack circuitry needs a deep inspection
#1
It all started with figuring out audio quality issues in the Mobian room over on the Matrix server.

Long story short, I messed around with gain settings but couldn't make it sound as expected. So I started digging around in the schematics and datasheets to see if there was a hardware issue. Turns out I was right; there are hardware issues.

Let's start in the middle with the centerpiece of the discussion, Broadchip BCT4717ETB-TR. This is an analog switch and in the PinePhone it's wired up to switch between headphone audio and debug serial. In the PinePhone v1.2 schematic on page 8 you can see it's connected to HPOUT_L/HPOUT_R on the A64 through inductors, to PB8-DEBUG-RX/PB8-DEBUG-TX on the A64 and to HP_L/HP_R on the headphone jack.

The issue here stems from the BCT4717ETB-TR being an analog switch. The way it is connected on the schematic implies it's being used as a non-inverting audio OpAmp even though it's meant for signaling. It lacks the linear properties of an audio OpAmp and the datasheet gain graphs don't even go below 1 MHz. The graphs cover 1 MHz to 1 GHz and 300 MHz is the point where it reaches -3 dB attenuation at 1.65 V_CC which matches up well with its rated bandwidth of 300 MHz. The graph isn't exactly flat in between which leads me to believe it's unlikely to be flat for lower frequencies as well, but that's still not the main issue.

The main issue is both the analog switch range and the output impedance. The analog signal range is specified as 0 to V+, which in our case should mean 0-3.3 V. That is sort of fine since we're using a virtual ground (connected to HP-FB on the A64) but it's a point of concern. The output impedance isn't explicitly defined but the output resistance is specified as 4 Ohm typical and 8.5 Ohm maximum. Together with the inductance that becomes a low pass filter, I haven't been able to find accurate data for our components in the audible range but the shape of the curve is inverse logarithmic. This could explain why the amplifier is so incredibly bass heavy. Furthermore even if we apply a constant impedance at 4 Ohms that's still way too high for most headphones you'd connect to a phone, which are somewhere in the ballpark of 8 to 40 Ohms at 1 kHz. This could lead to strange harmonics, especially at the lower end of that range.

Then there's yet another issue I discovered while trying to measure the DC offset which turned out to be in the mV range and too small to accurately measure with my old analog scope and a twitchy cable. After about 10 seconds of pausing the music the DC offset rose to a whopping 200 mV! This is not really a good thing if you leave headphones plugged in overnight as they typically don't like DC at all, let alone 200 mV.

This is about as far as I can go tonight, it's way past bedtime and I'm super tired but I wanted to get this written down somewhere before I forget the details. My conclusion for now is that someone needs to validate my results, if the 200 mV idle offset is reproducible on other units then we might need to issue a PSA about not leaving headphones plugged in when they're not in use. Furthermore I'd really encourage the hardware people to either use a proper headphone amplifier or separate out the debug serial port from the headphone jack.

I'll see if I can figure out a way of getting frequency response curves.
  Reply
#2
I don't interpret the schematic that way - R802 and R803 have a value NC/0R. Typically this is for a part that may only be populated for testing or as an alternate component. I haven't checked the board but my guess is they're not populated, and would be used to connect headphones if U801 wasn't populated. If R802 and R803 were populated the dip switch wouldn't be able to disconnect the headphones. I think it's being used as a pure switch.

The BCT4717ETB-TR datasheet general description calls out its well matched and flat on resistance for audio use, although the subsequent plots fail to cover that frequency range as you point out. Have you found the resistance of the series inductor? While the high output impedance isn't ideal it's also unfortunately not unusual, even with 'proper' headphone amps. It shouldn't introduce harmonics (unless the claim about linearity in the datasheet is wrong) but will alter frequency response if the headphones have a low enough impedance that varies with frequency. Typically it's a bit of a bass boost which I'm getting with CX300-IIs (18R). The Porta Pros always sound bass-heavy to me, and at 58R won't see so much effect anyway. The biggest issue I have is whatever causes the peaky CPU use leading to buffer underruns - much more intrusive than frequency response problems.

The possible DC offset is more of a concern - time to dig out the test gear...

If you want to do some proper audio testing have a look at https://www.roomeqwizard.com/ - it's capable of a lot more than just room acoustics measurement. I think you could use the offline measurement method with the PinePhone to get frequency response and probably a distortion profile.
https://www.roomeqwizard.com/betahelp/he...ments.html
You'll need an audio interface with a half-decent line level input.
  Reply
#3
If you think 200mV is whopping, I'm seeing a change from 0V to 2V 10s after I close squeezelite (player app), but this into a multimeter from a bare plug without headphones connected. If this was real it would produce a massive pop in the headphones, but all I hear is a faint one. I'll have to solder up a test cable to see what happens with headphones connected, but I suspect the output is going into a high impedance 'off' mode to save power, and can't put significant current into the headphones. I should probably have a look at the A64 datasheet...
  Reply
#4
(09-25-2020, 04:02 AM)wibble Wrote: I don't interpret the schematic that way - R802 and R803 have a value NC/0R. Typically this is for a part that may only be populated for testing or as an alternate component. I haven't checked the board but my guess is they're not populated, and would be used to connect headphones if U801 wasn't populated. If R802 and R803 were populated the dip switch wouldn't be able to disconnect the headphones. I think it's being used as a pure switch.

The BCT4717ETB-TR datasheet general description calls out its well matched and flat on resistance for audio use, although the subsequent plots fail to cover that frequency range as you point out. Have you found the resistance of the series inductor? While the high output impedance isn't ideal it's also unfortunately not unusual, even with 'proper' headphone amps. It shouldn't introduce harmonics (unless the claim about linearity in the datasheet is wrong) but will alter frequency response if the headphones have a low enough impedance that varies with frequency. Typically it's a bit of a bass boost which I'm getting with CX300-IIs (18R). The Porta Pros always sound bass-heavy to me, and at 58R won't see so much effect anyway. The biggest issue I have is whatever causes the peaky CPU use leading to buffer underruns - much more intrusive than frequency response problems.

The possible DC offset is more of a concern - time to dig out the test gear...

If you want to do some proper audio testing have a look at https://www.roomeqwizard.com/ - it's capable of a lot more than just room acoustics measurement. I think you could use the offline measurement method with the PinePhone to get frequency response and probably a distortion profile.
https://www.roomeqwizard.com/betahelp/he...ments.html
You'll need an audio interface with a half-decent line level input.

From what I can tell populating R802 and R803 would bypass the analog switch and put the headphone jack into audio mode permanently. Since they are listed as "NC" I assume they were to be used for testing after removing U801 (the BCT4717ETB-TR). Do note that populating those resistor footprints on the board with 0R might damage U801 since it's going to put all it's available sink current into making COM1/COM2 follow either NO1/NO2 or NC1/NC2 using its internal reference(s).

The DC offset should be measured under load and across L/R just to be sure. We don't know if the A64 HP-FB pin is high or low impedance but I think it's pretty safe to assume the BCT4717ETB-TR is low impedance as long as it's powered on. I measured the DC offset with my scope and the transient isn't sharp enough to be heard as a pop, it takes around a second for it to settle so I'd say it's well below the audible range.

As for the datasheet mentioning audio switching I think they meant at the preamp stage (that said I still disagree with the application when they're specified for strictly positive signals). Switching amplified signals (which is what we're doing) can be done but it's a can of worms and in applications like these a discrete OpAmp would be more suitable. But please don't do that, use a complete headphone amplifier IC instead. Using an off the shelf IC knocks down the board space requirements, has huge advantages in external noise suppression and usually comes with click/pop rejection.

To test things out I connected an external headphone amplifier with high input impedance (>1k) and the bass remained boomy but slightly attenuated compared to a direct connection. I might try connecting it straight from the R802/R803 pads later if I can find them.

The rule of thumb with amplifier impedance is to have at least 1/8th of the headphone impedance, which would require us to have <1 Ohm to sound good with anything we can reasonably expect users to plug in. This is because any harmonics inherent of the headphone will be attenuated by current induced back into the amplifier through the membrane driver coils. If the amplifier output has too much impedance the attenuation here will suffer because it cannot drive the amplifier output hard enough to match the amplifier input through the induced harmonics from the headphones. This isn't linear along any dimensions so you need a good chunk of luck or a catch-all like low impedance to make it sound good on dynamic headphones. Planar headphones do not suffer from this in the same way but I think those are rare enough among PinePhone users to be treated as an edge case.

BTW, the impedance of the series inductor looks to be specified as 600 Ohms at 100 MHz but no other details. That number doesn't mean anything in the audible range since 100 MHz is very far off the audible range and from the graphs I've seen they should more or less turn into oddly behaving resistors in analog audio circuitry. They were probably meant for digital signaling.

This is one of my test tracks which turns out to sound particularly bad on my device and headphones https://www.youtube.com/watch?v=GAdn1ny1JmA (although I have purchased FLAC versions I use for testing). It has plenty of detail and a wide range of effects. Listen for distortion in the mids and you'll know what I mean.

For reference I use a Scarlett Solo 3rd Gen fed into a Loxjie P20 in fully balanced mode with Ericsson 5670 tubes and a set of balanced modified ATH-M50x headphones. I'm not expecting the PinePhone to match that performance (even though my desktop combination has some impedance issues), but it has got to do better than what it does right now by the time we reach a wider market than developers and early adopters.

Thanks for reminding me that REW can do offline measurements, I'll have to get a hold of some adapters first but I'll definitely give it a try.
  Reply
#5
Alright, so I did some measurements with REW and they confirm my findings.

   

Here you can clearly see the dips in the 100-1k range and noise in the 10k-20k range. Phase looks all kinds of weird as well.

   

Not much difference with the headphone amplifier at -24dB.

   

This is where things get a bit interesting. Adjusting DA0 and DAC to -3dB produces significantly cleaner output in the 10k-20k band. There's still what looks like a phase inversion at 11k but the difference is actually audible (previous noise-shaped SPL deviance at the most extreme was about 8dB peak to peak).

What's slightly confusing though is that as far as I can tell the headphone amplifier, DA0 and DAC are entirely internal to the SoC with only the amp outputs being externally connected. I have no idea how to fix this without involving Allwinner so we're probably better off just sticking with the -3dB attenuation even on future designs.

Anyway the major dips are at 78, 110, 156, 220, 311, 440, 622, 880 and 1195 Hz. This definitely looks like harmonics to me.

I tried attaching the data files to the post (a little under 3 MB each) but apparently they were too big and I got an ngnix error. Looking at the attachment section it seems I have an attachment quota of 2.93 MB so I guess that makes sense. I'll try to find another way of distributing them in this post but they are currently available in the Mobian chat room on Matrix.org .

Edit: Further testing shows the noise in 10k-20k disappears at anything below unity gain for DA0, as illustrated below with -0.75dB gain.
   

Edit 2: These graphs are wrong, they illustrate a separate bug in Lollypop. The high freuency issues are still there and I'll post better graphs using mpv instead on Lollypop soon.
  Reply
#6
Very interesting! There should be an answer from pine84.org...
  Reply
#7
Can you redo the plots with a more useful scale please? Say between 0dB(FS) and -100? Same goes for phase - if you're using phase wrapping there's no need to go beyond +/-180

That response is just plain odd - as if there's an 8-band graphic eq in there with all bands set to -20dB or so. What load and sample rate were you using? There's no clear sign of a bass hump from interaction with output impedance, or an HF roll off from the series inductors, which were the worries as I understood them based on the schematic.
  Reply
#8
It turns out there's a bug in Lollypop affecting the frequency response. Please disregard the above ones and look at these instead (with hopefully more useful axis scales).

   

Massive distortion starts at about 8.5k and is clearly audible.

   

-24dB on the headphone amplifier doesn't make much of a difference (adjusted levels).

   

-24dB on the headphone amplifier in addition to -3dB on DA0 and DAC makes a huge difference.

   

Separate testing (earlier measurement so levels are slightly different) points to DA0 being the culprit. -3dB on DA0 alone makes the frequency response pretty much flat aside from the very high range above 15k and even then it's off by less than 1dB.

I think -3dB on DA0 is an acceptable workaround for the current hardware when used as a line out. I have yet to test this under any significant load so the dynamics with actual headphones attached are still unknown.
  Reply
#9
Nice work! Looking forward to your progress...

Sent from my PH-1 using Tapatalk
  Reply
#10
That's much more reasonable, and thanks for the effort. It's not exactly unknown for DACs to misbehave with 0dB(FS) signals so that may be what's happening here. Please post sufficient info on test method and settings for others to reproduce your results.
Edit: and what load is this into?
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question What's the Pinephone headphone jack/similar part? nfd 1 1,266 01-16-2022, 02:05 PM
Last Post: sundog
  audio jack: OMTP or CTIA? desca 2 3,759 08-12-2020, 08:16 AM
Last Post: desca
  Pin missing,loose spring in phone, audio jack not working Jantje 3 4,482 06-09-2020, 02:47 PM
Last Post: wibble
Lightbulb [Solved][BraveHeart] PinePhone Failed Headphone Test MrArca9 4 5,820 02-11-2020, 02:30 AM
Last Post: bcnaz

Forum Jump:


Users browsing this thread: 1 Guest(s)