Atmega ticking

I’ve built up a project based around an Atmega328 which activates 5V relays and LEDs (it’s a relay-based true bypass looper for guitar).

Everything works as it should code-wise, but there’s an audible ticking coming from the atmega that bleeds over into the audio signal. Seems to be a pretty high frequency, but I don’t have a scope or any fancy tools like that to analyze it. FWIW - I’m using the internal 8 MHz clock, no external crystal. And I’ve filtered the 5V supply just as I have done on a couple other projects without issue.
Clipped this piece of schematic from another project, but the supply to 5V is identical (just ignore the other stuff):

I can post a full schematic later if needed, don’t have it on hand at the moment

I know the bleed over into the audio signal may be due to the PCB layout, but i’d like to try to cure the tick coming from the chip itself before a complete redesign if possible.
Any ideas?? Thanks for any help!

5V power supply.PNG

It's hard to say without the schematic, and even then it might be a layout problem, so an image of the PCB layout would probably help.

I'm no expert, but my bit of experience with these things informs me finding the source of audio noise can be difficult.

But, I'm unclear on one thing: You say the clicking is audible, as in mechanical noise you can hear with an ear next to the Atmega328 device? And, that audible sound is somehow winding up as an electrical signal that's mixing with the audio signal being controlled? I'm betting that's a coincidence. Either that, or one of the components is acting as a microphone -- not unheard of. But, are you sure it's not the relays you hear clicking? And if so, there are several ways the activation/deactivation of relay coils could be causing this (more later).

But, my modicum of experience with audio circuit design, where a digital element exists, drives me to offer the following suggestions:

  • Use separate regulators for the digital components and the audio components, OR at least decouple the audio supply with a resistor/capacitor combination (i.e. a low-pass filter). It's especially important to isolate the supply that runs those relay coils, from anything that powers the audio portion. [but, I suspect this one doesn't apply. I don't know what a "true bypass looper for guitar" is, but it sounds like the audio path is only through the relay contacts.
  • Grounds! It's my experience that most "noise in audio" problems, if not from the supply line, are likely from the ground. It's especially important to tie all ground, from all circuit "sections", to the same ground point. And it's especially important to never connect an audio circuitry ground to some point up a ground line that supplies anything that draws widely varying currents -- like relay coils, or even digital circuitry ('cuz everytime a digital device switches, it causes a current spike -- less so with CMOS, but still a factor). Those varying currents, produce varying voltages across the resistance of a length of wire -- or PCB trace, etc. BUT, it sounds like even this may not apply to your project, if, once again, the only thing the audio signal touches is the relay contacts.
  • Ground loops in power cables: like AC extension cords, wiring in the walls, etc. Those wires are resistors, and if your circuit is producing varying currents (like when the relay coils energize), they can turn into noise in those lines [I'm sure you are aware of the nightmare of ground loops :stuck_out_tongue: ]. One way you could mitigate this effect is to include a low-pass filter in your power lines. The idea being to smooth out those current spikes [reduce their frequency component to sub-audio], so they don't produce audible noise in the AC lines. This usually involves inductors and capacitors arranged in one of several filter arrangements -- try Googling power line filters, or power supply noise filters, etc.
  • You have diodes across your relay coils, right? This is very important, because relay coils are...well...coils. And coils, when de-energized, produce something called Reverse EMF. Essentially this is a voltage spike that can reach rather high voltages and wreak all manner of havok! You might even need snubbers on those coils, since audio is involved.
  • This is a shot-in-the-dark but, magnetic coupling, from one or more of those relay coils, to ??? [/i]

That's all I can think of.

BTW: On a couple of occasions, I have noticed an audible click or buzz in circuit components that shouldn't be able to generate a sound! In one case it was a circuit with an LED. Whenever I applied power, it produced a little "tink" sound, like I've heard in filament lamps! The only thing I can think of is some sort of piezoelectric effect.

I'm debating whether those 100Ω resistors are necessary [R1, R2 & R6] -- and R6 is on the circuit side of C2. Shouldn't it be on the power side of C2? That might actually have something to do with noise being coupled into your audio signal. If, say, IC1 is causing current surges [e.g. when internal gates switch, etc.], that is going to generate large-ish voltages across R6 that could be coupled to IC2 [or vice-versa] -- especially if there are no despiking capacitors [and I don't see any].

The 78Lnn series of regulators do a very good job on their own of rejecting supply noise [worse case 41dB -- which, actually, may not be enough for something like a pre-amp, so maybe the 100Ω resistor is needed on the audio supply leg]. Basically, the combination of the resistor and the capacitors create a Low-Pass filter -- with the goal of passing power with a frequency component as close to DC as possible. It's important to design it to do this for the highest possible amplitude of power variation. In other words, the capacitor(s) must be able to directly supply current, with low enough "ripple" that no appreciable noise can get to the otherside of the regulator. Such a filter is only necessary, if the regulator's own ability to reject noise is inadequate. So, this means, either the supply line is very noisy, or the circuitry being supplied is VERY sensitive [for instance an audio pre-amp]. The fact that relays are involved, makes the former a possibility. --just thinking out loud, here.

I would suggest the elimination of the mechanical relays for some sort of electronic switching solution, BUT that may be difficult, considering analog signals are being switched and must be switched with little or no distortion.

And, an aside: Is D1's role to crowbar any backwards connected power source [i.e. a crude sort of reverse polarity protection] -- which causes less smoke if something like a fuse is involved.? There are better ways. Google "mosfet reverse polarity protection".

Wow thanks for the quick and thorough reply!
Probably should have prefaced this before, but I'm just a dumb mechanical engineer... the whole electrical/electronics thing is Greek to me sometimes, but i'm learning :slight_smile:

Away from my personal computer right now, but can post full schematic and layout later.

To answer your main question, yes, the ticking is audible if I put my ear next to the atmega. And I'm 99% sure its not coming from the relays. It's a bit quieter than the relays normally sound when switching.

  1. There is no voltage supply to any portion of the audio path. Its all passive. The relays basically just route the audio signal and the uC is there to switch them.

  2. The audio sections and digital sections do share a ground. I've heard/read about separating digital/non-digital grounds. But to be honest, I have no idea how to actually do this (maybe this discussion should wait until i post the schem).

  3. Again, dumb ME here so bear with me. The intent of the 100r and 10uF [R1 & C1] are to create a LPF to smooth the 9VDC to the regulator, RIGHT?? Also, this noise doesn't sound like a typical ground loop hum which I am VERY familiar with unfortunately.

  4. Nope. No diodes across the coils. I've used this exact same setup with an ATtiny85 and single relay for bypassing a single pedal with no issues. This design is really just an extension (x5) of something that I've continually used with no problem. These are TQ2-L-5V single coil latching relays. Maybe I'm not thinking about this right, but wouldn't the diode prevent the uC from reversing the HIGH/LOW signals to the coil pins to reset the switches??

  5. I have no idea what you're talking about :stuck_out_tongue:

So the power schem I posted is from another project that needed 5V, 3.3V, 9V, and 4.5V... none of the other supplies are in this project, just the 5V. But as a side note, on the previous project, the separate power rails were all screwed up until I added those 100r resistors.

Guitar pedals are a hobby of mine and D1 and C1 are components i see in lots of schematics. Yes D1 is for reverse polarity protection, and i believe C1 is a smoothing cap for DC ripples??

Hi,

You say it's an audible tick... it's highly likely that is coming from the relay(s), you could investigate by:
a) does it stop if you disconnect the relay(s) ?
b) add a delay(2000); in your program loop, does that make the tick stop for 2 seconds ?

This may indicate that your program is continuously pulsing the relay(s) when you don't think it should be.

You are correct that the usual one-diode-across-the-relay-coil won't work with a single-coil latching relay, but you can add several diodes like this:

The 4 diodes clamp the spikes from the coil switching
(ignore the LS244 part, I just googled for a sort-of suitable diagram from here )

Yours,
TonyWilk

Also, this noise doesn't sound like a typical ground loop hum which I am VERY familiar with unfortunately

AC hum is not the only thing that can present in a ground loop. A ground loop could also be a path for this clicking into your audio component(s) -- but, the fact that this clicking is audible, is really puzzling!!

Nope. No diodes across the coils.

I would say you've been lucky. The diodes are really important.

Try shorting out the 100Ω resistors (either all at once, or one by one) and see if that either quiets the audible clicking or, at least, removes it from the audio signal. Especially R6, which really looks like it should be on the other side of C2. In most cases there is no need for such a resistors. Only needed if noise reduction is an extreme requirement -- and inductors are a better choice. The regulator already does a bang-up job of reducing noise.

mo62987:
I've built up a project based around an Atmega328 which activates 5V relays and LEDs (it's a relay-based true bypass looper for guitar).

I also believe that those 'ticks' are from the relays. One way to check is to temporarily disable those relays....and see if there are any ticks to be heard.

I have a project, on my workbench, right now, that ticks when I apply power to it. Until now, I treated it as an odd curiosity that I might pursue some-other-time. Well, this post lit a fire -- so I rustled up a length of hose, and probed the board while powering it on and off. I traced the faint sound to a pair of SMD ceramic capacitors.

I have heard of ceramic capacitors behaving like microphones, due to a piezo response in the ceramic material -- which means it could also act as a speaker!

In fact, I found an article on it from a credible source [Kemet]:

Kemet Article: PIEZOELECTRIC EFFECTS CERAMIC CHIP CAPACITORS
(Singing Capacitors)

BUT, if this is what is happening in your case, then how is the sound being coupled into your audio signal?

Hi,
Can I suggest you drop the value of the 100R filter resistors to 10R?

What is I2C-power (9v) connected too?

A complete circuit diagram would be good.

Can you post some pictures of your project so we can see your component layout please?
As l well as your PCB pattern.

Thanks.. Tom... :slight_smile:

You might try making an improvised stethoscope with a piece of 3/8 inch or 10 mm OD soft vinyl tubing, make sure it's clean, hold one end (gently) in your ear canal and probe around with the other, might help localize the ticks. Don't laugh :grinning: I've done it before, it works. :slight_smile:

TonyWilk:
across-the-relay-coil won't work with a single-coil latching relay, but you can add several diodes like this:

The 4 diodes clamp the spikes from the coil switching
(ignore the LS244 part, I just googled for a sort-of suitable diagram from here )

Nice. When the coil voltage is exceeds around two-times the diode forward voltage, then this allows current through the inductor to flow, right?

The thing you must avoid is powering the relay coils from the same supply as the audio circuitry - entirely
separate power and ground harnesses are required, and if you need to share grounds do so at one point only so
no ground loops are created.

You can easily get breakthrough from the relay magnetic field to the audio signal if the audio signals are not
routed properly - analog switch chips are a better choice for low-level audio signal switching.

MarkT:
The thing you must avoid is powering the relay coils from the same supply as the audio circuitry - entirely
separate power and ground harnesses are required, and if you need to share grounds do so at one point only so
no ground loops are created.

Yes. I forgot to mention that ground loops are a problem in other places than the studio. If a PCB is not laid out properly, ground loops can occur there, too. See my previous discussion on eliminating noise, where I discuss this very issue (I just forgot to use the term "Ground Loop") -- also, my schematics, where I attempt to illustrate the cause of noise injection due to wire resistance, feature the "High Side" [i.e. the positive power lines]. But, the same principle causes this on the ground side. And the method I prescribed for preventing this, is the same for the ground side.

Also, I'm beginning to think the audible ticking sound and the noise present in your audio signal, are unrelated. Or, if they are related, one is not causing the other. They are each being caused by the same other thing [i.e. something that is all together different]. For instance, a current surge [like would be caused by energizing a relay coil], could be, both causing a capacitor to "tick" and could be causing the Audio Signal noise by some sort of coupling [capacitive, magnetic, electromagnetic transmission, or merely a ground loop, etc.]

Man, left town for a couple days and come back to lots of good info here... thanks for the input!

All the "It's the relays" comments had me second guessing everything, so I had a look back into the code. Looks like I never brought the relay coils back LOW again after they latched. There's a good chance it has something to do with that. Unfortunately, I'm having other issues with just uploading a sketch all of a sudden. So I won't be able to test the theory until I get that sorted out. If that doesn't end up solving the problem, I'll follow up with all the documents. Thanks for the help.

mo62987:
Man, left town for a couple days and come back to lots of good info here... thanks for the input!

All the "It's the relays" comments had me second guessing everything, so I had a look back into the code. Looks like I never brought the relay coils back LOW again after they latched. There's a good chance it has something to do with that. Unfortunately, I'm having other issues with just uploading a sketch all of a sudden. So I won't be able to test the theory until I get that sorted out. If that doesn't end up solving the problem, I'll follow up with all the documents. Thanks for the help.

If I remember correctly (been on multiple threads, so tend to get them confused :P), you have no diode protection on your relays? If so, consider that a possible source of your strange behavior.