Controlling two high power LED drivers - Circuit okay?

Hi...

I want make a PCB for driving two high power LEDs and control the LED drivers with an ATTINY. I've previously soldered individual boards together with some wires, but thought it would be so much neater to have all the circuitry on a single PCB. I've drawn up the schematics as an attachment and before starting the actual layout and ordering the boards I wanted to get some feedback whether it's likely to work or just blow up in smoke. I know it's rather large and complex, but if you can give me advice on even a single one of my questions below, that would be great!

Basic setup:

  • Input from batteries, likely in the ranges of 4-6V (4AA) or 6-8.4V (2S LiPo) or even 10-14.4V (4S LiFePo). All components are currently specified to run in the range of 3-16V.
  • The "brain" is an ATTINY84A, although I think I should be able to swap it for an ATTINY841 just as well.
  • The legwork is done by two ST LED2001 buck controllers, which, according to the manufacturer, should work up to 4A although I'd rather stay in the range of 1A-3A anyway. There is an extensive discussion of the driver IC over here but the main conclusion is that at 4A it needs proper heat sinking and that's why they stopped developing their ideas any further.
  • I want the two drivers for two LEDs, so that I can have a "spot light" and a "flood light" option, and I'd like to control them independently.

My questions for the "brain" part:

  • I'm planning on using a MP1703A to power the brain at 2.8V, see IC1. The datasheet says it's happy with one 1uF cap either side, so I put in C1 and C2. Should be enough, or is it advisable to make them a bit bigger?
  • I added a jumper switch JP3 so that the MCP1703 can be disconnected during programming. Also I hope this will make sure that the LED drivers will not start drawing 3A each from the programmer. Should work, shouldn't it? Is there an easier solution?
  • Around the actual ATTINY84A I've got another 0.1uF decoupling cap (C3) and a 56k pull-up for the reset pin (R4). This should be enough to get the microcontroller running, shouldn't it? Is a 56k pull-up okay? The datasheet says 30k-60k is recommended, but not more than 10k if debugWIRE is used (never heard of it) and at least 4k7, which I find a bit confusing to be honest...
  • Speaking of pull-ups, there will be a cable to two switches (JP2) that connect to pins 7 and 8 (PA5 and PA6) of the ATTINY. I'd ideally use momentary switches and the internal pull-ups of course, but I'm wondering what would happen if I put the same board to use with latching switches? Wouldn't there be about 100 uA constantly wasted in the switch while it's on? Any ideas about that? (Although, I guess I could live with that compared to what the LED drivers use :slight_smile: )
  • On pin 12 of the ATTINY (PA1) I've got a circuitry to monitor the battery voltage. It starts off with a 3V Z-Diode (D1), so instead of 3-16V I'll see 0-13V (at least that's the intention. If the voltage drops below 3V, everything will shut down anyway and I wouldn't want to read the voltage anymore, although I don't really know what sort of measurements PA1 would get in that case). Next I've got a 10M, 2M7 voltage divider (R1, R2). These should get the 0-13V down to 0-2.76V - a perfect match! The small 0.1uF cap C4 should make the measurements stable and the overall thing should draw no more than 1 or 2 uA, worst case. Does this all make sense?
  • Pins 11 and 13 (PA0 and PA2) of the ATTINY go to two TMP36, which, in the SOT23 package have a shutdown pin to reduce the current consumption. I'll use these to measure the temperature of the LED's, but I'll only check every couple of seconds, so pin 2 of the ATTINY (PB0) is connected to the shutdown pins. Should all be sound, shouldn't it? (I have previously considered using the same output to en-/disable the battery voltage measurements, like e.g. here, but I'm not entirely sure I properly understand what's going on there. MOSFET's are still a mystery to me!)
  • I hope I also connected all the relevant pins to an ISP header (JP1). As mentioned I'd envisage that JP3 would be opened while programming so that most of the circuit would be disconnected. Still High Voltage programming is probably out of the question. MISO and MOSI are simultaneously used for the aforementioned switches, shouldn't cause a problem. I wanted to use SCK to have a small status LED on the board (LED1 and R3). After lots of puzzling about whether this leads to conflicts and why the LED is connected differently on every single Arduino board, I came up with the solution involving a small MOSFET (Q2) of type FDV303N. I hope this will ensure that the LED is suitable isolated from the SCK line and programming will not cause any troubles at all?

That's almost it, I'm not going to ask about the "legwork" in the two buck converters (if anyone has a better suggestion than an LED2001, that would run of about 4-15V and drive LED's at around 2-3A, please let me know!)

Two more questions, though:

  • At the very beginning of the circuit I've added a PSMN0R9-25YL as Q1, a N-channel MOSFET, which is supposed to act as reverse polarity protection. With V_DS up to 25V and V_GS up to +-20V along with a low threshold voltage around 1.5V, miniscule R_DSon and ample current capacity, this should be a suitable MOSFET for the job? Did I miss anything?
  • I've added two more of the aforementioned MOSFETs as Q3 and Q4, because the LED2001 unfortunately has quite a noticeable quiescent current. So apart from the two PWM lines coming from pins 5 and 6 (OC0A and OC0B) of the ATTINY, there are also two more signal lines coming from PB3 and PA3 and going to the MOSFETs Q3 and Q4, which will switch the bucks on or off. First of all, R7 and R10 with 470 Ohm each should make sure there is not too much current sucked from the ATTINY into the MOSFET gate capacitances, shouldn't they? And the overall idea should at least work in principle? However, the N-channel MOSFETs mean that the buck converters and the "brain" have ever so slightly different grounds. What will the PWM signals think of that? In my limited understanding of electronics, everything should still be fine, but maybe I'm missing something?

Well, thanks for reading all this. Any helpful comments or suggestions even for a single bit of this long post would be greatly appreciated! Otherwise I'll just go ahead and waste my money on PCBs that turn out to be completely useless...

I'm won't attempt to analyze your circuit and I don't have any experience with the LED2001, but I don't think you need the MOSFETs. The dim-control input should give you anything between off and full-brightness.

I've previously soldered individual boards together with some wires'

If you've proven the circuit works when hand-wired, the same circuit should work on a PCB (as long as you don't make any PCB layout errors).

Input from batteries, likely in the ranges of 4-6V (4AA)

AA batteries have a rating of about 1 Amp-Hour with a heavy load. How much battery life do you need? ...You'll will get more current out of the buck converters than you put-in (and lower voltage out than you feed-in).

Like doug I don't see the purpose of Q2, Q3, Q4.

You have very high values for the resistors in the voltage divider R1 and R2. 100K and 27K would be better. C4 shouldn't be required and your use of D1 isn't going to give you the clean voltage drop you're expecting. Zener breakdown voltage varies by current and your current is really really low right there; that behavior of the zener should be documented in the datasheet with an amperage v. zener voltage graph.

IMHO it's easiest to just remove the ATTiny from the board when programming at that eliminates any question of what will happen when you're programming it in-circuit. But if you need to remove power to the ATTiny when programming you should just remove/disconnect the battery with JP3 instead of disconnecting the output from the linear regulator. A battery switch will be much more useful anyway.

You might not need anything other than C1 but I always like to have another spot available, in parallel, for an electrolytic capacitor "just in case". That would be referred to as a "bulk capacitor" and it will ensure that any surges caused by your LED drivers will not affect power into the digital/analog side of your circuit. Doesn't hurt to have it when you don't need it, but really hurts not having it when you do need it.

When you select your battery it should be only a few volts higher than your LED forward voltage. While you are using switching drivers you'll still get more efficiency when that battery voltage is close to the LED voltage - the driver doesn't have to switch so much so it won't get so hot.

When you're making your schematic it's much cleaner to (for example) just create a short line off the ATTiny, LED driver, linear regulator, etc. and then label it on each end. Having the actual connections strewn across the schematic makes things very messy, makes it harder to adjust, and doesn't improve the readability.

The problem with "testing the circuit when hand-wired" is that most components are only available in SMD packages, which will be tricky to hand-wire and test.

About the MOSFETs:

  • Q1 is intended as a reverse polarity protection, and there ought to be something here! I hope the chosen MOSFET is fine?
  • Q2 seems necessary to switch on and off the small status LED.
  • Q3 and Q4 are indeed a bit superfluous, but let me try to explain. Since I'm running on batteries, I obviously do not want to run both buck converters at full power the whole time. That's what the switches will be for, I'll have several not quite so bright modes. PWM dimming will get me from 0 to 255 just fine, but if I run one of the bucks at say 100mA and the other one is off, it will still draw a quiescent current of up to 2.5mA, according to the data sheet. Even worse, if I switch both bucks off and forget to unplug the battery, it will be flat in not very much time. That's why I wanted to put in Q3 and Q4. Does it make more sense now?

Regarding the voltage divider for the battery measurements, I was mostly following the ideas of » Measuring the battery without draining it » JeeLabs and tried to reduce the current "wasted" on voltage measurements by increasing the resistors and throwing in the cap. I didn't find a diagram about Zener breakdown vs. current, but will rethink at least this part a bit, thanks!

About programming in-situ: Since most of the components (in particular the LED2001) are only available in SMD, I thought I might as well take an ATTINY in SMD package and reduce the overall size of the circuit. Then again, through holes could save me the programming header, the jumper and Q2... maybe I should reconsider this indeed...

About JP3: (only relevant if I stick with my original plan of programming in-situ) The datasheet for the MCP1703 says that the maximum voltage rating on any pin is about the V_IN voltage plus half a volt or something. So if the current is suddenly coming the other way, unspecified things might happen. Might be better to cut it off, I thought?

I'll put in another bulk capacitor. But should it be "before" the MCP1703, and parallel to C1 as your post suggests, or after? I'd think after, and therefore parallel to C2/C3?

The manufacturer website for the LED2001 has a flashy online-tool that spits out efficiencies, bandwidths and phase margins (whatever they are) for a given configuration of capacitors and inductances and so on. I'm aware that the input voltage should be as close to the output voltage as possible, but according to the manufacturer tool the efficiency in general appears to be close to 90% most of the time.

By the way, my understanding of the "bandwidth" of a buck converter is that PWM pulses that are shorter than this bandwidth will not be sufficient to turn on the output current, and for some converters high PWM frequencies and low analogWrite() values will therefore just not work. Is that about right or do I have to read a pound worth of electronics textbooks before I'd be able to understand the relation between them?

Regarding the voltage divider values - I won't argue with the Jeelabs guy.

Regarding the zener, see http://www.nxp.com/documents/data_sheet/BZX84_SER.pdf figure 5. Using the example of the 3.0V zener you're using you'll see that the zener voltage is about .7V with the 10-7ma current going through your divider.

The bulk capacitor should be "before" the regulator.

Regarding JP3, I dunno, I've just never had a problem with the ICSP messing up my regulator. I'll let someone else field that one.

The ATTiny's PWM frequency is ~500Hz and the LED2001 switches at 850KHz. There's not a problem there.