Attiny25/45/85 FW Development Thread

1911 posts / 0 new
Last post
ToyKeeper
ToyKeeper's picture
Online
Last seen: 4 min 52 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10231
Location: (469219) 2016 HO3

The SU should work fine, but it’s bigger than the SSU. It might not fit onto the usual driver layouts, or it might need its pins bent underneath.

The temperature threshold can be defined in the code (and already is), but I’ve found individual variation between attiny units is generally too wide to make a “factory default” very useful. I calibrated one carefully, flashed the same firmware on another unit, and it started stepping down at room temperature.

Mitko
Mitko's picture
Offline
Last seen: 4 months 2 days ago
Joined: 09/19/2014 - 05:20
Posts: 1537
Location: Bulgaria

Thanks TK!
Will i meet any issues using Attiny 25-20SSU instead of 10SSu?

ToyKeeper
ToyKeeper's picture
Online
Last seen: 4 min 52 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10231
Location: (469219) 2016 HO3

I doubt it matters much. The data sheet says they’re the same package but 10SSU runs at up to 10MHz with a voltage down to 1.8V, while the 20SSU runs at up to 20MHz with a voltage down to 2.7V.

It’s usually abbreviated here as attiny25 (20SSU) versus attiny25v (10SSU).

Most drivers are using the lower-voltage version, attiny25v. But I have an early one from RMM using the non-V version, and it seemed to work fine too. It just runs the risk of failing before LVP is complete. I don’t know what happens if the attiny voltage gets too low to function.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

Last night I tried a Attiny85 on a PD68 Double-down 17mm board for the first time and couldn’t get the 0.1 uF cap across the MCU grnd and VC pins to fix the problem. Also adding the stacked 2nd 10 uF cap didn’t work as well.

I’m testing the driver on the bench, even using a low performing under charged TF Flame cell, and the highest level modes don’t work, and strobe modes don’t work as well (strobe uses full FET). Not sure if it’s just FET full mode, or also the 30%-40% 2nd high mode also. I’ll try another 0.1 uF cap to see if it’s just the cap – could be.

Boy, sure wish there was someone helping with this trouble-shooting of the 25/45/85 problems. Yes – I’m begging for help again. Also wondering if anyone else is having these problems. Not sure if no one else is working with these MCU’s or just being silent on it.

This behavior of losing all high FET modes is one type of failure. The other is more subtle, where changing modes seems to work for a while then, occasionally resets the MCU – I can tell because in my Narsil firmware, I blink twice with low power on startup.

vex_zg
Offline
Last seen: 1 year 9 months ago
Joined: 08/10/2014 - 11:08
Posts: 420
Location: Sweden

TOM E, did you try adding a 10uF cap across vcc and gnd? In an investigation thread regarding the FET induced spikes that was the preferred solution.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

Ohhh? Shoot, missed that. It was indicated to me to keep the cap as small as possible, interesting… I’ll try that tonight. thanks!! Do you have a thread link, or search criteria I could use to find that thread?

Mitko
Mitko's picture
Offline
Last seen: 4 months 2 days ago
Joined: 09/19/2014 - 05:20
Posts: 1537
Location: Bulgaria
Quote:
Not sure if no one else is working with these MCU’s or just being silent on it.

I do, actualy i have a builded driver with a Narsil firmware and initial test show its working but i am quite busy lately at work, family and those hunting flashlights

BTW Tom, what had happened with that Y3-like firmware? Did you finnished it?

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

Oh boy, refresh my memory… Y3 like? I know I’m behind on many fronts. Work has been, and is goin nuts.

DEL
DEL's picture
Offline
Last seen: 2 years 1 month ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

Tom E wrote:

Boy, sure wish there was someone helping with this trouble-shooting of the 25/45/85 problems. Yes – I’m begging for help again. Also wondering if anyone else is having these problems. Not sure if no one else is working with these MCU’s or just being silent on it.

This behavior of losing all high FET modes is one type of failure. The other is more subtle, where changing modes seems to work for a while then, occasionally resets the MCU – I can tell because in my Narsil firmware, I blink twice with low power on startup.

Hi Tom, I could probably do more to help. I have the test equipment, just limited time and still using 13As exclusively.

As discussed last time, you should not need more than 1 uF for local decoupling (the C spanning pins 4 and 8). So 10-20 uF in the C1 spot and an additional 1 uF directly across pins 4-8 should do the trick. It really is not normal for the 13A to work as well as it does without proper decoupling.

I just recently set up a ‘test-bench’ with an A6 driver in the open. The di/dt spiking/ringing on the FET drain pin is impressive. A second improvement you can try is to add 100-200 ohm resistance between the MCU output pin and the FET gate. This will slow the FET switching and reduce the inductive ringing. Depending on the driver PCB layout you will probably have to cut and scrape a track to fit this resistor.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

Ohh, the resistor has to be in-line then on that trace. Hhmm – I usually use a 10K-12K resistor on the FET gate, but the resistor goes to ground, so I’m sure not the same effect as what you have proposed. Ok, I’ll see what I have, and see if I can do something like that. Think you might have told me the same thing, or something similar wayy back, but I’ve been using the caps successfully up til now, but on the wight FET+1 boards, not the PD68 Double Down’s.

Actually got some 0402 10K resistors, and am using that on this board for the FET gate to grnd resistor because it fits better to the FET pins. Maybe I should remove it for testing going forward — it’s a real PIA anyway to solder it. Basically, can’t see what I’m doing when I solder, and only with a magnifier afterwards can I inspect it. Gonna go back to 0805’s.

vex_zg
Offline
Last seen: 1 year 9 months ago
Joined: 08/10/2014 - 11:08
Posts: 420
Location: Sweden
Tom E wrote:
Ohhh? Shoot, missed that. It was indicated to me to keep the cap as small as possible, interesting… I’ll try that tonight. thanks!! Do you have a thread link, or search criteria I could use to find that thread?

I think this tread should be made sticky, I think lot of people (building FET drivers) have missed this

http://budgetlightforum.com/node/32506

BTW, from my own research gate and gate pulldown resistors increase inefficiency of the FET by increasing time required to turn it on. Only after FET has been turned on, it has low resistance&heat disipation.

In the solution from the above thread, only a new 10uC cap across +Batt and GND was needed. I think the old Cap & gate resistors are to be removed. Check it out, very interesting thread.

DEL
DEL's picture
Offline
Last seen: 2 years 1 month ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

Tom E wrote:
Ohh, the resistor has to be in-line then on that trace. Hhmm – I usually use a 10K-12K resistor on the FET gate, but the resistor goes to ground, so I’m sure not the same effect as what you have proposed. Ok, I’ll see what I have, and see if I can do something like that. Think you might have told me the same thing, or something similar wayy back, but I’ve been using the caps successfully up til now, but on the wight FET+1 boards, not the PD68 Double Down’s.

Actually got some 0402 10K resistors, and am using that on this board for the FET gate to grnd resistor because it fits better to the FET pins. Maybe I should remove it for testing going forward — it’s a real PIA anyway to solder it. Basically, can’t see what I’m doing when I solder, and only with a magnifier afterwards can I inspect it. Gonna go back to 0805’s.

The gate pull down resistor is a good thing normally, a FET gate should not be left ‘flapping in the wind’. One of those components left out for simplicity and PCB size limitations. It may help for the flash some get when going from full-on to moon mode or similar.

DEL
DEL's picture
Offline
Last seen: 2 years 1 month ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

vex_zg wrote:
[
BTW, from my own research gate and gate pulldown resistors increase inefficiency of the FET by increasing time required to turn it on. Only after FET has been turned on, it has low resistance&heat disipation.

In the solution from the above thread, only a new 10uC cap across +Batt and GND was needed. I think the old Cap & gate resistors are to be removed. Check it out, very interesting thread.

True, but the idea is just to take the edge off, not to dampen it so much that the FET is operated any significant time in the linear region. It does put a limit on maximum sensible PWM frequency to use. See the recent BLF D80 driver for an example of how not to do it.

These things are like the suspension on a car. Too hard, or too soft, and you are bound to have a bad time depending on the road you are trying to follow.

EDIT: Thank you for that thread link, but probably the thread discussion was around tiny13a drivers? Seems the 13a is much more forgiving than the bigger MCUs. Local decoupling on any chip like an MCU is basic stuff, it should not be neglected like it has been.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

K, spent some time reading thru the comfy FET scope images thread. Post #44 seems to be the result (??) - 10 uF cap in parallel with the diode. I gotta try this... This is old stuff - I followed the thread at the time, somewhat. With all the pics back, it's once again useful info.

Dunno.... Really not sure if I can understand it all, and if there is a final solution from it. dave_'s posts seem impressive/correct, but no real solution posted as a result?

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

Just fyi, the 10K-12K 0805 resistor I use on the FET gate (to grnd) always works!! No loss of output, definitely gets rid of the flicker switching to moon mode. I've experienced those flicker problems in lights, tore them apart - added the resistor, and then flicker is gone!

Update: removed the 0402 10K resistor, put a 0805 12K in it's place, and with the stacked 10 uF cap, the mode changing problems all seem to have gone away! Dont have any other caps or other extra resistors, just the two 10 uf caps on C1. Testing was on the bench - installing it now in the JM70 light.

FmC
FmC's picture
Offline
Last seen: 8 hours 50 min ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU
Tom E wrote:

Just fyi, the 10K-12K 0805 resistor I use on the FET gate (to grnd) always works!! No loss of output, definitely gets rid of the flicker switching to moon mode. I’ve experienced those flicker problems in lights, tore them apart – added the resistor, and then flicker is gone!


Update: removed the 0402 10K resistor, put a 0805 12K in it’s place, and with the stacked 10 uF cap, the mode changing problems all seem to have gone away! Dont have any other caps or other extra resistors, just the two 10 uf caps on C1. Testing was on the bench – installing it now in the JM70 light.

I have some of these 22uF Caps ready to try, rather than stacking the 10’s, but don’t currently have a driver that is playing up to test one out.

DEL
DEL's picture
Offline
Last seen: 2 years 1 month ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

Regarding the inductive ringing at the off edge of the PWM or strobe pulses, this is what we are dealing with:

Yellow trace is the voltage at the drain of the FET (so 0 V = FET full on, 0 V is at the second division from the bottom).
Blue trace is the voltage at pin 8 of the MCU, same scale.
This an A6 driver from Banggood driving one XM-L2, using a fresh 30Q cell.

We can see some boosting of the pin 8 voltage.
Note the FET drain peaks at > 6 V at switch-off.
Also note the frequency of the oscillation, around 10 MHz. We’re in HF radio frequency band.

Now lets shorten the wires between the emitter and the driver from 4” to 1”:

Frequency of the oscillation goes up, but peak goes down below 4 V – as can be expected with the lower inductance of the shorter wiring.
I know adding a gate resistor will tame that oscillation, but I did not want to scrap the driver (yet), so tried a drain-source snubber on the FET:

The snubber consists of a 0.1 uF capacitor in series with a 4.7 ohm resistor. Not calculated and for sure not optimum values, but a good improvement.
Something you might want to try Tom, if all else fails. For the test I used regular TH components with the leads cut short. One leg of the snubber capacitor on the black wire pad, one leg of the snubber resistor on the tab of the 7135 (better option would be the source pins of the FET).

The voltage at pin 8 of the MCU looked surprisingly good, all things considered. I would not use more than 0.1 uF between pins 4 and 8.

Emitter wire length also makes a big difference, so keep them short. This is also with the snubber, but with the 4” emitter wires:

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

The assembled light is working pretty well, as described earlier: 85, 2 uF caps in parallel on C1,12K FET gate resistor to ground.
The ThorFire JM07 hits 1900 lumens at start with an XM-L2 U4 1C, 56 kcd, UCLp lens, spring bypass’s, on a BASEN IMR 4500 26650. Running Narsil of course, but not sure yet if everything is ok – seems the clicky switch is not working for mode changing, though it seemed to work fine on the bench — no OTC cap, but seemed to work on other builds even without enabling brown-out in the fuses. Also memory seems to be turning on, even though it’s turned off – not sure if this is a straight bug or not, but never seen this before.

What you have there looks good – got to study this more. Hhmm, don’t even have the 0.1 uF cap across pins 4 and 8 now…

ToyKeeper
ToyKeeper's picture
Online
Last seen: 4 min 52 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10231
Location: (469219) 2016 HO3

DEL wrote:
Regarding the inductive ringing at the off edge of the PWM or strobe pulses, this is what we are dealing with:

{lots of scope pics}

You just answered months worth of questions, speculation, and argument. Seriously, this is extremely helpful information.

Also, I didn’t realize that my long emitter wires were making the problem worse. Oops. I just thought it might reduce overall output by a tiny bit while providing much easier access for flashing; didn’t realize it would actually worsen the voltage spike.

A while ago I managed to figure out that the worst spike was on the trailing edge of a FET pulse, by slowing a driver down so far that I could see the individual pulses… but I, um, didn’t realize that would also make the driver un-flashable without special hardware. Oops. I should probably get myself a fuse resetter or high-voltage serial programmer.

Anyway, your tests just now settled quite a few open questions and the scope images make it much easier to understand. Smile

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

Looked this over more carefully. There's a lot to this I'm either learning, or not quite understanding - I don't have a good electronics foundation, but Wikipedia has just helped me out a little (now I know the "drain" of a FET is the output).

The length of the LED wires, and the location of the snubber is a surprise to me - in my limited knowledge, once the signal goes out the FET, you are done - why would it have any effect at this point? But apparently it does.

The other thing I don't understand was I thought our main concern is the MCU pin 8 input - spikes, voltage boosts causing MCU resets and strange behavior, etc. But in the scope images, it looks like the blue trace is pretty much unaffected?? So, I don't understand, but I'm guessing the problems I'm seeing are more about the FET and not the MCU?

In this particular light, and all I work on, I keep the LED wires at their minimum. Only lights they have to be long in are SRK or multi-LED types that have a screwed down reflector, so you have to have extra lengths of wire to keep the driver dangling when screwing down the reflector from inside the pill area.

DEL
DEL's picture
Offline
Last seen: 2 years 1 month ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

TK, happy to help! Smile

Tom, pin 8 is important. Every time we switch the FET on we basically short pin 6 to ground (momentarily, while the FET gate charges up), This current is limited by the output impedance of the pin 6, but probably peaks at around ~50 mA. This current has to come from somewhere, and somewhere very close by, otherwise the voltage at pin 8 will dip. Enter the local decoupling capacitor. Which we do not have in the current design.

But, as you say, pin 8 looks surprisingly good under the circumstances, for the 13A anyway.. And the corruption mechanism seems to be over-voltage, not under-voltage.
There is also the possibility of EM interference. AC currents tend to induce currents in neighboring conductors, look at that 10 MHz oscillation.

Can you try the snubber on a light that is troublesome?
Exact values are not important. Optimum values will depend greatly on the exact layout, wire lengths, etc.
Try a C of 0.1 uF and R of 2.2 to 10 ohm.
This was my crude arrangement, leads should have been shorter on the snubber components:
(As mentioned above, a better arrangement would be to have the snubber span the FET. Easy to do with SMD parts, but I do not have big selection of values in SMD.)

DEL
DEL's picture
Offline
Last seen: 2 years 1 month ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

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).

DEL
DEL's picture
Offline
Last seen: 2 years 1 month ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

Sharpie wrote:
That looks in line with expectations.

FET basics:

http://www.irf.com/technical-info/appnotes/an-937.pdf

The ringing without gate resistor is what I expect, and undesirable.

How does it look at turn-off ?

Hopefully this will be slowed down a bit, also, and the spike reduced.

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:

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

DEL wrote:
Can you try the snubber on a light that is troublesome? Exact values are not important. Optimum values will depend greatly on the exact layout, wire lengths, etc. Try a C of 0.1 uF and R of 2.2 to 10 ohm. This was my crude arrangement, leads should have been shorter on the snubber components: (As mentioned above, a better arrangement would be to have the snubber span the FET. Easy to do with SMD parts, but I do not have big selection of values in SMD.)

 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?

ToyKeeper
ToyKeeper's picture
Online
Last seen: 4 min 52 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10231
Location: (469219) 2016 HO3

DEL wrote:
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.

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.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

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...

ToyKeeper
ToyKeeper's picture
Online
Last seen: 4 min 52 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10231
Location: (469219) 2016 HO3

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. Sad

ToyKeeper
ToyKeeper's picture
Online
Last seen: 4 min 52 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10231
Location: (469219) 2016 HO3

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.

DEL
DEL's picture
Offline
Last seen: 2 years 1 month ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

Tom E wrote:

 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?

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

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.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 46 min ago
Joined: 08/19/2012 - 08:23
Posts: 12648
Location: LI NY

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.

 

Pages