Driver microcontroller hacking

Wurkkos

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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)
 

linterno

Enlightened
Joined
Dec 19, 2007
Messages
348
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:

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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?
 

linterno

Enlightened
Joined
Dec 19, 2007
Messages
348
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.
 

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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:

Tohuwabohu

Newly Enlightened
Joined
May 8, 2008
Messages
184
Location
Germany
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:
p1010162fx5.jpg

The microcontroller is an Atmel Tiny13V

Photo of one of the DX drivers
p1010163tg3.jpg

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:

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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:

linterno

Enlightened
Joined
Dec 19, 2007
Messages
348
Sorry. I thought both drivers were using the same microcontroller. They usually put pic16f629 in theirs drivers.
 

ifor powell

Enlightened
Joined
Nov 18, 2007
Messages
230
Location
Bristol UK
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
 

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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...
 

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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?
 

linterno

Enlightened
Joined
Dec 19, 2007
Messages
348
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.

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.
 

ifor powell

Enlightened
Joined
Nov 18, 2007
Messages
230
Location
Bristol UK
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
 

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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 :p I'll have to learn a lot before I can do this... if I can even muster the willpower. :p
 

linterno

Enlightened
Joined
Dec 19, 2007
Messages
348
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?
 

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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.

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.
 

Tohuwabohu

Newly Enlightened
Joined
May 8, 2008
Messages
184
Location
Germany
I removed the microcontrollers from two of my drivers.

DX SKU 15880 without the PIC12F629
dxzp6.jpg

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.
kdko9.jpg

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

Fallingwater

Flashlight Enthusiast
Joined
Jul 11, 2005
Messages
3,323
Location
Trieste, Italy
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.
 

Tohuwabohu

Newly Enlightened
Joined
May 8, 2008
Messages
184
Location
Germany
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.
 
Top