STAR Firmware by JonnyC - Source Code and Explanation

1335 posts / 0 new
Last post
zeremefico
zeremefico's picture
Offline
Last seen: 10 hours 10 sec ago
Joined: 03/27/2012 - 02:44
Posts: 1389
Location: Greece

I would like to build a flashlight for general & bicycle use.
I am thinking for h-l-strobo.
Is it possible to add a slow strobo in Star firmware?

₪₪₪₪ ΟΥΔΕΝ ΚΡΥΠΤΟΝ ΥΠΟ ΤΟΝ ΗΛΙΟ ₪₪₪₪

My YouTube channel

Flashlights & edc gear

K40M F16

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

Hopefully a quick question.

I read the below wiki post on changing the PWM frequency.

https://github.com/JCapSolutions/blf-firmware/wiki/PWM-Frequency

Why would a frequency below 9kHz be desirable?

As I understand it, the setup around 9kHz generates the least PWM noise.

Any insights?

Tom E
Tom E's picture
Offline
Last seen: 5 hours 38 min ago
Joined: 08/19/2012 - 08:23
Posts: 14626
Location: LI NY

zeremefico wrote:
I would like to build a flashlight for general & bicycle use. I am thinking for h-l-strobo. Is it possible to add a slow strobo in Star firmware?

Boy, long time - no one asnwered. Yes, of course it's possible. I got more advanced versions, but based on STAR - got lots of blinkies as options.

Tom E
Tom E's picture
Offline
Last seen: 5 hours 38 min ago
Joined: 08/19/2012 - 08:23
Posts: 14626
Location: LI NY

HighEfficiency wrote:
Hopefully a quick question. I read the below wiki post on changing the PWM frequency. https://github.com/JCapSolutions/blf-firmware/wiki/PWM-Frequency Why would a frequency below 9kHz be desirable? As I understand it, the setup around 9kHz generates the least PWM noise. Any insights?

No, think he means 9 kHz is too low, higher rates are desirable and possible. I use phase mode on the Tiny25 and Tiny85 at about 15.6 kHz, and I beleive my 13A code uses 18 .8 kHz in FAST mode.

DEL
DEL's picture
Offline
Last seen: 3 years 6 months ago
Joined: 06/28/2015 - 08:35
Posts: 559
Location: Canada

HighEfficiency wrote:
Hopefully a quick question.

I read the below wiki post on changing the PWM frequency.

https://github.com/JCapSolutions/blf-firmware/wiki/PWM-Frequency

Why would a frequency below 9kHz be desirable?

As I understand it, the setup around 9kHz generates the least PWM noise.

Any insights?

Efficiency, lower and more stable moon mode.

High PWM frequency is OK for FET drivers. 7135 chips, on the other hand, are relatively slow and require a minimum PWM pulse width to fully turn on. This is why you may see discussions around using minimum 5-6/255 PWM duty cycle, and the sensitivity of this number related to the exact hardware in use (cell voltage, emitter type, driver, etc).

Against BLF wisdom I use 2.4 kHz PWM with FET+1 drivers. I do not PWM the FET though, only the 7135. No audible whine, and no visible (to me) PWM. Nice low moon mode. FET is used only for full-on turbo mode.

You could try 18.8 kHz PWM for the FET (MCU clock at 9.6 MHz, phase-correct PWM) and switch to a PWM divider of 8 (2.4 kHz PWM) when only the 7135 is in use. That should give the best of both worlds.

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

PWM frequency is something which depends a lot on personal taste.

Some people can’t stand anything in human hearing range, since the pulses make noise. So, nothing below 16kHz or 18kHz or whatever the top of their hearing provides.

Some people (like me) can’t stand anything with visible pulses, and sensitivity to that varies a lot per person. Like, I can see 8 kHz or slower PWM pretty easily, and anything under 2 kHz looks like a strobe light to me.

Some people prefer to focus on efficiency and stability instead, which slower pulses are better at. Slower pulses work on more hardware and provide more consistent output with higher efficiency. So, those are some pretty good reasons to slow it down as far as you can tolerate.

… and some people (mostly cheap light companies) just go for whatever is cheapest, which is usually super slow.

In general, the most useful range is from about 1 kHz to 20 kHz. Slower than that, and almost everyone can see the pulses. Faster than that, it loses more and more efficiency without any real benefit. I prefer the 16 to 20 kHz range.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

Thanks everyone for the input.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

Looking at the versions of this code I’m wondering if the Momentary version is intended to be used with a tactile switch (as opposed to clicky). The dev notes say it’s intended to be used with a “single momentary switch” but I’m not sure what that actually is.

Maybe I’m dreaming but I’m hoping I can find a tactile switch mounted to a 17mm or 20mm PCB to use with this firmware and a 105c.

Thoughts?

Thanks in advance.

Tom E
Tom E's picture
Offline
Last seen: 5 hours 38 min ago
Joined: 08/19/2012 - 08:23
Posts: 14626
Location: LI NY

"single Momentary switch" means electronic switch - wired up to a pin of the MCU, for how they use the wording. A tactile switch is still a power switch, just like a clicky.

If you have a flashlight that is an e-switch with a driver mounted switch, our standard way of mod upgrading is to piggyback on a driver with true e-switch support. We usually use pin #2 of the MCU as the switch input, instead of the OTC, and figure out a way to wire up a jumper from the driver mounted switch. Also we usually strip off all parts, accept the switch, from the stock driver. I've ton a ton of them, many different types and sizes.

If you want to convert an e-switch to a tactile switch, oh boy... Dunno - the mounting and supporting the deeper throw of a mechanical switch may be a challenge, but probably has been done and posted about somewhere...

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

My attempt to search out an e-switch has been hindered by the fact that E-switch is also a company.

Here’s what I’m after: the ability to use a tactile switch with a 105C running the STAR firmware. The physical nature of it I can handle by machining something in a pinch, it’s the firmware aspect that I’m trying to get a handle on.

I was under the impression (based on who knows what) that this would require a MCU different than the ATTiny13a. I thought a clicky switch operated differently then a tactile switch in that a clicky physically opens and closes the circuit where as a tactile would “tell” the driver to turn on, off, etc.

Is it possible to use STAR, a 105c, and a tactile switch together?

LightRider
LightRider's picture
Offline
Last seen: 3 years 5 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

The way you are describing a “tactile” switch is actually describing an E-switch. A tactile switch is a type of clicky switch. A tactile switch is the same as a Forward clicky as aposed to reverse clicky. The difference is that a forward clicky makes contact with power prior to latching/clicking. A reverse clicky clicks and then makes contact to power. Usually firmware is interchangeable for these two types of clicky switches. One requires you to select your mode level prior to clicking and the reverse clicky alows you to change modes after clicking and while the flashlight is latched on.

If you want an Eswitch, which is what you are describing, then you need a different firmware. Not a different mcu, just firmware. So, the 105c can be used with any of these switches depending on the firmware.

I think Wink

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

That’s the way I originally understood it as well.

For the sake of clarity by tactile switch I mean a switch like this: http://www.digikey.com/product-detail/en/e-switch/TL3340AF160QG/EG4627CT...

LightRider
LightRider's picture
Offline
Last seen: 3 years 5 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

HighEfficiency wrote:
That’s the way I originally understood it as well.

For the sake of clarity by tactile switch I mean a switch like this: http://www.digikey.com/product-detail/en/e-switch/TL3340AF160QG/EG4627CT...

Ahhh… Tactile, not tactical… Ok well that is a momentary e-switch. You can use it with the 105c attached to pin 2 of the mcu or star 4. However, you need a momentary firmware. A 105c flashed for use with a clicky will need to be reflashed.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

Ah ha!

Was mighty confused there for a bit.

So, I should be able to use STAR momentary with a 105C and a momentary e-switch.

Is anyone aware of a source of e-switches mounted to 17, 20mm, etc. PCBs?

LightRider
LightRider's picture
Offline
Last seen: 3 years 5 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

HighEfficiency wrote:
Ah ha!

Was mighty confused there for a bit.

So, I should be able to use STAR momentary with a 105C and a momentary e-switch.

Is anyone aware of a source of e-switches mounted to 17, 20mm, etc. PCBs?

I am unaware but someone may know of something. It’s usually a self job. I’ve used driver boards from cheap eBay lights I’ve had laying around. I strip it of all components and attach the switch then pot it together with my driver of choice.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

Makes sense.

Was hoping for something like this with or without the spring but using an e-switch instead of a clicky.

LightRider
LightRider's picture
Offline
Last seen: 3 years 5 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

I think the reason they are unavailable is because each lights Eswitch lines up in a different place with many sizes for hole diameter. It would be impossible to make a generic Eswitch board that would fit many lights.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

When using a regular clicky switch with these drivers, all of the current flows through the switch.

When using an e-switch in the configuration we’ve been discussing would the current not flow through the switch?

I ask because I’m looking at switches on Digikey and none of them appear to have the necessary current rating.

Just wanted to double check.

http://www.digikey.com/product-search/en/switches/tactile-switches/11142...

finges
Offline
Last seen: 2 weeks 2 days ago
Joined: 11/19/2014 - 14:50
Posts: 504
Location: Germany

No the curent wouldn’t flow through the eswitch. Because of that you can use very small switches and thin cables for the eswitch

Tom E
Tom E's picture
Offline
Last seen: 5 hours 38 min ago
Joined: 08/19/2012 - 08:23
Posts: 14626
Location: LI NY

+1 w/finges. I use 26 AWG or 30 AWG silicone. The two connections are from ground (BATT-) and usually pin #2 of the ATMEL MCU.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

Very helpful. Because I’m a bit dense, it would be wired as below:

Ground->switch->pin #2 of the MCU

Thanks

Dutcheee
Offline
Last seen: 1 day 14 hours ago
Joined: 12/19/2015 - 21:40
Posts: 481
Location: Netherlands

A bit late, but yes, that’s the way to wire the e-switch. Or the other way around, doesn’t matter Wink

If you check out the text in the firmware you use(open the *.C file in a text editor), it’s usually described in the beginning which pin is the switch pin on the MCU. If it’s not described, it’s probably a clicky switch firmware.

HighEfficiency
HighEfficiency's picture
Offline
Last seen: 4 years 2 months ago
Joined: 02/05/2014 - 11:33
Posts: 74
Location: USA

Excellent info. Thanks

JonnyC
JonnyC's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 01/14/2011 - 19:12
Posts: 1148
Location: Green Bay, WI - USA

Hey guys! I’m surprised to see that STAR has stuck around this long! I’ve been out of the game for a long time, but I’m back for a little bit just to check out the amazing drivers and firmware people have created to simplify things and add features (no cap needed for off-time, adjustable turbo timeout, add temp monitoring, even a lighted tailcap).

Anyways, my question is, even though my GitHub site (http://jcapsolutions.github.io/blf-firmware/) doesn’t get much traffic, I’d like to update the top of the page to make note that development has stopped, and that there are so many other better options out there. What site(s) should I link to that are good starting points for people new to flashing and want a description of the firmware options and process?

- Jon

Texas_Ace
Texas_Ace's picture
Offline
Last seen: 1 day 8 hours ago
Joined: 03/24/2016 - 07:44
Posts: 9353
Location: Everything is brighter in Texas

These would be a good place to start I think, TK has taken a lot of time to combine most of the firmware around.

http://budgetlightforum.com/node/38364

https://code.launchpad.net/~toykeeper/flashlight-firmware/trunk

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

JonnyC wrote:
What site(s) should I link to that are good starting points for people new to flashing and want a description of the firmware options and process?

I’ve tried to gather things together and put them in one place. Basically, click the Link in my signature for the introductory page. A lot of the further details and links are in the readme in the repository, while a summary of available code is in the index file.
giorgoskok
giorgoskok's picture
Offline
Last seen: 2 days 14 hours ago
Joined: 11/13/2015 - 10:46
Posts: 2671
Location: Greece

I would like a little help .

I flashed the firmware (dual switch) on wight’s fet driver : http://budgetlightforum.com/node/35507
and the boards i used : https://oshpark.com/shared_projects/1f37BlaL

First question : Should i use OTC cap for memory ? Or what ?

2nd : the switch should be connected between ground and “A” or “B” ?
http://prntscr.com/cciirq

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

You can use OTC to control the timing boundary between a short press and a long press (or even short/medium/long), or with some code changes you could leave that part out. IIRC, the STAR dual switch code needs the OTC.

About connecting the switch, neither A nor B is the right spot. If I understand the driver layout, you probably need to connect the switch to ground and to pin 3 of the MCU. It’s the pin just to the right of “L+” on that last picture.

This is not the easiest driver layout to use for an e-switch light.

cherkess_jan
Offline
Last seen: 3 years 15 hours ago
Joined: 12/22/2016 - 09:49
Posts: 12

Input voltage is used at the calculation of the variables ADC_LOW, ADC_CRIT in STAR.c (and others?). Can i tweak the equation since the input i would use would be 12V? Thus;

Quote:
((12.0 – 0.25 ) * 4700 * 255) / ((19100 + 4700) * 1.1 )

But since this is mains powered, not a battery, the voltage won’t decrease. So what should i do, assign the same integer to both?

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

If you’re doing mains-powered 12V, you should probably turn off the voltage-related functions.

However, if you still want to measure voltage, you’ll at least need to change the voltage-divider resistors to keep the expected voltage within the MCU’s usable range.

You’ll also need to limit the voltage used to power the MCU, using a Zener or LDO or something. It’ll fry at 12V. So, at least one hardware modification is needed.

Pages