Klarus        
Page 1 of 3 123 LastLast
Results 1 to 30 of 75

Thread: Driver microcontroller hacking

  1. #1
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Driver microcontroller hacking

    Browsing DX I found this fully regulated driver. Only problem it has are the modes; five are too many for me, especially with strobe and sos.
    Looking at the pictures, I see that the board has a microcontroller on the underside that probably takes care of the modes via PWM.
    The pictures aren't detailed enough to make out all the lettering, but from what I've been able to read and from the general shape of the writings it seems that it's more or less the same thing as the microcontroller in this buck-only two-mode driver.

    This got me wondering... I don't have nearly enough knowledge in the field of microcontrollers to modify the programming myself, and even if I did I don't have the tools to program whatever kind of uC that is.
    But what if I unsoldered the uC from the fully regulated board and swapped it with the one from the buck-only one? Since the uC only does PWM dimming, would this not give me a fully regulated two-mode board? (and a five-mode buck-only board if I bothered doing the swap on the other one as well)
    Eat, drink and be merry, for tomorrow you may die.

  2. #2

    Default Re: Driver microcontroller hacking

    You could do the IC swap if the PIC12F629 output PWM pin in both drivers is the same. You should do a little bit more research on this.

    In KD's driver it seem to me that the pin 7 is the output. but, in DX cannot see clearly, nothing that with wires and lifted pins cannot be solved.
    Last edited by linterno; 01-05-2009 at 01:18 PM.

  3. #3
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    So even if the output PWM pin isn't the same, bending up the pin and connecting it properly would work? In other words, in one way or the other this can be made to work?
    Eat, drink and be merry, for tomorrow you may die.

  4. #4

    Default Re: Driver microcontroller hacking

    I couldn't absolutely say yes, but it is very likely.

    I don't know what PWM frequency and duty is being used in each driver. But, if both do PWM I would give it a try.

  5. #5
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    Ok then, I'm placing an order for a KD five-pack of the five-mode regulated drivers (I have five buck-only ones incoming already). Will report on my findings when they eventually get here.

    Edit: done. Apparently the ones in the KD 5-pack are 20-mode, which is better - if I complete the swap with the other board I'll have 20-mode AMC boards to use in less important projects; I dislike 20-mode drivers less than I dislike 5-mode ones, because almost all 20-mode ones have a group with just three steady levels and no strobe. It's too easy to change group by mistake though.
    Last edited by Fallingwater; 01-05-2009 at 02:53 PM.
    Eat, drink and be merry, for tomorrow you may die.

  6. #6
    Flashaholic Tohuwabohu's Avatar
    Join Date
    May 2008
    Location
    Germany
    Posts
    184

    Default Re: Driver microcontroller hacking

    Swapping the microcontroller could be more difficult than you think.
    I got a 5-pack of the KD linear buck drivers in december - they had a completely different layout and a different microcontroller.

    Photo of one of the drivers I got from KD:

    The microcontroller is an Atmel Tiny13V

    Photo of one of the DX drivers

    The microcontroller is a PIC12F629.

    The PWM output pin and even the supply voltage pins are different.

    It could even be that they use a oppisite voltage levels to switch the output on and off. Instead of 100% and 15% you could get 0% and 85%. But I'm not sure about that.
    Last edited by Tohuwabohu; 01-05-2009 at 02:57 PM.

  7. #7
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    Are you absolutely sure you placed your order for the same item I did?

    Well, it's too late to cancel the linear board order - they shipped it a few days ago; all I can do now is hope that I get the ones pictured in the KD page.
    If I get the kind you did I'll try to get KD to send me the right ones, though I have little hope that they'd listen to me (since they've never replied to anything I've asked them).

    If I'm stuck with these I'll still try to figure out what pin does what and rewire the regulated board so as to accept the Atmel ATtiny. It shouldn't be too hard, considering only three pins seem to be connected to anything in both cases. Hopefully I won't let any magic smoke out...
    Last edited by Fallingwater; 01-05-2009 at 03:11 PM.
    Eat, drink and be merry, for tomorrow you may die.

  8. #8
    Flashaholic Tohuwabohu's Avatar
    Join Date
    May 2008
    Location
    Germany
    Posts
    184

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by Fallingwater View Post
    Are you absolutely sure you placed your order for the same item I did?
    Yes, I think so. I ordered these drivers from KD.
    I'm hoping that they have a higher PWM frequency than the older version.
    But I did not yet use them in any light.

  9. #9

    Default Re: Driver microcontroller hacking

    Sorry. I thought both drivers were using the same microcontroller. They usually put pic16f629 in theirs drivers.

  10. #10
    Flashaholic ifor powell's Avatar
    Join Date
    Nov 2007
    Location
    Bristol UK
    Posts
    230

    Default Re: Driver microcontroller hacking

    Here is a link to the info on the tiny. vcc pin 8 top left in the pic. gnd pin 4 bottom left the pwm will be from 6. If you realy want to play you can get somthing like a dragon programer for the avr's for not much ($40?) and the free software tools are very good although you would probobly have to work in asembler rather than C for the tiny13 it's about the chepest one Amtel do.

    Never done any pic programing so no quick help there...

    Ifor

  11. #11
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by ifor powell View Post
    Here is a link to the info on the tiny. vcc pin 8 top left in the pic. gnd pin 4 bottom left the pwm will be from 6.
    Thanks, this will be very useful.
    Do you know how the 3 pins would be connected to the PIC as well?

    Never done any pic programing so no quick help there...
    I've done some, but my current knowledge is too low to write programs from scratch. Can one extract the program from a microcontroller, tweak it in C and then put it back in? That I could probably do...
    Eat, drink and be merry, for tomorrow you may die.

  12. #12
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by Fallingwater View Post
    Can one extract the program from a microcontroller, tweak it in C and then put it back in? That I could probably do...
    Well, turns out that's impossible.

    So the next question is: has anyone written flashlight code for PIC12F629 or ATtiny13 MCUs that they're willing to share/opensource?
    Eat, drink and be merry, for tomorrow you may die.

  13. #13

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by Fallingwater View Post
    Do you know how the 3 pins would be connected to the PIC as well?
    In PIC12F629 VCC is Pin 1, GND is Pin 8 and PWD could be 7 ( DX SKU 6190 uses pin 7; see HOWTO: Making your own digital driver.) However, could be other. You will need to find it out.

    Quote Originally Posted by Fallingwater View Post
    Can one extract the program from a microcontroller, tweak it in C and then put it back in? That I could probably do...
    I don't think so. I guess the developer/programmer could have protected the flash memory from reading. Even if you could read it you won't be able to convert it to C language.

    I still believe you can replace the PIC12F629 microcontroller with the ATTiny13V. PWM is PWM and, even if ATTiny13V can do inverted PWM, I don't thing they are doing it. I am almost sure the driver's uc does non-inverting PWM . The LED needs VCC not GND.

  14. #14
    Flashaholic ifor powell's Avatar
    Join Date
    Nov 2007
    Location
    Bristol UK
    Posts
    230

    Default Re: Driver microcontroller hacking

    The programming for these types of driver is interesting where they have a single switch that controls the power. I have never done it but I read somewhere about it. You basicaly have a capacitor to give you slow decay on the power that enables you to destinguish between a brown-out reset for just a quick click as opposed to a full power on reset for comming on from off for a long time. It's tricky and you may well find that just swapping the controller from your two drivers will not work because of it, they may need differny capacitor values and be set up for different brown out voltage levels for example.

    My only coding experiance with lights is with re-working a bflex that I fried the AVR on and subsiquently swapped. I span my own software for this. It is a lot easier though as the bflex has a proper switch and has a more beafy Tiny85 which has 8k of flash and more ram and eprom so C coding is ok for the limited interface I have put on it. I am tempted though to get hold of the avr based driver you have linked to and have a play...

    Ifor

  15. #15
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    I'll try a MCU swap first. If I get the PICwhatever boards it'll probably be a simple unsolder-solder job; if I get the others I'll try adapting the Atmels, if that doesn't work I'll try swapping the capacitors as well.

    I'm seriously tempted to invest some time in learning more programming, getting a smaller programmable MCU (the ATmega168 I have now is unnecessarily complex for the task), design my interface the way I want it to be and then swap the programmed MCU in one of these drivers.

    Don't hold your breath though I'll have to learn a lot before I can do this... if I can even muster the willpower.
    Eat, drink and be merry, for tomorrow you may die.

  16. #16

    Default Re: Driver microcontroller hacking

    You could learn PIC Programing easily if you do it in Basic language. Not the best but the easiest.

    There is a free demo of MikroBasic which is a good compiler for Microchip microcontrollers. Mikroelectronika also has MikroC compiler which is a C language one. These compilers already have a lot of fuunctionality available including PWM. The demo version is limited to 2K words of code, more than enough if you want to program PIC12F629, PIC12F675 and PIC12F683 microcontrollers, which are good 8 pins ones.

    Currently the best and less expensive PIC Programmer (to burn the program into the microcontroller) is PICkit 2 Microcontroller Programmer directly from Microchip ($ 35).

    You can buy inexpensive PIC Microcontrollers delivered to Italy with cheap delivery cost from Futurlec. I have bought from them a couple of times. I would recommend you to buy PIC12F683 since it has A/D functionality which could be a good option if you want to implement Low Battery Disconnect in your driver.

    I guess your ATmega168 is an Italian Arduino. Isn't it?

  17. #17
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by linterno View Post
    In PIC12F629 VCC is Pin 1, GND is Pin 8 and PWD could be 7 ( DX SKU 6190 uses pin 7; see HOWTO: Making your own digital driver.) However, could be other. You will need to find it out.
    Whoops - I missed this post. I'll adapt the pins, thanks.

    Quote Originally Posted by linterno View Post
    You could learn PIC Programing easily if you do it in Basic language. Not the best but the easiest.
    I didn't know you could program MCUs in Basic. I remember some Basic from when I dabbled in it a bit ages ago; it is indeed easier than C. I'll investigate this, thanks.

    Currently the best and less expensive PIC Programmer (to burn the program into the microcontroller) is PICkit 2 Microcontroller Programmer directly from Microchip ($ 35).
    I thought programmers were a lot more expensive. I'll order this soon, I think.

    You can buy inexpensive PIC Microcontrollers delivered to Italy with cheap delivery cost from Futurlec. I have bought from them a couple of times. I would recommend you to buy PIC12F683 since it has A/D functionality which could be a good option if you want to implement Low Battery Disconnect in your driver.
    Noted. Will order one or three soon.

    I guess your ATmega168 is an Italian Arduino. Isn't it?
    It doesn't have anything to do with Arduinos, at least as far as I'm aware. Or with Italy for that matter. It's just one of the more complex MCUs from Atmel. It came in a NerdKit which I received for review.
    Eat, drink and be merry, for tomorrow you may die.

  18. #18
    Flashaholic Tohuwabohu's Avatar
    Join Date
    May 2008
    Location
    Germany
    Posts
    184

    Default Re: Driver microcontroller hacking

    I removed the microcontrollers from two of my drivers.

    DX SKU 15880 without the PIC12F629

    Only 3 pins are connected.
    VCC is pin 1, GND is pin 8 and PWM is pin 7.

    The 2-mode linear buck converter I got from KD without the Atmel Tiny13V.

    VCC is pin 8, GND is pin 4 and PWM is pin 6.
    Pin 2 is connected to the two resistors R1 and R2.

  19. #19
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    Hmm. Perhaps the Atmel can work without the two resistors? Otherwise I'll have to somehow put the resistors on the other board along with the MCU, if that is even possible.

    What does the fourth pin do, anyway? It seems unnecessary.
    Eat, drink and be merry, for tomorrow you may die.

  20. #20
    Flashaholic Tohuwabohu's Avatar
    Join Date
    May 2008
    Location
    Germany
    Posts
    184

    Default Re: Driver microcontroller hacking

    Pin 2 of the Atmel can have different functions depending on the programming.
    Perhaps I can try what happens when I remove both resistors or change the value of one of them tomorrow.

  21. #21
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    It might be related to battery status or regulation. We'll see.

    Thanks for this... with our resources combined we might just hack together the best cheap driver out there
    Eat, drink and be merry, for tomorrow you may die.

  22. #22
    Flashaholic ifor powell's Avatar
    Join Date
    Nov 2007
    Location
    Bristol UK
    Posts
    230

    Default Re: Driver microcontroller hacking

    Looking at the picture I would say that the two resistors are a voltage divider and pin 2 is bing used to do an analog to digital conversion to mesure the voltage. This is probobly to do with working out the switch stuff as I aluded to before. Having the switch on the power makes things tricky but with a sutible capacitor you could see the voltage start droping for just a small click and still stay active. That's just a guess but I expect you will need it for the code to work properly.

    Ifor

  23. #23

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by Fallingwater View Post
    So the next question is: has anyone written flashlight code for PIC12F629 or ATtiny13 MCUs that they're willing to share/opensource?
    I put up this thread,Build a Basic uC 3 Level Led Driver - A Tutorial
    http://www.candlepowerforums.com/vb/...d.php?t=201383
    on how to make a Attiny Led driver from scratch, no smds required.

    it is listed in the Flashlight Electronics - Batteries Included - Threads of Interest

    Let me know if you need more help,
    matthew
    Last edited by mpf; 01-07-2009 at 03:04 PM.

  24. #24

    Default Re: Driver microcontroller hacking

    A have tinkering with some PICAXEs which are PIC microcontrollers. There is no need for a programmer to load the program to it. Simply connect the PICAXE to your computer's serial port an you can download the program to PICAXE.

    These are programmable in Basic and there is an 8 pin SMD model (PICAXE-08M Surface Mount AXE007MSM) which is fully compatible with PIC12F629.

    Currently I own some PICAXE-08M (non SMD) and PICAXE-18X.

    I am going to work on a program to replace PIC12F629 in these drivers. Just give some time to do it since I am some busy these days.
    Last edited by linterno; 01-07-2009 at 03:32 PM. Reason: Spelling correction.

  25. #25
    Flashaholic Tohuwabohu's Avatar
    Join Date
    May 2008
    Location
    Germany
    Posts
    184

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by Fallingwater View Post
    It might be related to battery status or regulation. We'll see.
    I think you are right.
    Pin 2 of the Atmel seems to be used for low battery detection.
    When the supply voltage of the board drops below 3V the driver switches to low mode and starts to blink.
    When I pull pin 2 to GND (by shorting R2) the low battery warning is activated even when the supply voltage is above 4V.
    When pin 2 is pulled up (by shorting R1) there is no low battery warning.
    The voltage divider R1/R2 sets the level of the low battery detection.
    I did not yet test what happens when both resistors are removed.

    The PWM frequency of the board I tested is 580Hz.
    In low mode the ON-time is 0.22ms, OFF-time is 1.5ms.

    A member of the german Messerforum.net reported a PWM-frequency of 21kHz in low mode for some drivers he got from KD in october.
    But he didn't buy the 5-pack, he bought some single drivers.
    Some board he got earlier had a PWM frequency in the range of 500Hz to 540Hz.
    But nobody ever mentioned a low battery warning for any of these boards.

  26. #26

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by Tohuwabohu View Post
    When the supply voltage of the board drops below 3V the driver switches to low mode and starts to blink.
    This is excellent. 3 volts could be the ideal low voltage disconnect for Li-Ion batteries.

    I have a question here: Would a simple voltage divider be enough to detect low voltage? I guess this ATtiny13V is doing some ADC in that pin.

    EDITED: ATtiny13V has an internal voltage reference of 1.1V independent of the power supply. That is enough to detect low voltage.
    Last edited by linterno; 01-07-2009 at 04:30 PM.

  27. #27
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by linterno View Post
    This is excellent. 3 volts could be the ideal low voltage disconnect for Li-Ion batteries.
    Low voltage prevention is theoretically a good thing, but in my experience (with the NDI) the drivers aren't smart enough to differentiate inbetween the battery actually going low and temporary voltage fluctuations given by a slightly flaky switch.

    Tohu, could you do a check and see if there's a time limit? In other words, does pin2 need to be grounded for a certain amount of time before the driver starts blinking (thus insuring temporary fluctuations don't activate the protection) or is it instant?

    If it's instant I'll most likely permanently keep it up and remove the protection altogether. In that case I'll just use protected cells.

    I did not yet test what happens when both resistors are removed.
    If you happen to test that please let me know
    How are the connections inbetween the two resistors, and the board?

    Thanks for this research you're doing at the risk of your own driver board.

    KD haven't yet sent the regulated drivers. Argh, I'll have to wait a while before I can experiment myself.
    Last edited by Fallingwater; 01-07-2009 at 03:51 PM.
    Eat, drink and be merry, for tomorrow you may die.

  28. #28
    Flashaholic Tohuwabohu's Avatar
    Join Date
    May 2008
    Location
    Germany
    Posts
    184

    Default Re: Driver microcontroller hacking

    Quote Originally Posted by linterno View Post
    I have a question here: Would a simple voltage divider be enough to detect low voltage? I guess this ATtiny13V is doing some ADC in that pin.
    Pin 2 of the Tiny13 can be configured as ADC input.
    I'm not sure but I think it can also be used as a simple anlog comparator
    With the voltage divider the low voltage detection level can be set to the desired value.

    Quote Originally Posted by Fallingwater View Post
    Tohu, could you do a check and see if there's a time limit? In other words, does pin2 need to be grounded for a certain amount of time before the driver starts blinking (thus insuring temporary fluctuations don't activate the protection) or is it instant?
    I'm not yet sure how but I'll try to do it tomorrow.

    How are the connections inbetween the two resistors, and the board?
    You can see it on the photo.
    The upper end of R2 is connectet to GND, the upper end of R1 to VCC of the Atmel.
    Pin 2 of the Atmel is connected to the connection of R1 and R2 (the lower end of the 2 resistors).

  29. #29

    Default Re: Driver microcontroller hacking

    Fallingwater:

    If you are planning to buy or already bought this driver "from DX", not from KD, and you want to replace the microcontroller with the one in these drivers from KD then you can simply swap them since both drivers are using PIC12F629.

    If you bought or are planning to buy these drivers from KD and want to replace the microcontroller with the one in these drivers from KD then that is a different story.

  30. #30
    Flashaholic* Fallingwater's Avatar
    Join Date
    Jul 2005
    Location
    Trieste, Italy
    Posts
    3,323

    Default Re: Driver microcontroller hacking

    Wait, I'm confused.

    Aren't this and this exactly the same from a hardware point of view? The pictures certainly seem of the same thing.
    Compare and contrast:

    DX:
    http://www.dealextreme.com/productim...ku_15880_1.jpg
    http://www1.dealextreme.com/producti...ku_15880_3.jpg

    KD:
    http://www.kaidomain.com/UploadFiles...3074060000.jpg
    http://www.kaidomain.com/UploadFiles...3072653750.jpg

    The components are all in the same places, have all the same connections and those whose readings I can decipher are the same.

    The MCU programming is probably different, since the KD one seems to be 20-grouped-modes and the DX one only has five, but everything else seems the same.

    I ordered these, because they are just like the above one from KD but in a five-pack and thus cheaper per-unit.

    I was under the impression that the potential problem here lies in the fact that I ordered these buck-only circuits with the same PIC MCU as the regulated driver, but that I'll probably receive the revised version with the Atmel microcontroller instead, which will need its pins adapted to the new board.
    Eat, drink and be merry, for tomorrow you may die.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •