PYNQ: PYTHON PRODUCTIVITY

Pynq Z2 Audio - any suggestions to cure / reduce noise?

When playing audio in passthrough mode (line in -> headphones out) on the Pynq Z2, I seem to be getting quite a lot of “electronic” noise (buzzes, clicks and pops rather than white noise hiss).

This occurs whether I am using the base overlay, or my own overlay which handles the audio I2S streams in quite a different way in detail.

As expected, the noise goes away if I mute the codec output.

Does anyone have any suggestions on how to overcome or reduce this noise?
(Audio noise gating doesn’t really help, as the noise is audible even when sound is playing).

Is it likely to be something inherent in the layout of the Pynq Z2 board? Or is it perhaps due to timing glitches causing missed / repeated samples? I’d readily believe that of my own overlay, but as the base overlay also shows a similar kind of noise (although different in detail), it seems less probable this is the cause.

Any suggestions gratefully received. Thanks!

Further remark. If I scale down the input values before sending them back out, the noise gets scaled down as well. So, the noise is getting injected in the input side of my design and is present in the digital values before they are sent back out.

This make me more inclined to suspect incorrect capture of values from the I2S input stream, probably a timing / clocking issue…

Pynq-Z2 uses a 10MHz clock as master clock for ADAU1761:


while the typical spec introduced from the data spec is using 12MHz:
Page 4 of https://www.analog.com/media/en/technical-documentation/data-sheets/ADAU1761.pdf

It might be the case that 10MHz is not good enough for your application. We have tested the audio notebook https://github.com/yunqu/PYNQ/blob/master/boards/Pynq-Z2/base/notebooks/audio/audio_playback.ipynb, and it looks acceptable. I am not sure how good definition you want with your audio? But it does not look like we can change the master clock since it is hard-wired (page 11 of http://www.tul.com.tw/download/TUL_PYNQ%20Schematic_R12.pdf)

Thanks for the information; your code is a useful source of reference.

I am reprogramming the ADAU1761 codec from scratch, and use a 25MHz master clock (easy to get by dividing FCLK0 by 4) in my own overlay. The problem is not “definition” (number of bits) but “noise” (unwanted buzzing sounds / pops / clicks).

The schematic / constraints file show that pin U5 drives the audio MCLK pin on the codec. U5 is indeed the pin I am driving at 25 MHz. My clock control register calculation is accordingly :
; Using a 25 Mhz clock rate, with divider 2 we get (49.152 * 2 / 25) = 3 2913/3125
; 3125 = 0x0C35
; 2913 = 0x0B61
; Divider 2, Integer part 3, PLL on => 0x1B01
; so reg[2] <= 0x0C 0x35 0x0B 0x61 0x1B 0x01

I think that’s all OK, so I’ll take another look at the code converting the I2S stream into parallel data.

Thanks again for taking time to reply.

Ralph

I am still a little confused about the noise you mentioned, since we may have not noticed that before. I am wondering if this could be a single case of the pynq-z2 board with dissatisfactory quality.

Aha, it is very useful to know that you apparently don’t get the noise with the base overlay.

Just to double check - route line in direct to the headphone out, and play some silence (i.e. a signal with 0 volume, at line in). If you have the noise I can hear, it will be clearly audible if you have the headphones set to a normal listening level.

I did have a further look at my serialization / deserialization code but cannot see any obvious faults.

It’s a bit expensive for me to buy another copy of the board to find out if they are all the same, but I guess I can try double checking the soldering where visible.

Thanks again for taking the further time to reply.

Ralph

Hi,
I saw your other post about problems with codec, and reusing code from Zedboard.
Just to add to this, the Pynq-Z2 has an audio codec (unlike the Z1). You need to be really careful to program the codec properly (I’d suggest you check the sample rate carefully), and then send data in the right format, and at the right sample rate of your source audio. If your source can’t keep up, you’ll miss samples and get noise. I’ve seen this with some projects in the past, especially when code is reused.

Cathal

Thanks Cathal. I have noise with the base overlay as well as my own bitstream, and I guess (hope!) the sample rate is OK for the base overlay, as its codec set-up. The source should be keeping up, as I am simply sending the input samples straight back to the output. So, while your observations may well be relevant to some projects (including my own overlay, possibly), they don’t really explain why I am getting noise with the base overlay / pynq-provided bypass function, and others aren’t. I suppose I’ll have to get another board in due course.

Well, sorry everyone. It turned out that my cheap audio cable was picking up noise. After I replaced it with a better shielded cable, the problem has gone away. Not all issues are in the digital domain!

Thanks again for the help.

Ralph

1 Like

I’ve had similar issues this week and thought I should help document the solution somewhere.

My (cheap!) audio cable was actually fine, but I was picking up lots of noise because I was powering the PYNQ board from a USB port on my laptop. Swapping over to a USB power bank or using the DC barrel jack made this much cleaner.

Cheers,
Craig

I’ve done this too, and the much smaller remaining noise has more or less gone. Thanks for the tip!

Hello Cathal,

I’m encountering a lot of noise on the Pynq Z2 too, and I think my issue might be related to the point you are mentioning: I’m using a source IP generating samples at a variable frequency (under 1 MHz) directly wired to a I2S serializer and sampling at 48.82 KHz. Maybe I should slow down the sampling rate or only enable the serializer when a new sample is ready?

Would you have any resources or example projects on this topic ?

Clement