Flashlight Firmware Repository

1939 posts / 0 new
Last post
chouster
Offline
Last seen: 11 hours 41 min ago
Joined: 02/20/2014 - 15:05
Posts: 685
Location: germany

Thanks FmC.

Ok so here you go: BLF-A6 single channel battcheck vpt

This should work, but might be good idea if someone with actual programming knowledge could look at it. I think it makes a hell of a driver out of a cheap 105C, without major modifications (just add OTC).

This was was tested and calibrated in an Eagle Eyes X6 host, spring to switch tailcap bypass, 8xAMC7135 105C driver from Simon Mao, spring bypassed.
OTC was Murata 1µF,0805,16V, X7R, soldered a bit strange

The .hex file can be found here

pilotdog68
pilotdog68's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 05/30/2013 - 23:31
Posts: 6419
Location: Held against my will in IOWA, USA

Anybody want to do a bit of work for me? I promise I can’t pay anywhere near a fair wage for your time, but I could send a few bucks via Paypal.

DEL previously helped modify blf-A6 so that Pin 3 could control the FET on my TripleDown boards. It didn’t look to me that it was a major change to the existing FW, but what do I know?

Job 1: Do the same thing with STAR momentary: make a “255” value toggle pin3 instead of the normal output

Job 2: Do the same thing with STAR dual-switch, as well as add dual-pwm support (that might be a bigger job?)

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

chouster
Offline
Last seen: 11 hours 41 min ago
Joined: 02/20/2014 - 15:05
Posts: 685
Location: germany

I think your knowledge of coding and all the driver stuff exceeds mine by far

I won’t even bother to mess with job 2 ATM

Anyways, I did this out of interest and for the purpose of learning something, maybe. I would be surprised if it works and if I’ve done it right. I have no e-switch host to test it.

But maybe it’s a starting point for someone who knows what he’s doing: Big Smile

diffcheck job1

EDIT:

I am sorry for posting such crap. This doesn’t even compile right. I had
#define TURBO 245
in there, and at least it compiled. Must have taken it out before posting. But anyways, it doesn’t work, I’ve tested it, goes 245 on channel 1 instead of driving the FET…

gangstead
Offline
Last seen: 3 months 2 weeks ago
Joined: 02/05/2016 - 23:44
Posts: 152
Location: Texas

I recommend github.com for sharing code. That way if you need to make a change you always have the version history to go back to.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

In hopes it’ll help me actually get stuff done, I posted my todo list at the beginning of the thread:
http://budgetlightforum.com/comment/738438#comment-738438

Help and encouragement are welcome. Smile

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

gangstead wrote:
I recommend github.com for sharing code. That way if you need to make a change you always have the version history to go back to.

The repository is currently using bzr + Launchpad instead of git + Github, but migration is still possible if a majority of the people involved want to switch.

I realize git won the DVCS wars, so bzr is definitely not the most popular choice. Launchpad now supports git though, so it’s also possible to use git without actually moving to Github.

As for Launchpad vs Github, many of their features overlap but Github is organized per-person while Launchpad is organized per-project, Github has some wiki-like features, Launchpad has much more extensive bug/task tracking, and there are a variety of other significant differences.

In any case, the options are on the table but would need a majority in favor. So far, there has been very little interest in revision control and project management tools, so I’d be happy with pretty much any system as long as people used it. I’d much rather review merge proposals instead of pulling files from forum posts, pastebins, and dropboxes…

gangstead
Offline
Last seen: 3 months 2 weeks ago
Joined: 02/05/2016 - 23:44
Posts: 152
Location: Texas

I’m an avid github user. All my personal code is on it and all my code for work is on it as well. I’m biased, but when I found the Launchpad site it took me too long to find the source code. To me that’s the number one feature of a code repository – SHOW ME THE CODE. With Github a project might be under a user, but there’s no limit to the number of contributors you can have. Also it’s distributed so anyone who wants to do their own thing can fork off of the main repo and it doesn’t affect that main repo in any way. Maybe the code gets merged back in, maybe it never does. Github also has organizations (that are free to create) for projects that turn into a real community effort. A lot of projects that start out under one person’s account get transferred to an organization as they take off.

That’s just my opinion but I haven’t actually contributed any code yet so I consider it fully without merit or standing. I’ve got a lot of ideas though, and debuggers recently delivered and a sack of Nanjg 105c’s on a slow boat from China headed my way. I’m fully cognizant that there’s nothing you can’t do on Github, Launchpad, Gitlab, etc and I will get source code from wherever the developer chooses to share it. When I have something to share I’m putting it on Github.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

From what I recall of its early days, Github started as a simple place for individual people to share git repositories. Other features were added later but weren’t as deep a part of the overall design. So, it excels at “show me the code”. Launchpad was designed more as a full-featured large-scale project management platform and a replacement for older systems like Sourceforge. Designed specifically for facilitating Linux distro development with thousands of contributors and complex relations between individual component projects built together into a whole. Its broader focus makes the code somewhat less front-and-center.

Both are good tools, though their styles are very different.

Git and bzr are functionally and conceptually almost identical. The main differences are a matter of interface. However, there is one significant conceptual difference — bzr has a concept of a “mainline” but git does not. This explains some of the consequences of that: http://toykeeper.net/tutorials/bzr-vs-git/

In common usage, git is dramatically more popular. They use different terms for the same concepts, which can be confusing. Git puts all the heads or tips into one directory while bzr defaults to one directory per head and one head per “branch”. Git prefers to wrap or reimplement common tools for use on a single directory while bzr encourages using stock tools on separate directories. Bzr supports git as just another pluggable storage back end. Git favors fast-forwards and implicit merges, while bzr favors explicit merges.

For BLF purposes, the technical differences are mostly unimportant. It’s primarily a matter of what the participants want to use.

Halo...
Halo...'s picture
Offline
Last seen: 2 years 3 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

Soo, the attiny25/45/85 has a useful extra feature (not available in tiny13) that I’ve been meaning to bring up. Tiny25/45/85s can measure their 1.1v bandgap reference. And this is really useful to us because by setting the ADC reference to vcc and measuring the 1.1 bandgap we can calculate the battery voltage. Of course it’s backwards from how measurements are normally done (use a known reference to measure an unknown) but it doesn’t matter.

Looks like setting REFS[2:0] to 0bX00 will select vcc as ADC reference, and setting MUX[3:0] to 0b1100 will select the 1.1v internal bandgap as the voltage to measure.

Apologies for letting time slip by, not bringing it up sooner.
I would have posted this in the attiny25/45/85 thread but it seems to be occupied with other things at the moment.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

Hmm, interesting. So if I understand correctly, we could free up a pin and maybe remove two resistors on 1-cell tiny25/45/85 drivers? And this wouldn’t work on zener-style drivers because VCC is artificially capped?

In exchange for freeing up a pin and potentially removing a couple components, the voltage resolution would be decreased somewhat… but we’re already getting ~4.5 ADC units per 0.1V, so we have some resolution to spare right now. And it’s currently only using 8 of the 10 available bits of precision anyway.

Is this more or less correct?

Halo...
Halo...'s picture
Offline
Last seen: 2 years 3 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

Yep. I think the greatest benefit might just be gaining a bit more room on the 17mm single sided pcb. Since it sounds like we need to add components to get better stability. Small decoupling cap, FET gate resistor and/or pulldown.

pilotdog68
pilotdog68's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 05/30/2013 - 23:31
Posts: 6419
Location: Held against my will in IOWA, USA

pilotdog68 wrote:
Anybody want to do a bit of work for me? I promise I can’t pay anywhere near a fair wage for your time, but I could send a few bucks via Paypal.

DEL previously helped modify blf-A6 so that Pin 3 could control the FET on my TripleDown boards. It didn’t look to me that it was a major change to the existing FW, but what do I know?

Job 1: Do the same thing with STAR momentary: make a “255” value toggle pin3 instead of the normal output

Job 2: Do the same thing with STAR dual-switch, as well as add dual-pwm support (that might be a bigger job?)


Any takers? PM me. I’m offering $10 for Job 1 and $15 for Job 2 if they work. I think there should be a fair amount of crossover between the two.

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

fixed it
Offline
Last seen: 16 hours 42 min ago
Joined: 12/08/2015 - 14:27
Posts: 392
Location: Canada

pilotdog68 wrote:
pilotdog68 wrote:
Anybody want to do a bit of work for me? I promise I can’t pay anywhere near a fair wage for your time, but I could send a few bucks via Paypal.

DEL previously helped modify blf-A6 so that Pin 3 could control the FET on my TripleDown boards. It didn’t look to me that it was a major change to the existing FW, but what do I know?

Job 1: Do the same thing with STAR momentary: make a “255” value toggle pin3 instead of the normal output

Job 2: Do the same thing with STAR dual-switch, as well as add dual-pwm support (that might be a bigger job?)


Any takers? PM me. I’m offering $10 for Job 1 and $15 for Job 2 if they work. I think there should be a fair amount of crossover between the two.

I’ll do it freely if you’re not in a hurry (I have a busy week ahead) and are willing to accept that you might flash a few buggy revisions. I just got my AVR programmer working and it’ll be a change from trying to hack something from scratch, which I’m certain will involve spectacular failure at some point Smile

Part 1 seems pretty clear but about part 2, do you mean dual-pwm as in the STAR momentary, with ALT_MODES driving pin 5? Does that mean you also need PWM mode selection? I’ll post back in your driver thread once I get around to getting something done.

pilotdog68
pilotdog68's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 05/30/2013 - 23:31
Posts: 6419
Location: Held against my will in IOWA, USA

I’m happy to help as much as I can testing revisions, I just need someone’s help that understands this better than I do.

Both should have pwm options for pins 5 + 6 (like star momentary already does) plus toggle pin 3 for turbo and such. Really exactly what DEL did to blf-a6 for me, but versions for momentary and dual-switch lights

Dual-pwm was really overdue for STAR dual-switch anyways, but JohnnyC just didn’t see the demand for it I think

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

Tom E
Tom E's picture
Offline
Last seen: 7 hours 11 min ago
Joined: 08/19/2012 - 08:23
Posts: 10995
Location: LI NY

Fyi, Halo asked me if I was disabling the AtoD upon sleep mode in my Narsil version, and noticed I wasn't (same as STAR Momentary). So I added turning OFF the AtoD during power sleep mode and it cuts parasitic drain in half -- big gain for a small easy mod in the e-switch firmware we commonly use.

 

So, the STAR Momentary and Ferrero-Rocher both do not have this disabling of AtoD from what I can see, unless there's something I'm missing. Post #789 here has the sleep_mode code. Post #790 here has the result of using 10X values for the R1 and R3 - reduces parasitic drain by a factor of 10. I think this resistor mod needs more testing and review, because it sounds technically it's out-of-spec of the Atmel MCU's, and I'm not sure it can be used with 13A's.

fixed it
Offline
Last seen: 16 hours 42 min ago
Joined: 12/08/2015 - 14:27
Posts: 392
Location: Canada
Tom E wrote:
I think this resistor mod needs more testing and review, because it sounds technically it’s out-of-spec of the Atmel MCU’s, and I’m not sure it can be used with 13A’s.
It’s not a hard spec like the allowed VCC or frequency range (and even these can be stretched). What I could find in the 13A’s doc is:
Quote:
The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely. The user is recommended to only use low impedant sources with slowly varying signals, since this minimizes the required charge transfer to the S/H capacitor.

The way I read this is that you can use larger resistors but the ADC will not run as quickly, which we don’t care about at all.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 11 min ago
Joined: 08/19/2012 - 08:23
Posts: 10995
Location: LI NY

Ahh, that's interesting... So sounds like a pretty good solution for us. If reducing parasitic drain is important to you, then for our e-switch based lights with our custom firmware, this option of using 220K and 47K resistors is the way to go, combined with modding the code to turn off AtoD during sleep mode.

In my tests, I measured from 0.314 mA originally, then with the mods down to 0.016 mA, about a 95% drop.

RMM
RMM's picture
Offline
Last seen: 1 month 1 day ago
Joined: 07/23/2013 - 13:47
Posts: 4006
Location: USA

I am also not sure how much the MCU reading the ADC will affect things when you are using resistors that are that high of value.

I haven't tested values this high myself on the drivers so this is just a guess, but I am predicting much lower precision overall if you go to 10x higher values.  

Also, remember that higher values affect MCU turnoff times when you cut the power.  This won't matter much for momentary only, but for any clicky setup it is something to keep in mind.  It may not be an issue, and you may be able to compensate for it in other ways, but it is something to keep in mind.  

Mountain Electronics : batteries, Noctigon, and much more! What's new? 

Tom E
Tom E's picture
Offline
Last seen: 7 hours 11 min ago
Joined: 08/19/2012 - 08:23
Posts: 10995
Location: LI NY

All I did was simple tests of a cell at 3.6v and one at 4.1v and my firmware blinked out the correct voltage. Need to do a lot more testing, but I've never done calibration to begin with. I've found accuracy though to be pretty good, within 0.1v for the most part using the tables TK had, think from Dale's measurements.

Edit:

Did more tests of various cells, various levels:

Voltage Level Blinking

Actual Voltage (DMM)

18650 cell

4-1

4.12v

AWT 2500

3-5

3.505v

HE4

2-8

2.811v

Sam 15M

4-2

4.21v

30Q

4-2

4.18v

MJ1

4-1

4.14v

MJ1

2-8

2.776v

15M

2-7

2.725v

15M

2-7

2.691v

15M

 

It's about as good as any of my other e-switch lights.

Mike C
Mike C's picture
Offline
Last seen: 1 day 20 hours ago
Joined: 01/22/2014 - 08:03
Posts: 2080
Location: Sweden

RMM wrote:
I am predicting much lower precision overall if you go to 10x higher values.

Maybe calibration is more important when using higher values. With the calibration and using 10 bit values from the ADC I have very good accuracy. Without calibration it was good enough until I bumped into that MCU with a lower internal reference voltage.

As I have E-switch and off time cap on the same pin as the voltage divider I perhaps pay more attention to what is going on. I wrote a debugging routine that blinks out X.XX volts and I want it to be as accurate as it can be. I use real voltage values for off time measuring so the off times are calibrated with the voltage calibration. It was easier for me to see what happens with off times when checking with full and depleted cells, during different temperatures and how the voltage monitoring and off time cap charging behaved during E-switch presses and so on.

I guess for “normal” use you want need calibration, but when using these three functions on the same pin I got much better consistency if I calibrated the internal reference voltage, at least for MCUs that have unusually low/high internal reference voltage.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

RMM wrote:
Also, remember that higher values affect MCU turnoff times when you cut the power. This won’t matter much for momentary only, but for any clicky setup it is something to keep in mind.

I think the plan is to also go with a new driver layout which adds an explicit OTC drain resistor, and probably a bigger OTC. That should help eliminate dependence on voltage divider parasitic drain.

Or use the higher-value resistors on boards which don’t care about OTC, like the fancy lighted tailcaps. If it can sleep at 0.01mA instead of 0.30mA, that’s a huge bonus for tailcap use.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

So… you know how I’ve complained about not knowing how to support Windows? And how it takes pages of explanations with several screenshots to show how to do something that would only take a few short commands on a unix system? Apparently this sort of thing is so common that Microsoft decided to support unix instead of expecting unix tools to support Windows.

Windows 10 is getting the ability to natively run unmodified versions of Ubuntu. In today’s “insider preview” version, it already works.

This means that, even in Windows, you should be able to do flashlight firmware development with a few simple commands. For example, to get the tools, compile something, and flash a driver, you should be able to do something like…

  • Enable the new “Windows Subsystem for Linux” feature.
  • Click the ‘bash’ icon, or start a cmd.exe shell and type ‘bash’.
  • In that shell, run a few commands:
    • apt-get install bzr gcc-avr avr-libc binutils-avr avrdude
    • bzr branch lp:flashlight-firmware
    • cd flashlight-firmware/ToyKeeper/blf-a6
    • ../../bin/build.sh blf-a6
    • ../../bin/flash.sh blf-a6.hex

You don’t even have to type some of it, because pressing <Tab> will auto-complete a lot of things, and the <Up> key recalls previous commands. After the first time it’s easier since you already have it set up (assuming Windows saves the state instead of installing a fresh OS each time).

It’s only a preview so far, but once it’s a little more mature I hope this will make things easier for everyone.

Halo...
Halo...'s picture
Offline
Last seen: 2 years 3 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

I was just reading about the Windows Subsystem for Linux on Arstechnica Why microsoft needed to make windows run linux software. Still, it feels crazy.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 11 min ago
Joined: 08/19/2012 - 08:23
Posts: 10995
Location: LI NY

It’s been around a long time to run VM’s, either a shareware, or full up 3rd party sources. Pretty much everyone in development does this now – I’m not sure I know a developer who doesn’t run multiple OS’s on their computers via VM’s. I would think most servers are now running under VM’s as well – VMWare dominates the market there. Both my clients converted to VMWare a few years back, and pretty much all other shops I’ve heard of with servers to manage have done the same. There’s just so many advantages to it.

I have a Win 7 desktop for my primary development @work, but with Oracle VM VirtualBox, I run Win XP when I need to run old dev tools. For testing, we have VM’s of a whole bunch of Win versions (XP/Win7, Win8’s, Win10 in 32/64 bit versions), including International versions. Same thing can be done for various Unix/Linux/etc VM’s.

I’m not sure if extending Win10 to have the native support is that much of an advantage, maybe some advantages.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

Tom E wrote:
It’s been around a long time to run VM’s, either a shareware, or full up 3rd party sources. Pretty much everyone in development does this now – I’m not sure I know a developer who doesn’t run multiple OS’s on their computers via VM’s. I would think most servers are now running under VM’s as well – VMWare dominates the market there.

Ish. There’s a definite push to have lots of little servers instead of one big one, and to make those little servers independent of the hardware. But instead of fully virtual machines, it’s a lot more efficient to use containers (LXC, chroot, bsd jails, etc). Isolation instead of emulation. And preferably with automatic deployment and load scaling. This often gets grouped under the label of “cloud” computing, using popular tools like OpenStack.

The thing Microsoft just did is to make it possible to run an Ubuntu container under Windows. This probably required a lot of kernel-level API glue code, to translate Linux system calls into Windows system calls, but otherwise should be relatively simple.

Virtual machine-based solutions are still popular, using VMware and Xen and similar tech, but after peaking in 2009 it seems to be declining now in favor of lightweight isolation. This isn’t the best representation, but here’s a trend graph from Google.

mattlward
mattlward's picture
Offline
Last seen: 2 days 9 hours ago
Joined: 06/19/2015 - 09:20
Posts: 2338
Location: Illinois, USA

I am very interested in trying this… but kinda hate to on my main system since it is all beta… I will give it a little time and will try it!

EDC rotation:
Convoy S2+, 6*7135, XM-L2 3D, 10 degree TIR, PilotDog lighted tailcap.
Convoy S2+, H17F, XM-L2 4C, lighted tailcap
Zebralight SC52w-L2
Zebralight SC62w
Olight S1A
Olight S1R

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

mattlward wrote:
I am very interested in trying this… but kinda hate to on my main system since it is all beta… I will give it a little time and will try it!

I have no idea if it’ll actually work (the bash-on-Windows stuff) because I don’t have a Windows computer to try it on. However, it’s supposed to be pretty close to the real thing.

In particular, I’m really unsure if the avrdude step will work, because that requires Microsoft to have all the USB access stuff wrapped properly… and that’s not an easy thing to do. They may have done just networking and task management, since that’s all it would need to get basic web development tools working.

vestureofblood
vestureofblood's picture
Offline
Last seen: 2 days 8 hours ago
Joined: 08/17/2012 - 15:21
Posts: 1663
Location: Missouri

Hi All,

Does anyone have theory as to why I can no longer get atmel 6.2 to recognize my programmer? When I click into the programming box there was always an option that said AVRISP MKII. Now it only says “simulator”

When I disconnected and reconnect the box it makes the noise you would expect. In device manager windows claims its working properly.

Any ideas would be helpful Smile

In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

will34
will34's picture
Offline
Last seen: 2 weeks 3 days ago
Joined: 12/18/2012 - 00:12
Posts: 3411

A little help here… I’m running windows 10 64 bits and have been trying to get my USBASP recognized by either AVRdude and eXtreme burner AVR and nothing…

I did the necessary steps to get the drivers correctly installed, it already appears as USB ASP device in device manager.

This is my programmer and has a jumper to select 3.3V and 5V, I suppose it goes in the 3.3V slot?

Thanks!

ToyKeeper
ToyKeeper's picture
Online
Last seen: 3 min 5 sec ago
Joined: 01/12/2013 - 14:40
Posts: 8243
Location: (469219) 2016 HO3

will34 wrote:
A little help here… I’m running windows 10 64 bits and have been trying to get my USBASP recognized by either AVRdude and eXtreme burner AVR and nothing…

This is my programmer and has a jumper to select 3.3V and 5V, I suppose it goes in the 3.3V slot?

I don’t know how to get it recognized in Windows, but you probably want it configured for 5V.

Pages