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

Will do. The pin layouts between the 13 and 25 are identical so as far as I can tell you should be able to readily compile code written for the 13 to run on the 25. Fuses may be different but I know sweet F.A. about them at the moment!

My issue now is that I think (haven't had the opportunity to check yet) that the pin associations on my PCB are different to what you typically find on the KD/DX boards people use here. I'm hoping at least a few a similar. My board has:

  • Voltage monitoring on pin 7 - VIN to a 3k resistor, sensed on pin 7, and 10k resistor to GND.
  • Temperature monitoring on pin 3 - Vref out of pin 2, into a 10k resistor, sensed on pin 3, and a 100k NTC thermistor to GND.
  • PWM out is on pin 6.

Ideally I will just modify the luxdrv firmware to move functions to different pins (if required) and to work with my particular components, but as yet I have no idea where to start.

I'm sure i'll be back here in the coming days begging for help lol.

Cheers,

- Matt

No, one nasty difference between the TINY13 and TINY25/45/85 is the register value that you have to write to select the 1.1V bandgap reference for the A/D converter. Atmel could have easily made the registers compatible, but they screwed up…

The TINY25 does have an internal temperature sensor, you could use that instead of an external thermistor.

Shows how much I know lol. The pin layout is still the same is it not? I'll have to grab the datasheets again and check...

As for the temperature sensor - I'm using a leaded NTC thermistor so I can place the actual sensor tip closer to the LEDs (or whatever parts I specifically want to keep an eye on). Granted I did not realise the 25 had an internal sensor - I chose it for the added flash so I can have more complicated code and features.

I'll post in DrJones' luxdrv thread and see if he can help me convert the luxdrv to run on the 25. He seems to be very busy at the moment though so I may be waiting a while :(

Ah well!

Recently, I have modified Tido’s codes to suit my driver with LM45 temperature sensor. Three modes, light level step down to a pre-set level when over-temperature.

The codes are deleted.

The driver code that I have is not compatible with the Nanjg style drivers and would not be of much use… I plan on doing some Nanjg compatible code… someday, hopefully soon.

Have a look from post #155 on in the luxdrv thread: https://budgetlightforum.com/t/-/4672?page=3#comment-406170

There is some discussion there regarding the use of the luxdrv firmware on a Tiny25. I am busy working on code that will work with the Tiny25, but again it is based on the luxdrv firmware. I'm also VERY new to this so it'll take me days, whereas people like PilotPTK, texaspyro, DrJones, Tido etc could probably smash something out in 5minutes.

Note the code PilotPTK posted in post #157 has a few typos and 1 or 2 bugs in it. These are pointed out later on in the thread.

No problem, I will patiently wait for your good news.

Microa use a service to share code, don’t paste it into comments.
pastebin
ideone
gist.github.com
etc.

But don’t worry it seems you’re not the only one who can’t share code online. I guess this is normal outside programming places… but it’s horrible.

Mattaus: Fuses, Fuses calculator, and the rest just try to google or search on atmel and atmel/avr forums/programming related places

Fuses are settings of the chip. And no you can’t probably just take settings from one type of chip to another. Maybe they would work when the only difference is just the speed etc. But you gotta make settings for each chip you program for. Or at least be damn sure they are the same between those chips. And refer, see the chip’s documentation for the settings. There is something online, sure but it may be outdated. And I think you can even render your chip useless, brick it by wrong fuses so be careful what you set the fuses to.

great constructive comments yet again Jack, thanks. I found scanning through the code very useful and I’m more more inclined to read through it here than go to another site, open it in another program and then probably forget where it is or what it’s called. This is a fun and friendly place so quit being such a snobby ass.

Thanks Jack - I actually stumbled across those fuse calc pages in my own Googling :) I posted my progress and links in the luxdrv thread and have successfully flashed my Tiny25 circuits several times now - if only I could get the hardware to behave as expected now lol!

Thanks for the suggestion on Microa. I normally do use that or pastebin in other forums, but the mood around here is so relaxed that most people really don't seem to care...that being said however using a service like those two prevents emoticons from popping up in code directly pasted into the forums haha.

- Matt

Sorry for my impolite to post the codes here. I thought that the codes are originally wretten by Tido which is better to put them in the same place.

I'm a complete idiot with all this so far, I have managed to read & write to the drivers and can get the various VLD programs loaded and working (via copy-paste from the wiki page into the command line avrdude, just so you know any suggestion to 'change these two fuses and edit this line' will be something I'm not up to yet) but cannot for the life of me figure out how to lock in a group in the 'programmable' version. Tap sequence has me completely lost. I can get it into the extended mode, but cannot get it to stick there. 'Tap' is a half-press turning the light off, or on? AAAARGH

I think posting code here is the best approach. Links go bad over time. Code will be easier to access and preserve here.

The code you paste here may contain parts that are not allowed or convert into formatting on the forum.
You do not get syntax highlighting and you can’t save it to use it without selecting and copying, making a new file, pasting it, saving it…

It’s a good practice to not post code directly. If anything at least use CODE or NOPARSE BBcodes if this forum supports them or make HTML pretty code print.

Also you are likely to reach post length limit if you paste code into your post.
Plus some people prefer not to scroll over several pages of code when expecting comments.


Editing flashlight wiki AVR Drivers so it’s more up to date.

Will try to add the fuses info links there later.

Though somebody should update the BLF-VLD page.
If you guys are using BLF-VLD and modifying it, put some info there for others. So others don’t have to read hundreds of comments in this thread to find anything about BLF-VLD but can easily find it on wiki.

New stuff on wiki, maybe somebody will find it handy.

*the pictures is updated and the traces under ATtiny13A are correct now

Excelent stuff, thanks JackCY, I was just getting ready to dismantle a Nanjg 105c because I need it to be in square shape :slight_smile:
I found one side but not the other till now

Ah, cool, I may do that with one of mine as well and then update the traces but I could do it earlier with this picture :slight_smile:
The traces are a guess under the ATtiny13A.

I need it somehow on a computer so I can figure out where to put another SOIC8, I think it’s PowerPAK SO-8, an Sir424DP. Hopefully get it sideways instead of Q1 & Q2 and heavily modify the traces or add my own small piece of board and hope I did not cut down too much of the battery compartment space. Might still have 3mm spare, might.

How did you take off all the components?
Just soldering iron or do you have a heat gun?
It’s kind of a bother to get these multiple pins components off.


Any guides on how to program these AVRs?

As I see everybody codes it a little differently and it’s a bit messy to read the codes available. They are not bad and are commented, which is nice but still, there is too MANY codenames (short meaningless names) and random numbers inserted all over the code :frowning:

And I need to write a custom driver anyway.

That’s not my picture, found it here on BLF but I have no idea in which thread.
As per component removal, you can do it with ordinary 3$ butane torch but you have to practice a bit so you won’t roast them :slight_smile:

P.S. about the programing: I am preparing myself for that step a month or so but but can’t force myself to do it already so I could say that you are asking right question but the wrong guy :bigsmile:

Yeah yeah I was waiting for a long time and putting it off too :smiley:
I’ve found something around so I will read, watch it, just need to know what I can use = already found a list of the libraries and functions I think. Plus need to know how to setup things, no problem to probably decode the numbers and such, just what to call and what to use how.

I hope this thread is still followed… :slight_smile:

I finally got a connection with ATTiny13A based chip and still didn’t flash anything on it… I’m trying to figure out the difference in command lines… AVR Wiki is using Tido’s files to flash finished firmware onto ATTiny13A and it’s using EEPROM file in command line…

The command line for flashing Dr.Jones’s NLITE firmware onto 105c skips eeprom.eep line completely… what is eeprom for ??? In Wiki for reading from chip, after comand line is executed, four files are created with .hex extension… flash is for flashing, fuses are probably fuses, just copy hex values into command line but what to do with fourth file, eeprom.hex?

All this stuff is brand new to me but I want to get as much knowledge as I can about programming these drivers…

Like… is it possible to read from driver (if it’s not protected) and then “clone” that firmware onto same driver later on? In case those four .hex files are to be used, what would be a command line for flashing be?

Thanks in advance…