Forums

Fairy Lights PWM Part 2

Started by Tim Watts December 7, 2019
Follow up from the thread Oct 2019
Minimising EM noise from PWM switched fairly lights?

Hi folks,

Recap - this is an educational project for my son to drive some existing 
garden LED fairy lights from a Raspberry Pi ZeroW

The only problem, as fully expected, is they are chucking out more EMI 
than I'd like and I don't want to be causing problems for others. So - 
yes, it's a crappy control method but we are where we are (see below) 
This is a case of trying to do a little more with a non ideal starting 
point and I'd be super grateful for any pointers on that basis :)


The noise I have is showing up on an AM radio as a clear buzz at the 
base PWM frequency (100Hz), audible across the MW range. This becomes 
undetectable about 5 - 10 yards from my property boundary depending on 
direction. The locals have been warned and no one's complained yet. 
However it's a lot noisier than the supplied controller and without a 
scope I can't see what the manufacturer did - but that leads us to Q1:


Q1) Would I understand this better with a £99 PicoScope, basic 10Mhz 
model, simple few turnes of wire antenna and looking at the spectrum (I 
think spectrum software comes bundled with the Picoscope)?

Q2) I've read about frequency dithering of PWM to spread the noise out 
from narrow to broadband. That's something I could do in software 
easily. No quite sure how far to dither - 100-200Hz, 100-1000Hz? Anyone 
heard of that?

Q3) Low pass LC filter to attentuate some of the higher harmonics:
https://imgur.com/a/8UeNy2f - analogue isn't my thing, not quite sure 
where to start with L and C values. Happy to buy a few values and suck 
it and see, if Q1 gives me a sensible method of measuring the effect.




On the plus side, I am really pleased with the software :) Pity my 
electonics skills suck which is why I'm reduced to using pre built 
HBridge L298 modules from ebay. But I'm keen to try to learn a little 
more and this is as educational for me as the lad - any help gratefully 
received :)


If starting from nothing, I wouldn't do it like this - I'd go straight 
to NeoPixels and have all the lamp control localised to each lamp. I 
might indeed order some strngs from China next year - but for this year, 
I do have these existing lights wrapped around trees already - and PWM 
is an instructive project in its own right. I am just mindful that I 
have the responsibility to not wreck havoc on my neighbours :)


Cheers and all the best,

Tim



============Lights spec =============

This is the equivalent circuit: The LEDS are wired in alternate-reversed 
configuration so that lamp 1,3,5... are driven on a forward current, 
lamp 2,4,6... are driven on reverse current.

Drive voltage 30V, about 140mA for all 150 lamps in 3 strings.

https://imgur.com/a/K9iGr2J

That's what it is - they're wrired like that as bought based on 4 
wires. Not certain of the exact configuration - might be 5, 6 or more in 
series depending on the exact Vf of the LED.
=====================================
On Saturday, December 7, 2019 at 9:08:28 AM UTC-5, Tim Watts wrote:
> Follow up from the thread Oct 2019 > Minimising EM noise from PWM switched fairly lights? > > Hi folks, > > Recap - this is an educational project for my son to drive some existing > garden LED fairy lights from a Raspberry Pi ZeroW > > The only problem, as fully expected, is they are chucking out more EMI > than I'd like and I don't want to be causing problems for others. So - > yes, it's a crappy control method but we are where we are (see below) > This is a case of trying to do a little more with a non ideal starting > point and I'd be super grateful for any pointers on that basis :) > > > The noise I have is showing up on an AM radio as a clear buzz at the > base PWM frequency (100Hz), audible across the MW range. This becomes > undetectable about 5 - 10 yards from my property boundary depending on > direction. The locals have been warned and no one's complained yet. > However it's a lot noisier than the supplied controller and without a > scope I can't see what the manufacturer did - but that leads us to Q1: > > > Q1) Would I understand this better with a £99 PicoScope, basic 10Mhz > model, simple few turnes of wire antenna and looking at the spectrum (I > think spectrum software comes bundled with the Picoscope)? > > Q2) I've read about frequency dithering of PWM to spread the noise out > from narrow to broadband. That's something I could do in software > easily. No quite sure how far to dither - 100-200Hz, 100-1000Hz? Anyone > heard of that? > > Q3) Low pass LC filter to attentuate some of the higher harmonics: > https://imgur.com/a/8UeNy2f - analogue isn't my thing, not quite sure > where to start with L and C values. Happy to buy a few values and suck > it and see, if Q1 gives me a sensible method of measuring the effect. > > > > > On the plus side, I am really pleased with the software :) Pity my > electonics skills suck which is why I'm reduced to using pre built > HBridge L298 modules from ebay. But I'm keen to try to learn a little > more and this is as educational for me as the lad - any help gratefully > received :) > > > If starting from nothing, I wouldn't do it like this - I'd go straight > to NeoPixels and have all the lamp control localised to each lamp. I > might indeed order some strngs from China next year - but for this year, > I do have these existing lights wrapped around trees already - and PWM > is an instructive project in its own right. I am just mindful that I > have the responsibility to not wreck havoc on my neighbours :) > > > Cheers and all the best, > > Tim > > > > ============Lights spec ============= > > This is the equivalent circuit: The LEDS are wired in alternate-reversed > configuration so that lamp 1,3,5... are driven on a forward current, > lamp 2,4,6... are driven on reverse current. > > Drive voltage 30V, about 140mA for all 150 lamps in 3 strings. > > https://imgur.com/a/K9iGr2J > > That's what it is - they're wrired like that as bought based on 4 > wires. Not certain of the exact configuration - might be 5, 6 or more in > series depending on the exact Vf of the LED. > =====================================
I think others have explained pretty well that it is the fast rise and fall times that are the problem. They have harmonics well up into the MHz range. While those harmonics fall off, they don't go to zero and have potential of being radiated well by the "long wire" antenna you call a pixie light string. So there are two ways of fixing the problem. One is to find a way to not radiate the noise such as improving (or degrading, depending on how you look at it) the antenna properties of your wiring. The other is to minimize the edge rates of your transitions to reduce the harmonics. One way of minimizing the harmonics that just occurred to me is to not have any, by driving the strings with a combination of a low frequency sine wave and DC. Any brightness level of the two sets of LEDs can be obtained by combining a DC level between the +max and -max along with an AC component with an amplitude of 0 to max value pp. A class D amplifier can drive the lights and a simple filter can remove all the problematic harmonics that would be generated by the class D output. All that remains is a 100 or even 60 Hz output and a DC component. No harmonics, no interference. -- Rick C. - Get 1,000 miles of free Supercharging - Tesla referral code - https://ts.la/richard11209
On 07/12/2019 18:50, Rick C wrote:

Hi Rick,

Thanks for your reply.

> I think others have explained pretty well that it is the fast rise and fall times that are the problem. They have harmonics well up into the MHz range. While those harmonics fall off, they don't go to zero and have potential of being radiated well by the "long wire" antenna you call a pixie light string. > > So there are two ways of fixing the problem. One is to find a way to not radiate the noise such as improving (or degrading, depending on how you look at it) the antenna properties of your wiring. The other is to minimize the edge rates of your transitions to reduce the harmonics.
That's the RC filter option?
> > One way of minimizing the harmonics that just occurred to me is to not have any, by driving the strings with a combination of a low frequency sine wave and DC. Any brightness level of the two sets of LEDs can be obtained by combining a DC level between the +max and -max along with an AC component with an amplitude of 0 to max value pp. A class D amplifier can drive the lights and a simple filter can remove all the problematic harmonics that would be generated by the class D output. All that remains is a 100 or even 60 Hz output and a DC component. No harmonics, no interference. >
I'm not going to pretend to understand why that works - but I understand what you describe. So we do as you say by using what we have (HBridge) but driving at a higher clock rate and finding a digital tranform to represent the 100Hz sine + DC offset. Did I understand that correctly? The pigpio library is set up by describing a waveform in terms of a chain of on and off times for a set of GPIO pins. So if a complete 100Hz cycle can be adequately represented in the available memory which should be possible, a full cycle can be set up and left running, until it needs adjusting for a new brightness. I'm going to have to get my head around how (set-1-duty-%, set-2-duty-%) maps to x.DC-level + y.sin-amplitude though :)
On 07/12/2019 14:08, Tim Watts wrote:
> Follow up from the thread Oct 2019 > Minimising EM noise from PWM switched fairly lights? > > Hi folks, > > Recap - this is an educational project for my son to drive some existing > garden LED fairy lights from a Raspberry Pi ZeroW
Just an aside: If this all proves too tricky, we'll relegate the idea to a spare set of the same lights on the Christmas Tree: 1/3 of the problem, small area, indoors, round the back and much less likely to cause long range issues. But I'll have a try with some of the new ideas just for education - but playing it safe.
On 2019-12-07, Tim Watts <tw@example.com> wrote:
> Follow up from the thread Oct 2019 > Minimising EM noise from PWM switched fairly lights? > > Hi folks, > > Recap - this is an educational project for my son to drive some existing > garden LED fairy lights from a Raspberry Pi ZeroW > > The only problem, as fully expected, is they are chucking out more EMI > than I'd like and I don't want to be causing problems for others. So - > yes, it's a crappy control method but we are where we are (see below) > This is a case of trying to do a little more with a non ideal starting > point and I'd be super grateful for any pointers on that basis :) > > > The noise I have is showing up on an AM radio as a clear buzz at the > base PWM frequency (100Hz), audible across the MW range. This becomes > undetectable about 5 - 10 yards from my property boundary depending on > direction. The locals have been warned and no one's complained yet. > However it's a lot noisier than the supplied controller and without a > scope I can't see what the manufacturer did - but that leads us to Q1:
if it's audio-frequency PWM but it's coming out an AM radio it's the broadband noise of the steps that's making the noise, you need to round off those PWM corners.
> Q1) Would I understand this better with a &pound;99 PicoScope, basic 10Mhz > model, simple few turnes of wire antenna and looking at the spectrum (I > think spectrum software comes bundled with the Picoscope)?
if it has a spectrum analyser mode it could show you what others describe.
> Q2) I've read about frequency dithering of PWM to spread the noise out > from narrow to broadband. That's something I could do in software > easily. No quite sure how far to dither - 100-200Hz, 100-1000Hz? Anyone > heard of that?
dithering the PWM frequency will not reduce the noise amplitude in any way and will make it more annoying to AM listeners.
> Q3) Low pass LC filter to attentuate some of the higher harmonics: > https://imgur.com/a/8UeNy2f - analogue isn't my thing, not quite sure > where to start with L and C values. Happy to buy a few values and suck > it and see, if Q1 gives me a sensible method of measuring the effect.
perhaps just put a bigger resistor in series with the MOSFET gate.
> On the plus side, I am really pleased with the software :) Pity my > electonics skills suck which is why I'm reduced to using pre built > HBridge L298 modules from ebay. But I'm keen to try to learn a little > more and this is as educational for me as the lad - any help gratefully > received :)
oh, right modules. you have those anti-parallel LED strings. use a low resistance capacitor (10nF or so ceramic) across the lines and a common-mode choke in series with them. either salvage one from some junk, or buy one. -- When I tried casting out nines I made a hash of it.
On Saturday, December 7, 2019 at 2:50:24 PM UTC-5, Tim Watts wrote:
> On 07/12/2019 18:50, Rick C wrote: > > Hi Rick, > > Thanks for your reply. > > > I think others have explained pretty well that it is the fast rise and fall times that are the problem. They have harmonics well up into the MHz range. While those harmonics fall off, they don't go to zero and have potential of being radiated well by the "long wire" antenna you call a pixie light string. > > > > So there are two ways of fixing the problem. One is to find a way to not radiate the noise such as improving (or degrading, depending on how you look at it) the antenna properties of your wiring. The other is to minimize the edge rates of your transitions to reduce the harmonics. > > That's the RC filter option?
No, that would be changing the geometry of the wiring to not be an effective radiator and it is not likely to work well. Even with twisted pair it's still going to radiate enough. I don't think a simple RC filter will do a very good job with your circuit. By definition you need to have a strong AC component in order to drive both polarity LEDs. It could be worth a try, but you will lose power in the R and need a larger C to make up for keeping the R low.
> > One way of minimizing the harmonics that just occurred to me is to not have any, by driving the strings with a combination of a low frequency sine wave and DC. Any brightness level of the two sets of LEDs can be obtained by combining a DC level between the +max and -max along with an AC component with an amplitude of 0 to max value pp. A class D amplifier can drive the lights and a simple filter can remove all the problematic harmonics that would be generated by the class D output. All that remains is a 100 or even 60 Hz output and a DC component. No harmonics, no interference. > > > > I'm not going to pretend to understand why that works - but I understand > what you describe. So we do as you say by using what we have (HBridge) > but driving at a higher clock rate and finding a digital tranform to > represent the 100Hz sine + DC offset. Did I understand that correctly?
I was thinking of ditching the H bridge and using a class D amp, but you could use the H bridge to roll your own amp. It would in essence be PWM of the instantaneous drive level required. This CAN be filtered much more easily, better by an LC than an RC though. With the higher frequency it will work with much smaller L and C.
> The pigpio library is set up by describing a waveform in terms of a > chain of on and off times for a set of GPIO pins. > > So if a complete 100Hz cycle can be adequately represented in the > available memory which should be possible, a full cycle can be set up > and left running, until it needs adjusting for a new brightness. > > > I'm going to have to get my head around how (set-1-duty-%, set-2-duty-%) > maps to x.DC-level + y.sin-amplitude though :)
You will have three mappings. One is two LED levels mapped to an AC plus DC levels. The DC plus AC levels are mapped to instantaneous levels over the course of the sine wave. These instantaneous levels are mapped to a duty cycle in a pretty simple manner. 0 to max is zero pulse width to max pulse width and then deal with the polarity. There will be some complications involved. Don't forget to take into account that the original circuit every drove an LED to half amplitude because of the duty cycling. So the max DC ever needed is half the max amplitude. There is also the issue of the max AC value will only be 0.707 time the peak value, but that is RMS and I expect what will be important is average which is 0.637 times the peak value. So you may not be able to get full brightness from the string with the AC waveform. The same would be true of an RC filtered square wave since the ramp times take away from the amplitude. This can be improved by adding in the third and maybe the fifth harmonics. 300 and 500 Hz are still well outside of anything that will cause interference. That will give you something pretty close to a square wave without the annoying harmonics. -- Rick C. + Get 1,000 miles of free Supercharging + Tesla referral code - https://ts.la/richard11209
On Saturday, 7 December 2019 14:08:28 UTC, Tim Watts  wrote:
> Follow up from the thread Oct 2019 > Minimising EM noise from PWM switched fairly lights? > > Hi folks, > > Recap - this is an educational project for my son to drive some existing > garden LED fairy lights from a Raspberry Pi ZeroW > > The only problem, as fully expected, is they are chucking out more EMI > than I'd like and I don't want to be causing problems for others. So - > yes, it's a crappy control method but we are where we are (see below) > This is a case of trying to do a little more with a non ideal starting > point and I'd be super grateful for any pointers on that basis :) > > > The noise I have is showing up on an AM radio as a clear buzz at the > base PWM frequency (100Hz), audible across the MW range. This becomes > undetectable about 5 - 10 yards from my property boundary depending on > direction. The locals have been warned and no one's complained yet. > However it's a lot noisier than the supplied controller and without a > scope I can't see what the manufacturer did - but that leads us to Q1: > > > Q1) Would I understand this better with a &pound;99 PicoScope, basic 10Mhz > model, simple few turnes of wire antenna and looking at the spectrum (I > think spectrum software comes bundled with the Picoscope)? > > Q2) I've read about frequency dithering of PWM to spread the noise out > from narrow to broadband. That's something I could do in software > easily. No quite sure how far to dither - 100-200Hz, 100-1000Hz? Anyone > heard of that? > > Q3) Low pass LC filter to attentuate some of the higher harmonics: > https://imgur.com/a/8UeNy2f - analogue isn't my thing, not quite sure > where to start with L and C values. Happy to buy a few values and suck > it and see, if Q1 gives me a sensible method of measuring the effect. > > > > > On the plus side, I am really pleased with the software :) Pity my > electonics skills suck which is why I'm reduced to using pre built > HBridge L298 modules from ebay. But I'm keen to try to learn a little > more and this is as educational for me as the lad - any help gratefully > received :) > > > If starting from nothing, I wouldn't do it like this - I'd go straight > to NeoPixels and have all the lamp control localised to each lamp. I > might indeed order some strngs from China next year - but for this year, > I do have these existing lights wrapped around trees already - and PWM > is an instructive project in its own right. I am just mindful that I > have the responsibility to not wreck havoc on my neighbours :) > > > Cheers and all the best, > > Tim > > > > ============Lights spec ============= > > This is the equivalent circuit: The LEDS are wired in alternate-reversed > configuration so that lamp 1,3,5... are driven on a forward current, > lamp 2,4,6... are driven on reverse current. > > Drive voltage 30V, about 140mA for all 150 lamps in 3 strings. > > https://imgur.com/a/K9iGr2J > > That's what it is - they're wrired like that as bought based on 4 > wires. Not certain of the exact configuration - might be 5, 6 or more in > series depending on the exact Vf of the LED. > =====================================
the problem is due ot how fast you're switching. Changing the 100Hz will have no significant impact on that. Since you're using a module you can't slow its output down so easily, but you could add ferrite beads to the output lines, fitting them close to the driver module. You could also add a very small cap across the aerial close to the beads. NT
Place a ferrite around the cable, easy fix, no soldering needed

http://www.meisongbei.com/emi_ferrites/2009-12-24/8919.chtml
On 08/12/2019 17:42, Klaus Kragelund wrote:
> Place a ferrite around the cable, easy fix, no soldering needed > > http://www.meisongbei.com/emi_ferrites/2009-12-24/8919.chtml >
This removes common mode noise? As the wires were balanced I assumed there wouldn't be much - but happy to give it a try :) Cheers, Tim
On 07/12/2019 20:18, Jasen Betts wrote:

> dithering the PWM frequency will not reduce the noise amplitude in > any way and will make it more annoying to AM listeners. >
This is one of the references I found: https://www.eetimes.com/novel-technique-improves-dithering-reduces-emi/# It's too much for me to understand (I can only really grok the headline) but the claim is that it take sthe same noise and spreads it out over the spectrum, reducing the average EMI at any one frequency. That's about as much I could get :)