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

Hello

winavr and avrdude work fine on win7, I use them both.

are you using the right syntax from an elevated command prompt? (run cmd as admin)

Test connection:
avrdude -p t13 -c usbtiny -n

Flash .eep and .hex files:
avrdude -p t13 -c usbtiny -u -U flash:w:BLF-VLD.hex:a -U eeprom:w:BLF-VLD.eep:a -U lfuse:w:0x79:m -U hfuse:w:0xed:m

I also place the .eep and .hex files in “C:WindowsSysWOW64” so avrdude finds them.

Craig

I am building a new torch its a small single 18650 with XM-L U2 and Nanjg 105C with two extra AMC7135’s added.

I would like to reprogram the 105C but have no experience at this programming language.

Here is what I would like to achieve.

Always starts on mode 1.

mode 1 just enough to read a map or find things in a tent.
mode 2 just enough to walk by
mode 3 about 120 lumens then reducing to keep a constant 3v
mode 4 strobe slow fade from 10 lumens to full brightness and back

Turbo mode accessed from any mode full power for 3 seconds drops back to the mode it came from then after 10 seconds does a battery check one blink good, two blinks getting low.

I have ordered the programer which will take a few weeks to arrive.

I need pointing in the right direction.

Any help would be much appreciated, is there some software I can test programs before burning them.

I think that you should start with something simpler, especially if you do not have any experience in C programing language. For start modifying available code to grasp some basics.

Also code needed for request above might be too vast for attiny13 memory capabilities and/or hardware resources.

Thanks for the reply. If space is a problem the strobe can be dropped. Reading through this loooooong thread every other feature has been implemented except the turbo button but in different configurations. At the moment I a 3/4 of the way through a python course. When that finishes just after Xmas I don’t mind learning C. Turbo feature is quite important to me as the host is tiny and would over heat very quickly.

Is there any way to simulate or test code so I can experiment before the programmer arrives.

Slightly off topic but I seem to recall somewhere (and I'm not sure if it was in this thread or a related thread) details regarding cell voltage detection/low voltage protection (LVP). The post in question was dealing with how to modify the ATtiny13 circuit to allow for this to take place. The reason I am after this is because the ATtiny chip can apparently perform voltage level detection via the VCC pin, but only if it's lower than 1V. This is easily achievable via a voltage divider circuit, however as far as I know the ATtiny13 is not capable of running below 1V...

Anyway, if I can find that post it might help me understand what's going on a bit more. I also notice that on DrJones LuxDrv thread he has implemented LVP using the standard setup which implies to me that the above statement regarding 1V is horse-poo.

Any ideas?

- Matt

Think the answer to the voltage divider is here post 5

The NANJG has a voltage divider on board (19k/4k7) to do that. That voltage then is compared to an internal 1.1V reference.

The voltage detection of the Vcc pin is for brown-out detection. The Attiny13A has 3 speed grade, 0-4MHz@1.8-5.5V, 0-10MHz@2.7-5.5V, 0-20MHz@4.5-5.5V.

I just got a few of the KD 7135 V2 drivers, is it possible to write firmware and flash it via AVR/usb programmer? Or maybe desolder the PIC (?) and add an atmel?

Short answer: Sorry, no to both.

Has anybody tested any of those cheap SOIC8 Clips?
http://www.ebay.com/sch/i.html?\_udlo=7.88&\_sacat=0&\_from=R40&\_mPrRngCbx=1&\_udhi=11&\_nkw=SOIC8+Clip&LH_PrefLoc=2
(black ones,
blue ones may be problematic, according to AVR Drivers - Flashlight Wiki )

I have a black one, it works just fine. Once in a while I do have to re-seat it on the chip, but it beats any alternative!

I have one of these on the way will let you know how it works.

The soic clip (5250) I received was a blue POMONA. Worked first time out no problems.
Using tido’s v.4 but cant figure out how to keep the mode I have selected in the extended modes. To go to the first three modes. I read tido’s read me file and can not seem to get it to work.

You mean "programming" the light, i.e. reconfiguring one of the main modes with a new setting?

Are the programmable and proghelper flags on?

If I remember correctly, the procedure is this: Tap until you reach your desired extended mode, use it for a few seconds. After tapping once, a timed sequence starts:

  • you have to tap again within <1s
  • you have to tap again within <1s
  • you have to tap again within >1s, but <2s
  • you have to tap again within <1s

An indicator blink (proghelper) helps: Tap right after the blink (it blinks at 0.25s for steps 1,2,4 and at 1.0s for step 3).

From the wanted extended mode it's like tap-tap-tap-pause-tap-tap.

I finally got it Drjones thanks. You have to wait for the flash each time you tap. As soon as you see the flash tap again and hold until the next flash. Going to try Luxdrv next.
I’am using the 105c 5-mode 2800ma driver from lightmalls.

Could somebody explain the memory after off mod?
What to get, what is the schema and how it works, is it already built into some code or does it have to be coded?

#177 nice but not replicable without specs and info.

Welcome
I have a little problem with saving the selected programmable batch mode.
After uploading .hex and .eep everything works I have 3 modes low, medium and high after a few clique have flash and choose the level but I do not want to remember it.
My driver is a standard 105C with ATTINY13V and ATtiny13A and second in both cases there is the same problem.
My fuse settings is -Ulfuse:w:0x79:m -Uhfuse:w:0xed:m, I will add that other programs such as Fixed Modes, Simple, Default work well, but do not want to remember Programmable modes selected.

Regards

Hi Jack, I got your PM.
Making a drawing can take a little while. In the meantime you can read about the
background in post#249
The modes in post #254
The code link in post #264 (code ready compiled for 105C)
(also links in post #467)
Memory tip and link to spreadsheet in post #469

Memory_after_on:
Will save the mode after using it for appr. 2 sec. Then if you want the next mode one tap will not give you that but will start a new 2 sec window where you have to tap again to shift mode.
If you shift mode and shot down in less than 2 sec, then the next time you turn on, the mode will shift to the next again because the memory knows that you already have tapped once.

To overcome this we have Memory_after_off:
An external condenser is charged through a diode when the light is on. When you switch off, the charge on the condenser will bleed through a large resistor so the voltage will be low after appr. 0.5 sec. The condenser voltage is sensed via an input to the MCU just after turn on. If the voltage is sensed to be high (after a short tap), then the mode will shift else the old mode will be kept. After that, the condenser is charged again as long as the light is on.

I use MCU input pin 2 for the sensing. On the NANJG 105C pin 2 is connected to the rightmost star so I mount the condenser there. The 101AK is more difficult, there I must solder a wire to pin 2 and take it through a hole to the other side of the board where i mount the components.

Eventually I may try to make a drawing of the components which are:
1 condenser/capacitor 100 nF keramic (from pin 2 to resistor and diode(anode)
1 resistor SMD0805 10 MOhm (from condenser to ground ring)
1 diode eg. 1N4149 (from condenser to ground ring (kathode)

I’m trying to program a driver, but this stuff is over my head. :frowning: