[WIP] 15mm PAM2803 w/ ATtiny13A rough layout / possibility

Wait a minute! Are they serious? 1AAA 3W LED Voltage-step up 10mm circuit board (19 modes 3 groups)

Can you really get 800mA from a single AAA cell?

Sounds like it functions but still a wip so probably some unknowns for discovery in field testing and obvious questions like a bleeder resistor for LTC (maybe in 2cell lights bypassing boost IC).

Hmm. The pictures are low quality, but I see on top:

  • inductor
  • SOIC8 IC (same physical size as common ATtiny or PIC MCUs)
  • SOT23-3 (identified on PCB as Q2?)
    and on the bottom:
  • SOT23-3 (at top)
  • Capacitor (identified as C1, top right)
  • Diode (D2 on left)
  • Capacitor (C2 on left)
  • Diode (D1? on right)
  • SOT23-3 (Q1? at the bototm)

Transistors are often packaged in SOT23-3, but that seems like a lot of transistors. Sometimes “Modes chips” (simple purpose-built PWM flashlight driver controllers) are packaged in that form factor as well. MCUs, MOSFETs, boost controllers, and many other things can be packaged in SOIC8. We can assume that this on is not a MOSFET since all the pins aren’t together on the PCB traces.

This is at least vaguely interesting for now, but not enough for me to order some.

Meh. It’s different and using 100% made up [eg imaginary] specifications. Who knows what it is.

To get 800mA output the driver should need >2A input. This is quite possible with LSD NiMH AAA, but not with Lithium primary AAAs.

Thanks a lot HQ. I remembered some of that when trying to get STAR ontime working the last time, but clearly not enough! I even tried Minidrv since I knew you’d been using it for testing and it’s so straightforward. I was missing something or making a mistake. Who knows where, I didn’t save the code. Doesn’t matter, it’s working now (STAR ontime).

I went ahead and tested about 20-30 mode switches on 2xAA. They were resting at >1.2v each. Nothing bad seemed to happen. :slight_smile:

  • Sorry I got confused about the PWM freq stuff. Maybe we should try PWM=0/255. That’s “a thing” with either fast or phase correct, but I forget which. If necessary a new firmware could be written with soft-PWM to go lower.
  • Offhand the datasheet seems clear about the PWM calculation. w/ a prescaler of 1 FastPWM = clk/256. That said I am very rusty at the moment and this might be a better question to ask in a firmware thread.
  • IIRC increasing the PWM freq can significantly affects the response curve for the thing receiving the PWM. In other words we get “mode compression” where the modes shift towards high or low.

Disclaimer: I didn’t compare “Phase Correct PWM” with “Fast PWM”. Just looking at Fast PWM, 0/255 = ~8mA input current while 1/255 = ~16mA input current. On the output side that seemed to be ~1mA vs ~2mA. All of this was measured using a free HF DMM set on the 10A scale, so very rough measurements. I’d say that it’s still probably not low enough to really be a ‘low’ moonlight… but I didn’t try it in a flashlight or in the dark.

I think this is the same driver HKJ has tested here
It’s only 1xAA.

800mA with 1.5V perhaps, but not with a single AA/AAA. Extrapolate the light blue line (current in) to 1.5V and you would need about 3.5A input current without voltage sag to get an output current of 800mA…
With a bench power supply it might work.

As far as I remember I checked all of HKJs driver tests when looking for a good boost driver. The drivers based on the PAM2803 (nanjg110 and our Fasttech-driver, HKJ tested both) had a better efficiency than this one and were only topped by the LD30 which is much more complex. But I did this long before this thread started when I hadn’t hoped to get a driver with good modes.

If you want to compare drivers you can find a remarkably long list of tested drivers on HKJs website
www.lygte-info.dk/info/indexLedDrivers%20UK.html

Very good. As I said I was very reluctant to burn my scarce PAM2803 (a real nuisance that they can’t be sourced in small numbers), but that would give me enough hope to try a built without the resistors.
I’m yet unsure whether I will remove them from my design as long as nobody can tell us for sure what they are for in the FT-driver, but it would certainly free some space. The 15mm driver is very tighly packed, small pads, and just so to avoid clearence errors. Not really easy to build…

.

That’s a good one, I had completely forgotten about this 255-not-truly-on / 0-not-truly-off issue. And I had only tested FastPWM modes with 3 frequencies, not PhasePWM. No reason behind it, was the quickest way to programm. Will try other values.

Just for the record: my results (25/15/9mA) are LED current, not input current. Measured with a shunt between driver and LED. Darn bright.

Calculations are fine, I had made a table for comfychair ages ago, will include it below.
37.5kHz would be possible only with FastPWM/divider1/9.6MHz and that might be the highest frequency. Soft PWM is above me.

PhaseCorrect FastPWM
kHz CPU freq divider fuse CPU freq divider fuse
1.2 kHz 4.8 MHz :8 0x65
2.4 kHz 9.6 MHz :8 0x6a 4.8 MHz :8 0x65
4.7 kHz - - - 9.6 MHz :8 0x6a
9.4 kHz 4.8 MHz :1 0x75 - - -
19 kHz 9.6 MHz :1 0x7a 4.8 MHz :1 0x75

CPU frequency is set by the fuse (Low Fuse bit 0 and 1) and “#define F_CPU” should be set accordingly.
PWM is set by TCCR0A (where 0x23 is FastPWM and 0x21 is PhaseCorrectPWM)
The divider is set by the fuse (Low Fuse, bit 4) and can be :1 or :8

This way you can reach 19 kHz with Phase correct PWM and Fast PWM.

In addition you have the prescaler (TCCR0B) which is not the divider. You can combine divider and prescaler and set them differently.

  • Ah, that’s right. I remember referencing your table in the other thread. :smiley:
  • I’d rather avoid getting into soft PWM because (a) that’s firmware stuff I’d rather avoid and (b) I’m pretty confident that it will increase power usage by the ATtiny a lot.
  • Caution made plenty of sense in that case. I’ll be sure to post here if I burn one, but it seems fine so far. Looks like PAM2803 has gotten cheap on AliExpress: $0.20 USD /ea in QTY=10 seems good to me!
  • In fact, with cheap PAM2803 available in reasonable quantities the door is open to fully scratch-built drivers. Too bad that “good” inductors cost as much as the whole FT driver. I wonder how much advantage there is to using one which is properly specced. I assume that the one on the FT driver saturates or acts badly a lot of the time.
  • TK points out over here that LVP can still be useful for a AA boost driver. Using “low” modes extensively can easily pull batteries way, way down without the user noticing.
  • I think that these drivers may end up being reflow only. Proper hand-soldering pads for the inductor will eat a lot of space.

OK, pursuant some of those things… v22 switches to the Coilcraft XLF4020 footprint (here is the Eagle part I created for it - note that the tDocu markings are the full maximum 4.3x4.3mm the datasheet allows for). This is by no means a final layout; it is just food for thought. RSENSE has been reduced to 0603. R1 is under the MCU, R2 is to the right of the MCU. They should be spaced properly for the clip. The XLF4020 footprint should accept the inductor from the FT donor board. Looks like I forgot to hook up the OTC.

As can be seen, there is plenty of room for LED- but not enough room for LED. Looks like progress to me though. Ah! I should just move C (OUT) to the left. LED can be located between C (OUT) and the diode. Hmmm :slight_smile:

EDIT: I forgot to mention (a) doesn’t pass DRC but it’s close (b) apparently I’ve been using a 0.75mm keepout for this project for a while.

Revisions:

  • Passes DRC.
  • LED+ and LED- added
  • OTC hooked back up

I still think that we can do much better than this.

Is it possible to hand solder by heating a pad connected to one that is obscured?

For most folks? Not a good idea. For a very determined individual? Maybe. My biggest concern would be delaminating the PCB. The pad on the left is easily doable - that’s basically just a normal exposed pad like any other component. If the layout doesn’t change any I think that there is space to expose copper for the right-hand pad as well.

Determined he is, clever he is not. I think Yoda needed a good flashlight. Thanks Alex, I’ll try it.

LVP included, very well.
The OTC does not block the SOIC-clip?
I had worked with a similar inductor-part before, but even if reflowing: you can’t see whether the solder is done. The inductor is all copper and ferrite and eats a lot of heat. That’s why I used these halfmoon pads which are just so much to the edge that you can see the solder paste and the reflow result.

Just for the record the PCB Layout Guidelines from the PAM2803 datasheet:
“The input capacitor and output capacitor should be placed respectively as close as possible to the input pin and output pin of the IC; the inductor and schottky diode should be placed as close as possible to the switch pin by using wide and short traces for the main current path; the current sense resistor should be placed as close as possible between the ground pin and feedback pin.”

When I stare at my 15mm board the design is really not prone for adapting to the LVP. scratch head

Any idea at which voltage the LVP should cut off in low mode?

I’m busy til sunday, but can’t wait to crash-test some drivers.

  • Good point. The OTC probably does block the clip. I forgot that my “guide” measurements are for a closed clip, I need to allow for room to put the clip in place. This OTC is in the same place as earlier versions… but I haven’t yet populated the OTC on the v18 I built. Oops!
  • The layout guidelines just say “as close as possible” - I think my parts are pretty close together since they are all under 15mm. :wink: On a more serious note, they cover 5 components in their placement guidelines. As far as Cinput and the inductor, they are more than close enough. The Schottky diode is a little farther away but <6mm. The sense resistor is about 3mm away from it’s closest possible placement. Coutput is by far and away the worst offender here at maybe 8mm away from it’s best possible placement. I’ve [apparently] already gotten away with that on the existing v18 design and I continue to not be too worried about it. Take a look at some of these boost IC evaluation boards. They certainly vary, but some of the placements are actually quite far apart. … all that said, I do plan to thicken traces and improve the layout where possible, unless I just come up with a whole new layout.
  • RE: “the design is really not prone for adapting to the LVP” - (a) Your current board has many more components than my previous board! (b) To adapt my own board I first added the LVP resistors to the schematic and started poking around. It did not look good. Next I just ran the command “ripup;” which rips up all traces. At that point I scooted/rotated things around until they looked better, laid down a few traces, then shuffled some more. Using the schematic really helps IMO.
  • Good cutoff’s would probably be 1v and 2v based on TK’s thoughts and HKJ’s measurements. [WIP] 10mm DD+single-7135 driver: double sided 10440 torture for Dual-PWM - #128 by ToyKeeper

While fast PWM 0/255 does generally work, it has also been rather unstable on every device I’ve tried. As one example, I was getting 3 lm on a full cell, 0.1 lm at about 3.9V, and barely enough to see the LED at 3.6V. Nothing at all below that.

Phase-correct PWM at 1/255 is much more stable at different voltages.

Then again, I haven’t tried anything remotely like this boost driver. It might behave very differently.

At a guess… If it has only a FET and no constant-current channel, moon mode probably isn’t feasible. OTOH, you might be able to add a separate moon mode with a simple resistor from a MCU pin to the LED. The MCU should be able to power the LED directly. No PWM necessary, and I think the MCU can even go to sleep with an output pin high. So, it might be pretty efficient.

Just an idea. You know, for when you find extra room on the already-cramped board. :slight_smile:

TK, I’d say that this is pretty different from the FET/linear drivers you are accustomed to. Like 7135 driver the base circuit here (from the PAM2803 datasheet) attempts to provide constant current. Unlike the 7135 this circuit has the ability to pull more power from the battery as input voltage drops. With only 1xAA ouput current is not actually constant AFAIK, but I speculate that results will be better than DD & linear drivers. I could be 100% wrong about this next bit, but I suspect that having a low-duty-cycle PWM (like PWM=0/255 FastPWM) will probably allow the PAM2803 to perform a good bit better than the datasheet shows. (Better in this case meaning more able to drive the 0/255 at a consistent level.)

RE: driving the LED from an MCU pin w/ resistor. That’s an interesting idea for this situation. When the normal output PWM channel on the MCU is turned completely off the PAM2803 will boost to almost exactly 5v and stay there. I’m assuming that this should give much more consistent output than any DD or linear driver attempting this approach. Choosing a load resistor is a simple matter of using any online LED calculator, they all expect a constant input voltage and that’s what we’d have here (5v).

Earlier today I realized that I had an important question for you RE: this driver. What’s the state of offtime without the cap? I know it’s workable, but what are the details?

Offtime without the cap generally works fine as long as you don’t care about having more than “short” and “long” and don’t need to tweak the threshold between the two.

The attiny’s SRAM basically has either decayed, or it hasn’t. At least, when looking at a single byte. In my experiments, this happens at anywhere from 0.3s to 4.0s, depending on how long the rest of the circuit takes to settle. On a nanjg driver it’s about 0.5s. On a FET+1 it’s generally about the same. But if there is an OTC, and that OTC is charged, the SRAM decay doesn’t happen until after the OTC has discharged most of the way.

In general, most of the SRAM bits decay to a “1” state. So, set a byte to 0, read that byte on boot, and if it’s still 0 you know the light hasn’t been off for very long.

IIRC, something like two thirds or three fourths of the bits decay to a “1” state. So it’s possible that the selected byte could just happen to decay to all zeroes, but it’s very unlikely. The chance is something like 1 in 20,000.

Using this trick to store values between boots is somewhat more risky if there is no OTC or other power source to sustain the data for a few seconds. The long/short detection byte might be all zeroes, but the data byte(s) may have had a bit decay. The time window for this is pretty short though, and risk can be reduced by using more than one detection byte… Still, any genuinely important data should be stored somewhere more stable. Or use a different method to measure time, and only trust the decay-prone data when the time is safely under the limit.

That’s probably more detail than necessary, but hopefully it gives you more of an idea what to expect. The attiny can hold values in SRAM until it runs out of power from other components, and this is around half a second on most BLF drivers.

So the 2803 has both a switch pin and Vin, can pwm be applied to the switch obviating the need for the fet?

@all - measuring input current on my HF DMM it seems really nonlinear vs PWM. Could be PWM confusing the DMM though.

Heh, I’ve had the same genius idea myself several times. Eventually I have to snap myself out of it - the unfortunate and in-hindsight-obvious answer is no. The MCU won’t run if the PAM2803 shuts down, it is bootstrapped on the PAM2803’s output.

I suppose it actually isn’t obvious if you haven’t read the OP in a while or aren’t familiar with the term bootstrap or it’s use in this context… OK, so here we go. The MCU (ATtiny) won’t run on low voltages like 0.9v, but the PAM2803 will. We currently have the Enable/Shutdown pin on the PAM2803 tied to Vinput, so it turns on as soon as battery voltage is applied. The PAM2803 uses a sense resistor to do CC (constant current) output, so once it turns on it will drive the LED at the current set by the sense resistor. (On 0.9v input it won’t do a good job, but it will try). Generally speaking this means that we’ll get something like 3-4v output from the boost circuit (to match LED Vf at the set current). The MCU is attached to the same output as the LED, so the MCU doesn’t start until after the PAM2803 starts boosting. The LED is hooked up through a transistor and once the MCU is up and running it can PWM that transistor. During any time period where the LED is not hooked up the sense voltage drops to 0v. The PAM2803 will attempt to increase the sense voltage (eg the sensed output current) by increasing output voltage. We depend on the PAM2803’s overvoltage protection here: the PAM2803 has OVP set at approximately 5v. The peaks are within the MCU’s regular maximum of 5.5v. If we were turning the whole PAM2803 off here it would be like blipping the clicky switch.

Other stuff:

  • The “Switch” pin isn’t what you think it is. Switch is a pin which the PAM2803 will momentarily connect to GND as part of the boost circuit’s operation. “Shut Down” / SHDN is the pin which would turn the chip off (and we can’t use for the above reason).
  • I had something else…