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...