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

170 posts / 0 new
Last post
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 7 hours 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

Oh, I thought 1.1V was the bottom end of the attiny’s built-in voltage measurement range… When using the default 1.1V reference, can’t it measure anything between 1.1V and 5.5V?

If that’s the case, I think it should work… but the voltage values you use might be in the range of 10 to 30 instead of the default values of like 120 to 190.

wight
Offline
Last seen: 1 year 8 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

ToyKeeper wrote:
Oh, I thought 1.1V was the bottom end of the attiny’s built-in voltage measurement range… When using the default 1.1V reference, can’t it measure anything between 1.1V and 5.5V?

If that’s the case, I think it should work… but the voltage values you use might be in the range of 10 to 30 instead of the default values of like 120 to 190.

This is incorrect. The ATtiny13A measures betweeen GND and Vref.

Vref may be taken from the internal Vref (1.1v) or Vcc (you’d want it to be tightly regulated of course, a Zener attached to a battery is not good). Some other AVRs allow for taking Vref from an external pin as well, but I don’t think the ATtiny13A does IIRC.

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: 4 days 18 hours ago
Joined: 10/31/2011 - 09:25
Posts: 6099
Location: Johnstown, PA

Wow, I had no idea this mod was going to get so complicated.  Great job ImA!  Keep up the good work!  (And sorry it didn't turn out to be so simple.)

-Garry

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

, MTBR’s Lights & Night Riding Forum
NOTE: Now hosting my photos from my Google account. Post up if you can’t see them. Older photos hosted on Photobucket or Flickr may disappear (PM me if you want access to them).
ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

The voltage divider of interest consists of the 3 components (C2,R2,R3) on the top right of the below picture:

Using this diagram (Linked to Voltage Divider Calculator that wight introduced us to), the component ratings are as follows:

R1 (Labled "R3" on PCB) is 43.2k ohms (E96 marking of 62C)

R2 (Labled "R2" on PCB) is 10K ohms (E24 marking of 103)

There is a capacitor parallel to R2

 

VCC is wired as follows:

  • B+ into a 150 ohm Resistor
  • After the resistor the trace connects parallel to the following:
    • A zener diode (Labeled "W8") connected reversed biased.  The is what regulates to a solid 5.19-5.20 volts out.
    • Capacitor
    • The other "voltage divider" looking grouping to the left (R4,C3,R5).  The component in "R4" looks like it might be a multilayer inductor.  I don't think this circuit impacts anything much as R5 is a 31.6k ohm resistor.
      • The other side of the above are connected to B-.
  • The trace continues on to a inline diode (can't make out marking on diode).  It is in bay "D1" on the main PCB.  This appears to be for reverse polarity protection. 
  • The diode connects to the VCC pin of the MCU.
    • There is a Capacitor between it and ground (See far right of the pic below).

 

ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

garrybunk wrote:

Wow, I had no idea this mod was going to get so complicated.  Great job ImA!  Keep up the good work!  (And sorry it didn't turn out to be so simple.)

No worries.  Problems and complications are good learning opportunities.  And, it's great having ToyKeeper and wight helping out.

ledoman
Offline
Last seen: 1 week 4 days ago
Joined: 09/25/2010 - 06:27
Posts: 937
Location: Slovenia (EU)

ImA4Wheelr, is it possible that the other group of elements (R5,C3,R4) includes thermistor - R4 (no markings) for thermal protection? Similar like here - left side near W8 diode: http://m2.dealextreme.com/upload/reviewpicture/201311/e834b9ca-3352-46ee-a695-c74b8862fb5e.jpg

Also the stock 14 legs chip is quite similar like this:  http://m2.dealextreme.com/upload/reviewpicture/201311/fddd88bc-763b-467d-8077-ca9075360617.jpg

Pictures are from my discussion thread at DX - http://club.dx.com/forums/forums.dx/threadid.1343534  It is looooong thread, but you might learn something along, specialy from things posted by LEDsShine. 

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

Fixed the link to your DX driver discussion. 

-Garry

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

, MTBR’s Lights & Night Riding Forum
NOTE: Now hosting my photos from my Google account. Post up if you can’t see them. Older photos hosted on Photobucket or Flickr may disappear (PM me if you want access to them).
ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

ledoman,

Very interesting.  That makes sense.  That would explain the kind of random, but fairly tight readings (due to room temp environment) I have been getting.  Garry's component looks a little different (Contacts on end curve inward on the body).  Do you know how I can test it?  I'm guessing connect a voltmeter and start heating it up to see what happens to output. 

If it is, Garry wants thermal protection.  Obstacles would be getting code written (that also fits in the Attiny13a) and he would have to give up one of the two pins that is for voltage indicator LED's.

EDIT: Yeah, that is probably the same MCU.  Probably a PIC 14fxxxx or something.  With the right clip I could probably copy the program that is on it (it's probably in hex). 

ledoman
Offline
Last seen: 1 week 4 days ago
Joined: 09/25/2010 - 06:27
Posts: 937
Location: Slovenia (EU)

Don't know about electronics so I can't help much except for some testing. I still have HD-016 and also new driver from DX. Will do some resistor and capacitor mods on DX one (see pages 17 onward in the disscussion) for next project.

This DX driver has one of the best UI I've ever seen in cheapo bicycle drivers. It would be nice to decode the program from it and flash it to the HD-016 or similar drivers. Some hard work would be needed. But let this alone for the future. You are already working hard...

wight
Offline
Last seen: 1 year 8 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Ah yeah, I see what you mean now. With 3 voltage indicator lights there is no room without using the Reset pin.

Pins:
1. N/C – Reset
2.
3.
4. GND
5.
6. PWM
7. Voltage ADC
8. Vcc

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)

wight
Offline
Last seen: 1 year 8 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Come to think of it, there’s already no room! You need a pin for button input as well as the 3 outputs for status LEDs.

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: 4 days 18 hours ago
Joined: 10/31/2011 - 09:25
Posts: 6099
Location: Johnstown, PA

Is there anyway to leave the stock MCU in place to drive the indicator LED's (& thermal protection if it's in there too) and just use the Attiny to control the light output to the XM-L2's?

-Garry

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

, MTBR’s Lights & Night Riding Forum
NOTE: Now hosting my photos from my Google account. Post up if you can’t see them. Older photos hosted on Photobucket or Flickr may disappear (PM me if you want access to them).
wight
Offline
Last seen: 1 year 8 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA
garrybunk wrote:

Is there anyway to leave the stock MCU in place to drive the indicator LED’s (& thermal protection if it’s in there too) and just use the Attiny to control the light output to the XM-L2’s?

-Garry

I think some of that should work:

  • leave the stock MCU in place to drive the indicator LED’s – YES, good idea
  • (& thermal protection if it’s in there too) – NO, the ATtiny will handle all actions which involve control of the buck circuits.
  • use the Attiny to control the light output to the XM-L2’s – yes

Low voltage warnings through the ATtiny could be disabled, so that only Low Voltage Protection / shutdown would be present. You’d have different microprocessors running the LED status indicators and the actual shutdown. The LED status indicators would remain the same and continue to behave as they did on the stock light, potentially including or not including heat warnings.

In order for the light to shutdown or throttle based on either temperature or battery voltage the ATtiny would also have to be hooked up to those dividers. That should give you just enough inputs to hookup 2 dividers (the temp thermister is likely part of a divider, I think that’s the normal setup) plus the momentary button.

The LVP shutdown may not be as effective with so many devices idling – 2 buck controllers and 2 MCUs. At least the ATtiny13A will go to sleep, but the rest of it may not do as well. I still think that it’s a good idea, I just want to point that out.

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: 7 hours 40 min ago
Joined: 01/12/2013 - 14:40
Posts: 10804
Location: (469219) 2016 HO3

I doubt heat will be an issue during a ride, but low battery definitely can be. If you have to choose features to not enable, I’d suggest leaving out thermal monitoring.

Using the stock MCU for the indicator lights is an interesting idea, and eliminates the pin overload. Smile

It definitely sounds like it would be a bad idea to leave the light connected to a low battery though… since several components will always be powered up and we don’t have control over most of them.

This project is kind of fascinating in a bizarre way. I know almost nothing about circuit design, so I keep seeing surprising things here.

ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

^ I agree.  Given the power levels Garry has decided upon and with Turbo Timeout, heat should not be a issue in most situations.

How would we keep the stock MCU in an "On" mode?

It only runs lights the indicator LED's when it is powering one of the two headlight LED's (an "On" mode).  It would need to be connected to a momentary switch or something in order to turn it "On" in case it goes into "Off" mode.  I'm guessing it would go into "Off" mode every time it's disconnected from power.

wight
Offline
Last seen: 1 year 8 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

ImA4Wheelr wrote:

^ I agree.  Given the power levels Garry has decided upon and with Turbo Timeout, heat should not be a issue in most situations.

How would we keep the stock MCU in an “On” mode?

It only runs lights the indicator LED’s when it is powering one of the two headlight LED’s (an “On” mode).  It would need to be connected to a momentary switch or something in order to turn it “On” in case it goes into “Off” mode.  I’m guessing it would go into “Off” mode every time it’s disconnected from power.

Good point! There are probably a couple of options. How does the stock driver respond to holding down the button from off? If it simply switches to the first mode and stays there then that’s your answer.

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)

ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

^ Very clever wight.  You're saying if it works that way, then just hard wire the stock MCU's momentary switch pin to ground, right?

Ledoman,

Can you please try holding down (and not releasing) the power switch from Off mode and tell us what the light does?

EDIT: Ledoman,

Your suspicion was correct, that component is some sort of thermistor.  When I aim a hair blow drier at it, voltage output drops quickly.  Turn off the blow drier and the voltage starts climbing back up slowly.  I just don't know how to get a good read on what temp equals what voltage.  I don't believe I have anything that can measure temp of such a small object.

EDIT2: The voltage dropped pretty rapidly and slowed down when it started to approach .3 volts.  I would say it seems like .28 would be a good starting point.  I could have to run the light assembled to see at what exterior temp the thermal control kicked in and then adjust the settings from there.  I guess we need to hear what ledoman says about the power switch being pressed and held.  Then it seems to be decision time.

wight
Offline
Last seen: 1 year 8 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

Exactly. The status lights would always be on when batteries are attached. Really that’s OK, as we’ve already established that storing the light with batteries attached would not be the best thing to do.

Regarding calibrating the temperature measurement: you are thinking about the situation in reverse. Based on your comments I assume you have an IR thermometer. It needs a half inch diameter circle or similar to measure, much much larger than the thermister. If the thermister was a 0805 component which generated heat we would be unable to measure it’s temperature: it’s too small. But since we are talking about a 0805 component which responds to heat… which we are testing with a large hair drier… we can safely assume that the entire 0.5in circle around the thermister is also the same temp. So using any old temp gun should be able to get you an accurate reading. Smile

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)

ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

Yes, Garry said he disconnects power when not using the light.  Just need to hear back from Ledoman or anyone else that has a HD-016.  Reassembling the driver is a last resort to getting that info.

 

Good point on testing.  I'll do that. Thank you. Smile

ledoman
Offline
Last seen: 1 week 4 days ago
Joined: 09/25/2010 - 06:27
Posts: 937
Location: Slovenia (EU)

ImA4Wheelr wrote:
Ledoman,

Can you please try holding down (and not releasing) the power switch from Off mode and tell us what the light does?

Sorry I was away. Edit: Upon holding down the switch from Off the light does nothing. Also the status leds are not powered up.  Only short press puts it into wide beam on and brings up status leds.

Regarding stock MCU you might look just posted circuit drawing about DX driver (http://club.dx.com/forums/forums.dx/threadid.1343534?page=21) - IC4. It might help you resolving it's functionality. It has pretty much different UI, but the pinout should be about the same.

 

ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

Thank you Ledoman very much for trying that out.  Wow, that driver's MCU has so many differences in nin out that they really are not comparable.  Like you, I figured they would be similar too.  Garry's pin out is as follows:

01  Vcc

02  Indicator LED

03  Momentary Switch

04  NC

05  Indicator LED

06  Indicator LED

07  PWM for one Headlight Driver

08  PWM for the other Headlight Driver

09  NC

10  NC

11  NC

12  Tempature Sensing Circuit

13  Voltage Dividing Circuit

14  Gnd

ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

Ok, With the info we have collected, I propose the following approach regarding the MCU's.  Please chime in with an concerns, thoughts, better ideas, etc.

  • Cut Pins 7 ,8, 13 (See Post 51) and reinstall the stock MCU.  The stock MCU will only control the indicator LED's.
    • I think the mode cycle for the stock MCU is Wide Beam On, Wide Beam Strobe, Throw Beam On, Throw Beam Strobe, Both Beams On, Both1 Beams Strobe, Off.  So most of the time the indicator lights will be on as 6 of the above modes are "On".  Every time Garry hits switch 7 times, the stock MCU will turn off.  He will need to cycle 4 clicks to return to a the same mode on the Attiny13a and also have the stock MCU on (that's if he even wants the indicator light on at that moment).  If he changes modes often, there is really no concern because the next mode change will turn on the stock MCU.
  • Attiny will control drivers and have external temperature and voltage divider monitoring and safeguards.
  • Piggy back the Attiny connecting Vcc to stock Pin Pad 1, and Ground to Pin Pad 14. Pin Pads 7 and 8 (Head light PWM), 03 (Momentary Switch), 12 (Temp sensing), 13 (Voltage Divider) will connect to Attiny as determined by the FW.

The above is dependent on Toykeeper's and Garry's approval.  They will need to nail down what they want to do regarding:

  • External temperature monitoring.  Will the FW have it?
    • If yes, is Turbo Timeout still needed?

In the mean time, I will get some temp/voltage readings and finish the work on the thermal path (AR coated lenses have arrived).  Do I nee to change resistor in the thermal circuit to increase voltage?  Right now it looks like the .2x volts will be the target voltage at which the FW would step down a mode?  I'm guessing not because it is a fraction of 1.1 (e.g. .28 volts would be about a value of 65 in the FW).

EDIT: Plan outlined above is not viable due to how stock MCU is turned Off (Long press).

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

Well stock modes were: wide led on, narrow led on, both LEDs on, both LEDs strobe, then off (I think). Nope, back to wide led on. It's a press-n-hold from any mode to turn it off. So is that close enough to the Attiny's FW to stay "aligned"?

-Garry

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

, MTBR’s Lights & Night Riding Forum
NOTE: Now hosting my photos from my Google account. Post up if you can’t see them. Older photos hosted on Photobucket or Flickr may disappear (PM me if you want access to them).
ledoman
Offline
Last seen: 1 week 4 days ago
Joined: 09/25/2010 - 06:27
Posts: 937
Location: Slovenia (EU)

Stock modes are as follows: wide beam on, throw beam on, both beams on, strobe with both leds on, ... repating ...  Long press in any mode turns light off. There is no off mode in the cycle.

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

Wait- if the Attiny were put into it's strobe mode that would throw off the "alignment", right?

-Garry

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

, MTBR’s Lights & Night Riding Forum
NOTE: Now hosting my photos from my Google account. Post up if you can’t see them. Older photos hosted on Photobucket or Flickr may disappear (PM me if you want access to them).
ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

OK, good info Garry and ledoman.  I think my idea needs to be scrapped.  I got nothing at the moment.  Anyone have any good ideas?

EDIT: What if we toss the stock MCU and just use one pin on the Attiny for the indicator LED's?  It could blink one or all of them when voltage gets down to a certain level.  Maybe faster as voltage gets lower.

ImA4Wheelr
Offline
Last seen: 2 months 3 weeks ago
Joined: 02/03/2013 - 14:51
Posts: 7935
Location: SC

For anyone interested in some of the circuits outside of the drivers, here is a very high tech diagram.

The dots are thru-holes.  They are just from memory so there may be some I forgot.  Pin 3 connects to the Momentary Switch.

wight
Offline
Last seen: 1 year 8 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

I think that we can control the stock MCU with a different, relatively simple, circuit. Whether you’ll want to build one is up to you. I’ll hammer something out and post it in a minute.

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)

wight
Offline
Last seen: 1 year 8 months ago
Joined: 11/27/2013 - 16:40
Posts: 4969
Location: Virginia, USA

I think that a “monostable multivibrator” is the tool for the job if we want to turn on the stock MCU when power is applied. – http://en.wikipedia.org/wiki/Multivibrator#Monostable

You could certainly build one, and it wouldn’t take many components or much money… but you can also buy one in an IC for <$1. I specifically glanced over the datasheet of the SO-16 packaged 74AHCT123AD,118 ($0.40) and it seemed suitable. I think that at least 2-3 external components (at least one cap and one resistor) will be required. At a glance the SSOP-8 packaged TC7WH123FUTE12LF also looks suitable and is smaller.

  • What a circuit like this should allow us to do is trigger an output pulse on a ‘rising edge’ (power being applied).
  • I think that we can setup the pulse length using a resistor/capacitor/both.
  • If it fails to trigger due to the chip being powered on at the same time as the trigger input is produced (eg we are applying power)… I think that we can put a capacitor between the “positive edge triggered input pin” and GND, then put a resistor between that and Vcc. That should slow down how quickly it triggers, I think.

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: 4 days 18 hours ago
Joined: 10/31/2011 - 09:25
Posts: 6099
Location: Johnstown, PA

ImA4Wheelr wrote:

EDIT: What if we toss the stock MCU and just use one pin on the Attiny for the indicator LED's?  It could blink one or all of them when voltage gets down to a certain level.  Maybe faster as voltage gets lower.

I'm totally fine with this. I don't need all three lit, just some indication that the battery pack is getting low. Would be nice if indication was in two steps: 1) 10% battery (or whatever is most appropriate) and 2) flashing indicator LEDs and either dropping output to low or shutting off. I would plan to change battery at the first indication so the light cutting off during a ride probably wouldn't happen. 

-Garry

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

, MTBR’s Lights & Night Riding Forum
NOTE: Now hosting my photos from my Google account. Post up if you can’t see them. Older photos hosted on Photobucket or Flickr may disappear (PM me if you want access to them).

Pages