Flashlight Firmware Repository

2239 posts / 0 new
Last post
FmC
FmC's picture
Offline
Last seen: 7 months 3 days ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

Atmel Studio v7 released.

 

I was switching over to a new PC today, & went to d/load v6.2, but noticed that v7 had just been released.

I'm still d/loading as I type, so can't give any feedback yet.

Anyone else taken the plunge?

 

FmC
FmC's picture
Offline
Last seen: 7 months 3 days ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

v7 Up & running, tested by building the A6 firmware.

Had to set the optimize for size (-Os), as per previous versions.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 hours 35 min ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3

Cool. BTW, what size was the output? Does it let you see the actual gcc command line? I get 1002 bytes:

[-(Sun 2015-09-27 14:43:22)-(~/src/torches/trunk/ToyKeeper/blf-a6/)-]> ../../bin/build.sh blf-a6
avr-gcc -Wall -g -Os -mmcu=attiny13 -c -std=gnu99 -DATTINY=13 -o blf-a6.o -c blf-a6.c
avr-gcc -Wall -g -Os -mmcu=attiny13 -o blf-a6.elf blf-a6.o
avr-objcopy --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex blf-a6.elf blf-a6.hex
Program:    1002 bytes (97.9% Full)
Data:         13 bytes (20.3% Full)
FmC
FmC's picture
Offline
Last seen: 7 months 3 days ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

ToyKeeper wrote:
Cool. BTW, what size was the output? Does it let you see the actual gcc command line? I get 1002 bytes:
[-(Sun 2015-09-27 14:43:22)-(~/src/torches/trunk/ToyKeeper/blf-a6/)-]> ../../bin/build.sh blf-a6
avr-gcc -Wall -g -Os -mmcu=attiny13 -c -std=gnu99 -DATTINY=13 -o blf-a6.o -c blf-a6.c
avr-gcc -Wall -g -Os -mmcu=attiny13 -o blf-a6.elf blf-a6.o
avr-objcopy --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex blf-a6.elf blf-a6.hex
Program:    1002 bytes (97.9% Full)
Data:         13 bytes (20.3% Full)

Here's the entire output stream;

---------------

"D:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -o GccApplication2.elf  main.o   -Wl,-Map="GccApplication2.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=attiny13a -B "D:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny13a" 
        Finished building target: GccApplication2.elf
        "D:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures  "GccApplication2.elf" "GccApplication2.hex"
        "D:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom  --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0  --no-change-warnings -O ihex "GccApplication2.elf" "GccApplication2.eep" || exit 0
        "D:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "GccApplication2.elf" > "GccApplication2.lss"
        "D:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "GccApplication2.elf" "GccApplication2.srec"
        "D:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "GccApplication2.elf"
           text       data        bss        dec        hex    filename
            996          0         13       1009        3f1    GccApplication2.elf
    Done executing task "RunCompilerTask".
    Using "RunOutputFileVerifyTask" task from assembly "D:\Program Files (x86)\Atmel\Studio\7.0\Extensions\Application\AvrGCC.dll".
    Task "RunOutputFileVerifyTask"
                Program Memory Usage     :    996 bytes   97.3 % Full
                Data Memory Usage         :    13 bytes   20.3 % Full
    Done executing task "RunOutputFileVerifyTask".
Done building target "CoreBuild" in project "GccApplication2.cproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "Build" in file "D:\Program Files (x86)\Atmel\Studio\7.0\Vs\Avr.common.targets" from project "C:\Users\FmC\Documents\Atmel Studio\7.0\GccApplication2\GccApplication2\GccApplication2.cproj" (entry point):
Done building target "Build" in project "GccApplication2.cproj".
Done building project "GccApplication2.cproj".

---------------

ohaya
Offline
Last seen: 2 years 7 months ago
Joined: 03/16/2013 - 19:01
Posts: 5337
Location: US

Hi,

Does anyone know if there is firmware that works similar to the FT NANJGs, i.e., where you can switch between one of 2 mode groups via clicking in low mode and which would work with a single FET driver with PWM on pin 6 on an ATTINY13A:

Group 1: Low – Medium – High
Group 2: Low – Medium – High – Strobe – SOS

Also, where it’d be fairly easy to modify the modes in the mode groups in the source.

Basically, I want to have a UI in a ATTINY13A-based FET driver that mimics the FT NANJGs, but where I’d probably add a moonlight to both mode groups.

Thanks,
Jim

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

Using JohnyCs  star off time how would I get a tubo timer that is like 6 min?
http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/view/he...

I see that I need either more possible ticks than 255 or longer than 500ms, but I am not certain what to change.

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.

sb56637
sb56637's picture
Offline
Last seen: 1 day 17 hours ago
Joined: 01/08/2010 - 09:29
Posts: 6882
Location: The Light

Oops, I just realized this thread wasn’t sticky. It is now.

Budget Light Forum ...where Frugal meets with Flashlight!

ohaya
Offline
Last seen: 2 years 7 months ago
Joined: 03/16/2013 - 19:01
Posts: 5337
Location: US
sb56637 wrote:
Oops, I just realized this thread wasn’t sticky. It is now.

Thanks! Good idea :)!

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 hours 35 min ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3

FmC wrote:
Here’s the entire output stream; …

D’oh. It looks like that includes everything except the first step, the one where it converts a .c file into a .o file. And that’s the one I’m most hoping to see. Smile

In any case, it appears that the new version saves about 6 bytes. I’d like to know what build options it uses to make the result smaller. Maybe it’s just a newer version of gcc, but maybe not.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 hours 35 min ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3

ohaya wrote:
Does anyone know if there is firmware that works similar to the FT NANJGs, i.e., where you can switch between one of 2 mode groups via clicking in low mode … Also, where it’d be fairly easy to modify the modes in the mode groups in the source.

Basically, I want to have a UI in a ATTINY13A-based FET driver that mimics the FT NANJGs, but where I’d probably add a moonlight to both mode groups.


The main options right now are STAR or NLITE, and neither is quite what you described. I don’t think anyone has done the mode group switch via blink-on-low, because very few people seem to like that. Neither one has blinky modes, either. STAR’s code is open though, if you’d like to use it as a starting point.
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 hours 35 min ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3

vestureofblood wrote:

Using JohnyCs  star off time how would I get a tubo timer that is like 6 min?
http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/view/he...

I see that I need either more possible ticks than 255 or longer than 500ms, but I am not certain what to change.


Change the ‘ticks’ variable to a uint16_t and set its limit to 65535, and then you can have a turbo timeout up to about 9 hours.
FmC
FmC's picture
Offline
Last seen: 7 months 3 days ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

ToyKeeper wrote:
FmC wrote:
Here's the entire output stream; ...
D'oh. It looks like that includes everything except the first step, the one where it converts a .c file into a .o file. And that's the one I'm most hoping to see. Smile In any case, it appears that the new version saves about 6 bytes. I'd like to know what build options it uses to make the result smaller. Maybe it's just a newer version of gcc, but maybe not.

This may be what you are interested in?;

Invoking: AVR/GNU C Compiler : 4.9.2
        "D:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG  -I"D:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.0.68\include"  -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=attiny13a -B "D:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.0.68\gcc\dev\attiny13a" -c -std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c"
        Finished building: .././main.c

Maybe I missed it this morning, as I was running late for work when I posted.

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

ToyKeeper wrote:
vestureofblood wrote:

Using JohnyCs  star off time how would I get a tubo timer that is like 6 min?
http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/view/he...

I see that I need either more possible ticks than 255 or longer than 500ms, but I am not certain what to change.

Change the 'ticks' variable to a uint16_t and set its limit to 65535, and then you can have a turbo timeout up to about 9 hours.


Thanks TK.

I clipped this beginning at line 272.

ISR(WDT_vect) {
	static uint8_t ticks = 0;
	if (ticks < 255) ticks++;
	// If you want more than 255 for longer turbo timeouts
	//static uint16_t ticks = 0;
	//if (ticks < 60000) ticks++;


Is this the correct place to change it from?


So it will look like this?

ISR(WDT_vect) { static uint16_t ticks = 0; if (ticks < 65535) ticks++; // If you want more than 255 for longer turbo timeouts //static uint16_t ticks = 0; //if (ticks < 60000) ticks++;

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.

pyro1son
pyro1son's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

Think it should be:

ISR(WDT_vect) {
//static uint8_t ticks = 0;
//if (ticks < 255) ticks++;
// If you want more than 255 for longer turbo timeouts
static uint16_t ticks = 0;
if (ticks < 65535) ticks++;

Pastebin                                      &nbs

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

Oh duh, your probly right.   I did not even notice that bit at the bottom where it already had the static uint16_t ticks = 0;   bit.

I had tried before asking in the thread by just enabling the 6000 ticks part and commenting out the unit_8 bit.   

I will try that and report back.

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.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 hours 35 min ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3

FmC wrote:
This may be what you are interested in?

Invoking: AVR/GNU C Compiler : 4.9.2 …


Thanks! That had all the info I was looking for.

It looks like the options make no difference in size, but the version of the compiler does. I’ve currently got 4.7.2 on one box and 4.8.1 on another; it seems debian doesn’t have 4.9.2 yet. Smile

Fortunately, the difference is small… 1002 bytes, 1000 bytes, or 996 bytes (for 4.7.2, 4.8.1, and 4.9.2).

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

pyro1son wrote:

Think it should be:

ISR(WDT_vect) {
//static uint8_t ticks = 0;
//if (ticks < 255) ticks++;
// If you want more than 255 for longer turbo timeouts
static uint16_t ticks = 0;
if (ticks < 65535) ticks++;



Ok that did do the trick.     T timer is good now.      

One more question.     Does anyone happen to know what causes that whining noise on MED mode.     What I mean is with some setups I get it and some I dont.      I use the same FET drivers for almost all my lights, just different firmware and emitters, hosts etc.

Right now I have this driver setup with 2 26650s and an XHP70.    On low (2) I get no PWM whine, on med (39) I get a bad one. and of course none on high.  

Is there a fix for this?

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.

ReManG
Offline
Last seen: 5 hours 25 min ago
Joined: 04/25/2015 - 22:52
Posts: 2643
Location: Between the Mexico's
vestureofblood wrote:

pyro1son wrote:

Think it should be:

ISR {
//static uint8_t ticks = 0;
//if (ticks < 255) ticks++;
// If you want more than 255 for longer turbo timeouts
static uint16_t ticks = 0;
if (ticks < 65535) ticks++;



Ok that did do the trick.     T timer is good now.      

One more question.     Does anyone happen to know what causes that whining noise on MED mode.     What I mean is with some setups I get it and some I dont.      I use the same FET drivers for almost all my lights, just different firmware and emitters, hosts etc.

Right now I have this driver setup with 2 26650s and an XHP70.    On low (2) I get no PWM whine, on med (39) I get a bad one. and of course none on high.  

Is there a fix for this?

I surrounded my one driver that was doing this (Edit: JUST the FET, left room to attach the SOIC clip) with some RTV, seemed to help. I guess duct seal would work as well (search for POTTING here on BLF) and be more temporary if you wanted to remove it later…

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

I think the driver whining is still an unresolved question.

Has any tried potting a whining driver? Preferably with something removable like fujik heatsink compound, neutral cure silicone, or one of those removable potting mixes that people have posted.

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

30 sec too slow. Big Smile

You only potted the fet, not the caps and resistors, correct? Did the driver have a spring? Consider trying those small brass pillars that they sell?

ReManG
Offline
Last seen: 5 hours 25 min ago
Joined: 04/25/2015 - 22:52
Posts: 2643
Location: Between the Mexico's

Halo… wrote:
30 sec too slow. Big Smile

You only potted the fet, not the caps and resistors?

Yes, just the FET, as far under it as I could. A big dab on top as well. It wasn’t that loud of a whine originally, but I couldn’t hear it afterwards.. I would bet that changing something acoustically would cancel your whine, as it is a sympathetic vibration, not a direct tone being generated. Changing the airspace with a chunk of old pencil eraser or a packing peanut may even help…

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

Yes, I have potted drivers many times to resolve this.   Using various items ranging from the silicone heat sink material that comes with some Chinese drivers all the way up to full encasement in JB weld.   

EDIT:  One other thing I have noticed that helps is not using a spring on the bottom of the driver.   Especially one like the spring that comes out of the switch post of a maglte.   These act like small record needles or amplifiers.   

I was just hoping there was a fix that could be done by editing the firmware.   For example tweaking the PWM level of medium mode a few percent or something.

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.

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

I just noticed something else.    What would happen if I changed this line. 

#define FAST_PWM_START        8 // Above what output level should we switch from phase correct to fast-PWM?


What would be the effect if I changed that 8 to like a 50?    

The reason I ask is it seems to have reduced the whine of the medium mode slightly ( maybe I imagined it), but I am wandering if there will be any side effect?   Like a flicker on med or something?

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.

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

Phase correct is slower PWM. But different people have different tolerances for flicker. If this is for a personal light and your aren’t bothered by it then no harm.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 hours 35 min ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3

In general, phase-correct PWM tends to be easier to hear than fast PWM… but it really depends on the harmonics of your exact build.

I’d like to see if the whining issue goes away with attiny25 drivers and a higher clock speed.

The loudest I’ve heard is actually a different issue… on my Cypreus (triple XP-L HI, FET+7135), it clicks every time it goes between off and turbo. So, the strobe modes make both light and (a bit of) sound.

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

Ya, part of what has me so stuck right now is the light body I am using.     I finally gave up and JB welded the driver and insulated it with some foam in addition.     There is still a little whine when its outside the host, but much less.    However the body of this light is a very thin stamped metal that acts like a radio antenna when its installed.
http://www.flashlightmuseum.com/Rayovac-Flashlight-D367F-7-Cell-Sportsma...

Very cool and retro looking, but man has it been a pain.

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.

pilotdog68
pilotdog68's picture
Offline
Last seen: 1 year 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6420
Location: Held against my will in IOWA, USA

I have something strange happening. Can you see any reason in this code that the turbo timer would step down at 30 seconds in the first group, and not step down at all in the second group?

edit: here is a diff check. (Stock BLF A6 on the left, the FW in question on the right.)

I tried both “255” and “TURBO” to designate turbo in the mode groups, and i tried both 88 and 90 as the turbo timeout, but still the same results.

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 hours 35 min ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3

pilotdog68 wrote:
I have something strange happening. Can you see any reason in this code that the turbo timer would step down at 30 seconds in the first group, and not step down at all in the second group?

edit: here is a diff check. (Stock BLF A6 on the left, the FW in question on the right.)


I don’t see anything which looks like it would explain that, but you might want to also remove the details for the hidden modes instead of just setting the count to zero. And I’d suggest setting channel 2 to 0 instead of 255 while on turbo, since the 7135 chip actually reduces output on turbo.

With those settings, turbo should be stepping down at 45 seconds, not 30 seconds.

pilotdog68
pilotdog68's picture
Offline
Last seen: 1 year 1 week ago
Joined: 05/30/2013 - 23:31
Posts: 6420
Location: Held against my will in IOWA, USA

I’ll try that. Is there some kind of clause in the FW that doesn’t trigger the timer when only the 2nd channel is at 255?

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 20 hours 35 min ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3

Turbo only activates when the first power channel (FET) is at 255. Here are some lines which explain why:

#define TURBO     255
...
output = pgm_read_byte(modesNx + mode_idx);
...
if ((ticks > TURBO_TIMEOUT) && (output == TURBO)) { ... }

So, it bases its actions on the content of the modesNx array. This gets pointed at either the first or second mode group’s FET channel.

Pages