Attiny25/45/85 FW Development Thread

Ohhh sorry - I wouldn't have known cause I don't have it here at my mother-n-laws down in N. Carolina, but glad you got it. So it compiles smaller now? I recall a while back I passed along the compiler and linker settings to TK, and it helped her save a few desperately needed bytes - it's all good.

Ya. It compiles at 83% with battcheck but without the blinkies. I changed the optimization setting to Os and it saved 15-20%.

The relevant build settings are in the build.sh script:

http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/view/head:/bin/build-25.sh

I don’t know exactly how to apply those settings within the Atmel IDE though. The most important ones are “-Os” and “-std=gnu99”. You shouldn’t need to remove anything from bistro to make it fit at 100% or less.

I didn’t find the std setting but the Os setting really helped. If someone else is looking, this setting is under Project-“project name” properties-Optimization
Or Alt+F7 - Optimization.

I just posed this is in the Q8 thread, but I thought the audience here might be interested in the details:

As discussed a few times in this thread, the 25/85 MCUs seem to be more temperamental than the 13a, especially in higher power builds. After putting the Q8 V3 driver through its paces, and forcing the issue somewhat by using long-ish emitter wires (parasitic inductance), I am really not surprised.

For the Q8 driver we took a few precautions:

- There is a series gate resistor on the FET. This makes the FET switch slightly slower, lowering inductive kick-backs
-There is a good de-coupling capacitor arrangement for the MCU

The result was a stable driver, but a scope on it showed there are still issues. We can see inductive spiking and ringing over 6 V in amplitude on the power rails. I tried several things, but in conclusion the solution was a simple series resistor ahead of the D1/C1 we have on typical DD drivers. Of course the LED (s) still wire directly to the cell(s)+. The improvement is remarkable, and I do not see any downside. With this arrangement C1 can be upstream or downstream of D1, solving that debate as well. For best ADC results R1 should be connected to C1, whether up- or downstream of D1.
EDIT: But C1 after D1, and connected with short traces to MCU pins 8 & 4, is better. Or add a C2, as on the Q8 driver.

From the Q8 thread:

The scale for all traces are 1 V/div. 0 V for all traces is the second division from the bottom. Yellow is pin 8 of the MCU.

Here I am using a 2.2 ohm resistor. Eventually I settled on 4.7 ohm, but any value from 1 to 10 ohm will give a day-night improvement over the current designs. I hope this small addition will find its way into exiting designs. SPICE tells me the power dissipation in this resistor is a few mW, so almost any package size can do the job.

EDIT2: Un-scaled the image to clear up the text.

DEL, it’s an interesting find. If I’m not mistaken, it should also help with inrush current which was discussed a while back somewhere (either here or the Q8 thread). If the lower values are enough, I’d lean on that side as the MCU is already running below its supposed required voltage on near empty cells and this will only add to the voltage drop of the diode.

It is a compromise. The larger the resistor, the smoother the voltage at pin 8, but the larger the voltage drop as you mention.

But we are talking mAs for the MCU. Average MCU current is around 5 mA. 5 mA x 4.7 ohm = 24 mV, or about 10% of the drop over D1.

Very interesting information. How does this affect the performance of the light? Meaning, what are the consequences or benefits in terms of user operation?

Being dense over here, am I to understand that the 4.7K resistor can stop a Manker Bistro driver from bumping to moon when powering a high discharge light such as a triple? Where exactly does this resistor need to go on Wights FET+1 driver to accomplish this?

No effect on performance that I can see. Keep in mind that the power feed to the LEDs and power part of the driver circuit stays mostly the same, we are just filtering the control power used by the MCU.

Overall the MCU should be more stable under extreme conditions and in addition functions like voltage detection and low voltage/high temperature step-down should be be more consistent.

Not sure - what is this in reference to? Where is the 4.7K resistor? Ohhh - do you mean 4.7 ohms? I doubt DEL has analyzed the Wight FET+1's. He's looked at and discussed Richard's MTN17DDm v1.1, and we have a possible placement for the 4.7 ohm resistor there.

Basically, the 4.7 ohm resistor should precede the D1 diode, and actually all other parts fed by BATT+, accept the LED(s) of course. The Wight FET+1 drivers don't lend themselves well to doing that, I believe - haven't looked carefully at one in a while.

The Manker Bistro driver has quite a few problems, so doesn't surprise me it has some bad behavior in differing conditions. If anyone scoped it, I bet they'd see lots of signal spikes out of tolerance of the MCU, just like what DEL was seeing, but worse.

Personnally if I had that problem with a Manker Bistro driver, 1st thing I'd try is a "C2" mod (C2 from our BLF Q8), which is a 0.1 uF cap between MCU GRND and VCC, and the FET gate to grnd resistor (40K-60K) - I've mentioned this and shown it several times, and I've done it repeatedly on Wight FET+1 drivers using a 25 or 85 MCU - Richard's 25 driver uses the FET gate to grnd resistor as well. All the 85 mods I've done apply to the 25 as well, accept with the right 25, you don't have to bend the pins of the MCU to have it fit the 13A pads.

Unfortunately Manker didn't know much of what they were doing with that driver. Initially, it didn't work consistently, so it was passed along from me that I used a 20 uF C1 at that time, so they bumped C1 from 10 to 12 uF, and then it seemed to work better. They didn't do the other tweaks though, and apparently didn't scope the signals. They seemed about the same level as me, in working with and understanding it - a bad thing...

Triples are a bit different than normal mods because of the high amps and longer LED wires - DEL has seen the effect on signals of long wires, even if they are heavy gauge.

Not dense at all Dale, we should really get into the habit of showing circuit diagrams. I will try to post something better later.

The new resistor has to be inserted between battery+ and C1. D1 is then taken from this new junction to MCU pin 8. On some existing drivers this will not be an easy retrofit, might have to cut traces and wire in some components. The Bistro driver looks like one of these, with the LED+ wire basically soldered to C1.

Note that it is a 4.7 ohm resistor, not 4.7 kohm. Whatever you have between 1 and 10 ohm will work though.

BAT+ ---+------[4.7]---------+---------------|>|----------------MCU pin 8
        |                    |               D1
        |                    = C1
      LED+                   |
                             |
                            --- GND

There really should be a C2 directly between MCU pins 8 and 4 as well, but that should get you going.

EDIT: TomE got it! :slight_smile:

DEL, thanks for the scoping. Great result with such a small component. I’ll include that resistor as well.

I undestand that the ringing is gone now, but what about that seemingly large spike that still remains. Is that of no concern?

The circuit diagram helps a lot. Yes, we need to improve there and I say that knowing that I’m shy of at least one diagram myself… :innocent:

To elaborate on C2. This is an essential component consistently neglected on most drivers, probably due to space constraints. It protects the power feed to the MCU from outside disturbances, as well as from within the MCU (e.g. output pins switching).

We can probably get away without C2, provided C1 is located after D1, as close to pins 8/4 of the MCU as possible. For the A6/X6 drivers, just adding the new R and leaving C1 in front of D1, will however give a drastic improvement already.

Yes, it is scary. Try it without the series resistor on the FET gate and it is really impressive. I was not happy at first. But this feeds straight back into the cells. Regenerative braking…kind of!

My only concern is for the little 7135. It gets that spike on its pin 1, seems to handle it OK though. The 7135 datasheet is of no use here of course.

EDIT: Other issues will be radiated EMI/RFI and audible noise. Neither should be an issue for what we are doing.

Great then. I was thinking it might draw more current but on doing a few more calculations, the FET doesn’t draw that much current at such low frequencies so it’s all fine. I hope it makes its way onto drivers. You’re awesome with the scope!

Does anyone here use diptrace?

I have a tripledown Schematic made up in it that would be easy enough to carry over to these FET + 1 drivers as well.

Once you have the Schematic in diptrace building the PCB is SOOO much easier, it tells you exactly what connects to what and where and you can add/change or remove things from the Schematic and it will directly send those changes to the PCB design as well.

I tried eagle briefly and found it clunky and very frustrating by comparison. Which was why I started from scratch on diptrace.

The other benefit is that you can very easily post Schematic’s on here for people to read.

diptrace - I've heard of it for sure. Maybe the guys here @work use it, because it sounds very familiar - I'll ask around.

So, it can do the full PCB design, and generate the files in a format OSHPark accepts? If so, it sounds so much better than Eagle...

Quick schematic:

Thick lines are the main current path. 7135 not shown.

C2 and R4 are optional, but recommended.
If C2 is not used, C1 should be moved over to its position.
R5 is the new resistor, 1 to 10 ohms.

I’ve just this week been looking for a pcb design software. I was going to try eagle but maybe I should try this? Which is best for someone just learning?

I want to layout a charging circuit in 16mm pcb. Then I will transfer the parts from a basic charging circuit from eBay. I can then use direct drive driver in some lights without sacrificing the charging circuit. Many lights now come with this feature.