I am trying to build a color fading RGB controller with an ATmega328, three MOSFETs and an TSOP4838 IR receiver. The RGB LED is 50 Watts and is driven by a 45 Volts off the shelf switching power supply.

The IR decoding I have programmed works perfectly if the RGB LED is not lit. It also works if the LED is running with 100% PWM duty cycle. But as soon as I change color to some RGB mixture where duty cycle is not 100% (at around 350 Hz or so), the IR receiver seems to provide junk signals and so the IR remote doesn't do anything. The MCU still works because the color is still shown correctly. Also, the coupling doesn't seem to by optical (I guess a tiny little bit of visible red might go through the IR filter of the receiver, especially at high brightness) because shading the LED doesn't improve anything.

But the oscilloscope shows that the 5V operating voltage for the MCU and IR receiver is oscillating with the PWM frequency in the range of several tens of millivolts. And on top of that there are very sharp spikes, several tens of nanoseconds in length, in the several hundred millivolts range that seem to come from the switching power supply for the LED (but the spikes don't seem to be the problem because they are also there at 100% duty cycle). Overall I guess it could be called a truly messy nightmare of an EMI scenario.

But my electronics knowledge as opposed to my programming knowledge is not good enough for me to know what to do against these problems. I have tried several things, to no avail. For example, I have put an active filter (R, C and Transistor in common collector circuit) before the converter that provides the 5V. Also putting big electrolytics to the 40V and the 5V did not help. In fact I am not really sure if I have understood the coupling path(s) that cause the problem. Is it via the power traces directly, or is it coupling via the MOSFET gates back into the MCU and from there disturbing its digital inputs or the IR receiver? I guess the PWM frequency (300 something Hz) is too low for parasitic impedances to become important. But other than that, no idea.

What could I do?

PS: in the meantime, I have increased the value of the bypass capacitor on the TSOP from the recommended 4.7 uF to up to 220 uF in order to stabilize the supply voltage of the IR receiver. The cap and the resistor of this RC-filter have been soldered directly to the IR-receiver. But still no success. Using a battery improved things a little bit, but there were still operating states where there was interference from the PWM frequency. I am out of luck...

enter image description here

  • 1
    \$\begingroup\$ You'll probably need to filter the IR receiver power supply. You may also want to try to find a PWM frequency which is not harmonically related to the typical IR detection frequencies (38 KHz) but that would likely require a PWM frequency of several KHz, which may not suit your hardware. The faster the PWM, the easier it will be to filter. A quick test you could do would be to rig up a distinct electrically isolated battery-powered IR receiver and put it next to the project to verify if power coupling is at fault. Regulating the IR supply to say 3v3 might also help. \$\endgroup\$ Nov 22, 2019 at 22:56
  • \$\begingroup\$ The reason why I have this low PWM frequency is that I want smooth color fading and thus close to 16 bit accuracy. But at 16MHz clock frequency this means 16M/65536 = 244 Hz (currently don't remember why I got 300 something Hz). So unfortunately setting the PWM faster is not an option. I will try the battery powering thing. \$\endgroup\$
    – oliver
    Nov 22, 2019 at 23:13
  • 1
    \$\begingroup\$ Try something more like 12 bits per pixel or use a faster clock. Or just use 8 bits for now and try to solve your immediate problem before worrying about color precision. It's also possible your IR decoding algorithm is making unreasonable assumptions of perfection and needs to be reworked to be more robust. Once did a project of capturing signals with issues on an scope, transferring them to a waveform generator, and improving the code until it could tolerate that issue, then on to the next. \$\endgroup\$ Nov 23, 2019 at 0:20
  • 1
    \$\begingroup\$ before you do anything else, make sure that the problem is not optical ... put the receiver and the remote control inside a cardboard box .... or put the receiver and remote control into another room \$\endgroup\$
    – jsotola
    Nov 23, 2019 at 0:44
  • 1
    \$\begingroup\$ Vishay's RC filter (that you've tried) may not be aggressive enough for your case. You have a common ground connection between Atmega, MOSfets, IR receiver. Those MOSfets switch a lot of current through that ground, and the Atmega must supply spiky current to switch on/off MOSfet gates. Running that common ground right back to the DC supply through JP3 exacerbates this problem. I'm with Chris on this: try a local 5V (or 4.5V) battery supply. Ground routing paths might be a problem too. \$\endgroup\$
    – glen_geek
    Nov 23, 2019 at 3:35

3 Answers 3



  1. You have conducted noise from DC-DC that demands a low pass filter to IR Rx.

  2. You have conducted optical noise that pumps the IR Rx and demands you add a daylight blocking filter and the PWM LEDs are pulsing the IR Rx AGC gain.

There may also be radiated noise crosstalk.

  • 1
    \$\begingroup\$ Tony, have you ever seen one of these IR Rx chips that didn't block daylight? I once tested a filtered phototransistor to see how much 10mW HeNe would get through its filter. Nada! Amazing! I'd go with Opinion #1. \$\endgroup\$
    – glen_geek
    Nov 23, 2019 at 3:42
  • 1
    \$\begingroup\$ @glen_geek I know but wasn’t sure of SNR of Red/IR being radiated. \$\endgroup\$ Nov 23, 2019 at 5:52
  • \$\begingroup\$ was that a PULSED HeNe laser? \$\endgroup\$ Nov 23, 2019 at 9:44

Is the LED drive coupling into the IR photodiode? You've got 50 volts, PWM modulated.

Suppose the IR photodiode is 1mm by 1mm, and is 10mm away from the LED chain.

Use the parallel_plate capacitor model, because there are lots of bits of metal around the photodiode, to impose a nearly vertical Efield flux pattern.

C = Eo * Er * Area/Distance = 9e-12 Farad/meter * 1mm * 1mm / 10mm

C = 9e-12 * 1e-6 / 1e-2 = 9e-12 * 1e-4 ~~ 1e-15 Farad.

Now lets compute the charge Q = C * V = 1e-15 Farad * 50 volts ~~ 1e-13 coulomb (rounding up)

What is the charge floor of the IR receiver?

Q = I * T = 1nanoAmp * 1 microSecond = 1e-9 * 1e-6 === 1e-15 Couomb

Thus the charge from the LED variations is far stronger than the IR receiver threshold.

by the way, someone already suggested "filtering the IR receiver power supply". That is crucial.

10pF (photodiode) and 0.1 volt (VDD trash) is 1e-12 Coulomb of charge.

  • \$\begingroup\$ I don't understand the calculation of the charge floor of the IR receiver. Is it referring to something in the datasheet of the TSOP? Independent of that: the calculation isn't really different if the LED voltage is just 1V. Then we have 1e-14 Coulomb, which is still stronger than the said receiver threshold. But anyways, you're probably right, I should not rule out capacitive coupling prematurely. \$\endgroup\$
    – oliver
    Nov 23, 2019 at 6:58
  • \$\begingroup\$ 1 volt on the LEDs, switching on and off, is 1e-15 Coulomb. If I recall rightly, the minimum signal to handle is 1 nanoAmpere from the photodiode. If the Return-to-Zero pulse is 1uS duration, then the charge is also 1e-15 coulomb. Which makes the SNR to be 0dB. A difficult data detection issue. \$\endgroup\$ Nov 23, 2019 at 9:25
  • \$\begingroup\$ Ah sorry, you're right, 1e-15, I missed you're rounding up. As to photodiode I don't know. Doesn't that depend on the model that is used inside the receiver? I am already working on the power supply. Using two Li-Ions and a linear regulator improves things somewhat. But there are still operating points where erratic signals are recognized by the receiver (I am passing the input from the receiver to another port with a small monitoring LED in order to be able to see when something is "received" although the remote is not sending) \$\endgroup\$
    – oliver
    Nov 23, 2019 at 10:29
  • \$\begingroup\$ Yes, the photodiode capacitance depends on the partnumber. I suggest you install a LOWPASS FILTER in the VDD to photodiode: 1Kohm and 1uF. That is 1milliSecond tau, 160Hz F3dB corner, and will knock 1MHz switchreg trash down by 60dB, if you properly ground the cap. With 1KOhm in series with VDD wiring, even a 0.1 ohm ESR cap will not degrade the filtering. \$\endgroup\$ Nov 23, 2019 at 17:42
  • \$\begingroup\$ I am a little bit confused: I have already installed the lowpass filter. Initially I had the recommended 100 Ohm + 4.7 uF from the datasheet. 1kOhm is not an option because the IR receiver already draws 5mA, so with the additional resistor it will most probably be undersupplied. However: I have even tried it with 40 Ohms + 220 uF (f0 = 18 Hz). Although this suppresses the mid frequencies (up to kHz range) pretty well, the circuit seems to get conductive for the "MHz switching trash" again. They just get through like butter. I simply don't understand what's going on... \$\endgroup\$
    – oliver
    Nov 23, 2019 at 20:16

After having fried (originally I thought it was due to shorting something on the attached breadboard) the MCU on my first board, I decided to make a second board with a proper ground plane, better routing and including a two stage RC filter before the MCU and another two stage RC before the IR receiver (both with f0 close to 10 Hz).

The supply voltages of the new board showed up pretty clean on the oscilloscope. However I eventually fried that MCU as well. I suppose it must have been because I had no overvoltage protection on the MCU and so the 44 Volts must have made it through to the MCU somehow on turning on power.

I take all these difficulties as a sign that I want to do something that does not want to be done (common ground). So now I have decided to switch to galvanic isolation where the MOSFETs are driven by opto isolators. Since I have no doubt that it can be done this way, I mark the question as solved.

PS: in hindsight I guess that at least part of the original interference problem was caused by the fact that the LED power supply was current limited (to the maximum current necessary if all three colors are fully on), which causes voltage to break down to some extent if current is drawn (i.e. with the PWM frequency). Because my 5Volts have been generated from the LED supply by a buck converter, I think that all could explain the observed strong sensitivity from the PWM.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.