Electronic – arduino – What’s wrong with this simple PCB design? (midi synth)

arduinomidinoisepcbsynthesizer

I am designing a simple synth with Arduino (just the Atmega IC) and it works fine. The only thing is this annoying clicks I barely hear constantly if I raise the volume somewhat.

I had this problem in the past that's why I was trying to fix it by designing the PCB, separating 3 ground sectors in digital and analogue parts on one side of the PCB. In theory that should stop the digital part contaminating the analogue part.
It seems it didn't quite worked because I can still hear the clicks.

There are two things making clicks at the same time, according to my tests:

1- the Atmega crystal: If I remove the Atmega IC, that click stop.
**UPDATE: **That click was caused by the Atmega program. But I still have this other midi click sounds:

2- the Midi messages: When Midi is not connected, there is no click. After each midi message is sent (a note or clock i.e) I hear a click. For example the clock makes a constant stream of clicks and are sped up if I increase the tempo on the master device sending the BPM. If I take the Atmega IC and send midi messages, I can hear the clicks, so it's independent of it. That's why I'm thinking it's a PCB design issue

To strip down the problem I removed the LM358 part where the "scissors" are in the schematic picture and I just get the output from where it says PWM, that's just the output from the atmega IC.

So, my question is: Do you see any PCB design flaws? What could be causing the click noises?

Thanks!!

PD: I can upload the Eagle file if requested.
PCB][]

Best Answer

The 6N137 datasheet says:

A 0.1 μF bypass capacitor must be connected between pins 5 and 8.

This is required not only to prevent the 6N137 itself from oscillating, but also protects the rest of the circuit from dips in the power supply.

You have an inductor in front of the ATmega's digital power supply, but it might be a better idea to move/copy it to protect the analog part of your circuit from any of the digital parts.