Domestic Led Lighting project. - Page 1
Forum section: electronics / projects

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: May 26, 2012, 02:24:59 pm
content: I want to change all the wiring of the lights in my house to DC, using leds.At least half the mains wiring in my house is for lighting, a lot is old and running a separate earth, sometimes no earth.Ps. I am a sparky and allowed to do this stuff.I want to start with 24 volts but possibly move later to 36 or 48 volts.I am also thinking of putting in a few DC wall sockets. At one of those nomimal voltages.As part of this I want to choose an inline plug and socket to use as the standard for the house.Also I would like a wall mount GPO equivalent.Specs Max voltage: 48 v dcmax current: Say 2-5 amp DC.I also need a nice looking standard light switch dimmer control, which just has a pot and a switch instead of a thyristor or triac or whatever they use these days. Each light switch itself is not switching/ dimming current of any real power.One further thought is if there is any defacto standard that exists or that looks like catching on, then I might want to go with them.So I need to find:Wall Socket and matching plug. similar to a 10A gpo in use but with different power requirements and obviously different shape. Hopefully with a switch.Inline plug and socket. for general purpose DC connections it would be good if it was the functional equivalent of an extension lead.Light Switch with dimmer.DC low current circuit breaker. I think Jaycar has some but don't know if they are any good.Has anybody got any ideas on what would be most common and most suitable.I do have some ideas but I have never found anything satisfactory.ps. It has got to look better than my usual home made stuff.Obviously I am from Aus but happy to purchase anywhere where the goods and the price is right.As far as the led lighting goes I have purchased about 100 cree XTEs warm white, and my own mcpcbs, 660 of them, The leds should at least do part of the house. I also have two types of home made constant current led drivers. I haven't decided which type to use yet. One is based on an Attiny461 and the other on NCL30160.I will post more about these later.

author: T4P
author_rank: Super Contributor
timestamp: May 26, 2012, 03:03:13 pm
content: Look for a constant current buck driver that has pwm inputs for dimming << that works best or you can find them premade

author: SeanB
author_rank: Super Contributor
timestamp: May 26, 2012, 03:20:08 pm
content: Why not order Shucko sockets, as they will fit in the AUS boxes, and are available with a switch. Otherwise a double switch plate and mount an IEC female socket there in place of the one switch, and use IEC male leads on the DC power lines. All you need is to use a power system that is not used in AUS, so choose any from around the world, and order them from China.

author: IanB
author_rank: Super Contributor
timestamp: May 26, 2012, 04:16:24 pm
content: Low voltage halogen modular lighting systems come to mind. Do they have a standard design of plug and socket you could reuse? Though it may be designed for 12 V and so not so suitable for higher voltages.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: May 27, 2012, 02:07:06 am
content: QuoteThanks for the idea, it hadn't even crossed my mind to use non Aus power sockets, it seems like a good idea I may go with the Shuckos unless something better comes up, I am fairly sure it would be legal too, the only trouble is it may be confusing to overseas visitors. Not that we have many of those.I will keep looking though.

author: codeboy2k
author_rank: Super Contributor
timestamp: May 27, 2012, 07:02:06 am
content: I was starting to think along the same lines as you a few years back, but I never did anything. I am not a licensed electrician, so technically I can't wire my house, even though I know what I am doing. I didn't have the time to get started.But I was thinking that with everything moving to LED lighting, and more and more handheld, electronic, low voltage devices, battery powered equipment and battery chargers in our lives now, that all these AC-DC-DC convertors at point of load are not so efficient in a modern home. It would be more efficient to eliminate the first stage AC-to-DC conversion (the PFC stage) at every point of use, and just do that once at the demarcation point, and supply a DC bus inside the house. I was thinking 24 or 48 V too.I hope there is some new low-voltage DC standard bus for homes, and that future homes have AC outlets and AC appliances as now, but there is also a single, high efficiency AC-DC convertor at the breaker box, and DC fed lighting, and DC outlets for powering electronics and portable stuff. I am sure electricians won'tapprove it, as they would then have to run 2 separate services through the home.

author: IanB
author_rank: Super Contributor
timestamp: May 27, 2012, 07:17:53 am
content: It would be interesting to figure out the typical power load of a low voltage DC system and see how that maps to current load and wiring requirements at different voltages.For instance with LED lighting alone, suppose you need 100 W per large room and 50 W per small room on average, then you could easily have 300 W typical load in a house. At 12 V that would be 25 A, at 24 V 13 A, at 48 V 7 A. That's not allowing for other devices like LCD TV's, computers and so on. It's not hard to see the need for quite heavy gauge wiring with a central power distribution point. It may be better to have localized low voltage systems per room, rather than a centralized system?

author: SeanB
author_rank: Super Contributor
timestamp: May 27, 2012, 09:09:27 am
content: 48V would be good for lighting, as there are many converters available that are meant for telecoms use which is 48V based. High enough voltage to keep current low, but only needs cheap 100v capacitors on the input side, and smallish inductors, plus the power devices are cheap as the voltage stress is low along with the current.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: May 27, 2012, 10:59:32 am
content: Thanks for the input, ideas, I appreciate it.I am actually going with the high efficiency AC-DC convertor idea but near the middle of the house. I have an 24V 7amp (from memory) Meanwell switch mode psu. If I need more I will get another similar. The I find my current to each light is only going to be about 1.5 amps at 24 volts but I think I will need 2 lights per room. I am trying to use everything to make the system as energy efficient as possible and dont worry so much about the up front cost.As you say at low voltage you are going to need a lot of amps for any high power but I am really not wanting to replace all the mains in my house, just the lights and fire alarms and maybe a few small things.I will probably end up settling on 48 volts as these give a nice long led string and great efficiency, maybe 14 x hbleds.The only advantage of 36v is there seems to be a lot of 40V chips that I might be able to use, including the NCL's.I am going to start with 24v only because that is my Meanwell psu.I have my first home made light running at 3 x 7 xte led strings with a Netduino controlling the dimming(dont ask) and 3 x Ncl30160s as the current drivers. 24 volts in and about 1.2 amps in. My lack of heatsinking on the leds means they are running a little warm. But not excessively.All in all it is a beautiful light.The NCL's dont seem to dim well at the low end. I will probably go back to the Attiny drivers.

author: T4P
author_rank: Super Contributor
timestamp: May 27, 2012, 03:04:12 pm
content: Eh wait ... 7 LED's in series ? NOThat's dangerous

author: SeanB
author_rank: Super Contributor
timestamp: May 27, 2012, 03:10:46 pm
content: No, 60 LED's in parallell on a OHLJ torch is dangerous. Especially as they do current limiting by using the resistance of the thin traces, the wiring and the 4V SLA battery internal resistance. I added a 1R2 series resistor, to make it a little more sane. Wonder where I will get 4V cells when these die, they are not a common size I have seen in shops. Cyclons are very expensive.

author: Zero999
author_rank: Super Contributor
timestamp: May 27, 2012, 09:54:35 pm
content: Quote from: SeanB on May 27, 2012, 09:09:27 amAnother advantage is safety.Quote from: SeanB on May 27, 2012, 03:10:46 pmRS and Farnell both sell 2 and 4V lead acid batteries, albeit in a limited range.

author: johnwa
author_rank: Frequent Contributor
timestamp: May 29, 2012, 09:50:06 am
content: Quote from: HackedFridgeMagnet on May 26, 2012, 02:24:59 pmHi,I have got a similar setup going using a 24V battery backed system. There are a few options for connectors that I am considering. The Clipsal 402/32 sockets are standard for this application, see e.g:http://www.12volt.com.au/General%20Htmls/webcat2003/plugs2.html#plugs. However, these are rather expensive.One other possibility is the IEC C19/C20 connector:http://au.mouser.com/ProductDetail/Qualtek/743W-00-02/?qs=4zF2lffhceFneFZOI9verGYnNrLlYXgx. Though nominally a 240V connector, use for this seems to be fairly rare, at least here in Australia. Good for 16A, and available in all combinations of line/panel plug/socket. You could make quite a neat job of a wall outlet using a panel socket and a standard GPO blanking plate.I have also got a quasi-standard power over ethernet system running from my 24V supply. With suitable fusing, an RJ45 plug should be enough to run a few LEDs.Quote from: HackedFridgeMagnet on May 26, 2012, 02:24:59 pmThese would be an option, though I am a little dubious of these thermal breakers in higher energy applications. I think you can get proper DIN rail mount magnetic breakers in low current ratings if you look hard enough.Regarding the choice of voltage, I think 24V is a good choice for a small system like this. 12V is too low for anything larger than a vehicle. You are already four times better off with wiring losses compared to 12V. While there is a lot of 12V equipment available for the automotive market, there is still quite a bit of stuff made for 24V. This figure is used in trucks, industrial automation, printers and photocopiers, vending machines, etc, so there are plenty of things on the market to suit it. With some things, such as LED light strips, you can just run two 12V units in series as well.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: May 29, 2012, 10:35:01 am
content: Thanks johnwa.I had seen those clipsal ones and was considering them, but as you say the price is expensive.I like the IEC C19/C20 connectors, I think I may try them first. The shucko ones look great but obviously they could cause confusion, even in Australia.The reason I want to go with higher voltage is I get efficiency gains in my system. I can get 14 leds running at 500mA from one channel of driver with barely a heatsink and generating a useful amount of light.In Australia we can go to 50Vdc before the wiring needs to be done by a sparky. So I want to keep under this.

author: johnwa
author_rank: Frequent Contributor
timestamp: May 29, 2012, 11:11:39 am
content: Yes, I think I have convinced myself to use the C19s as well. Unfortunately the plugs are a bit dearer, but I managed to snag some on eek-bay for $5 each including postage, which isn't too much more than you would pay for a normal 240V plug. Mouser also have right angle style plugs, around $8 each I think.Fair enough on the higher voltage, if you are only running lights you probably don't need to be as flexible. I have just been running pairs of 12V LED light strips from dealextreme, without the need for any driver:http://www.dealextreme.com/p/3528-5w-75-led-380-lumen-plastic-shell-white-led-light-bulb-12v-50cm-33059?item=2.I seem to remember reading someone managed to get a usable amount of light from 120V CFLs running from a fully charged 48VDC battery bank, though I am not sure what the life expectancy would be like running this way.Are you planning on including a battery in your system HackedFridgeMagnet?

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 02, 2012, 02:24:30 pm
content: No batteries for the time being, not unless somebody donates them.Next in line as part of this is my dimmable led driver circuit.As far as goals for this board:efficiency,no flicker,3 output channels if possible from 1 IC,input voltage 24-48 volts.capable of 1 amp but I am only going to run it at about 500-700 mA per channel.dimmable by a 1 or maybe 3 pots,low/no power when off,temperature shutdown if possible.no problematic em noise.cost per unit I am not so worried about, but obviously lets not waste money.I really want to do this as a pwm micro with discrete components.Feel free to point out the disadvantages of this method. But I have searched without success for chips that will give what I want and haven't found them.I will rely on a fuse for overcurrent protection if micro control fails.Attached is the simulation of the driver part of this. A micro will watch the current and dimmer and set the duty cycle. I have tried the Attiny461A before and it performed ok once I ironed out the oscillations.The fets, bjts components and inductor size are not firm.The ones in the LTSpice model are not my choices, just similar.the actual components areNPN: PBSS4560PNP: PBSS5560 ( I could change to two types if there is a reason)FET: FDMC86324For a small explanation:The micro sits with its Vcc on the 24volt rail and its ground on 19V (using a 7905 or similiar)It works out the PWM(possibly a bit of PFM too) output based on the dimmer level and the sense current.Q4 changes level from 24-19 volts to 0-12 volts.Q1 and Q2 totem pole output to give fast charge/discharge of the Fet's Gate. still roughly 0-12 volts.M1 main drive fet, drain voltage = 0-24 volts when in continuous mode.L1 will be discontinuous at low-medium duty cycle, I can't do much about this due to the low speed.Switching speed as fast as I can get out of an Attiny or some other micro, hopefully at least 128khz. at 8 bit pwm resolution.I guess the first thing I want to get nailed down is what speed can I get out of an inexpensive micro, I am not sure I really need to run fast due to the nature of the leds as a load.Then attiny or msp430. (I haven't done any PIC).Then what Fet to use at this speed and what size inductor.Next would be suitable drive transistors for this fet.Another thing I have been thinking of is reducing the Sense resistance and using a rail to rail input opamp to amplify the voltage so I have some sense current resolution but with lower losses.ps. My first version of this circuit uses the attiny at about 64kHz with L = 100uH, some cheap to220 Fet, 2n2907 and 2N2222, it does work fine, but I want to improve it where I can.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 03, 2012, 02:11:27 am
content: Does anyone know if I can run an ATTiny461A at a pwm of say 256kHertz with a resolution of at least 256 steps?According to my calcs in fast pwm mode I should be able to get 256kz. But I have never got more than 64khz.From memory I must've been in 10 bit mode with the main counter.Is it possible to increase this if I use the Sigma Delta technique as implemented by Amspire and AHellene in thehttps://www.eevblog.com/forum/projects-designs-and-technical-stuff/general-purpose-power-supply-design-7488/thread?If it is possible, which I suspect it is then I can design around this chip and this switching speed.If it isn't then I might have to change chips or strategies.Slightly revised driver stage with model attached.

author: Kremmen
author_rank: Super Contributor
timestamp: June 03, 2012, 02:43:34 pm
content: Quote from: HackedFridgeMagnet on June 03, 2012, 02:11:27 amJust for your information, some time ago i implemented some led drivers for my sister's solar powered summer house. I had good luck using the Supertex HV9910 led driver that is available from DK under $2 in single quantities. Dead simple to apply and it has dimming both by analog pot or external pwm signal (a few kHz), making it easy to control by a microcontroller. Note that the external pwm is not the one driving the leds; that is defined by an RC constant in the driver (typically 100 kHz). The HV9910 is capable of off line topologies so input voltage will not become an issue. Also it can operate in constant off time mode avoiding stability issues.

author: A Hellene
author_rank: Frequent Contributor
timestamp: June 03, 2012, 04:49:43 pm
content: The t261/t461/t861(A) have a high speed timer-counter (TC1), which is 10-bit wide. Using TC1 in Fast PWM Mode as an 8-bit counter (by setting the TOP count (OCR1C) equal to 0xFF), the PWM cycle speed will become equal to: 64MHz/0xFF = 250KHz. But, I can see no reason why not to increase the PWM resolution and run the inductor at lower frequencies.A problem might be the current loop, which is digitally implemented by reading the voltage drop on the LED shunt resistor (which will additionally need a typical low pass filter because the ADC might sample a zero LED current point during the transition of the inductor cycle states). The ADC can accurately run up to 15Ksps at full resolution (that is 10-bit wide) or up to five times faster at lower resolutions (8-bit accuracy, typically). Care should be taken when changing the differential or amplified ADC channels; please, read the data sheets.A typical current loop implementation would be reading the ADC (in free-running mode) and decide either to increase or to reduce the target PWM output value by one unit, within the ADC ISR. Since this can be done fast enough, there will be no actual need for any additional PID or even PI control loops.Now, what I would do to improve the design is to redesign the application to be ground-referenced. This will help the ADC to produce more accurate results and, thus, a more stable output.-George

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 04, 2012, 01:18:12 pm
content: Thanks KremmenThat does look like a useful chip, 8-450volts is pretty amazing. I will bear it in mind and maybe get a few as they look like they would suit many jobs.I do doubt that I can do better than the Supertex HV9910 but part of this is a learning experience, so I am going to continue to implement my own driver and gradually in other projects move up into higher power things.Thanks also A HelleneI realise there are tradeoffs everywhere designing converters, and I am in no position to make the correct decisions without a bit of testing anyway.I was hoping that I could run at high speed an so run in continuous mode to reduce em noise, although I must say my version 1 ran fine at 64kHz. As long as I know I can get 256khz if I want it I will lay the board out assuming I may run at that speed, I can always run slower, on the same board. I will oversize my inductor just in case.Yes a low pass filter, I don't know why I neglected it, I should know better. I actually did it in code which was stupid. This is why I am throwing my ideas out for review.I will flip the circuit around to be ground referenced and use single sided adc. Because I know my load I am not worried about having the low side sense resistor.Or probably I will put a rail to rail op amp in to increase my current resolution.I am assuming A Hellene that you think the t261/t461/t861(A) are the suitable for the job, can you confirm this.I was thinking of trying the MSP430s. I have limited AVR experience but quite a bit of experience in C++ on the Netburner modules. It takes me some time to even read assembler, I normally use C or C++ on embedded.If you can be bothered and are not heartily sick of the whole saga.You should start a thread and tell us what is going on in Greece, I assume you live there, I would be interested to hear what the word on the street is.My view from a distance is that the Greece would be better off to default and start anew. But really dont know, I only know what I hear on news.

author: A Hellene
author_rank: Frequent Contributor
timestamp: June 04, 2012, 03:55:13 pm
content: Yes, the tinyX61 is more than enough for the job. TC1 actually is a stripped-down 3-channel Fast 10-bit Power Stage Controller with fault protection unit, dead time generator, etc. The ADC is adequately fast to monitor and regulate all the three output channels --even for an RGB LED solution, maybe.You can also do the job by using the 8-pin t25/t45/t85 chip, whose TC1 is a single channel Fast 8-bit counter/timer, and its ADC also has a software selectable gain stage.Using the internal 8 MHz internal RC oscillator clock (that will run slightly faster at 5.0V, since it is factory calibrated for use with Vcc=3.0V --but this can be easily corrected if needed) the AVR ADC can be running at (8MHz/32)/13.5 = 18.5 Ksps without any noticeable accuracy loss. The selectable ADC gain of 1x/8x/20x/32x can help reduce the LED current sensing shunt resistor value to a few tens of milliohms, making it possible to directly use a logic level MOSFET driven by a complementary emitter-follower stage gate driver (i.e. the 1.0A BC639/BC640 matched pair), and reading the FET source current by inserting the shunt resistor between the FET source and the ground.You can also use both the buck or the buck-boost topologies. For the timing and the component calculations you can read the data sheets and application notes of HV9910, Kremmen suggested above.The only problem I can see is the bloating, the use of high level programming languages (C++ or even C) will introduce, especially when CPU cycles counting becomes critical...__________Now, Greece should have never entered the Eurozone in the first place; just like Britain did or, more accurately, just like[The Corporation of ]The City[ of London]did withthe help of the scumbag calledGeorge Soros, whose actionsjustifiedBritain's (The City's, actually) refusal to enter the Eurozone. That the Euro is a hard currency does not make it suitable to be the currency for any nation. For example, the Greek Drachma used to be one of the hardest currencies in the world until 1975, when the bankers begun shutting down sector by sector the Greek industry, and flooding steadily the country in debt since 1980:Please note that during the ministry of Simitis, the debt did NOT decrease, as it seems it did at the chart above: This was the outcome of the "creative accounting" trick PM Simitis pulled with the help of Goldman Sachs, in order to make Greece deceptively meet the requirements to join Eurozone.What needs to be done (or, needed to have already been done) is Greece to renounce that Goldman Sachs loan asOdious Debt; but to do that we need politicians of integrity and not the bankers' clowns our Parliament is infested with...-George

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 04, 2012, 10:55:34 pm
content: QuoteYes, I think we have some of the same politicians, only ours are doing more hours for the mining industry than the bankers at the moment.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 04, 2012, 11:26:00 pm
content: Thanks for the inputOk a couple more descision made,No external op-amp to amplify the current sense, I will investigate the software selectable gain stage.I will brush up on the Avr assembler,Now I need to choose between either the tinyX61 (3 channels) or the t25/t45/t85 chip (1 channel)then I can layout a prototype.

author: A Hellene
author_rank: Frequent Contributor
timestamp: June 05, 2012, 12:21:38 am
content: You are welcome!Since breadboarding can save you lots of time, almost any stage of this project can be breadboarded; with the exception of the high current paths.Additionally, do not be afraid of making mistakes because mistakes are the best teachers any designer can have.-George

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 05, 2012, 12:56:50 am
content: No, I'm not afraid of making mistakes, sometimes that's my problem.

author: Psi
author_rank: Super Contributor
timestamp: June 05, 2012, 01:28:29 am
content: I've not read the entire thread, by why do you want ~250khz PWM for leds?Seems really excessive.My led room lighting PWM is running at 1khz.EDIT: ah, i see, you want to make a constant current switchmode system with the pwm, not drive the leds directly with it.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 05, 2012, 01:49:00 am
content: Hi PsiI guess it has got to do with whether you are running as a buck converter in mainly continuous mode, or as a buck converter in discontinuous mode or without the inductor as a chopper.My idea being that the advantages of inductor being in continuous mode being less noise and less stress on the leds, and possibly greater efficiency.The advantages of the chopper being simpler, no resistive losses in the inductor therefore possibly greater efficiency.Running at low speed means you are more often running in discontinuous mode, for the same sized inductor, and If you go for a bigger inductor then you have more cost and more losses.Also bear in mind I want dimming.It is very hard to weigh these up without just making something and testing.Whatever frequency I choose I am going to try to stay away from those that may cause problems for other equipment.I should probably give low frequency a try.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 15, 2012, 01:54:42 pm
content: QuoteA Hellene said this and I don't doubt it, but I was wondering why it would be better ground referenced? If I am using differential inputs and separate analogue power inputs.The reason my topology is not ground referenced is so I can use a low side n-channel fet and have current sense without an op-amp.Another thing I was wondering about is Gate Drive bjt selection.A Hellene suggested BC639/BC640 matched pair, and I was looking at BC807/bc817 and also zxtn2040/zxtp2041 but I am going to lay it out as sot23 and try a few. It probably doesn't matter too much as the fet is probably going to be around 30nC gate and I am not going at very high speed so I think an collector current of 500ma will be good enough.The NPN: PBSS4560 PNP: PBSS5560 were unsuitable.

author: A Hellene
author_rank: Frequent Contributor
timestamp: June 15, 2012, 05:28:11 pm
content: The ADC analog inputs are more linear near the ground potential than near their positive power rails, because of their internal bias circuitry topology. Even if when using differential inputs for the ADC, where a complex network of internal switches and capacitors moves charges from the differential inputs to the ground-referenced input comparators of the SAR ADCs, most of the microcontrollers have.As I wrote above, there will be no problem at all to monitor a ground-referenced shunt resistor that exists between the power MOSFET source pin and the ground. For example, a 10 milliohm shunt resistor will have a 55mV voltage drop at a MOSFET peak current of 5.5A; this 55mV voltage drop multiplied by a factor of 20x will give a full 10-bit resolution ADC output that has as a reference the internal 1100 mV generator; on the other hand, this 55mV voltage drop will not really interfere with the ~4.3V MOSFET gate drive that a complementary emitter-follower stage driven by the 5.0V PWM output will provide.I recommended the BC639/BC640 pair because these medium-power transistors have 1.5A maximum collector current. The low Vce saturation, 2.0A peak collector current ZXTN2040F/ZXTP2041F transistor pair is even better for that purpose. Now, why do you need a >1A peak gate driver with a signal period of 2*7.8ns (= 1/64MHz)? Try doing the math of transferring a 25nC gate charge in a less than 2ns time window, in order to catch up with the 64MHz PWM AVR output pin rise and fall times...This is a (*draft*) schematic of a 5.0V AVR LED driver circuit, able of working in both the Buck or the Buck-Boost topologies:-George

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 16, 2012, 12:49:57 am
content: Thanks a lot George I really appreciate the comments and the corresponding effort.QuoteI knew you had your reasoning, and so I am glad to hear it.Quotethanks again George I'm sorry you had to spell it out again via the diagram, the current sensing looks perfect, I guess I had it locked into my head that I should be sensing current only directly in series with the leds.QuoteI am not sure why but I was basing my calculations on 256khz rather than the actual rise and fall times? Then assuming I was so far under requirements that I didn't actually calculate the current needed.So I will go with the ZXTN2040F/ZXTP2041F transistor pair.I will post a schematic again soon, similar to yours but with an extra voltage level transistor and a non logic level fet.For this project efficiency is the most important factor.Jon.

author: A Hellene
author_rank: Frequent Contributor
timestamp: June 16, 2012, 01:14:31 am
content: You are welcome, Jon.-George

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 16, 2012, 01:33:22 am
content: Revised output stage of circuit.Also I have to generate the 12 volts and the 5 volts for the Vcc and also probably a separate voltage for the Analogue Vcc.I plan to do this in parts 24-48 -> 12 via a tiny switched mode -> then 12->Vcc via a regulator. and 12 ->Vcc analogue via a regulator.The switched mode I think I will use is the black 2 transistor regulatorhttp://www.romanblack.com/smps/smps.htm, as I only have a small current draw.

author: Unknown
author_rank: Unknown
timestamp: June 16, 2012, 02:18:43 am
content: Quote from: HackedFridgeMagnet on May 29, 2012, 10:35:01 amWrong! Nanny state legislation says any FIXED installation requires a cablers certificate! (a useless piece of government/union/insurance industry inspired piece of bureaucracy) Conroy's bungling ACMA at it's peak. You are correct that LV and above wiring requires a licensed electrician.

author: A Hellene
author_rank: Frequent Contributor
timestamp: June 16, 2012, 02:41:44 am
content: QuoteJon, for the AVR power requirements you will only need a single 2.7V .. 5.0V supply.If you are using the t25/t45/t85 you are good, since there is no special analog supply line for this family.If you are using the t261/t461/t861 connect the analog supply line (AVcc) to the digital supply line (Vcc) through an additional filter consisted of a 10 µH inductor (between Vcc and AVcc) and a 100 nF decoupling capacitor (between AVcc and GND), as recommended by ATMEL.In both the cases above, the AVR power supply should be as clean as possible.Additionally, use Kelvin connections for the ADC differential inputs and shield them by using guard lines connected to the analog ground (1 LSB represents 53.7 µV, in the previous example of the 55 mV full scale); and a star grounding scheme for the PCB layout (a technique in which all the partial subsystem ground planes and ground lines connect to the system ground at a single point, making a 'star' pattern).-George

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 16, 2012, 02:48:13 am
content: QuoteWhen did that come in? I guess I should read up on that.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 16, 2012, 03:29:24 am
content: I plan on using the tinyx61a series. at Vcc = 5 volts.I was going to use a separate analogue supply derived from a voltage regulator as I wanted to keep them really separate.Probably I should just follow the data sheet and use the inductor and the cap.But shouldn't I keep the Analogue Vin one volt less than Vcc. for an tinyx61a?QuoteThat is why I want to use a regulator from 12 down to 5 volts.QuoteI guess guard lines follow the input tracks. I will have to look this up.QuoteI am familiar with this, I will do it this way.I have another question George,Because three of my differential inputs are attached to ground, I should be able to share the input pin for these inputs, as long as I only join them near the pin itself. Is this a reasonable strategy?Also, every time I switch between the differential inputs for the 3 channels I must always wait for the change to settle. I can do this by either waiting longer or by throwing away the first reading after a change. So if I want to take a series of readings to average them I might want to do it like this.Sequentiallychannel 1: take 6 readings but only count the last 5 toward the average.channel 1 : adjust outputchannel 2: take 6 readings but only count the last 5 toward the average.channel 2 : adjust outputchannel 3: take 6 readings but only count the last 5 toward the average.channel 3 : adjust outputOrfor(int i=0; i<5; i++)// in assembler of course and probably done as interrupts{channel 1: take 2 readings but only count the last 1 toward the average.channel 2: take 2 readings but only count the last 1 toward the average.channel 3: take 2 readings but only count the last 1 toward the average.}channel 1 : adjust outputchannel 2 : adjust outputchannel 3 : adjust outputor don't bother with taking averages .channel 1: take 2 readings but only use the second.channel 1 : adjust outputchannel 2: take 2 readings but only use the second.channel 2 : adjust outputchannel 3: take 2 readings but only use the second.channel 3 : adjust output

author: A Hellene
author_rank: Frequent Contributor
timestamp: June 16, 2012, 04:54:45 am
content: QuoteThis limitation applies only to the AREF (the external voltage reference) input:Quote from: ATtinyX61A datasheets rev.C, p.156At the electrical characteristics section is stated that: AVcc = Vcc ± 0.3V.QuoteI have never done that (meaning, switching between differential channels with this particular chip), so I do not know and I would certainly experiment with it.According to the datasheets:Quote from: ATtinyX61A datasheets rev.C, p.156Also:Quote from: ATtinyX61A datasheets rev.C, p.147The reasonable way to do it is to initially start the ADC in free-running mode and in every ADC ISR:1. to count the conversion results and discard the first sample after a differential channel change,2. to set the desired channel after getting a valid ADC sample, and3. to adjust the PWM output accordingly to the ADC current reading.All the above can easily be done within the ADC ISR. Of course, discarding every second ADC result costs in sampling speed by reducing it in half, something thatmightaffect the output stability.Now, since the current averaging has already been done in hardware (at the very slow RC filter stage of -3dB at 159Hz, which is a typical value that will certainly need recalculation), there is no need for any further processing. You just scale the 10-bit ADC result (in the case of using a PWM resolution lower that 10-bit) and adjust the PWM output accordingly, increasing or decreasing the output value by 1 LSB after every ADC valid result.-George

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 16, 2012, 06:44:38 am
content: Thanks that sounds good for the ADC firmware.QuoteSorry I was confused between the Aref and the AVcc

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 16, 2012, 11:47:47 am
content: Pin assignment for attinyX61a, I am looking for 3 independent channels. The previous version of this circuit used Single sided adc and therefore had no internal gain.I seem to have enough pins for the differential inputs if I share a few ground pins.From the datasheet I have the corresponding mux codes.I am using 1 x gain for the dimmers, and 20/32 x gain for the current sense.After a bit of shuffling I can use 32x gain for the current sense inputs.Edit: moved dimmer channel 2 (green) to adc3 because it will interfere with _Reset.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 22, 2012, 02:20:40 pm
content: Finally finished a schematic.Anyone is welcome to give constructive criticism, or ask questions.It should work.One improvement, I think r5 could live on the output of the regulator. Probably don't need it anyway, as the Micro is an always connected load, but I wanted pads there just in case.The 12v is low power and just for the gate drive and input to the 5v regulator.

author: arclight
author_rank: Contributor
timestamp: June 26, 2012, 02:52:43 pm
content: I'm surprised nobody has mentioned it, but have you looked at using Anderson Power Poles? These are available in several current levels (the 15A and 30A interchange) and there are wall socket kits for them as well. Have a look at:www.powerwerx.com/anderson-powerpoles/Spec sheet is here:http://www.powerwerx.com/techdata/PP15.pdfWe use these a bunch for ham radio and on our search & rescue team for things requiring DC power.Arclight

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: June 26, 2012, 11:52:31 pm
content: Hi arclightI have looked at them on the web about a year a go for a different project but never actually touched one.I guess I dont get the way you join the multiple poles together, can you do it so that it is mechanically strong like an extension lead?But I am wondering how they would go for extension leads, wall sockets, and pcb mount connectors.They probably cant do all of that but probably could do some of that.Do you think they could be used in any of the above roles at less than 10 A?I might have a short flying lead on each light at say 48 volts 3 amps max. It would go up into the roof cavity, where I can just clip a power lead into it coming from the dc power supply. The Anderson power pole may suit this. Very few insertions, I assume they lock.I should probably just get some and so I am familiar with their capabilities.Thanks for the reminder.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: July 06, 2012, 11:17:12 am
content: Three channels fitted onto a Seeed Studio 10x10 cm board so I went with them. So cheap.I almost put the inductor footprints upside down, they are vertical toroids. That would've been a bit of a disaster. 811-1216-nd from Digikey.I hope ADC on the current sense is ok, basically I have mimicked the ADC inputs on the differential negative inputs which are connected to ground, but not so there is any significant current flowing through them.I had to share the negative differential input between channel 1 and 2.

author: SeanB
author_rank: Super Contributor
timestamp: July 06, 2012, 03:12:43 pm
content: Anderson connectors themselves are non locking, but you get covers for certain pin combinations that are either locking, waterproof or both.

author: sarfata
author_rank: Contributor
timestamp: September 01, 2012, 05:11:45 am
content: Hi HackFridge!I had a wow moment when I saw your design and realized that the PWM from the Attiny was to regulate the current.Have you built it? Does it work?What is your current total BOM cost?I was also wondering how you intend to get the dimming to work. Will you apply a lower frequency PWM to the "fast" PWM that regulates the current? Or will you lower the target current-sense voltage?I believe the first option would give better color rendering as the LED would always get the same current but of course the dimming PWM must be slow enough to let the current-PWM do the regulation properly.My design which you saw in another post with an LT3518 is too expensive. I am trying to cut costs down and I believe your schematic is by far the cheapest switching solution. Linear regulation with a mosfet and a transistor is also very cheap but complicated heat-wise.thomasEDIT: I see that you have RC-filters on the dimmer input so I am guessing it's PWM that you are translating to analog readings. Why not use the "PWM-state" of those pins in a "AND" test in your current-PWM loop? You could alsto stop adjusting the current PWM when the dimmer input is low.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: September 01, 2012, 12:34:21 pm
content: Hi SarfataIf I remember rightly you were also doing your own 3 channel Led Driver, and I posted a link back to here.Yes I have built 4 of them, I only made one major mistake on the PCB, a transistor backwards, which was a shame but fixable, the error is actually on the schematic I posted, but I have 4 boards working.I haven't calculated the BOM price properly, A lot of the BOM cost is inductors and connectors. I could even forgo the connectors as I am going to integrate it into the light fitting. For me the issue wasn't really about Led Driver price but about efficiency. I think I am roughly about 93%. Nothing feels hot except the Led MCPCBs.Quotethe dimmers can either take pwm in or just a pot.Another way would be to use serial control( RS232 or SPI ) but I would have to flip the pins around a bit.I do have an instability at low pwm settings it flickers, but I know a good work around for this.My real problem is making the light fittings, and making them look nice enough to use in a house, my level of craftsmanship is at the opposite end to Robenz's.I have some good diffusing glass but it is flat and looks a bit like a flouro fitting.I have been stalled here for about 3 weeks.My test installation shows the leds looking their best when shined up at a white roof. So I may drop the diffuser and go strip lighting on the wall, facing up.QuoteI am not sure how much cost you will save as there is a fair bit of labour in the extra transistors. The Led Driver is only a small fraction of what I envisage as the total cost of installing a light fitting. Something like $300 installed for something that looks good. Saving $5 for me is not the priority. I just have had no success with the integrated drivers, that is why I like the ATTiny. I guess I do like the gazillion switching BJTs too. Nice to check the waveforms.I am happy with the electronics though, it's all running very cool. A lot of the cost is in the LEDS, I did my own MCPCB and mount the leds myself, they are working well and run at about 50 Celsius without extra heat sinking (around 400mA Cree XTE)QuoteYou are right, unless your doing a flash light You need PWM or PFM definitely. One other option is linear control as opposed to micro control. I like the microcontrollers as they give a lot of integration possibilities, which from memory you are interested in too.

author: sarfata
author_rank: Contributor
timestamp: September 02, 2012, 09:34:00 pm
content: Hi,I have been running simulations in LTSpice but I am reaching to the limits of my analog electronic skills and I will have to work on that more ...Just one quick question, you said you built your own MCPCB, how did you do that? Did you order them from someone? If you did that, why not put all the parts on this board and have just one board ?thomas

author: sarfata
author_rank: Contributor
timestamp: September 02, 2012, 10:57:32 pm
content: Hi again,Yes - you are absolutely right about my project. Thanks for telling me about yours and sharing the link to this thread. It has been very interesting reading your exchanges!So I have re-designed the circuit in LTSpice, starting with AHellene design because I would like to minimize the number of components and I will not have the two rails like you do. Also, I would like to understand each stepsI have a first basic question about LTSpice: If I set the duty cycle of the PWM to 100%, why is the current limited to 8 amp? This seems to be a characteristic of the LED (changes if I choose another one) but I dont really understand where it is coming from. It seemed to me that in the simulation, the current should be infinite and in real life the LED would blow up in a few uSec. I would love to understand that...My second question is about measuring the current. Assuming 100mOhm, the voltage on R1 will be equal to 1/10th of the current going through the LED when the switch is On. However, when the switch is Off, the current is 0. So the filtered voltage on Rsense will vary with the current and the switching frequency. Do you take that into account in your software?It would probably be (in a very simplistic way): Iled = Vrsense / 0.1 * D?This seems a little too simple, have you used something more advanced to get Iled?thanks!thomas

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: September 02, 2012, 11:59:32 pm
content: QuoteGood question, I think it took me longer than you to realise that this is the case.Effectively you are measuring the (Led current) - (the current in the shottky diode) whereas we really just want to measure just the led current.This is one disadvantage of this topology, but unless you need a linear response (dimmer posistion -> current) it doesn't seem to matter.One day down the track I may try to linearise things but the light output of the leds themselves is only roughly proportional to current anyway.currently It dims down to zero and dims up to full on with a reasonably sensible manner. So as an issue it is at the bottom of the list.The only thing really worth worrying about is the max led current, so you will have to consider the shottky diodes current for this.Because I generally run with as many leds as possible in a string and only about 1/3 max current, my top duty cycle is always 100% therefore there is no current in the shottky diode. I run like this to get more efficiency and to moderate the heat in the leds.Here is a link to my MCPCB threadhttps://www.eevblog.com/forum/manufacturing-assembly/metal-core-pcbs-from-zhejiang-zapon-electronic/QuoteNothing blows up in LT Spice, unfortunately, because in real life things do blow up. This is why when in development (firmware or hardware) I always fuse my leds, I learnt this the hard way.As far as LTSpice is concered the LED is just a non linear resisitor and it is in series with an inductor, so effectively your model of this branch of the circuit isIn Series:an Ideal inductor,an Ideal diode ,some linear series resistance,some forward voltage dropand probably some other non linear effect that models the exponential current/voltage relationship. I = Is * (exp (V/(n*k*T/q)) –1)the series resistance combined with the exponential relationship will limit the current after the transient effects have worn off.

author: sarfata
author_rank: Contributor
timestamp: September 12, 2012, 05:11:29 am
content: Hey HackFridgeMagnet, thanks for your replies.- MPCB => Thanks for sharing this. It is really useful! If I can fit my design on a one-side PCB, it would be really nice to have only one PCB for both the controller and the LED.- LED current control => I will try to run at the nominal current all the time. We will see how close I can get without burning the LED...One thing on the todo list is also to dim the light by PWM-ing a constant current, not reducing the current. It should improve the color rendering a lot.This is my new schematics that I will prototype tomorrow if the UPS-god is good to me.(LTSpice file attached to this post)I have adapted both HFM and A Hellene schema:- Input voltage is 9V (final voltage still to-be-defined)- Each "string" is just one LED with an approximate forward voltage drop of 4VAny feedback on my choice of components is much welcomed. I have worked from what was posted before but I am guessing I might be able to find a better mosfet that I could "saturate" better because my requirements are smaller than those of HackFridgeMagnet.thomas

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: September 12, 2012, 02:59:32 pm
content: My only query is that to produce a lot of light, you want good efficiency and so a higher voltage and longer led string would be better.If you want to go lower light levels then go low voltage certainly.For just a single channel then I think one of the six pin attinys might work.I am not driving the leds that hard, about 50% of max current plus the instantaneous ripple. They are slightly more efficient at around 400mA than at 1-1.5 amps and more efficiency means less heat, which is very important. One of the downsides of this is a higher initial cost.You might have trouble routing this circuit on a single sided board although you should manage it if you use zero ohm links to help.You dont 100% need MCPCBs for mounting leds, you can also use FRP with vias and heat pads and other tricks. Worth considering.The bjts I use I am very happy with. (Forgot the number but it's xx41 and xx40 I think). Though the ltspice models don't work.As for fets you need a "logic level fet" for 5v, the fds5680 might actually be ok but you probably want a Vgs(th) a tiny bit lower. If you switch at 9v it would be fine.Look at the Vgs vs Rds(on) graphs on the datasheet. Digikey lets you search on Logic Level fets.

author: T4P
author_rank: Super Contributor
timestamp: September 12, 2012, 06:39:38 pm
content: There are two categories of high power LEDs :Standard high power LEDs : usually around 900~1400mA random FvFlashlight type LEDs (higher efficiency) : random forward current 3.3V nominal FvSo you see, one thing's for sure though, like all SMPSs, they work best when drawing lower current but high voltage and that a SMPS is best when used around the 50% load mark.

author: sarfata
author_rank: Contributor
timestamp: September 14, 2012, 04:41:20 am
content: Thanks again HackFridgeMagnet for your insights, and thanks T4P for jumping in!To answer both your comments, I am using a Ledengin 10W RGB led that has R/G/B Fv of 2.0/6.4/3.2 and I am trying to find a good solution(here good also includes efficient although it's not my #1 priority) to control the three channels with one AtTiny. My goal is to build a current controller cheaper than "ready-to-go" package like the LT3518 I was using earlier or equivalents that cost $5 to $8. Turns out to be a very interesting challenge with lots of learning on the waySo I have built the design I sent two days ago. I used BC547/BC557 for the BJTs and a FQPF13N6L for the Mosfet. The inductor is 15uH, the LED capacitor 4.7uF and the zener is a 1N5361BG.I have added two buttons that allow me to change the Ton period. The Ton+Toff is 8uS right now. All of this is breadboarded of courseThis is a capture of the voltage at the gate (red) and at the drain (yellow) of the mosfet. You can see that it looks like the mosfet starts conducting current again before the beginning of the new period. I had never seen this in my simulation, any idea where that might come from?Where do the huge oscillations at each state change come from? How could I reduce them?This is what the PWM signal looks like out of the AtTiny (in red) and what the output of the RC filter looks like (in yellow). As you can see, it is extremely noisy but measuring this with my Fluke gives me very precisely what I expected (that is Idiode = Urcfilter * DutyCycle * 1/0.1ohm).I have decoupling capacitors on VCC and on my 5V. I also added a 10nF capacitor on GND/VCC of the Attiny otherwise it kept resetting every time I increased the duty cycle. I am now fighting with the ADC converter, without gain and using VCC as the reference, it returns 2.5V for the rc output. This is not right... will look at this more tomorrow. I am hoping I will still be able to read something through the noise.thomas

author: sarfata
author_rank: Contributor
timestamp: September 14, 2012, 04:45:44 am
content: Update: just found out that the bogus "mosfet conductions" only happens with a small duty cycle. If I increase it, it does not happen anymore. Also, if I remove the capacitor on the LED, they completely disappear at every duty cycle (but the oscillations are even worse).

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: September 14, 2012, 07:15:25 am
content: I guess you are breadboarding this design?If this is the case, it is very difficult to get rid of noise and inductive effects. In fact breadboarding gate drivers is hardly worth the effort, I have used vero board and it was ok. Dead bug might be worth a go.So shorten all lead lengths especially high current ones.Simplify your circuit first, even replace the load and cap with a 100 ohm resistor. and just get the gate voltage looking right.Dont worry about the feedback voltage, it seems as messy as what it is measuring.Can you lower the freq?The lower freq oscillations are normal as you may have discovered. It is just when the Fet and the Diode are both effectively off. The will probably be minimal/no current flowing at this time.As you know we need to get very close to a square wave on the gate. the top of the gate voltage square wave should be comfortably above the Vgs(th).

author: sarfata
author_rank: Contributor
timestamp: September 14, 2012, 09:26:36 am
content: QuoteYes I am. I wanted to breadboard it to make sure I could understand every step along the way. I did get a brand new vero board to do something a little cleaner.QuoteI did try the mosfet with just a few resistors in parallel. i had also removed the inductor. It worked fine.I could lower the freq. How do you think this could help?QuoteWell, I cant say I really understand itIt seems to me that if everything is discharged and the mosfet is off, then the voltage at this point should be 9V, I dont get the spikes to 0V.QuoteI understand that well. The datasheet for this Mosfet (http://www.fairchildsemi.com/ds/FQ/FQPF13N06L.pdf) gives a Vgs of ~2V for 1A, I feel like I am safely above that.What I am not sure about, is the positive spike when the mosfet turns on and the negative one when it is turned off. In my capture you can see a spike of +2V on the gate when the mosfet is turned on. Am I correct assuming that this is good and helps make sure that the switching time is as short as possible, and therefore the mosfet has the lowest possible resistance?Thanks again for your insights!thomas

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: September 15, 2012, 01:12:58 am
content: I was just thinking that we should be putting this stuff onto your thread, instead of mine. No harm done but it would make it easier for other people and myself to refer to the one design in one thread. As much as possible anyway.Hence I will give some opinion to your queries in your thread.https://www.eevblog.com/forum/projects-designs-and-technical-stuff/looking-for-feedback-on-my-design-of-a-high-power-led-driver-9612/

author: sarfata
author_rank: Contributor
timestamp: September 18, 2012, 05:59:55 pm
content: Hey,Wanted to post on this thread this very interesting Application Note from ST Micro which basically describes what you have been doing:http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/APPLICATION_NOTE/CD00263933.pdfTwo very interesting differences:- They dont use BJTs and drive the mosfet directly from the uC. Have you tried this? I thought the AVR would not be able to sink enough current but this got me thinking twice ...- They measure the current at Ton/2 to get the most accurate current reading. I think this is pretty smart (you probably have to read the article to understand this partthomas

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: September 19, 2012, 03:46:18 am
content: That's great Sarfata, thanks for posting.I will try to see if I can find any improvements I can make.

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: November 15, 2012, 10:52:44 pm
content: I have still been working on this, when I get the chance, but I haven't updated for a while.I got my 3 channel boards back and they work nicely, nothing gets hot on the driver at all, I only really made one error and that was one of my transistor footprints was wrong, so I had to flip the transistor over and do some ugly soldering.The next trouble I found was the diffusing of the light, I wanted a prismatic glass diffuser because the glass looks so nice when it is off, but it cannot quite diffuse the light enough, so you get this effect called dazzle. I think if I combine the diffuser with a very light pearl diffuser it may work but that can wait.My next plan is indirect strip lighting, narrow strips hanging of the wall but giving room lighting, the indirect light is very pleasant though I guess the efficiency is not so good.To do this I have made a few changes my 3 channel board to 2 channel, changed the format from 100mm x 100mm to 50mm x 100mm. to suit Seeed studio.This thinner board will sit better on the strip and each channel will go off in opposite directions along the strip.Other changes for version 3.I added a thermistor,fixed a problem with turn on where the leds flash momentarily at power on,added a switch to completely turn off power when I want the light off but doesn't increase the length of the power cable runmade the supply 36 volt, up from 24v so I can run 10 leds in series per channel.Anyway I sent Version 3 off to Seeed and I haven't received them back yet.But since then I have realised how many mistakes I put onto Version 3 of the board while plotting. The board is a complete and irretrievable failure.I didn't send the solder mask layer, I sent instead the solder paste layer.All my 8 bjts are inverted.My kelvin connection ground got flooded by the zone flooding.this is what happens when you aren't careful and are rushing.Last night I sent Version 4 off to Seeed, after fixing these mistakes.