PWM noise controlling LED introduces noise to audio through LDR

Good day everyone, i don't really know if this the right section of the forum to seek for help about this one:

I decided to build a digital tremolo guitar effect, based on the Shoot the Moon tremolo, which i have built in the past with my own PCBs and works perfectly. So the Schematic is more than verified :slight_smile:

I kept the lower part of the schematic with the LDR controlling the audio signal aplitude. And decided to replace the LFO with an arduino controlled LED. This is where it all began... Using pin 10 of arduino the default PWM frequency is at 490Hz, and as soon as i get the LED close to the LDR, this noise is picked up and sounds really louder than the guitar!

So after some reading, i changed the PWM frequency to 31KHz, which is above the audible range. The problem has mostly gone, but bringing the LED face to face with the LDR still gets noise on my audio signal. This is due to harmonics, and unfortunately this frequency i'm getting is changing depending on what i do with my PWM value. when i fade-in-out to the LED, between values of 200-255 i get harmonics at around 120Hz. when i fade it full range 0-255 i get harmonics noise at around 1700Hz. As you can guess it, they're all multiples of the original 490Hz pwm frequency EMI noise.

Then i applied a single pole low pass filter and did many many tests on resistors and capacitors, but as different harmonics are generated depending on the PWM signal, noise always passes to the LDR... i cannot find a way around this!

So i'm basically stuck, and question is...
would the sallen-key filter do a much better job or shouldn't i even bother building one?
I'm also open to alternative ideas of making a digital tremolo, though, i think, a digital potentiometer would not be an option due to cost and complexity...
any help/ideas would be highly welcome!

P.S: the noise is only passed by the LED to the LDR. there's no other parts of the circuit that pick up the rf noise. it's as if the LED is working like a pwm noise focuser, and the LDR acting like a really sensitive antenna...

P.S: the noise is only passed by the LED to the LDR. there's no other parts of the circuit that pick up the rf noise.

Is the noise getting-in optically or electrically? i.e. If you block the light, does it still pick-up noise?

Then i applied a single pole low pass filter and did many many tests on resistors and capacitors

Try a 10uF capacitor in parallel with the LED and/or a 0.1uF capacitor in parallel with the LDR. You can try higher-value capacitors but at some point they will filter-out the tremolo effect.

PWM at 31kHz should produce harmonics that are multiples of the main frequency. Why and how it should produce low frequencies like 120Hz?

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Can you please post a copy of your PCB design?

Have you got enough bypass capacitors around your PCB?
How are you powering the project?

Thanks.. Tom... :slight_smile:

You need to screen the LDR from capacitive pick up (but still let light through).

The tones are likely to be intermodulation products, not harmonics.

I thought that tremolo was on the order of 2 to 6 Hz.
Why are you using a higher frequency?
Herb

Well I don't understand the circuit linked in OP and I don't know what is its purpose. But it is said photoresistors are very slow. I think the slow speed of the photoresistor alone should be enough to filter 31kHz PWM heavily. If you also filter the input to the LED I cannot imagine enough power is left in the high frequency to be even detectable. I suspect some instability in the opamps - the resonance frequency is changing with resistance of the LDR.

vagos21:
around 120Hz

That frequency sounds like AC mains hum. Especially if you're in a part of the world that uses 60 Hz. An LDR can pick that up quite well from ambient light sources.

First of all, thank you guys for the many and fast replies!

Ok, i'll try to keep it as simple as i can, and also answer the most comments till now:

DVDdoug:
Is the noise getting-in optically or electrically? i.e. If you block the light, does it still pick-up noise?

yes, totally optically, i mean, the LDR seems to be emitting everything, both light and EMI. if i point the LDR anywhere on my audio PCB, nothing happens, but once i point it to the face of the LDR, hell breaks loose :slight_smile:

Smajdalf:
PWM at 31kHz should produce harmonics that are multiples of the main frequency. Why and how it should produce low frequencies like 120Hz?

That's also a good question, even though my PWM frequency is now set to 31KHz, when i fade the LED between values of 200-255, i get a hum at around 122Hz (multiples are 244/490...?);

TomGeorge:
Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Can you please post a copy of your PCB design?

Have you got enough bypass capacitors around your PCB?
How are you powering the project?

schematic and PCB will be attached as images, arduino is powered by a 9V wall wart (silent) and the LDR audio circuit by another 9V wall wart (also silent). When i use a flashlight on the LDR, no noise appears and it works perfectly. noise only appears then the arduino led comes face to face with the LDR.

MarkT:
You need to screen the LDR from capacitive pick up (but still let light through).

should i use a special mirror for that one? light goes to LED, EMI passes on through the mirror? crazy idea, will definitly be put to the test! :o

herbschwarz:
I thought that tremolo was on the order of 2 to 6 Hz.
Why are you using a higher frequency?
Herb

Yes Herb, you are right, but we are talking about the PWM frequency that fades the LED. this is the one that gets picked up by the LDR along with the light.

wvmarle:
That frequency sounds like AC mains hum. Especially if you're in a part of the world that uses 60 Hz. An LDR can pick that up quite well from ambient light sources.

You are also right, but without the arduino LED the audio board works perfectly (eg with a flashlight, a match, a cell phone light...)

and i just uploaded a short video so you can see and hear exactly what's happening. the video was filmed with the default 490Hz PWM frequency, but you can get the idea of the problem.

PS: just noticed i accidentally erased the ground connection of the opamp in fritzing (pin 4), but it does exist in the real board :smiley:

vagos21:
You are also right, but without the arduino LED the audio board works perfectly (eg with a flashlight, a match, a cell phone light...)

That's actually another indication that your mains frequency may be to blame. The flashlight, match, phone light all are sure to produce a constant light, no 120 Hz flicker.

If so, the question is of course: where does THAT come from? Maybe it's your power supply, that 9V may very well have a ripple if not smoothed sufficiently, getting worse as the load increases. Nonetheless 9V stepped down to 5V by a linear regulator should be very stable, this hum could be passed on in the LED as slightly varying brightness. One thing you could do to test for this is connect a scope to your power supply (while under normal load) and see how that looks. At least in theory it is possible for mains hum to make it to the Arduino in the form of minor voltage drops 120 times a second. A 0.5V drop is no issue for the Arduino itself, but it will definitely affect the LED brightness making it drop a bit at the same frequency.

Could you run your Arduino from a battery pack? Like 6x AA batteries. That way you can be sure your power input is stable, no ripple.

vagos21:
That's also a good question, even though my PWM frequency is now set to 31KHz, when i fade the LED between values of 200-255, i get a hum at around 122Hz (multiples are 244/490...?);

31000 / 255 = 121.5 so yes that's a match, but it's not how PWM works. No matter the analogWrite() value there will be 31,000 pulses per second, it's just that the duration of those pulses varies. I have no idea how that could possibly translate into a 121.5 Hz signal, so this match I would put aside as coincidence.

Hi,
Thanks for the images;
OPs pics;


Can you post a schematic of your PCB please?

When i use a flashlight on the LDR, no noise appears and it works perfectly. noise only appears then the arduino led comes face to face with the LDR.

If you used a code that just turns the LED ON continuously, what do you get? (Thats is NO PWM)

Tom.. :slight_smile:

Tom, yes I also tried continuous value for the analogwrite, and pwm is smart about it, sends no signal, and I get no noise at all. It's like pwm is completely off, but I only tried it for the max value of 255.

I will post the schematic of my pcb as soon as I get home.

Wvmarle, I'm sure it's not the power supply of either board, when there's a constant led light from the Arduino (like Tom suggested) there's no noise picked up by the LDR. Take a look at that video again and you can see that the whole EMI thing is emitted by the LDR.

Important notice: the noise is also detectible when the led is not connected to ground. Like I noted before, it's like the pwm pin acts like an antenna, and the LDR also as another antenna, very sensitively picking up the signal :slight_smile:

Note that all modern room lights will generate a very strong 120 Hz flicker in the US. Old halogen bulbs probably the least.

Paul__B:
Note that all modern room lights will generate a very strong 120 Hz flicker in the US. Old halogen bulbs probably the least.

In some countries, they flicker at 220Hz, it depends on the input voltage source. In my country its 220V that's why I mentioned.

Hi,
220Vac does not produce 220Hz.
110Vac does not produce 110Hz.

It is the AC frequency of the mains that produces the flicker/interference.

Tom.... :slight_smile:

220V, 50 Hz will produce a 100 Hz flicker.

vagos21:
Tom, yes I also tried continuous value for the analogwrite, and pwm is smart about it, sends no signal, and I get no noise at all. It's like pwm is completely off, but I only tried it for the max value of 255.

analogWrite(pin, 255) is translated to digitalWrite(pin, HIGH) internally. So indeed, fully on.

Did you try analogWrite values <200? You only mention 200-255.

Another theory based on mains hum: the time the LED is off, the LDR still sees the ambient light. How much that is, is subject to that 120 Hz flicker. That's another way your signal can be affected by mains hum. To test this, shield your LED/LDR combo from all ambient light (or switch off any lights in your room).

vagos21:
Important notice: the noise is also detectible when the led is not connected to ground. Like I noted before, it's like the pwm pin acts like an antenna, and the LDR also as another antenna, very sensitively picking up the signal :slight_smile:

This is strange. Try to make all wires as short as possible. Or if the EMI is from the board itself put the LED on long wires, twist them and keep the Arduino far enough to not cause the noise.

Hi,
I decide to reverse engineer your PCB, seeing as you haven't supplied one.
Pin 4 of the TL072 is GND pin, but it isn't grounded.

Tom.. :slight_smile:

Hi,
Schematic;


Tom.. :slight_smile:

Hello Tom and thank you for the hard work, you are right this is exactly the schematic! I just returned home as i said and uploaded :wink:
and i also mentioned that the ground from pin 4 was accidentally deleted in fritzing but it does exist on the real board :wink: so here is the schematic i was planning to upload

audioBoard_schematic.png