How To Build a Flashlight With Perfect Modes (picture heavy)

Yup, I think you're exactly right. I just did a crude connection with a 1uF capacitor, and with a DMM I see it bleeding off voltage starting at around 400mv when I power off the MCU. I'll have to take a less crude approach and hook up my oscilloscope (and learn how to use it) to see better what's going on.

Have you seen the post from the polish guys.
They just connect a capacitor between GND and a ADC input to determine if the switch got pressed long or short.

Well look at that, I got off-time memory working with a 1uF capacitor connected between the 4th star and ground using ADC to read the voltage on start-up, then charging the capacitor right after. When I get some more time I'll post some captures from the oscilloscope.

It’s not only capacitor, proper code is needed to work with off-time memory and all codes we have here are on-time memory based…
Right!

How much voltage left after half a second?

I'll get a reading with my oscilloscope this weekend. I'm thinking around .5v.

Great! Eager to see what you find.

but as I said, I think I'll have to give up some functionality to get space for the code associated. How much code did you add?

This shouldn’t take much more space than the standard ontime checking which gets then deleted…
What modes and functionality do you use?

I am curious to see the discharge informations.

I planned to make a routine to blink out the adc Value through a LED but measuring the discharge with a oscilloscope is even better to get a clue how it works over the time…

you can see the functionality in the end of my post #698. I was the first to make this (Dr.Jones later adapted my ideas in his various drivers). At that time I decided to keep as much of Tido's original version 4 code as possible to preserve the possibilities in the code but as Tido himself mention the code is a mess of possibilities that scares users away, so it is good that Dr. Jones simplified it.

Actually, when I think about it, it should not take much more code, you need to memorise mode every time upon activating any mode and check voltage between what ever star the capacitor is soldered and ground and add something like:
if
voltage = high then
power on in next mode else
power on in memorised mode
end if

Yes, that' exactly what I always do (check post #698) and I mount the 3 components needed (which I learned from the first BLF light in 2010, post#166). What I want to do is to adapt the Polish way with only one capacitor but I have to switch to ADC input to do that.

Edit: And I only have 12 bytes...

Yeah, I blink out the binary ADC value for testing the light.

The added code for the ADC checking is like 5 lines. It's the same code as is used for setting up ADC for voltage monitoring, just enabling it on a different pin. I do check the ADC value twice though as the datasheet says something about the first reading not being reliable. I need to spend more time reading the datasheet.

I'm running out of room too. It's like the NLITE where the program is changed by what stars are connected, has turbo ramp down, and low battery step-down and notification.

I also have it running now. The capacitor is 0.15uF and the ADC-limit I use is 100 (for decision short/long). I check only one time.

But I have to investigate if it is repeatable from one atTiny13 to another. Also I have to find lousy two bytes to not omit some functionality.

If you have done a zener diode mod to the board to allow it to run at higher input voltages, the timing cap hack may not work. The reverse protection diode on the Nanjg style drivers isolates the CPU Vcc from the LEDs and regulator chips. The zener diode mod allows the voltage on the timing cap to be able to flow back to the LEDs/regulators via the input protection diodes that are inside the CPU chip… it may discharge the timing cap much faster.

I guess every capacitor and driver needs to be calibrated anyway, my smd caps have horrible fluctuations in capacity…

With the Zener mod you can also charge it a bit higher to the zenervoltage, maybe it even discharges to slow to be comparable with the 1.1V reference….?

We should find that out if we compare the “blink” results…

Well I got some screenshots of my oscilloscope (it's a little DSO Nano that really needs to be calibrated). It looks like after 1 second the cap voltage is down to 160mV, which would equate to an ADC value of 37 if the reference voltage is 1.1. I'll have to give that a shot and see if it works.

However, this is strange to me. You can see the different max voltages in different modes, which makes sense because of voltage sag. But what doesn't make sense is that low has a lower voltage on the capacitor pin than medium or high.

@JohnnyC. Yes, that is a bit strange.

I prefer a tap-switch time of 0.25-0.5 sec and have a test light now with 0.1 uF and use an ADC value of 80. It functioned exellent last night, but this morning, when the light was cold I noticed that I had to switch off a longer time to not shift mode.

That could be a temperature dependancy, and the light is now in the freezer!

Could you please also investigate if temperature has a major impact?

Is the DSO nano expensive? I only have a very, very old 2 channel Philips with a formidable drift on the traces and would like something better.

Edit: This is bad! After 20 min. in the freezer the light had 2 secs of off-time instead of 0.5sec. I guess that when it gets hot, I'll have to be quick to shift mode

Edit2: This is good! If very hot, the light also functions well. So the problem only lies at cold temperatures. But that could be bad enough if there is a spread between the atTiny's.

I guess that a contributor in this is that we start off from a higher voltage when cold as a colder protection diode has a higher Vf. Then our limit value will be in a flatter part of the depletion curve.

Those parasitic resistances seem to be highly temperature dependent... Unfortunate, but quite plausible. On the other hand, those MLCCs' capacitance varies with the temperature, too.

Note that those scopes also induce some 'parasitic' current.

0.1uF seems to be fairly low, was it a smd capacitor?

The dependencies from temperature and voltage are really big for smd caps, TP gave this advice in the 15mm driver thread.

Here is a graph from the datasheet of the 10uF smd cap I have:

@Werner: The capacitor is a 0805 cheramical capacitor. My test temperatures was at about 25'C and 0'C. I can't imagine that the capacitance should be 4 times bigger at 0'C than at 25'C

Something else must also be involved.