Attiny25/45/85 FW Development Thread

OK, bent up the gate leg of the FET and wired in a gate resistor.

End result is better than with the snubber. Turn-on time is 5 times slower, 500 ns vs. 100 ns. So PWM faster than ~4 kHz will not turn the emitter on reliably at 1/255 PWM duty.

From yesterday, basic A6 driver, short emitter wires:
(Yellow = FET drain, Blue = MCU pin 8)

From yesterday, with RC snubber added across FET:

Now with Rgate = 100 ohm added, and snubber removed:
(Purple trace is the FET gate voltage.)

Turn-on without Rgate:

Turn-on with Rgate:
(Note time scale is 500 ns/div, compared to 100 ns/div above).

Sorry, should have added above, the top three scope shots are of the turn-off with various configurations.

EDIT: Photo of the crude test setup with the gate resistor in place:

Well, I have to create a trouble-some light at this point. I got my JM07's driver out now - I have the 12K resistor on the gate and dobled up C1 cap and it works fine.

Should I remove the extra cap and see if the problems come back? If so, then try it with leaving the 12K resistor on?

This is what it looks like:

Might be better starting with a clean driver. I got to reflow up a few more anyways... What do you think?

PWM will likely remain in the range of 9 kHz to 31 kHz (usually 15-19 kHz). However, it’s not required to have level 1/255 working; it’s a simple enough matter to use a higher floor. I can adjust the output calculation scripts and PWM levels without too much trouble.

Current FET designs actually light up at PWM=0/255 in “fast” mode at 16 kHz. That’s basically half a frame, or … (quick napkin-math estimate) probably around one eight-millionth of a second. Ish. It’s generally considered a harmless quirk, but fixing it would make some of the code a little easier.

In my 85 firmware, I stopped using PWM "fast" mode - only use PHASE mode now, but Phase mode is still quite fast, think in the 15-19 kHz range. I dunno if we want to return back down to 4 kHz or lower...

Yeah, phase-correct mode on tiny25/45/85 is pretty awesome. It runs at precisely 15.6 kHz with nearly zero variation between units, it has none of the side effects of “fast” PWM, it’s fast enough to be invisible during use, and only a tiny slice of the population can hear it.

The main downsides are that it’s not quite beyond human hearing range, and it requires running the MCU at 8 MHz instead of under-clocking for lower power. I’d prefer 10 MHz / 19.5 kHz instead, but that’s not really an option with current hardware.

The common nanjg 4.5 kHz PWM is both audible and visible during normal use. :frowning:

I’ve already done experiments on FET-driven moon modes with extra-fine pulse time adjustment. It didn’t work very well, and varied quite a bit with cell voltage even after voltage-adjusting the pulse timings as much as the attiny allows.

In contrast, a 7135 chip pretty much “just works” with no fancy algorithms. “Boring” can be a good thing.

If moon is the only non-FET mode desired, it’d probably work to simply replace the 7135 with a resistor and drive the LED directly from the attiny pin in moon mode. It would only work for moon mode though, not any of the other low/med modes in the 1 lm to 150 lm range. So, those would have to use the FET and would have their efficiency reduced.

I would suggest putting the driver back to stock and make sure it malfunctions. Keep in mind the ringing is much worse with a fresh hi-drain cell. Although not shown above, I did confirm this with different types and state-of-charge cells.
You can leave the 12 k though, it should not come into play.

Then you have two options.

The easier option is to add the snubber. Dead-bug style across the FET. This option does not affect the switching frequency, if you have any reserves about the PWM frequency limitations.

Second option is the gate resistor. Only one component to add, but more difficult. It is more efficient at lowering the turn-off spiking/ringing. Do not be too much concerned about the lower turn-on speed. For reference, with a 100 ohm resistor, my FET still switched about 15 times faster than a 7135. Of course you can always use a smaller resistor. Smaller resistor = faster FET, at the expense of more ringing.

How does one leave a FET gate drive floating? Since it must be 0-255, what value would be floating? Moon mode only uses the 7135, so the FET PWM output is set to 0, and typically the 7135 PWM output value I use for moon mode is 3. The MCU's have internal pull-downs on I/O pins as I understand it. These MCU's are quite advanced.

Section 10.1 of the Data Sheet on the 24/45/85 (http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf) says:

All AVR ports have true Read-Modify-Write functionality when used as general digital I/O ports. This means that

the direction of one port pin can be changed without unintentionally changing the direction of any other pin with the

SBI and CBI instructions. The same applies when changing drive value (if configured as output) or enabling/disabling

of pull-up resistors (if configured as input). Each output buffer has symmetrical drive characteristics with

both high sink and source capability. The pin driver is strong enough to drive LED displays directly. All port pins

have individually selectable pull-up resistors with a supply-voltage invariant resistance. All I/O pins have protection

diodes to both VCC and Ground as indicated in Figure 10-1. Refer to “Electrical Characteristics” on page 161 for a complete list of parameters.

I can't make all that much sense from all those posts, sorry.

About the flash going into moon mode, the 10K or 12K FET gate resistor solves it - been using it for months. Going back to PWM rates even under 1K is going backwards. Hope the high PWM rates don't have to be sacrificed to get clean pulses.

Decided to button up the JM07 now rather than experimenting with it. Started on a BLF SD10 (Lumintop) upgrade and thought I'd use it's new driver for the R&D. I had it populated, added the 12K FET gate resistor, programmed the 85 (Narsil), and wired it up, sandwich style on the stripped stock driver. Well, the darn thing works perfectly now - didn't need a cap or anything. Think this is the first one that didn't need a cap to change modes reliably... Only difference is that I'm supporting a green indicator SMD LED on pin #3 of the MCU. The SD10 light has a white/transparent button and had the green LED already there, so I "air wired" a 470 ohm resistor between the LED and pin #3, and it works great! In Narsil, I added the support of the LED, just ON or OFF. It's used as a locator light when the light is OFF (OFF by e-switch, not power), and will also blink for LVP, and blinks when blinking of the main LED is done for various reasons.

Yeah, I did that like a year and a half ago. It ramped between 16 kHz and 2 MHz depending on voltage. It was kind of neat, but it didn’t work anywhere near as well as a 7135 chip.

Agreed; it’s a bit hard to follow stream of consciousness text with one sentence per paragraph.

About the moon flash (the turbo-to-moon flash on clicky lights), it appears to be outside the attiny’s ability to control and can only be addressed in hardware. Even just changing to a different model of FET seems to help. Is that the one you were talking about, or is there another?

“A bit different” is one way to describe it. The code is dramatically different depending on switch type.

There are currently 13 e-switch firmwares in the repository, including three I made. Tom E’s Narsil is the most full-featured one though.

The ringing at the end of a full-power pulse still applies to these, and some firmwares take steps to de-bounce the e-switch signal when the wires are extra-long or thin, but at the moment I can’t think of any other stability issues encountered during actual usage. I’ve left a variety of them running for months at a time with no issues, as have other people around here. Dale has some running at 10,000+ lumens. It’s kind of amazing that a 17mm driver can handle ~40 amps.

I have been fighting with my first 25 driver and it all went to hell when battcheck25 did not work, now I have to removed the MCU and program it and put it back on just to run battcheck. Then do it all over to flash Bisto. I would love to see a built in programmable LVP. Maybe run a battery down to 2.9 volts, pop it into the light and enter config mode and tell it that it is now the shutdown point… Anyone considered this option?

I’ve been doing a lot of work on the 85s but I can’t help you here because I do not PWM the FET. My 17mm FET driver has, besides the FET, 8 x AMC 7135s which I find plenty enough for all modes under “full blast”.

Mike - ahh, always forget bout you… Of course! Are your designs (boards and firmware) open/available? The board design may be so different, there’s not much in common. I don’t use PWM’s on the FET much - for typical 5 modes, only mode #4 uses PWM on the FET. I can cause hickups going from full FET mode, to OFF, to moon mode on the 7135 for example, so PWM’s on the FET is never used in this sequence.
The bank of 7135’s typically means the 2nd highest mode is off the 7135’s, while ours is PWM on the FET — that’s about the only difference, but still, a big difference. Going to 7 modes or more would be more PWM FET modes.

I’d like to see this design from you. We need all the help we can get. :wink:

Wouldn’t it overheat at some point? I think that somewhere in the middle range it would need to get rid of close to 1W. Hardware is not my field but I expect that would require some reasonably good heatsink or a different package (or both). And if I’m not completely lost, this could be avoided by switching to PWM above perhaps 300mA or so.

No, not all - negates advantages e-switch firmware has, plus I've seen these glitch's happening with clicky lights/firmware as well. The BLF X5/X6 v2 problems were apparently solved by changing the cap from 10 uF to 12 uF. On clicky switch lights w/25 I've built, I usually go with 2 stacked 10 uF caps to fix the issues.

You have to be very careful operating FETs in their linear region. Most FETs are only specified for pulse/saturated operation. When running them in the “linear” region you can run into all sorts of issues. Hot spots can develop and kill the device, etc. Check the safe-operating-area specs/curves carefully… I know a lot of people were unpleasantly surprised when they tried to use the wrong FETs in adjustable power supply load testers.

I’ll have to take your word for it. My worry was that you’ll take the power being dissipated by eight 7135 and now have it all in a single FET. It seems like a lot to me but I’ll admit it’s just a very rough guess, I haven’t looked up any specs. I might try it and come back with pictures if I burn something :slight_smile:

Granted, but it’s convenient because you already have a heat sink for the LED anyway. Also, it’s not obvious to me that running the LED at very high current is much worse for efficiency than wasting power in the FET or 7135s. This probably depends a lot on the LED involved.

Anyway, how would you go about it? All I can think of for good control over the whole range is to build a crude 1bit DAC for the FET gate. I think it could be really poor if feedback from one of the ADCs is used to hold the output steady instead of having to rely on precalibration.