E-switch UI Development / FSM

511 posts / 0 new
Last post
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3
oto wrote:
there is slight delay when switching the light off. Is it there because of ramp down UI (click, click&hold)? Is it waiting second click&hold? The delay is a bit too long for my liking.

The delay is because it’s waiting to see if you’re going to click again for a double/triple click. The timing of that can be changed by re-defining RELEASE_TIMEOUT. The default value is 24 frames.

The delay can also be eliminated entirely by mapping the “off” action to EV_click1_release instead of EV_click1_complete (a.k.a. EV_1click), but this will interfere with detecting double clicks. So you’d need to have a “turn emitters off” action on button release, followed by a “go to ‘off’ state” action after the timeout happens. This should be safe, but has the side effect of making it briefly blink off after the first click, even when “off” isn’t the action you were intending.

oto wrote:
Now I am waiting impatiently for candle mode. Googling for “led candle flicker algorithm” shows up some interesting results.

I’m not completely happy with candle mode yet, but here’s an example graph of its output:

Mostly, it seems a bit too spastic when used at low levels, and perhaps a bit too spastic overall. It’s like a candle in a breezy environment. Perhaps I should change it from free-running waves to fading waves triggered by random disturbances. Or maybe just decrease the amplitude on the mid-frequency oscillator. Or maybe make the mid oscillator fade and refresh at random. It’ll take some experimenting. It already does a random sample-and-hold modulation on the mid oscillator frequency, which helps, but it feels like it needs further adjustments.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

In another thread, ‘stephenk’ mentioned that an adjustable strobe frequency is useful for light painting.

I suggested he look into Andúril, with its adjustable-frequency ‘Party Strobe’ and ‘Tactical Strobe’ modes.

He then mentioned that a momentary strobe would also be useful.

Could Andúril’s momentary mode also work with strobe modes? If not officially supported, could it be a compile-time option?

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

Momentary strobe? That’s not a thing I’ve considered.

I added it as a “TODO” note in the code, but I don’t have any plans to add it in upcoming production lights. I suspect that my rainbow saber thing may be more relevant for light painting anyway, since it’s specifically designed to make pretty patterns in the air while swinging a lighted sword. It does whatever patterns the user tells it to, and has a full color palette to work with. This includes a momentary “overdrive” function, which could potentially be configured in a manner similar to what he might want.

Hmm, I just tried it by turning the brightness down all the way on a police flasher mode, hoping that it’d become momentary-only so it only lights up in overdrive. However, the brightness mod is additive instead of subtractive, so it still flashes while idle — just not as bright. Overdrive works fine, but the non-overdrive isn’t dark like I had hoped. This could be fixed by making it subtractive, but I’m not sure if that’d be a good idea outside of this momentary thing.

zifzif
Offline
Last seen: 4 months 1 day ago
Joined: 04/28/2017 - 11:43
Posts: 31
ToyKeeper wrote:
dekozn wrote:
Is there a hex file available …

No, I don’t think it’s quite ready for stable release yet. This is all still alpha or beta code. It’s not even merged into trunk yet.

dekozn wrote:
TA FET+1+16 (or 8AMCs) driver? I want to order 2 drivers from lexel and would like em to be flashed with anduril, Lexel can flash them for me with any kind of firmware but he needs/wants the hex file as he “can’t calibrate Anduril like he’s used to in Narsil”. I myself have no clue what a HEX file is used for or if there is any difference between the hex file for a FET+1+8 and a FET+1+16 driver Facepalm

In general, the ramp (including moon level and ramp shape) needs to be calibrated for each combination of driver type and emitter configuration. A FET+7+1 and FET+16+1 have different ramp shapes, a single XP-G2 and a quad XP-L have different ramp shapes, a raptor-claw and failboat 7135 chip have different moon levels, a 1-channel/2-channel/3-channel driver all have different configurations, an old XM-L and new XM-L2 have different moon levels, a 1-cell (or parallel cell) host and 2/3/4-cell serial host have massively different ramp values (and need different methods of measuring voltage), hosts with/without indicator LED need different configs, hosts with/without a tail clicky need different configs, etc. The full set of configurations grows exponentially with each option.

There is the approach of trying to build a .hex file for every possible config, and hosting dozens or hundreds or thousands of them in the repository, but this means an awful lot of completely untested builds and it’s expensive in terms of repository size. It’s mostly just useful as a brute-force way to test builds to make sure each configuration can at least compile. I don’t think I’ll be hosting all those .hex files though.

My preferred solution is to provide sources only, plus a very small number of stable and well-tested .hex files targeted to very specific and popular hardware — like one for the D4, one for the Q8, and one for the FW3A. For hardware produced in smaller quantities, it’s someone else’s job to build and test.

I’m a bit late here, but I’d like to add my two cents. First of all, you’re 100% correct that it’s impossible to create, test, and host dozens of *.hex files for every hardware configuration out there. However, I do think there is good demand for an alternative to NarsilM on TA drivers. Perhaps we could talk you in to creating one “master” triple-channel *.c file, a la Bistro Tripledown? You’ve made it easy enough for all of us to utilize your /bin/ files for things like ramping table calculation, etc. I’m proficient enough in C and Python to write basic programs and edit your (very well-commented) code, but I have no clue where to start when it comes to adding a third power channel.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

In this case, the only change necessary to support popular hardware is to uncomment one line at the top of the file.

// Physical driver type
//#define FSM_EMISAR_D4_DRIVER
//#define FSM_BLF_Q8_DRIVER
//#define FSM_FW3A_DRIVER

There’s a good chance the TA drivers would work with the FW3A options.

However, adding a new driver type is a bit more tricky.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

At the moment, the moon-in-lockout checks the floor for both ramps and uses whichever is lower. This makes the behavior consistent regardless of which ramp is active, but it can also make moon too low sometimes. Do people think it should instead use the current ramp floor instead of checking both? This would effectively give it the ability to change the lockout brightness by switching between ramps, perhaps with a day mode and a night mode, but it might also lead to surprises if the user forgets which ramp is active.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

ToyKeeper wrote:
Do people think it should instead use the current ramp floor instead of checking both?
I think I’d prefer it use the current ramp’s floor.

I haven’t reflashed Andúril in a while. I’ve been waiting for Candlelight Mode to be perfected. Party

Has Muggle Mode been implemented? Does lockout work in Muggle Mode? I like the thought of being able to teach muggles the importance of lockout, both software- and hardware-based.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

Ah, been a bit distracted by holiday stuff and fixing FW3A issues, so candle mode hasn’t changed.

Muggle mode is implemented but not published yet. There hasn’t been much consensus about how that should look, so for now it’s a simple latching on/off at 1×7135 (~150 lm) with no bells or whistles. I haven’t even made it dim for LVP yet, though I probably should. For now, it just turns off.

Sirius9
Sirius9's picture
Offline
Last seen: 2 hours 44 min ago
Joined: 03/04/2012 - 19:23
Posts: 4437
Location: South Europe

How hard would be to do this:
only one mode (100%), it works while you hold down the e-switch, shuts off when you let go the e-switch. Driver is nanjg 105C?

Need this for diving light that had magnetic switch and driver died so I thought to use regular nanjg 105c and replace e-switch with reed magnetic switch!

 

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

Siruis9, that should be fairly easy but it’ll need to use something smaller as a code base. The FSM library doesn’t fit onto attiny13 like the nanjg driver uses. I’d suggest using STAR_momentary or Ferrero Rocher as a base, and basically just stripping out features until it’s a one-mode momentary interface.

Sirius9
Sirius9's picture
Offline
Last seen: 2 hours 44 min ago
Joined: 03/04/2012 - 19:23
Posts: 4437
Location: South Europe

Thanks TK, I will give it a try Thumbs Up

 

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

ToyKeeper wrote:

// Physical driver type
//#define FSM_EMISAR_D4_DRIVER
//#define FSM_BLF_Q8_DRIVER
//#define FSM_FW3A_DRIVER

There’s a good chance the TA drivers would work with the FW3A options.

However, adding a new driver type is a bit more tricky.

TK, do you have a suggestion as to what settings I should use for the BLF GT?

I’ve just gotta have Andúril in my GT when it arrives!

That’ll make nine lights running my favorite UI. Party

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

Oh, the GT will require some additional changes in order to work. Its power circuit functions somewhat differently than the Q8. I’m hoping to get a GT and port FSM to it, but I have no idea when that will happen.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

ToyKeeper wrote:
I’m hoping to get a GT and port FSM to it, but I have no idea when that will happen.
My GT should arrive in a few days.

Let me know if you’d like to borrow the driver / head / entire flashlight for ‘research.’ Smile

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

I demonstrated a few of my lights at a party last night. The GT, Q8, Meteor, and Emisars were all big hits.

It was about 0° F (-18° C) so thermal stepdowns were not an issue. Big Smile

About an hour later one of the kids announced, “There’s a flashlight going crazy outside.”

I had left my D4 outside on a windowsill in Andúril’s ‘Lightning Storm’ mode. Party

dave1010
Offline
Last seen: 1 day 10 hours ago
Joined: 07/04/2017 - 02:38
Posts: 16
Location: United Kingdom

Managed to flash Anduril on my D4!

That’s the first time I’ve ever modded a flashlight, so thanks ToyKeeper both for writing the firmware and introducing me to this exciting world.

I’m keen to tweak the C and have a go at implementing some new modes. I’ve that I’m not an expert at soldering though and wouldn’t be surprised if I damaged the D4 if I tried doing it again.

Did I read somewhere that the Q8 can be flashed without needing to solder anything? That might be a good enough reason to get one if so.

Also, is there a definitive list of lights that work with Anduril? I’m assuming anything with an e-switch and an attiny85 would work but it’s often hard to find out what chip a light has. Are there any C8 style lights that might work with it or is the D1s the closest thing?

This is going to get expensive now!

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

dave1010 wrote:
Managed to flash Anduril on my D4!

That’s the first time I’ve ever modded a flashlight, so thanks ToyKeeper both for writing the firmware and introducing me to this exciting world.

Congratulations! TK and Andúril got me into reflashing too! Smile

dave1010 wrote:
Did I read somewhere that the Q8 can be flashed without needing to solder anything? That might be a good enough reason to get one if so.
My first-run and second-run Q8s both have wires long enough to flip the driver over without desoldering anything. It’s an awesome light, too!

I’m not sure if the current Q8s allow this. Perhaps someone with a recent sample can chime in.

dave1010 wrote:
Also, is there a definitive list of lights that work with Anduril?
In addition to the Q8s, I have Andúril running on my Emisar D4, D1, and D1S. I also have it on a modded EagleEye X6R with a Texas_Ace driver from Lexel. The X6R’s design takes advantage of Andúril’s dual-switch option, which works great.
dave1010
Offline
Last seen: 1 day 10 hours ago
Joined: 07/04/2017 - 02:38
Posts: 16
Location: United Kingdom

Some more random observations and feedback, after playing with it for about a day:

  • bike flasher is excellent and means I’ve technically saved money by buying a USB programmer and SOIC clip (compared to a dedicated bike light).
  • Momentary moon on lockout is handy and good makes the D4 kid-safe
  • Having 2 different lockout moons (from the 2 ramps) would be ideal
  • Adjustable party strobe level (eg using using memorized level or bike flasher level) would be a nice to have but realistically, the party’s strobe won’t get lots of use anyway
  • Good night mode being ramp-able, maybe having a config for time to off, would be another nice to have. I haven’t actually tried good night mode yet though.
  • A good morning / alarm mode would be very cool. I know there’s issues with power usage though.
dave1010
Offline
Last seen: 1 day 10 hours ago
Joined: 07/04/2017 - 02:38
Posts: 16
Location: United Kingdom

goshdogit wrote:
My first-run and second-run Q8s both have wires long enough to flip the driver over without desoldering anything. It’s an awesome light, too!

I’m not sure if the current Q8s allow this. Perhaps someone with a recent sample can chime in.

Thanks. I guess if longer wires can fit then you could always do a one-off resolder for longer wires if needed. I’d give that a go on my D4 but I doubt there’s space and there’s a good chance I’d damage the driver.

goshdogit wrote:
In addition to the Q8s, I have Andúril running on my Emisar D4, D1, and D1S. I also have it on a modded EagleEye X6R with a Texas_Ace driver from Lexel. The X6R’s design takes advantage of Andúril’s dual-switch option, which works great.

The X6R looks nice. With the cost of getting a new driver for it the D1S looks quite reasonable though.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

So far, only a single e-switch is supported… with the option of also using a power switch to make it do momentary-style use in the regular output mode (no need for a separate momentary mode). Without an e-switch it won’t do much.

Two different lockout moons is easy to do; it mostly just depends on whether people think it’s better.

Adjustable party strobe brightness is a little tricky. The pulses are generally only ~4 PWM cycles long. It turns on for 4*512 clock cycles, then turns off. If the brightness is adjustable, it’ll actually pulse 4 times per strobe instead of once. That’s not ideal. Of course, the method I’m using for short strobe pulses already isn’t ideal. I’ve been meaning to make it control the power chips in more of a raw mode, on for N clock cycles instead of N/512 PWM cycles, but that adds code complications because it bypasses the abstraction used to control output brightness. So it locks brightness to a sweet spot on the ramp where PWM is steady, and sometimes stays lit for 4 cycles or sometimes for 5, depending on random factors.

Anyway, um, kind of a long tangent, but party strobe has some known limitations which aren’t trivial to fix.

Making the sunset mode adjustable, and adding sunrise mode, seems like a better thing to prioritize.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

dave1010 wrote:
The X6R looks nice. With the cost of getting a new driver for it the D1S looks quite reasonable though.
The D1S is an amazing bargain.

I built my X6R before the D1S was available. The smooth, tapered shape is a bit more ‘pocket friendly,’ and like using it with the tailcap switch for momentary turbo while hiking with a headlamp.

If I had to choose between the X6R and D1S, I’d choose the D1S. Party

BTW, I posted some beamshot comparisons of the X6R, D1, D1S and a few other lights when my D1S arrived.

What light will you be using on your bike and how will you mount it?

dave1010
Offline
Last seen: 1 day 10 hours ago
Joined: 07/04/2017 - 02:38
Posts: 16
Location: United Kingdom
goshdogit wrote:
What light will you be using on your bike and how will you mount it?

I used the D4 today on the road. Pointed down almost 45° as it’s so floody. Mounted on one of these but I’ll probably order a more lightweight clip.

I’m considering getting a D1S or Q8 though, as the D4 is currently my farthest thrower. Just need a good excuse to spend the money!

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3
dave1010 wrote:
I’m considering getting a D1S or Q8 though, as the D4 is currently my farthest thrower.

Both are good, depending on what you need. One of the main things is to match the beam type to what you’re doing. From floodiest to throwiest:

  • D4: ~4 cd / lm
  • Q8: ~12 cd / lm (?)
  • D1: ~30 cd / lm
  • D1S: ~100 cd / lm

For biking I use a very floody light like the D4, and I find the D1 is usually throwy enough for my needs when I need to see farther. The D1S and Q8 are also very good at what they do, but I don’t use them as much because of the size.

Then again, size isn’t always a deal-breaker. I might have a BLF GT on the way (~500 cd / lm), which totally dwarfs all these other lights. It won’t exactly be an EDC, but I’ll make excuses to use it… because that’s just the kind of item it is. Smile

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

FWIW, I pushed a bunch of changes to FSM / Anduril. A lot of things should be nicer now, but there’s one specific thing I haven’t tested yet and don’t trust. On a hotrod like a D4-219c, I don’t think it’ll regulate down fast enough on full turbo. However, it did pretty well on my FW3A at the highest regulated level, 8×7135. I need to do more testing and tweaking to make sure it won’t burn people with a quad 219c though.

FSM dev branch, getting closer to stable so maybe I can merge it into trunk soon.

Changes:

  • Made eeprom writes somewhat more atomic, less likely to do weird things if power is interrupted mid-write.
  • Added a super-simple muggle mode. One level, 150lm, click on/off. Has LVP.
  • Added candle mode, next to lightning mode. Is particularly nice in the bathtub.
  • Added FW3A support.
  • Made lockout moon level use current ramp config instead of whichever ramp is lower.
  • Completely reworked button debouncing so it’ll be okay even on a really noisy switch.
  • Fixed LVP / thermal issues (ADC was triggering 4000X / second instead of the expected 4X, which made things weird).
  • Thermal regulation changes…
    • Instead of ~85 steps, it now uses 256 or 512 (for a 2- or 3-channel driver). This makes adjustments invisible by eye, but they still show up on a lux meter. Try zak.wilson’s ceilingbounce app if you want to measure it.
    • Won’t adjust below 1×7135 level any more.
    • Adjustment speed changes with how far it needs to go.
    • Added the ability to calibrate the thermal sensor, to reduce issues from the attiny’s per-unit variation.

… and I updated the UI diagram a bit:

The thermal config generally involves a lot of clicks… sorry. Hopefully it only needs to happen one time though, to calibrate the sensor.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

ToyKeeper wrote:
FWIW, I pushed a bunch of changes to FSM / Anduril.
Great! I’m gonna update one of my Q8s to give Candle Mode a test. Smile

ToyKeeper wrote:

FSM dev branch, getting closer to stable so maybe I can merge it into trunk soon.
Did you mean to use this link?

It’s been several months since I reflashed a driver, and I’m still a noob. I’m using my notes to compile Anduril, but am running into 300+ errors.

The first is in Makefile line 79 “recipe for target ‘main.o’ failed”.

The next few errors are in main.c in lines 11 to 14 that seem to be caused by some references to folders and .png files in the repository.

The rest are in main.c lines 1500 to 3000 and are “stray ‘#’ in program” errors.

It seems I have a fundamental issue with my workflow, but as I mentioned, I’m a total noob.

Are my errors due to some change in the organization of code and header files? I see that Anduril.c has lots of stuff up top that wasn’t there before. LOL

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

I haven’t actually tried to build anything in Atmel Studio. It might be easier to use a build I made for Dale.

http://toykeeper.net/torches/dbcstm/anduril-d4.2018-01-24.hex
http://toykeeper.net/torches/dbcstm/anduril-q8.2018-01-24.hex

Anyway, I made some videos showing some of the fancier modes.

3 minutes of lightning storm mode:

3 minutes of candle flicker mode:

Play both videos at the same time if you want to simulate taking shelter by a fire while a storm goes by. ;P

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

ToyKeeper wrote:
I haven’t actually tried to build anything in Atmel Studio. It might be easier to use a build I made for Dale.
Thanks!

I’ll keep fiddling with AmtelStudio. I’ll report back if I end up with a successful build.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 56 min ago
Joined: 12/03/2015 - 21:28
Posts: 831

I’ve had some success getting closer to a build!

Turns out I mixed up some header files and somehow got an anduril.c file filled with XML code. Facepalm No wonder it looked so different! Silly

At this point I’m getting an error indicating that “region ‘text’ overflowed by 154 bytes” when attempting a build for the Q8.

The only changes I’ve made were to comment out the blinks at ramp floor, ramp ceiling, and channel boundaries.

zifzif
Offline
Last seen: 4 months 1 day ago
Joined: 04/28/2017 - 11:43
Posts: 31

I had that same “region ‘text’ …” error when trying to compile Narsil a few months ago. If I recall, changing the configuration from “debug” to “release” solved the problem. Must be some strange accidental modification in the config manager. Perhaps debug isn’t using any optimization?

FWIW, I’m also having trouble building Anduril in Atmel Studio 7. I might be overlooking something obvious, but I have all of the dependencies in place, and the only change I made for this first test was a #define for the hardware type.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 8247
Location: (469219) 2016 HO3

All the settings I use are in the bin/build-85.sh script. In theory, it should work by plugging those values into Atmel Studio, but I’m not sure where it puts them.

Pages