South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« on: December 24, 2012, 09:07:38 pm » |
Hi all. I am playing with the idea of installing up 12 x LED down-lighters in my lounge. I'm using 3W white LED MR16 bulbs and driving them with a BC337 which works well from the PWM pins. I thought I'd get a Mega due to the extra PWM pins so I could do it that way (need 12 PWM outputs currently) but it won't be very future proofed and I want to also control some RGB strips.
I have tried softPWM before and it works well for fading, but not for holding - when i do a analogwrite of say 50, you can see the PWM effect (strobing LEDs). So I don't want to use soft pwm.
What other options do I have? I'm not very good at coding yet so I need a really simple solution.
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 28
Posts: 1551
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #1 on: December 24, 2012, 09:43:30 pm » |
If your getting strobing, then you can put a capacitor on each pin. It should help get rid of some of the strobing. Try maybe 10uf to start.
|
|
|
|
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Dubuque, Iowa, USA
Offline
Edison Member
Karma: 13
Posts: 1532
|
 |
« Reply #2 on: December 25, 2012, 01:05:46 am » |
If those bulbs have drivers in them you're probably making them angry by PWMing power to them. More detail as to exactly what bulb you're using and what is inside those bulbs would be warranted.
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #3 on: December 25, 2012, 12:05:08 pm » |
I have got a few different ones on the way to test. The one I have is working fine when running direct from a hardware PWM pin though? But it strobes at low duty cycles using softPWM. The one I have opened up looks like it has a rectifier bridge and some kind of current limiting circuit, I might modify them for direct DC. This is the one I have http://www.ebay.co.uk/itm/251095501994and these on the way http://www.ebay.co.uk/itm/270758491217http://www.ebay.co.uk/itm/320736975011How would I wire a capacitor to them?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #4 on: December 25, 2012, 01:08:36 pm » |
What other options do I have? A few: 1) use external chips; 2) find a chip with > 12 channel hardware pwm and port arduino to that chip; 3) use 1 main pwm channel and AND it with individual pwm outputs. ...
|
|
|
|
|
Logged
|
|
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 131
Posts: 4656
|
 |
« Reply #6 on: December 25, 2012, 01:26:37 pm » |
Don't put capacitors on the pins, you'll overload the Arduino if you do.
If the lamps work OK using hardware PWM (and you may not know whether they do without running them for a long time - as HazardsMind says, the controllers built-in to the lamps may not take kindly to PWM), but you can see strobing using the softPWM library, then you need to increase the PWM frequency when using SoftPWM. This is 490Hz by default for hardware PWM, but only 60Hz for the softPWM library.
To increase the PWM frequency for the softPWM library:
1. Simplify the timer ISR (the function "SoftPWM_Timer_Interrupt(void)" in SoftPWM.cpp). Get rid of the fade up/fade down code (you can do fading outside the ISR) and the normal/reverse PWM code. Move the declarations of local variables from the start of the function to where they are actually used. What you are looking to do is speed up the ISR substantially.
2. Change the definition of SOFTPWM_FREQ in SoftPWM.cpp from 60UL to something higher. How high you can go depends on how much you have simplified the timer ISR.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #7 on: December 25, 2012, 01:32:07 pm » |
Yes. Many other vendors offer similar chips, Sanyo, Philips, Motorolla, or some asian vendors too. Search for LED drivers and you will get tons of them. Alternatively, you can get a few avr/arduino and program them as slaves being controlled by a master arduino. The slaves output independent pwm signals based on commands sent to them by the master.
|
|
|
|
|
Logged
|
|
|
|
|
Dubuque, Iowa, USA
Offline
Edison Member
Karma: 13
Posts: 1532
|
 |
« Reply #8 on: December 26, 2012, 02:54:36 am » |
Bulb #2 will take PWM fine because it's obviously using resistors for current control (low power LEDs; power input 5W but light output 2.5W). Bulb #1 and #3 are using high power LEDs and will have driver chips. It shouldn't be possible to see flickering above 100Hz and at 60Hz any flickering should be barely noticeable (do you see flickering in a 20ma/5mm LED?). I still think your problem is just that you're making the driver angry.
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #9 on: December 26, 2012, 03:17:54 pm » |
Don't put capacitors on the pins, you'll overload the Arduino if you do.
If the lamps work OK using hardware PWM (and you may not know whether they do without running them for a long time - as HazardsMind says, the controllers built-in to the lamps may not take kindly to PWM), but you can see strobing using the softPWM library, then you need to increase the PWM frequency when using SoftPWM. This is 490Hz by default for hardware PWM, but only 60Hz for the softPWM library.
To increase the PWM frequency for the softPWM library:
1. Simplify the timer ISR (the function "SoftPWM_Timer_Interrupt(void)" in SoftPWM.cpp). Get rid of the fade up/fade down code (you can do fading outside the ISR) and the normal/reverse PWM code. Move the declarations of local variables from the start of the function to where they are actually used. What you are looking to do is speed up the ISR substantially.
2. Change the definition of SOFTPWM_FREQ in SoftPWM.cpp from 60UL to something higher. How high you can go depends on how much you have simplified the timer ISR.
Thanks DC, that all sounds pretty complicated though and I think I will struggle  are there any easier ways?
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #10 on: December 26, 2012, 03:19:42 pm » |
Bulb #2 will take PWM fine because it's obviously using resistors for current control (low power LEDs; power input 5W but light output 2.5W). Bulb #1 and #3 are using high power LEDs and will have driver chips. It shouldn't be possible to see flickering above 100Hz and at 60Hz any flickering should be barely noticeable (do you see flickering in a 20ma/5mm LED?). I still think your problem is just that you're making the driver angry. Could I not just use a big resistor to current limit too the 3 x 1w LEDs, and chuck out the driver circuit? I think I might prefer #2 (when/if they turn up) because of the wide viewing angle
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #11 on: December 26, 2012, 03:52:42 pm » |
have you tried a joule ringer or several joule theif's in parallel on a 1.5 v input? A joule thief would light several led's in a row with little input, you could almost power the thief's with a pwm off of the board. you could do a two turoid setup and get all the lighting you want. You could have your arduino ran through an "external chip" to turn it on and off!
|
|
|
|
|
Logged
|
|
|
|
|
Dubuque, Iowa, USA
Offline
Edison Member
Karma: 13
Posts: 1532
|
 |
« Reply #12 on: December 27, 2012, 02:30:59 am » |
Could I not just use a big resistor to current limit too the 3 x 1w LEDs, and chuck out the driver circuit? Yes, but you don't want to. Looking at the "wide angle" bulb linked earlier, it's only driving the LED with 50% efficiency. A proper driver will do much better than that. Also, the high wattage resistors required are pretty expensive themselves, and then you also have the problem of them getting freakishly hot. The drivers in your bulbs might have a PWM option that is not being used, but again only a look at the IC in question would provide the answer. At worst you could find a replacement driver for ~$2 that has a PWM option; drivers based on the PT4115 are pretty common.
|
|
|
|
|
Logged
|
|
|
|
|
South UK
Offline
Sr. Member
Karma: 1
Posts: 479
|
 |
« Reply #13 on: December 27, 2012, 09:05:08 pm » |
Here is the driver from the bulb I have. I can't really tell what is going on apart from a bridge rectifier?
|
|
|
|
|
Logged
|
|
|
|
|
Dubuque, Iowa, USA
Offline
Edison Member
Karma: 13
Posts: 1532
|
 |
« Reply #14 on: December 28, 2012, 12:40:43 am » |
http://www.datasheetdir.com/ZXLD1360+download explains everything quite nicely. Aside from the ZXLD1360 that the driver is built around and the (unnecessary) bridge rectifier you identified, the only interesting component is the R300 (.3ohm) resistor that is used to set the max current for the driver. Per the datasheet .1 / .3 = 333ma. I can't see in the first picture clearly due to the glare, but the pin below the "0" on the chip labeled "1360", the ZXLD1360, should be floating (soldered to a pad that goes nowhere) currently. Wire the bulb with +12V and GND, then connect to that pin through a resistor (~10K) and to a PWM output on the Arduino. Voila.
|
|
|
|
|
Logged
|
|
|
|
|
|