Mod - GarryBunk's SecurityIng HD-016 (It's Finally Done!) - Pic Heavy

170 posts / 0 new
Last post
ImA4Wheelr
Offline
Last seen: 1 week 3 days ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

^ Thank you for the idea wight.  I'll have to think on that. 

I trust you on the theory (goes over my head), but I'm initially concerned about more components/complexity.  It increases the risk for problems and future failures.  Do you have any rough guess how much power this circuit would consume?

wight
Offline
Last seen: 1 month 3 weeks ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

ImA4Wheelr wrote:

^ Thank you for the idea wight.  I’ll have to think on that. 

I trust you on the theory (goes over my head), but I’m initially concerned about more components/complexity.  It increases the risk for problems and future failures.  Do you have any rough guess how much power this circuit would consume?

Fair enough. It’s not like I’ve built and tested one. There’s a lot of “I think” and “should” in my suggestion. Wink

As far as how much power would be consumed… I think sub 1mA, maybe waaaay below 1mA, but I don’t know and I’m not super confident. (I think that the IC cannot supply more than 75mA, so it should be safe to say that it would consume less than 100mA or something no matter how wrong I was about the rest.) In any case it should not be enough to affect battery life and in the most likely case the big drain will be keeping a 10-20mA LED lit.

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

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

Would it be easier to convert the power bank to parallel, bypass the stock MCU entirely (don’t even power it up, or the other stock components), and use only two of the three power indicators? That way, there’s no need to buck the voltage, no need to sync anything with the original MCU, and most common firmwares should “just work”.

wight
Offline
Last seen: 1 month 3 weeks ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

ToyKeeper wrote:
Would it be easier to convert the power bank to parallel, bypass the stock MCU entirely (don’t even power it up, or the other stock components), and use only two of the three power indicators? That way, there’s no need to buck the voltage, no need to sync anything with the original MCU, and most common firmwares should “just work”.
At that point your longest regulated runtime likely comes from switching to a linear driver as well (eg Nanjg-105c).

EDIT: switching the battery config doesn’t free up any MCU pins anyway.

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

garrybunk
garrybunk's picture
Offline
Last seen: 5 hours 4 min ago
Joined: 10/31/2011 - 09:25
Posts: 6062
Location: Johnstown, PA

I need/want to keep this light working with a standard 2S2P battery pack. 

-Garry

My Bike Lights Thread, Optics (TIR) Comparison Beamshots, Diffusion Techniques


NOTE: Moving my photos from PhotoBucket to Flickr. PM me or post in the thread if you can’t see my images and need me to fix or send a gallery link. PhotoBucket images should remain visible until November 2018.
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 14 hours 42 min ago
Joined: 01/12/2013 - 14:40
Posts: 10141
Location: (469219) 2016 HO3

Switching the battery config doesn’t free up any pins, but it does make most of the complexities disappear. I’m not a fan of complexity. However, I’m not doing the hardware so it’s not my call. Smile

The same battery capacity and runtime should still be available; it would just be four cells in parallel instead of 2S2P.

ImA4Wheelr
Offline
Last seen: 1 week 3 days ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

I'm with ToyKeeper regarding complexity.  I think we are on the verge of making a really nice light, but there is something much bigger than that I think we are creating.  So far, we don't have a viable DIY driver/FW solution that provides true thermal and series cell voltage protection.  It seems this build will provide a blue print for our board designers to add these much sought after protections with buck.  Modern emitters are more voltage hungry and series seems needed for the foreseeable future.  The thermal and voltage divider circuits on this driver are simple and elegant and can be used for DD too.  We, however, can not pull this off without assistance from ToyKeeper.  I'm more than happy to do all the measuring and tuning to make the hardware and software merry.

So my preference is to ditch the stock MCU and pursue using only the Attiny and ToyKeeper's FW.  If she is able to a squeeze in using the indicator LED's in some fashion, we should consider that icing on the cake.

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

From a firmware point of view, voltage monitoring is easy. The hard part is dividing it to a usable range and then calibrating the actual values needed on the internal 8-bit or 10-bit scale. Er, and the other hard part is fitting more than one battery into a flashlight. It’s all about the physical build and circuitry.

Thermal step-down shouldn’t be too difficult (again, after build concerns and calibration), but we start to run into limitations on the attiny13 in terms of ROM space and switching the ADC channel. Especially on e-switch lights, since handling that takes a lot of room. As is, only 174 bytes are left.

JonnyC has been trying to put together a solid firmware with both voltage and temperature monitoring, and last I heard he is seriously considering requiring an attiny25 instead so there will be enough ROM to hold the code. Everything is do-able, just very hard to fit into 1024 bytes.

It’s also a bit difficult for me to ensure anything works without having the relevant hardware. You may have to do a lot of tweaking and calibration.

ImA4Wheelr
Offline
Last seen: 1 week 3 days ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

I'll do the best I can if you are game.  I certainly don't want your time to be wasted and you seem to appreciate the same for me.  We just need Garry's agreement to proceed.

Garry,

I'd like to say that pulling off thermal protection (not faux turbo timeout) and voltage monitoring with series cells is not a small feat.  Adding another MCU to the mix creates more potential problems and potential failure points.  I recommend making the indicator lights optional (hopefully, they can be worked in some hobbled form) and ditching the stock MCU.

To me, FW is the critical factor as there is very limited space in the Attiny13a.  So I will do my best to work with whatever you and ToyKeeper want to do.

garrybunk
garrybunk's picture
Offline
Last seen: 5 hours 4 min ago
Joined: 10/31/2011 - 09:25
Posts: 6062
Location: Johnstown, PA

I'm fine with ditching the stock MCU. I'm also okay if you can't get the thermal protection to work and just keep the turbo timeout. I'm also okay if the voltage monitoring is hobbled down to just one of those LEDs flashing or something like that. I'm at your and TK's mercy as to what you all can pull off. 

-Garry

My Bike Lights Thread, Optics (TIR) Comparison Beamshots, Diffusion Techniques


NOTE: Moving my photos from PhotoBucket to Flickr. PM me or post in the thread if you can’t see my images and need me to fix or send a gallery link. PhotoBucket images should remain visible until November 2018.
ImA4Wheelr
Offline
Last seen: 1 week 3 days ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

Sounds good.  Thanks Garry.

TK,

Sure you know, but just in case.  The Thermistor circuit drops voltage to the MCU as it warms up.  So I'm getting assuming it decreases resistance with heat as it is between ground and the "R1" of the voltage divider.  It makes sense that is should work about like voltage monitoring from a FW point of view.  Not sure if you can use the existing voltage monitoring and use an "Or" type clause.  I think step down reading will likely be in the 60's.

No sure if turbo timeout takes up much space.  If it does, real thermal protection seems like a better safety measure.  Ideally, I'm guessing Garry would like to have both in place.

Finally, if you are able to include code for a voltage indicator output pin, the indicator LED's are hardwired to 5.19volts positive.  The MCU appears to provide ground via a 470 ohm resistor.  I could rewire them if you need them set up the other way around.

For some reason, I can't get the indicator emitters to light up when I take them to ground directly.  They test fine with a DMM.  I don't know what to make of that.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 14 hours 42 min ago
Joined: 01/12/2013 - 14:40
Posts: 10141
Location: (469219) 2016 HO3
ImA4Wheelr wrote:
The Thermistor circuit drops voltage to the MCU as it warms up.

Cool. I can just invert the value then.

What I was thinking is to do something roughly like setting the maximum PWM level to 255 minus the difference between some hardcoded value and the actual thermistor value. This way, it would ramp down smoothly and gradually above a certain temperature, and step back up just as gradually when it cools off. The scale might need to be multiplied or curved or something, but it seems like the concept should work.

The goal is something similar to ZL’s “PID” thermal controls, which behave like this (but less advanced):

Low voltage, though, should just use the standard approach found in STAR. When low, step down. If it’s already at the bottom level, warn and shut off.

ImA4Wheelr wrote:
Not sure if you can use the existing voltage monitoring and use an “Or” type clause.

Not really. The attiny can only measure one at a time, and it’s asynchronous, so it needs a bunch of extra logic just for switching back and forth between the two ADC channels. Plus, low voltage logic never steps back up.

ImA4Wheelr wrote:
No sure if turbo timeout takes up much space. If it does, real thermal protection seems like a better safety measure.

I agree, both would be redundant. Thermal protection will use more ROM space than turbo timeout though. We’ll have to see what will fit.

It’d be nice if we could just replace the standard attiny13 with attiny25 chips in all the common drivers. Twice the ROM space, and since half the space gets used for overhead it means like 1500 bytes to play with instead of 500.

ImA4Wheelr wrote:
Finally, if you are able to include code for a voltage indicator output pin, the indicator LED’s are hardwired to 5.19volts positive.  The MCU appears to provide ground via a 470 ohm resistor.  I could rewire them if you need them set up the other way around.

For some reason, I can’t get the indicator emitters to light up when I take them to ground directly.  They test fine with a DMM.  I don’t know what to make of that.

I have no idea. I’ve only done voltage indicators once, and the circuitry side of things was already fully taken care of. I just had to do the measurement and logic in the firmware.

This is just a guess, but I would assume that the attiny’s output pins run at the same voltage as its power source, so whatever the buck is feeding the attiny. It can run at up to 5.5V though, I think, which should be enough. And to control how much power is fed to those indicator LEDs you’d have to insert appropriate resistors along that path; the attiny can only turn it on or off. I don’t recall off-hand what the default attiny output pin current is, but you’ll almost certainly need to reduce it for indicator light use.

ledoman
Offline
Last seen: 1 day 4 hours ago
Joined: 09/25/2010 - 06:27
Posts: 936
Location: Slovenia (EU)

Guys, don't want to break out your brainstorming flow to much, but I have an idea for my usage only leaving stock MCU in place as is. First to resume what we have in stock form. As I understand it (I might be wrong) we have three circuits parts: 1 controling/user interface and 2 power controling for each led.

 

Now, my idea is to put both leds in parallel on both power controling circuits parts.  Leaving everything else as is I'm assuming we can get modes like 50%, 50% 100%, strobe. This of course is not very usable, but if I change sense resistance in the circuits to get: first 1/3 and in second 2/3 of desired power. Then I think we can get modes 33%,66%,100%, strobe.

 

This would be just fine for my usage leaving all other features (voltage indicators, thermal protection) in place. Not the best as would rather have strobe hidden and bit different mode spacing, but it's usable. 

Can someone look if this mode is possible? Resistor mod is trivial to me, but putting leds in parallel is in question electricaly. Phisicaly I can just connect two black wires and we are done Tongue Out.

What do you think?

 

ImA4Wheelr
Offline
Last seen: 1 week 3 days ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

TK,

All that sounds good to me.  I have no problem if you wish to go with a Attiny25.  I believe I could use the same equipment I already have.  I would just need to specify Attiny25 in Atmel Studio when first setting up your FW.  I would need to order some 25's.

I will play indicator leds to see what gets them to work.  It sounds like they must have some internal protection that blocks current when voltage is too high.

 

ledoman,

Interesting idea.  I don't know enough about electronics to answer your question.  It sounds like it would work.  I have paralleled drivers before to increase current.  I didn't have any of the drivers off though.   So I don't know if there would be any kind of back flow issue.  On this driver, I think you would have to connect both the positive leads and both the negative leads to each other to make it work.

ledoman
Offline
Last seen: 1 day 4 hours ago
Joined: 09/25/2010 - 06:27
Posts: 936
Location: Slovenia (EU)

Thanks, will wait what others have to say. Since hopefuly there is no PWM, just on/off, I expect no intereference between power circuits. Hopefuly!

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

ImA4Wheelr wrote:
TK, All that sounds good to me. I have no problem if you wish to go with a Attiny25.

I should mention that I don’t actually have any attiny25s or the tools needed to swap one out on an existing driver. I’m just basing my guesses on the usual difficulty getting everything to fit, plus JonnyC’s comments that he is having trouble with exactly the same features. I know I’ve had to pull some dirty tricks to make things fit into 1024 bytes in the past…

I can probably use a lot of what JonnyC already wrote, but I haven’t looked at the details yet.

ImA4Wheelr
Offline
Last seen: 1 week 3 days ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

^ I can only imagine how creative one has to get squeeze code into such a small space.  Just let me know if you do decide to go with the 25.  I would need to place an order for some.  I'd do my best to test code since you wouldn't be able to do the same with actual hardware.

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

I wonder if I should just get a hot air gun.

Or I found a BLF member selling nanjg drivers with the MCU replaced, but they’re $15 each plus $5.50 shipping. For the price of three, I could probably get a hot air gun and a few attiny25s and be able to upgrade arbitrary drivers.

ImA4Wheelr
Offline
Last seen: 1 week 3 days ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

Hot air guns are great to have for all kinds of things.  I find that even the cheapest ones work fine for reflowing. 

Not sure if you would be interested in the conversation that I trying to start here

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

Have you optimized the code enough? If you have based your code on Star there is a lot you can do. I’ve cut memory usage almost in half but still have the same functionality. Star is written for easy use and changing of modes and such, but can be optimized a whole lot to save space without changing functionality.

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

Mike C wrote:
Have you optimized the code enough?

It depends. I’ve definitely squeezed a lot of extra features into the available space before, on other firmwares… There is a lot in STAR that I don’t need or care about, which helps. But in this case I don’t actually have hardware so I haven’t written much code.
Mike C
Mike C's picture
Offline
Last seen: 1 day 7 hours ago
Joined: 01/22/2014 - 08:03
Posts: 2387
Location: Sweden

I was surprised at how much memory could be saved from a few changes. Saved me from having to dig into ATtiny25 programming… for now at least.

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

I managed to fit 15 modes into 1024 bytes on an off-time based light, including a battery check mode and a bunch of different styles of blinkies and a pulse frequency modulated moon mode which smoothly self-adjusts its speed to compensate for decreasing voltage over time. And 2-level turbo stepdown and low-voltage protection. And a short/med/long button press UI.

So I might be able to fit everything into 1024 bytes for the light in this thread… I’m just not totally sure, and it’s hard to know until I have hardware to test on.

If there was more RAM, I could compress the code and fit even more… but attiny chips have nowhere near enough RAM to run a decompression engine and then store a larger program in memory.

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

Seems like you’ve done a lot of optimizing Smile I’ve got two individually controlled PWM channels with separate output pins, 8 individual modes per channel (each channel with it’s own mode memory), turbo timeout, low and critical voltage step down, short and long press UI (off time)… and still have room to spare… Not finished with it yet though, don’t need a total of 16 modes so I’ve got more space to work with if needed.

ToyKeeper wrote:
So I might be able to fit everything into 1024 bytes for the light in this thread… I’m just not totally sure, and it’s hard to know until I have hardware to test on.

You don’t need any hardware to see if it fits, AVR Studio tells you how large the end result is after compiling.
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 14 hours 42 min ago
Joined: 01/12/2013 - 14:40
Posts: 10141
Location: (469219) 2016 HO3

Mike C wrote:
You don’t need any hardware to see if it fits, AVR Studio tells you how large the end result is after compiling.

Oh, I have the size calculation built into my build script. The question is whether the code actually works. I can easily make it small enough if it doesn’t have to work. Smile

In theory, practice and theory are the same. But in practice… well, not so much. Code is all theory until it’s running in its intended environment.

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

ToyKeeper wrote:
Mike C wrote:
You don’t need any hardware to see if it fits, AVR Studio tells you how large the end result is after compiling.

Oh, I have the size calculation built into my build script. The question is whether the code actually works. I can easily make it small enough if it doesn’t have to work. Smile

In theory, practice and theory are the same. But in practice… well, not so much. Code is all theory until it’s running in its intended environment.


Yeah, I couldn’t get anything done without the hardware. It’s just that wrote you where not sure if it would fit, guess I misunderstood that a bit. Of coarse you can’t be sure of the size until it’s all been tried and tested, I know that all too well Smile
ImA4Wheelr
Offline
Last seen: 1 week 3 days ago
Joined: 02/03/2013 - 14:51
Posts: 7924
Location: SC

Regarding Attiny 13a vs 25, I'm not sure what all in involved with converting the FW over, but part of my thought process if I was a programmer would include the following:

  • The Attiny13 has been a challenge memory wise for quite some time.  It probably has hobbled more than one programer.
  • The 25 is superior to the 13 and uses the same foot print.
  • Programing time will be needed to squeeze into the 13.  This same time could be used to convert to 25.  This time could be thought of as an investment into taking drivers to a new level going forward.
Mike C
Mike C's picture
Offline
Last seen: 1 day 7 hours ago
Joined: 01/22/2014 - 08:03
Posts: 2387
Location: Sweden

I’ve got a few of the 25s at home, and also a few 85s, but I wasn’t forced to use them as I just finished my head light project code (as described above) and it weighed in at exactly 1024 bytes! :bigsmile:

However, I’ve been looking at the datasheets for them both and comparing. I think it could be done rather easily. I just don’t have one of those component layout test boards (or whatever they are called) to test them. My 13a programming has been tested on Qlite boards, and I’m not that keen on attempting to replace the MCU on any of them. I’ll be getting one of those test boards though, and might dig into it then.

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

Has anything been decided about the hardware, like which MCU will drive the indicators? Where is the voltage coming in, and is it getting divided to a standard range? In general, how is the hardware turning out?

wight
Offline
Last seen: 1 month 3 weeks ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

I think the decision was:

  • Remove the stock MCU entirely.
  • Attempt voltage monitoring AND temp monitoring.
  • Drive one or more of the stock indicators using the final remaining pin on the ATtiny. (EDIT: together, as unit. So just make them operate together and maybe turn on solid for low, then blink for critical… or something.)

Still fine, still on a break. One day I’ll catch up with you folks! previous wight catchup Wink
list of my drivers & variants (A17DD, FET+1 stuff, WIP stuff, etc)

Pages