Attiny25/45/85 FW Development Thread

This seems like something comfychair or DEL would be good at debugging.

+1 - I was definitely think'n of comfy's setup with that low cost scope tool he had - think it was USB based and used the PC as the display.

Hopefully can get more tips to try today @work. I know texaspyro has a working Tiny85 based SRK (post #116 way back here), but I'm sure different driver setup, probably different FET, and probably not a FET+1.

Certainly someone with more driver/design knowledge could possibly help, but I'm assuming no one else seen this issue so could be tough.

Tom, are you using the 85 or 85V on this driver? Also, have you tried without PWM at all? By simply turning the FET pin on/high?

I have the 85V bought from Mouser I believe. No PWM's work great, i.e. value of 255. So full FET or full 7135 works great, also PWM's on the 7135 only works great. In post #430 above, of those 4 modes, it fails when switching to the 3rd mode either from 2nd mode or 4th mode - my UI (Werner style) can go in both directions.

Ooops - Ok, found texaspyro's thread on the tiny85 SRK mod: https://budgetlightforum.com/t/-/18833. So it's 7135 based, no FET's at all. Hhmm... Gotta review that thread when I get a chance.

Hi Tom,

An oscilloscope would really help here. Lacking that:

As with most drivers, the placement (and size) of the 10 uF is really not ideal for decoupling the Vcc of the MCU. Looking at the layout of the driver, the Zener diode pads seems to be a better location for a decoupling capacitor. Assuming you are not actually using a Zener, I would try installing a 0.1 to 1 uF on the pads intended for the Zener. Or temporarily add one directly on top of the MCU between pins 4 and 8, with short as possible wires/leads. Leave the 10 uF in place, or doubled up as you already did. You can also try to replace the Schottky with a 4.7-22 ohm resistor to isolate Vcc a little from the switching noise.

Another possibility is that you are getting excessive inductive kickback from the wiring. How long are the wires between the driver and the emitter(s)? Jumpers on the MCPCB? Any wiring involved between the cell and the driver?
Shorter wires would be easier to pulse. Keep the emitter wires close together (twisted) to minimize radiated noise and away from the MCU, if possible.

Also enable 1.8 V or 2.7 V brownout detection if not already done. At least then you could see the MCU reset on voltage dips, rather than freaking out.

Re. the timing of the 13A, apparently the oscillator calibration register boots up with the factory calibration value that applies to a clock speed of 9.6 MHz. If you want to have the advertised timer accuracy at 4.8 MHz, you have to manually overwrite the OSCCAL register during boot with the applicable factory calibration value (it is there, just not normally used).

Wow, all good suggestions! Thanks! Not sure if you are familiar with a typical SupFire M6 or SRK, but I'm using the stock M6 driver as a contact board (no driver springs at all), then piggybacking in the 22mm driver by using 3 short 22 AWG wires from batt- (ground) pads on the stock driver, then soldered to the 22mm driver's ground ring - so I feel the ground connection is pretty good.

For batt+ to the LED's, the 3P LED's are wired direct to pads on the stock driver using 20 AWG wire - wires must be little longer to accommodate access to the screw that holds down the reflector (like all SRK's pretty much). For batt+ to the driver, a short 24 AWG wire from a pad on the stock driver to the spring pad of the 22mm driver. For LED-, 3 20 AWG wires to the one single LED- pad on the 22mm driver. I think this is all pretty much a standard setup for SRK style lights. You really don't want to replace the stock M6 driver because the batt+ ring is super thick and I don't think any OSHPark board can be near the quality of that setup.

- Didn't try the brownout enabling -- will do!

- also I got a bunch of 0.1 uF caps today at work, so will try that as well.

- could try the resistor

Also I got a couple of bigger wired lead caps to try in place of the two 10's I got in there now (suggested by an EE at work).

I'm think'n we are on the right track because maybe the 25/45/85's are just a bit more sensitive to the large amp switching than the 13A?

Update:

First did the brownout 1.8v enable, and it still flaked out the same way - weird blinking, etc.

Then tried a big leaded cap -- got it working with a 47 uF leaded cap on the zener pad (with 2 10 uF caps left on the C1 pad). Removed 1 of the 10 uF caps, and it still worked. The cap I'm using is an old style - 47 uF 50V rated, big cylindrical shape. I can use it in my SupFire M6, but obviously won't work in triple/quad tube lights, and similar 17mm driver lights.

Been trying to revert back to brownout disabled, and revert back to FAST PWM, but my ASUS Win10 locked up, and after power reset, it's loading Win Updates now - great.... I think finding small package caps at larger values is not easy, maybe impossible?

Update #2:

Got the M6 assembled and doin some testing. So far so good. No brownout now, FAST PWM mode. 5000 lumens, almost as good as it was all newly modded. Real nice having the lockout capability.

Got in a Sunwayman C20C today from Illumn - wow, real easy to mod and great deal at $30 (1/2 price) - got it all torn down now. Might be tight fitting in a 17mm piggyback style. Stock driver is about 20 mm. It's a similar style to a Roche F6 but different - much lighter, little smaller. Nother great candidate for an 85 e-switch. Has a shallow reflector, so may also be a good candidate for a triple, in which case this problem needs further addressing for a 17 mm driver.

That would be an electrolytic capacitor. Being rated at 50v it would be larger than a 16v or 25v one. They also have tantalum caps, not a fan of those myself. The normal 0805 sized ceramic caps we use on our drivers are available up to 22uf. You could stack two. Mouser 22uf 0805 In order to get higher capacitance you need to move up to a larger size ceramic. Mouser 47uf 1210 ceramic 1 2

Thanks Halo for the research. The stacking of 2 of the 22 uF's may be a good option to try on the std wight FET+1 17 mm driver.

Just glad I got the M6 mod working well for now. The problem may not be an pronounced on the 17mm board. Dale is the only one that reported it.

Possible side effect -- last night I was re-flashing the 85 with the driver fully wired up in the M6 head, no batteries or external power source. When I'd plug in the USB dongle, the flashlight would do it's 2 blinks for power-up, then when programming, the light would go nuts in flashing the LED's. Wondering if the bigger cap is causing this? Also had a few verification errors at address 0x200. Finally got past it after a few attempts - dunno why that's happening now as well.

Update:

Problem came back - few times in a row, power resets etc. - still happened. Let it sit for couple mins, then it's working again. Huh?? Jury is still out - maybe heat related? But can't pin it on heat just yet - I got it even hotter afterwards and can't reproduce the problem. May need different/better cap solution - maybe Halo's recommendations. Might be worth investigating differences, etc. Maybe DEL's suggestion on the resistor and 0.1 uF cap, etc....

Since the emitter +power does not pass through the driver board, you can try to replace the 24 AWG wire with a 10 ohm resistor. Together with C1 this would create a low-pass filter for the power feed to the driver board. I would use 1 uF on the zener pads. The intent of this local decoupling capacitor is remove high frequency switching noise, mostly created by the MCU itself. Ceramic caps are much more suited to this than electrolytic. The ‘standard’ value here is 0.1 uF, but 1 uF may be more appropriate in this case. C1 at 10 or 20 uF should be sufficient. Keep in mind that C1 is located just beside the FET and depending on the capacitor type may be severely affected by heat (not damaged, just temporarily much lower value than nominal).

From your tests it seems the MCU is flaking out before BOD is triggered. The 85V is rated for 1.8 V up to 4 MHz. Can you test at 4 MHz? And also test 8 MHz with BOD at 2.7 V?

The bigger question is why does this only happen with hi-current cells and high current draw? It points to a ‘high’ resistance somewhere in the power circuit. Try to draw out the power circuit and think of ever wire, solder joint and PCB track as a resistor. Not familiar with the original driver board serving as ‘motherboard’, but I would look very carefully at the PCB traces and where you tap the power for the retrofit driver from.

Re. the flickering emitters during programming, if you still have the diode bypassed you are back-feeding 5 V from USB to the emitters+. This may interfere with the programmer.

Ok - this is all a huge help DEL. Yes - still have the reverse polarity diode out, wow - good to know, I'm sure then putting it back will fix it... Not sure bout testing at 4 Mhz, not sure what's involved.

I'm gonna do more tests though with putting the bigger cap(s), like 10 uF, on the zener pad - just the relocation might help. Right now, the C1 pad is before the diode which may make it less effective. Maybe should be on the MCU side of the diode to be better?

For the driver - here's a pic of the orginal mod (not now):

I simply replaced that piggyback'd driver with the new 85 based FET+1.

The usual thinking for decoupling is to have a smaller value capacitor millimeters away from the consumer and another larger value capacitor 10s of mm away. In this case the roles would be fulfilled by Czener and C1 respectively. The idea is to have a low inductance connection to the first capacitor. For this we need short or no tracks and a physically small capacitor.

D1 complicates things and we may inadvertently create some kind of charge pump. Will have to think about that one.

4 MHz should be easy…different fuses…#define F_CPU 4000000UL…and adjust _delay_loop_2 if you are using it. PWM will be half speed of course. And the clock will be outside factory calibration for the same reason as running the 13A at 4.8 MHz.

Looking at the photo there is potential for a ground loop. Test bringing only one ground wire to the driver and bring it to a point close to where the MCU takes its ground from (close to R2).

Ahh - ok. Thanks Again! For the CPU speed/timing, I know I need these 2 things to be accurate:

  • Watchdog timer
  • _delay_ms() function

Ok, got it working well now with this setup:

  • restored D1 diode (reverse polarity)
  • C1 is now empty
  • Zener diode has a 22 uF 1210 ceramic cap, with a 1 uF 0805 mounted on top of it

I combined advise from DEL and the EE's I work with. This setup is working well so far - need some testing time though.

Board is a bit messy, Should have cleaned it up Frown.

I just did a little research on the D1 and C1 positioning. The original Nanjg 105C and Nanjg AK-101 have the cap after the diode. Also an old BLF DD driver I had was like that as well - cap after the diode. But with BLF DD 1.0, the cap is before D1 and from then on, seems like we kept it that way.

Anyone have any ideas on this? Maybe it didn't have any effect at the time, and was easy to layout?

I’ve always put the cap after the diode just thought that’s how it was meant to be

Putting the cap after the diode can cause the CPU voltage to rise to unacceptable levels. Inductive spikes get stored on the cap, raising the voltage. The cap can’t drain back into the (low impedance) battery because of the diode… the circuit behaves like a boost converter. There is a thread that talks about the issue…

Hi Tom,

Great that you have it going!

I agree with texaspyro about the boost converter effect. This is the ‘charge pump’ I mentioned above.
A safer option would be to keep the bulk decoupling at C1 and just use a small capacitor (0.1 - 1 uF) on the zener pads.
There is normally nothing to gain by moving all the capacitance to the closer pads.

I looked briefly for a reference, this one seems as good as any and actually refers to boards without power planes like our drivers:

The larger capacitance may be a band-aid on the real problem….there seems to be an excessive voltage drop somewhere during high-current PWM. If this is the case then you will find that the C1 capacitor is useless because it will be loaded by the emitters during these voltage dips. This is where a 10 ohm or so resistor in series before C1 may help.

Thanks for al the info! So, the Nanjg's had/have this design flaw all along? Maybe not a real issue at 3A or less?

It's a shame that Comfy's scope images are gone(& Comfy himself!). Looks like we are at the same point that we were at a little over a year ago.

Post 1055 from the OSHPark thread;

Hhmm. Looks like comfy and wight didn't agree on this issue. Yep, a lot of history lost... Wight says in Post #1068 exactly the same thing an EE told me - "put capacitance very close to sensitive but low-draw devices". Neither seem to know enough of the theory, or have enough experience, but they certainly know more than I do.

DEL is probably right - maybe just adding the small cap at the zener pad would solve it, and keeping the original 10 uF at C1 - didn't try that unfortunately.