Creating the perfect flashlight

proto

Low cost flashlights are pretty awesome but I just couldn’t find one that did exactly what I wanted (nor a perfect mod). Being an avid Airsofter I was looking for something that I could use as a high power strobe but also as an every day carry light. Strobes on the market tend to be rather expensive for what you get and budget lights aren’t really suited for tactical strobes (although they do often have strobe modes).

Most budget lights that have a strobe feature change modes fairly easily, this means that a quick momentary use of the strobe (which happens often) would change it to another mode. I dedicated strobe would be a bit of a waste though. A decided to instead buy the parts and make one myself, DX proved to be an excellent source of parts. I needed a casing, driver, LED and pressure switch, all of which came in at around $30. Not bad at all for a 900 lumen light.

I opted for the NANJG 105 driver because it could be easily reprogrammed, It’s equipped with an Attiny13 and 8, 350mA current sinks. A brief internet search gave me everything I needed about this driver including the schematic. I had a couple of features I wanted for this light:

  • Should not accidentally change modes – For use as a strobe
  • Normal flash-light mode – For everyday use
  • Intensity adjustment mode – Just in case someone complained about a 10W strobe and for general use
  • Low battery warning
  • Normal Mode
  • Strobe Mode
  • SOS Mode
  • Fade Mode

After reading up on Flicker Fusion Threshold I decided that 1KHz PWM would be perfect, since it would give me 1mS interrupt as well, allowing me to time the other modes. One problem that got stuck in the back of my mind was that  the only interface to changing modes would be an on/off switch. This meant that the flashlight would need to do multiple EEPROM writes each time it was turned on, to save states etc. Since EEPROM devices have a limited amount of writes I decided to use a different memory location each time something was written to the device, this would significantly extend the EEPROM lifetime. Admittedly, the flash-light would need to see heavy use before this would be of any real benefit.

Although the Attiny13 has plenty of room for this type of application I replaced it with an Attiny25 for some additional program space. I used my AVRDragon to program the units along with some Pomona Soic clips. For some reason the Dragon reset when powering the unit directly so I had to hook up an external power supply, this at least had the benefit of allowing me to test the low voltage detect feature since I was using a variable supply.

proto_close

For the mode changes I decided that the flashlight would need to be turned on for between 1 and 2 seconds five times in a row to change modes. This eliminated the accidental mode changes completely. The sequence was as follows, when the flashlight turned on it started a 1 second timer and used the current mode. When the initial timer ran out a counter was incremented and stored in the EEPROM at the next location (or the new mode stored if this counter reached 5), another 1 second timer was started at this point. When this second timer ran out the mode was reverted back, and saved to the EEPROM (if changed) and the counter reset to 0. This approach has proven to be fairly reliable although a little cumbersome if you want to change the mode.

The 1mS interrupt was used to time the different modes as well as manage the mode changes, in addition, an ADC reading was taken against the 1.1V internal reference and a voltage divider on the board, this allowed measure the battery voltage. If this voltage dropped below approximately 3V the flashlight would fade out and enter a deep sleep mode, preserving the battery if non protected cells were used.

This unit has proven to be an excellent strobe (in my opinion at least). I’ve placed all the code for the project on Google Code if anyone is interested. Happy Hacking!

Advertisements

~ by s3c on 2013/10/18.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: