The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
I will give all the attiny project details, including hacky source code, when I can, give me a few days.
The attiny idea was not really mine, I think it was Marios, but I can see that it might be an option.
I was really just talking about mosfet drivers made from discrete components.
I think I used the attiny461 (4k) of ram. About 20 pins. It can do 3 channels but you need to add the output stage fet driver for each channel.
the other option I had in the back of my mind were those recom led drivers, but they are about $15-20 dollars each, for 1 channel, but includes the output stage. Quite nice but I have managed to blow a few of those too. there are probably cheaper equivalents too.
I guess both of them are just voltage controlled current sources.
I am not familiar with the TLC chips, I will have a look at them, maybe they can be used.
I will desolder the TLC's they were making the SPI a little tricky any way.
Right so a couple of questions...
As you know the netduino is doing a lot of work for the various things that make up the control of the fish tank so I have to be careful about pins, what would you recommend in terms of controlling the 30 x ATTINYs? Can they be daisy chained etc? I do have a fair few outputs from the 74hc595s but I'm guessing you need something that proides a signal not just a simple on or off. My serial ports are pretty crowded already COM1 is dedicated for the gainspan Wi-Fi module and then COM2 switches 4 ways using a 74hc4052. This switches serial between the PH stamp, LCD display and 1-Wire bus, there is one free channel on the 4052.
Parts and Diagram,
Please can you give me a list of parts and a diagram of how to connect them all together? Also do the ATTiny's daisy chain and then I address each one to control the various LEDs?
What should I use interms of a power supply and how do I split it across the 30 LEDs? If we think of it as you describe Mario, 30 x Little Boards with the Drivers on. Finally how can I make this as efficient as possible in terms of power and keep costs at a reasonable level?
Many thanks guys and I will get on removing my TLCs and the Oscilatitor circuit I just finished At least I took your advice Mario and made this on protoboard rather than sending it off to the print shop!
Dont desolder yet.
Attached is the details of the project.
I will send some build photos if you want, but I will have to take it apart first.
Remember all my project is, is a 3 channel led power supply controlled by faders.
I chose 24 volts and about 6 leds on each string. It is not currently integrated into the netduino at all.
To integrate this with the Netduino you may want to use the TLC chips. (After reading the data sheets. The TLCs wont integrate with the attinys)
I can see 2 ways to integrate the attinys and the Netduino, though somebody may have other ideas on how to add 30 channels of dimmable led drivers. Have a look at the RECOM led drivers, they are very efficient.
1)Use the TLC's to get 30 analogue channels out of a netduino. and put them into the attinys. instead of the faders. This is the dreaded 2 kinds of pwm.
2) Add some comms to the attiny, you may have to drop a channel and increase the ram. And rewrite the firmware.
In the simulation: the red is the led current. the green is the pwm input current coming out of the attiny, and the blue is the gate drive voltage.
I used LTSPice 4 to simulate (what an excellent bit of free software)
I used AVR Studio to build the firmware.
I used an avr dragon as the programmer for the attinys.
ps In this circuit, common is the positive rail, this was so I could use only one pin on the current sense resistor R7. In retrospect, I think it wasn't necessary to reverse the polarity of the entire circuit.
The buck converter has 2 switches (M2 and D4)and lowers the voltage. Using the diode d4 makes it a non synchronous converter.
For m4 I did not use an IRF4713 it is just in the simulation. But I did use an automotive fet (55V) and n channel enhancement, not logic level. Low Rds on.
q1 and q2 are the totem pole and they push and pull charge to the gate of the fet.
c1 I don't think c1 is important, possibly discard.
L1 holds the energy across the pulse, 100u is about right for this circuit at a switching speed near 100kz.
R4, R5 and R6 dictate the operating conditions for Q4. What is needed is that Q4 outputs the full required Fet gate voltage but doesn't go into heavy saturation. Which will ruin the square wave.
R4 might be my attempt to model the output impedance of the attiny. (cant remember).
V3 is the square wave from the attiny.
V4 is the 24 volt power supply.
put a fuse in line with the led(s).
The moment you start doing power electronics prepare to blow a few parts.
A current limiting supply would be really good for testing, development, you could almost make that yourself.
I had a look at those chips TLC5940.
Maybe you can use them after all.
I didn't realise that they are current sinks, and have current control built in.
You can also parallel them up for HBLeds. see the datasheet.
Although there is something I don,t understand here.
I am not sure why you don't need any sort of inductor.
By my understanding it must be dissipating watts of power when in the conducting phase.
(17 - 3.5 volts) x 120 ma = around 1.5 watts per channel(instantaneous).
After rereading the TLC5940 data sheet, not the application note, I can see that the excess power is consumed in the chip itself. So you just have to be careful about what you are asking it to do. It says that it can absorb between 1 and 4 watts across the 16 channels.
Well, I have very few time today...
I definitely agree with Magpie on just one thing: don't desolder the TLC!
About the Magpie idea, I'm still a bit suspicious, 'cos I don't understand where the advantage is.
The goal should be to simplify the led driving, possibly without paying too much.
Believe me: this thread is really intriguing, but I haven't so much time to follow enough.
The small boards with a tiny MCU is still the best one in my mind, although to program them you must use a special programmer (JTAG). That's obviously an overkill, unless you'll find some new project where re-use it.
I'd have a "breaking-change" about the JTAG problem, but it's still no more than an idea...
Instead of creating many small boards (which should require a PCB or else), we might consider several Arduino-like boards:
a single board can manage 4-6 leds independently
much compact than many small boards
ready-to-use (the Arduinos are easy to buy anywhere)
it's easy to program, via RS232 or via USB
it offers many I/Os than an ATTiny
Please, let me know whether I'm going off.
Biggest fault of Netduino? It runs by electricity.
Very interesting stuff guys, haven't ripped the tlcs off yet. My driver will eventually be one board, be it may multiple drivers all on one board. I have an AVRISP MK2, I have used it a couple of times but it can be a little confusing at times. I did manage to reflash my sparkfun serial graphic LCD.
Magpie thank you for the information s far look forward to reading more when you both get chance.
Hi guys, Yes I think it's an interesting project too.
From what I can see the TLC5940s are a standalone solution. They don't need extra current limiting or any extra circuitry but they do have heat dissipation and power wastage problems. I think they are designed with lower power applications in mind.
I think for your aquarium, where you want higher power that you would need to use a lot of these.
The other way of doing things is through a led driver which is normally based on a buck converter.
With a proper converter you don't waste as much power and therefore don't run into heat problems.
At a guess I think my converter is around 90% efficient, as are most other modern led drivers that use a decent inductor and a decent mosfet.
Maybe you could to a compromise solution, where your low power channels could run off TLC5940s and your high power ones run off buck based led drivers.
Rather than make them all yourself you could buy these.recom led driver
As far as the leds go I have used the Cree XPE for colours and XPG for white. The leds that mcinnes01 linked to dont give many details, what worries me is that a cheap 10 watt led might produce as much light as a Cree 5 watt led, but it will also produce 5 more watts of heat.
The Cree leds are very efficient. I think if you use high quality leds and drivers you wouldn't need much heatsinking at all.
Obviously the only problem with high quality is the expense, but you have to factor in the energy cost as well.
I guess before you decide on the drivers you should work out what LEDs to use and what type.
I am not sure how you like to work but I often find that I change my mind, especially once you see your project in operation, you might get another Idea to add some more lights somewhere, or you don't like that sort of LED. Or even you might find the cheap LEDs actually put out as much light as the Cree LEDS.
I would move into a proof of concept phase, which will be a subset of what is the current design. Eg. Get your highest power LED string (channel)sorted out your lowest power led string(channel). Try the cheap LEDs if your leaning that way and/or try the expensive ones.
For your power supply you could use an old PC supply, which can put out a stack of current at 12volts or if you want something nice a Meanwell power supply. (Very elegant) I used 24v as it's easier to be efficient with a long led string but I think if you have 30 channels you will be anywhere from 4v to 24v.
As far as the binning of LEDs go I can't remember much, the further down the alphabet the better it seems to be.
Try and fuse the leds at about half the full rated current, especially in development, otherwise it can get very costly very fast.
Put your finger over one LED when it is on, it will burn, but not from temperature, from the radiant light. Touch next to it and it is cool, amazing.
Mounting the leds is an issue, I screwed mine on, but for your final build glueing looks better.
I am not sure if you need a diffuser, but for humans you definitely do, they hurt your eyes if you look at them.
One thing about Colour temperature is that it seems to me to be a poor description of the outputted light. It is a single number that is actually representing a spectrum. It doesn't account for a narrow spectrum or a wide spectrum, so in my opinion you are better just looking at the spectrum chart. From memory most of the coloured leds actually have a broad spectrum, and hence a lot of white light in them. It means its hard to mix the colours and get saturated colours.
Eg. When I want a deep violet I get a pastel version. I think the only way around this is with filters.
I think those led driving chips are the standard solution to driving leds and hence probably the best, I haven't actually tried them but I have seen them in circuits many times. Definitely worth a try, look for one with an example circuit that exactly suits your purpose if possible. You probably don't need synchronous (2 Fets), you probably just need ( 1 Fet and a Shottky diode) as your two switches.
The other part of your proof of concept is how do you control the many channels with a Netduino? Make sure anything you test answers this question for all your channels.
I have found these crees for my whites, what do you think? cree
Obviously I need 14 of these.
If I went with these LEDs aiming for the 3w output, where would you suggest to begin in terms of driver?
I wonder for efficiency but to still allow me to individually control the LEDs if there is a simple but clever way around this?
Let me explain...
As everyone knows, reducing the voltage down to 4v is better for driving individual LEDs like I proposed to do, it wastes less energy than using resistors, but is ultimately still inefficient as the power supply will be more inefficient.
As you suggested 8 LEDs on a 24v supply is a lot more efficent, however this would require me having 8 in a string and hence the trade off is less control for better efficiency. Or is it????
Typically the lights are going to be on at a PWM controlled level, whatever that may be. If all lights were to be at the same level by design, then this would be fine, but as you know I plan on producing effects such as lightening, cloud cover, moon cycles, seasons and sun rise/ sunset.
Despite these effects there will for the majority of the time just be a consistent level of light and only at certain times would lights need individual control. What I am proposing is having 2 seperate drivers for the LEDs, one is a super efficient long string driver e.g. 24v 8 in a chain. Then the other driver will be to control individual LEDs for the effects. Now obviously this will have a higher component cost, but it gives me the flexibility of efficiency and control when required.
A slight deviation on this idea (this may be total rediculous btw but I'm just brain storming as fast as I can as I want to buy everything and get it built), the other idea is have all the LEDs run in the 8 LED chains, but then inbetween the LED and the actual power cables have something that I can control the current to that specific LED either by creating more resistance or using a capacitor and transistor as a switch that is controlled by PWM to reduce the charge supplied to the capacitor at a particular time. The capacitor would obviously level the switching out to a smooth consistent level. Now as you know my specific knowledge of electronics is still rather infant, but I think my understanding is correct, please correct me if not?
Also not sure if I dimmed one LED in this way by interrupting the flow of current to one LED, what the effect would be on the other LEDs in the 8 LED chain?
Those Cree XPEs are probably quite good, but for white leds the Cree XPGs have been out for a while and are probably better. My preference is for Cree XPGs, but it really comes down to price.
I dont think your idea for controlling the chained leds individually will work. Have you tried the LTSpice IV? I sent an .asc file which is a model of a buck driver. The model is quite good and behaves reasonably close to reality. If you want you can add caps and things to you chains and see what happens.
When you use a buck driver you will get at least 80% percent efficiency with dimming at any reasonable power and voltage, that is their advantage.
You can also get very good efficiency without dimming by putting a string together with the exact voltage required. Eg. 8 leds at 24 volts.
Although the exact voltage required can be hard to calculate.
But if you don't want dimming you may as well use fluorescents.
You still have to work out how to get 16-32 channels out of the Netduino. I think your TLC5940s could quite easily be control voltages for the Buck current drivers.
As far as I can see each channel has 3 options.
I think some sort of Low Pass filter could change the square wave from a TLC to an analogue control voltage.
1. Square wave out of TLC, -> analogue control voltage -> off the shelf buck driver.(recom or similar)
2. Square wave out of TLC, -> analogue control voltage -> home made buck driver. (Attiny etc.)
3. Use TLCs as designed and lose the efficiency.
I dont see why you cant use a mix of the three.
Do your proof of concept, so why dont you get the leds, try all the options with one led each, at say 12v. See what you like.
Because one thing is for sure, you never get it right first time.
OK so I've bought the SP-Es slightly less output than the SP-Gs but should meet my needs any way and they are like less the £2 each. Maybe I will upgrade one day but as you say during testing its likely that I ccould end up destroying or damaging a couple at least.
Next, I did have a go with the Spice program and could see the various waveforms, but I will be honest at this point it gets a little beyond me. While I can see what the ciruit is producing I don't really know how to interpret it or modify i to get my desired output.
This is the spec of the SP-Es
CCT (K) 10,000 – 5,000 Max Current (mA)1000 Viewing Angle (°) 115
XP-E Standard Min. Flux @ 350 mA 122 lm 114 lm 107 lm 100 lm XP-E HEW Standard Min. Flux @ 350 mA 139 lm 130 lm 122 lm
Product Status Active
I definately think a home brew buck driver is going to be the correct route for me, just based on a level of control and price factor.
How would I handle the open drain exactly from the TLCs so that it can provide a useful output to a buck driver? If for this example we say the buck driver is the suggested ATTINY solution.
I definately am going to do some testing before making a decision, but just need to know exactly what componets I would need to create a test buck driver and what components are needed exactly to turn the TLCs output in to something useful?
One thing with the LTSpice is if you hold down the alt key as you choose a spot to monitor, you get a graph of the instantaneous power.
The XPEs will be fine.
When you say the open drain, I think it is an open collector according to the data sheet page 8.
Doesn't matter. It's as far as I know an open collector current sink that has a variable PWM output.
What is needed is to turn the current sink output into a reasonable stable analogue voltage.
What about a pullup resistor and a low pass filter?
Vcc ----- pullup resistor ----- TLC out
|----- Cap ----- GND.
|----- Attiny input.
This would work though the code may need tweaking just to take more samples to smooth the input even more, without causing much too delay.
As you saw I put my whole attiny circuit upside down, I cant remember why. It might have been to put current sense on the high side or to use an n channel mosfet. I'll have a look and send a schematic through.
In the mean time so I dont hold you up.
BOM To make the 3 channel pwm.
1 x attiny 461a
1 x 12 or 24 volt psu. (choose current mainly for the leds, the attiny only takes about 20ma I think.
1 x 5 volt regulator ( for the attiny whatever it needs) 7905 if you want to go upside down.
1-3 x 10k fader (for testing.)
3 x 100uH inductor or there abouts.
3 x Fet 40-70 volts, low rds, n type enhancement. IRF1010e
3 x 5819 shottky diodes
3 x 0.5 ohm resistors
3 x 470 ohm resistors
3 x 180 ohm resistors
3 x 9 ohm resistors (attiny pwm out ?? into base)
6 x bc327
3 x bc337
3 x 10uF tantalum 35v caps
1 x 100uF or so 35v or greater electrolytic cap
Of course add your Wago plugs.
The inductors are cannibalised from old switch modes. But should be easy to get. I haven't actually measured there inductance but bigger is better.
The fets have lots of alternatives. Make sure N channel enhancement, VDS > 40 v , Rds is low and Vgs(threshold) is similar. We are driving the gate with 12v so it needs to be fully switched on before 12v.
I will send the photos of the build through soon. Be warned, it's no masterpiece. (Like most of my stuff.)
On the bom also are some 500ma fuses for your 1 amp leds.
I hope it doesn't put you off.
I was looking at the TLC5940s again they actually can run efficiently if the outputs are close to 0 volts at full current. But every channel has to be the same. By matching your led strings to the max current you set for it and the input voltage, this could be achieved.
The only trouble then is the em noise they must produce, as Mario pointed out ages ago. But I really need to quote Mario for the full impact.
Nor the Holy God won't release you any emission certificate, unless the entire circuit (from mains to leds) will be enclosed in a good metallic shield/box. Consider seriously this topic, 'cos you may have issues on TV, radio-remotes, etc.
Great thanks, I will dig my bench top power supply out and buy some components while I wait for the LEDs to arrive. At least chinese shipping starts again tomorrow, I have a backlog of bits and bobs I'm waiting on!
With the LEDs the crees spec says they can be driven up to 1amp. Is this an impractical level for long running and longevity of the LEDs themselves? Also in terms of the fuses if for example I were to drive them at 700ma would I be best getting 350ma, or just stick with 500ma as this will protect the LEDs to the point of not exceeding their maximum rating?
One thing that I remember from earlier on in this thread, Mario mentioned using a transistor to get a useful signal out of the TLCs, how would this work as a possible alternative to the pull up method you described earlier?
Thanks again for all the help, I will keep you up to date with how I get on and any other questions I may have.
Sorry I should have mentioned why I said 500mA, I blew some coloured XPEs that were fused protected. My fuse rating was 1 amp.
Fuses are rated in different ways, European is different to US, and are dependent upon ambient temp too. It's not worth trying to calculate exactly, it's probably easier to do some destructive testing.
Choose a 500ma fuse and see how much current you you can put through it. At a rough guess 500mA will safely blow before the led, but 1 amp wont.
I think I would drive the leds a bit lower than one amp, say 800ma. The efficiency drops off anyway. It also depends on your heat sinking. If you run the leds at say 200ma you probably dont need much more heat sink than the aluminium base. Use your fingers as your temperature sensor.
I tried moving the discrete driver around to make the voltage conventional, but failed. So everything needs to be referenced to your maximum voltage rather than ground.
The N channel fet wasn't turning off 100% in the model, so I left it how it was.
Attached is a circuit for connecting the TLC5940s, I am assuming they are ok with 5 volts as Vcc.
My diagram shows Vcc at pin 20 and gnd and pin 10 for both chips. This needs to be corrected to their actual pins.
The inductor L1 can either be a lossy inductor with thin wire, or a resistor, or a resistor + an inductor. With the cap it will make a low pass filter. I was thinking of one of those inductors that look like resistors. The 3db point should be very low, say 10-50 hz.
R1 should enable a voltage swing of near 5 volts, but it will depend on how you set your sink current.
To start I would get the Attiny dimmer going by itself first. At the same time get the 5940s talking to the netduino and driving leds.
When you are happy with the separate parts working you could merge them.
Attached is a circuit for connecting the TLC5940s, I am assuming they are ok with 5 volts as Vcc.
If you power the 5940 with 5V (which is within spec) then you will probably need a logic level shifter for the SPI. The 3.3V may not register as a logic 1 as (if memory serves) the minimum is 0.8 * Vcc for a high signal.
Just one point about the grounding/common.
You will need two power supplies for this.
One for the netduino/TLC5940 and one for the Attiny and the Drivers circuity.
As long as you only connect them together through the chip grounds (as marked) all should be well.
The this circuit and it's 24 volt rails are obviously shared with the driver circuitry posted earlier.