Arduino Forum

Using Arduino => Project Guidance => Topic started by: MrGlasspoole on Dec 21, 2012, 01:31 am

Title: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Dec 21, 2012, 01:31 am
Hi,

after searching through the web i found out that it seams that dimming LED's
is not so easy. There is more then PWM with a mosfet involved.

By clean i mean things like i can read here:
http://joost.damad.be/2012/09/dimming-12v-led-strip-with-mosfet-and.html
http://jeelabs.org/2011/11/8/fixing-the-arduinos-pwm/

Then i found this cool site - Highly Efficient 0-100% LED Dimmer:
http://www.opensourcepartners.nl/~costar/leddimmer/
But this is for 20mA LEDs

So i need a dimmer for 12 Volt LEDs up to 15 Watt.
Is there a way to modify the "Highly Efficient 0-100% LED Dimmer" and use it with
the Arduinos PWM?
Would it make sense?
Title: Re: Clean and energy efficient LED dimming
Post by: dhenry on Dec 21, 2012, 01:43 am
I think it is nuts for people to go into so much details just to control leds.

Having said that, one of the responders to the first link correctly identified the reason for ringing when switching a mosfet. That becomes a bigger issue when an inductive load (a motor for example) is being switched. I discussed that in one of my posts a couple days ago.

The last post's approach is excessively complicated. You can have a dedicated pwm controller to switch leds - those dc/dc converters with on/off pins are great for this.

Alternatively, you can use your arduino to perform conversion: you can use a sampling resistor + the analog comparator for cycle-by-cycle control; or you can use the sampling resistor + adc for averaging. The 2nd approach is very computationally intensive.
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Dec 21, 2012, 01:59 am
To much detail?
Hm, but nobody wants flickering lights in the living room?

Also the cables to my sleeping room ans bathroom will be around 10-20 meters.
In the moment everything is open - but when the wallpaper is done it's to late to change
something. So i need to make sure everything is planed correct and thats the reason
i read allot.

So what will be the best solution for my 12 Volt house lightning where everything can be dimmed?
Title: Re: Clean and energy efficient LED dimming
Post by: DVDdoug on Dec 21, 2012, 02:10 am
Some high-power LED power supplies will accept PWM or variable DC as a dimmer-control signal.   You can filter PWM to variable-DC, but sometimes it's a 0-10V control so you'd have to amplify the Arduino's 5V output.  Most of these supplies are highly efficient.

PWM is 100% efficient (in an ideal world), but in addition to (or along with) dimming, you need current limiting.   With low-power LEDs, you normally use a resistor for the current limiting, and that's not efficient, but no big deal if you are only wasting a few milliwatts.    In fact, switched current-limiting (very efficient) is usually based on PWM with feedback-control and a "smoothing" inductor.

Quote
Is there a way to modify the "Highly Efficient 0-100% LED Dimmer" and use it with
the Arduinos PWM?
Probably...   But, by the time I figure-out how that circuit works and how to modify it, I dunno...   

Quote
To much detail?
Hm, but nobody wants flickering lights in the living room?
As long as they flicker at a fast rate, nobody can see it.  Older flourscent lights flicker at 2 x the 50/60 Hz line frequency.   TVs flicker at the same rate.  Film flickers at twice the framerate (2x24Hz).   Most people aren't bothered by that.  Newer flourscents with electronic ballasts flicker at kHz frequencies and nobody is bothered by that.   The Arduino's default PWM rate is ~500Hz, and nobody can see that either.
Title: Re: Clean and energy efficient LED dimming
Post by: DVDdoug on Dec 21, 2012, 02:21 am
Quote
In the moment everything is open - but when the wallpaper is done it's to late to change
something. So i need to make sure everything is planed correct and thats the reason
i read allot.
I'd say try do make it easy to access the wires or run new wiring.  If you have an attic or crawl space, that's not hard to do.  Otherwise, maybe you can run some conduit.  It's very-likely that something will need to change in the future.

And, it sounds like its a little late to be designing some new-untested lighting concept.  For something permanent in your house, I'd consult an electrician and install something tried-and-true.  You can buy dimmable and non-dimmable LED home lighting that runs off 12V or 120/240V, and as far as I know it's all highly efficient so you shouldn't need to design something yourself unless you really want to.
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Dec 21, 2012, 02:25 am
So just an IRL540 and everything is ok?

Also here in the forum i saw calculations for the right mosfet because off power wasting.

I don't buy one off this LED power supplies - i just take this Eco-Friendly 4 Ampere wall wart's

Edit:
What do you mean by untested lighting concept?
Something tried-and-true?

Everything here is 230 Volts. I don't want that anymore.
If i make it 12 Volt i save energy and can power it one day with photo voltaic.
Title: Re: Clean and energy efficient LED dimming
Post by: PeterH on Dec 21, 2012, 04:30 pm
If you've only got one shot to run cables then I suggest you run a CAT5 or similar cables 'just in case'. This gives you several twisted pair cables for DC or serial comms, and also makes it possible to run in Ethernet. Once you have power and Ethernet available, almost anything you can imagine becomes possible.
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Dec 21, 2012, 10:38 pm
Hm, didn't think of that before.
I already run CAT6 SFTP to all my wall switches.

Its AWG 23 so the table says 0,259 mm2 in German size.
And the other table from the VDE (in English = Association for Electrical, Electronic and Information Technologies e.V.)
says your allowed to run 4 ampere through 0,25 mm2.

So i can power 48 Watt of LED light. And i also can make it PoE and have Ethernet at the lamps if i need it one day.
Wow thats a nice idea and i was on my way to use AWG 16 or 13 because thats what you use for normal halogen stuff (3x 35 Watt/12 Volt halogen lamp = 8,75 ampere).
Thats the problem if you still think analogue today *lol


But the reason for this thread was more: how to dimm them.
Cause i need to order electronic parts and also want to order the FET's.

Edit:
My first test LED lamp is here.
There is something i forgot. They work with AC and DC and it doesn't matter
where you connect positive and negative. So there must be some kind of electronic inside the lamp.
Somebody know how they work? How does this effect the dimming circuit i need to build?
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 14, 2013, 03:47 am
I did some tests now.
Just a IRLU8726PBF MOSFET: http://www.produktinfo.conrad.com/datenblaetter/150000-174999/161232-da-01-en-MOSFET_IRLU8726PBF_I_PAK_IR.pdf

Is it normal that i always measure 4.5V on the LED when there is no signal on the gate?
Here is my test code:
Code: [Select]
#define hallwayLightOff 22
#define hallwayLightOn 23
#define hallwayLightPin 6

int hallwayLightPWM = 0;

void setup () {
    Serial.begin(9600);
  pinMode(hallwayLightOff, INPUT);
  digitalWrite(hallwayLightOff, HIGH);
  pinMode(hallwayLightOn, INPUT);
  digitalWrite(hallwayLightOn, HIGH);
  pinMode(hallwayLightPin, OUTPUT);
}
long hallwayLightValue = 0;

void loop() {
  hallwayLightPWM = map(hallwayLightValue, 0, 1023, 0, 255);
  if(digitalRead(hallwayLightOff) == LOW) {
    if (hallwayLightValue++ > 1023) { hallwayLightValue = 1023; } // constrain high value
  }
  if(digitalRead(hallwayLightOn) == LOW) {
    if (hallwayLightValue-- < 0) { hallwayLightValue = 0; } // constrain low value
  }
  analogWrite(hallwayLightPin, hallwayLightPWM);
  Serial.println(hallwayLightPWM);
  delay(1); // speed of change
}

The problem is that already at "PWM 50", which gives me 9.6V the LED is full bright.
If i switch from "PWM 1" to "0" it really needs long until my multimeter goes down to 4,5V.

How is that with SSRs? Do they also not turn off completely? That would mean there is always
power wasting?
Title: Re: Clean and energy efficient LED dimming
Post by: Veco on Feb 14, 2013, 12:11 pm
I really wouldn't worry about an SSR drawing power when its turned off. If it does at all i suspect it would be in the µA range. It's not going to make a difference to your electricity bill.
Title: Re: Clean and energy efficient LED dimming
Post by: 0AlphaOmega on Feb 14, 2013, 12:28 pm
Looks like over-kill to me, but...

Test cable runs first and be wary of running 12 near 240 (they should NOT share the same conduit) crossing at 90deg is preferable.

Quote
Everything here is 230 Volts. I don't want that anymore.
If i make it 12 Volt i save energy and can power it one day with photo voltaic.

If you come to sell your house, will this effect the price? Will you want the availability of mains in the future.
If you have a ring main for the lighting, can you use the existing switch wires and place your 12V controllers above the lights, so effectively re-using the cables and not worrying about sending 12 over long distances? This would allow you to revert to 240V at any stage.
Title: Re: Clean and energy efficient LED dimming
Post by: 0AlphaOmega on Feb 14, 2013, 12:33 pm
Quote
Edit:
My first test LED lamp is here.
There is something i forgot. They work with AC and DC and it doesn't matter
where you connect positive and negative. So there must be some kind of electronic inside the lamp.
Somebody know how they work? How does this effect the dimming circuit i need to build?


Quote
If i switch from "PWM 1" to "0" it really needs long until my multimeter goes down to 4,5V.

Sounds like you may have a capacitor in there.
As to "brightness" your eye's sensitivity may not see much difference between 50 & 100% Have you used a lux meter (digital camera exposure meter?  8) )
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 14, 2013, 12:47 pm
What is over-kill?

Selling the house my parents build stone by stone with there own hands - never ever :)

I have no lux meter.
But what about the 4.5Volt i always have?
Why does the Mosfet not totally turn off?
Title: Re: Clean and energy efficient LED dimming
Post by: 0AlphaOmega on Feb 14, 2013, 03:04 pm

What is over-kill?

I meant the Highly Efficient 0-100% LED Dimmer; it's an interesting project, but is it necessary? You must be the judge of that. It is very easy to get carried away with specifications. I would imagine that one of your main criteria is long life and relative cheapness. It's akin to buying a hybrid car, I've driven a few, they are okay around town, they don't save the environment, they cost a lot to run and to purchase. The product needs to fit the requirements.


Selling the house my parents build stone by stone with there own hands - never ever :)

Lucky you, I'm envious  :smiley-mr-green:


I have no lux meter.
But what about the 4.5Volt i always have?
Why does the Mosfet not totally turn off?

If your fet is partially on, then you may be seeing a small voltage, they require very little leakage before they start to conduct. Try disconnecting the gate from the port and tying the gate with a resistor and see if you get the same result.
My suggestion was to use a digital (SLR) in place of a LUX meter as a crude replacement. Illuminate a scene with your LED and check that the exposure changes as you continue to increase the PWM. Maybe your source voltage is too high?
You may need to play with the position of the illumination and objects in the scene to get a full range effect. - just an idea.
To see how "unreliable" (fabulous) your eye is in this situation, take an exposure reading indoors in a bright room and then try the same outdoors.
As to flicker, I would think that the 490K of the Arduino ought to be okay, I can't report that it has ever bothered me when playing with LEDs, But I have not illuminated a room. I have to say that VW tail-lights annoy me, I don't know what frequency they cycle at, but I find the light trails as I move my head distracting.... Maybe they are just flashbacks?
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 14, 2013, 10:55 pm
The Highly Efficient thing was just a idea in the beginning when i was reading around and looking for infos.
Now i just want to get the dimming working.

Hm, a resistor at the gate? I have the 4.5Volt at the LED even with the gate not connected to the Arduino.

Source voltage? You mean the 12Volt that go to the LED? The IRLU8726PBF is made for up to 30Volt.

I can find allot 220Volt MOSFET circuits but nothing on logic level MOSFET.
From my understanding there is no need for a driver if you use a logic level MOSFET and
you can connect it directly to the micro controller.

I have just an 15 year old 2MP digital camera. No need for a new one until i have the luck to visit Disney World :D
Title: Re: Clean and energy efficient LED dimming
Post by: 0AlphaOmega on Feb 14, 2013, 11:57 pm
Quote
Hm, a resistor at the gate? I have the 4.5Volt at the LED even with the gate not connected to the Arduino.

To test. disconnect from the Arduino and tie the gate to ground using your pull-down resistor. You can short it to ground if you like. Check if you still have 4.5V

Quote
Source voltage? You mean the 12Volt that go to the LED? The IRLU8726PBF is made for up to 30Volt.

Sorry, that is fine, what I meant was do you have the correct limiting resistor for your LED for the voltage being supplied?

Are your grounds okay? Short, connected to a single point. Is your CAT6 shielded? and if so, is the grounding at a single point - it's not unusual for Radio2 to take control of your circuit ;) If you have wires spanning the house, you will have quite a nice antennae going. Look out for the WOW! signal ;)
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 15, 2013, 03:57 am
Grounding the gate changes nothing.
There is no limiting resistor cause its a 12V LED. Its one of those you can swap with
the 12V halogen lamps in halogen systems: http://www.amazon.de/ersetzt-35Watt-Halogen-warmes-Kelvin/dp/B0076J5AHG/
They are really bright like 35Watt normal lamps and make a nice light.
The first LED i saw that really make sense when it comes to price<->power saving (amortization).

There is no CAT6 at the moment. Everything is short and on the breadboard :D

But when you talk about shielding. Would you always connect the shield to ground?
Both ends ore just one?
I use just shielded cable:
Stranded CAT.5E SF/UTP for switches and flow sensors.
Stranded CAT.6 S/STP for network.
Solid CAT.6 S/FTP AWG23 for 12V power to the LEDs and Arduinos.
Lappkabel UNITRONIC LiYCY 2x0,25mm2 where i have to spread the 12V: http://products.lappgroup.com/online-catalogue/data-communication-systems/low-frequency-data-transmission-cables/din-colour-code/unitronic-liycy.html

And i want to make a extra cable from the breaker box to my home stereo.
I want to use Lappkabel ÖLFLEX 120 CH 3x2,5mm2: http://products.lappgroup.com/online-catalogue/power-and-control-cables/various-applications/halogen-free/oelflex-120-ch.html
But i'm not sure what to to with the shield on this 220Volt cable.
Title: Re: Clean and energy efficient LED dimming
Post by: spatula on Feb 15, 2013, 05:26 am
I'm no expert, but since MR16 lamps are designed to be compatible with halogen lamps their internal circuitry, by design, has to work in concert with transformers and dimmers made for halogen lamps. This compatibility requirement has led to proprietary solutions which may have important side-effects.

I'm not sure whether the source can be considered reliable, but here's a couple of articles that worried me
http://ledsmagazine.com/features/9/6/8 (http://ledsmagazine.com/features/9/6/8) and http://ledsmagazine.com/features/9/2/10 (http://ledsmagazine.com/features/9/2/10).
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 15, 2013, 09:27 am
God damn. After removing the LED i still had 12Volt.
From 10 Mosfets i picket a broken one :0

So i did some testing now and the electronic in the LED makes problems.
Here are some measurement:
Monitor PWM: 1, Pin 6 Volts: 0.03
D6 = 0.02 Volt
LED = 0.00 Volt (lights up)
LED turned = 0.21 Volt (lights up)
no LED = 11.3 Volt

Monitor PWM: 36, Pin 6 Volts: 0.72
D6 = 0.71 Volt
LED = 2.85 Volt (lights up)
LED turned = 2.85 Volt (lights up)
no LED = 11.5 Volt

If i connect the LED directly to the 12 Volt power supply i have 12 Volt at the LED.
In the PWM circuit i have the funniest volts.

There are allot PWM circuits out there but PWM is what the Arduino does.
Maybe a LED driver?
I found this: http://www.led-treiber.de/html/leds_grundlagen.html#PWM-Dimmer
and they write it works with all there LED drivers: http://www.led-treiber.de/html/getaktete_treiber.html

How about a power supply for all the LEDs and a "reverse phase control dimmer" in front of them
who is controllable with the Arduino?

There must be a way to dim those LEDs with some kind of circuit :-(
Title: Re: Clean and energy efficient LED dimming
Post by: lax123 on Feb 15, 2013, 09:48 am
your link to your LED:
http://www.amazon.de/ersetzt-35Watt-Halogen-warmes-Kelvin/dp/B0076J5AHG/

"Produktmerkmale: Nicht Dimmbar", cant be dimmed
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 15, 2013, 11:31 am
As a german i know what it means :D

But i think its there cause there are to many factors with transformers and dimmers.
I have a 12 volt halogen electronic transformer that is dim able with "reverse phase control dimmer" and
"phase control dimmer". But here the dimmer is in front of the transformer and its AC.
I was thinking DC and PWM the whole time - maybe there is another way.
I mean if i feed less volt to the LED its darker.
Maybe AC instead of DC...

Edit:
Just found this: http://www.youtube.com/watch?v=XgwNyO01mIg

So i need to do more research and use other words in google.
Was looking the whole time for PWM stuff.
Title: Re: Clean and energy efficient LED dimming
Post by: lax123 on Feb 15, 2013, 11:39 am
i asked in a german forum about this:

http://www.mikrocontroller.net/topic/287066#new

maybe it helps
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 15, 2013, 02:15 pm
After thinking i cant open the LED without breaking it i have it open now.
The 3 LEDs are series-connected.
The electronic was sealed in some silicon.
Looks close to this ones: http://detail.china.alibaba.com/pic/914205741.html

Its a MT7201 1A LED driver: http://www.maxictech.com/en/UploadFiles/MT7201_rev1.1_EN.pdf
And the circuit is close to this one: http://www.led-treiber.de/html/getaktete_treiber.html#MIC3201
But there are some diodes in front of it as rectifier.

Looks like you can PWM control this driver.
I will try to reverse engineer the circuit/PCB to find out what the LEDs need.

If i build my own driver, is it better to
1. put the MOSFET and driver near the LED
2. put the MOSFET near the Arduino and the driver near the LED
3. put the MOSFET and the driver near to the Arduino

And sure there are dimable LEDs out there, but they are not cheap and this have a really
good Colour Rendering Index and Color temperature.
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 16, 2013, 08:26 am
Ok, i did some measuring as you can see in the attachment.
I cant figure out the driver circuit cause its to small.
But there is a R25 and 3R00 on the PCB.
If i look at the M7201 data sheet that would mean they drive the LEDs with 0.1 / 0,25? = 400mA
That is close to my measurement.
If the 0.25? and 3? resistors are parallel its right: 0.1 / 0.23? = 430mA

If i look at the CRI and Color temperature and everything i bet they are Cree XLamp  XP-E High-Efficiency White LEDs. http://www.rapidonline.com/pdf/55-2568.pdf
But if the forward voltage is 3V, why do i measure 9V?
Shouldn't it be: 12V - 3 x 3V = 3V

So from all the reading around it looks like the driver needs to be near the LEDs.
So i need a third wire for PWM?
But how about the PWM cable length?
Title: Re: Clean and energy efficient LED dimming
Post by: lax123 on Feb 16, 2013, 04:51 pm
yea you need to connect pwm output to the adj pin as suggested on page 8-9 of the datasheet.
i dont think cable length does matter, as long its not something like half a meter. well you can calculate loss of voltage depending on cable length.
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 16, 2013, 09:50 pm
0.5 Meter?
It's a house. There are 5-10 meters...
I found this driver: http://www.leds.de/out/media/KSQ.pdf
And they write to make the cable from the supply not longer then 1,5 meters.
Or is it that they assume that power cables are always unshielded?
Title: Re: Clean and energy efficient LED dimming
Post by: lax123 on Feb 17, 2013, 06:18 pm
uhh 20 meters, i read in one of your first posts..

well a cable is like a resistor...the longer the cable the bigger the resistor...
http://www.elektronik-kompendium.de/sites/grd/1003191.htm


so maybe ur input supply is 12V with a cable of 20meters maybe only 10V depending on load "arrive" at the end of the cable

heres a calculator:
http://www.bmc-braunschweig.de/de/sonstiges/78.html
Title: Re: Clean and energy efficient LED dimming
Post by: MrGlasspoole on Feb 18, 2013, 02:47 am
@lax123, i thank you that you want to help me. But that is basic stuff i know.

And this calculator shows what i don't understand. Why so big and short cables for LED's?
I read stuff like 0.75mm2 - 1.5mm2 on most sides.
But if you look at eldoLED POWERdrive they write 3 meters to the LEDs.
And they write 0.2mm2 per 1 ampere.
They also wrote somewhere that 6 meters is no problem with CAT cable and also wrote that
they have customers who made up to 50 meters.

What i can't find is a answerer to PWM over longer distance.
If i have a LED driver with PWM in - how long can i make the PWM line from the Arfuino
to the driver.

There is also the option to dim analog. This would change the color temperature a little.
But i can't see in the Cree datasheets what color temperature at which ampere.
They write color temperatures from 2600 to 4300 for the XP-E High-Efficiency White LEDs.

Damn is this LED stuff complicated when it comes to dimming.
I wish i had a oscilloscope :D
Title: Re: Clean and energy efficient LED dimming
Post by: lax123 on Feb 18, 2013, 10:48 am
Hi,

can you link the source?
Quote
But if you look at eldoLED POWERdrive they write 3 meters to the LEDs.
And they write 0.2mm2 per 1 ampere.