Driver microcontroller hacking

BillyNoMates

Newly Enlightened
Joined
Jan 16, 2009
Messages
144
Location
Bristol,UK
This is an interesting thread. I used a PIC 16F506 in the bike light / headtorches I've been building. These little beasts are a great way of customisng the operation of any home brew light.

I wrote the program in assembler and here is a list of the functionality I included in my first application:

Four brightness settings (spaced apart by a factor of x3 in power) and two strobe settings (for urban riding).

Single button operation; long press to wake-up / sleep, double click to increase brightness, single click to decrease brightness (Note this control drives enable pins on the driver ICs rather than PWM).

Battery voltage monitor used to drive tri-colour LED and force minimum brightness mode when battery reaches 80% depleted.

Memory function that remembers the last brightness setting used when powered down. This resets to the initial state if the battery is disconnected.

Here's a pic of the PIC on my custom driver board (5x rebel headtorch / bike tail light design).

Rebel_5x_Top.jpg
 

ifor powell

Enlightened
Joined
Nov 18, 2007
Messages
230
Location
Bristol UK
Very nice looking boards. Whats the size? 20-25mm? What is the cooling like on the rebels? I guess you don't push them flat out?

Ifor
 

BillyNoMates

Newly Enlightened
Joined
Jan 16, 2009
Messages
144
Location
Bristol,UK
Very nice looking boards. Whats the size? 20-25mm? What is the cooling like on the rebels? I guess you don't push them flat out?

Ifor

Hi Ifor

The boards are 30mm in diameter. The 5x rebel optic from Ledil has a 35mm diameter, so that sort of defined the board size. It could go a bit smaller but that needs more effort on the layout !!).

The rebels run at 750mA each (the drivers will supply upto 1000mA per LED), so there is a reasonable amount of heat to get rid of. I rely on using the vias under and around the thermal PAD of the rebels to conduct the heat to the back of the board (plain copper) from where the heat is extracted and conducted to the main case/heatsink.

The microcontroller can be programmed in place so it is easy to change the function of the light if I so desire - I have different loads for front and rear for example.
 

gillestugan

Enlightened
Joined
Nov 20, 2007
Messages
242
Location
Nora, Sweden
I will be using two resistors to get voltage division and measure the voltage with the ReadADC command.
Same for temperature monitoring except I will use a thermistor in combination with a resistor.
Then simple "If" to make it lower output when temperature goes to high.

I will have one MC-E and two XP-Es in a 5*4*3cm housing, so it will easily get way too hot if I leave it on maximum for too long. I want the protection so I don't have to worry.

I have an exam later this week, but will continue work on it next week. Will post code, schematics and drawings when done. (may take some time...)
 

gillestugan

Enlightened
Joined
Nov 20, 2007
Messages
242
Location
Nora, Sweden
Hi Ifor
The microcontroller can be programmed in place so it is easy to change the function of the light if I so desire - I have different loads for front and rear for example.

That is great! very nice looking boards! Are the vias on the LED boards enough to keep the leds cool? Why did you choose to use normal PCB material instead of copper or aluminium? cost?

Are you using PWM regulation? If so, what is the drive level when led is on? 1000mA?

Are you selling the boards/lamps? They look very professional.
 

linterno

Enlightened
Joined
Dec 19, 2007
Messages
348
I will be using two resistors to get voltage division and measure the voltage with the ReadADC command.
You should better use ReadADC10, but anyways the resistor voltage divider won't work.

The ReadADC returns a value between 0 and 255. ReadADC10 returns a value between 0 and 1024. Using a resistor voltage divider you will always get the same value returned from ReadADC/ReadADC10 no matter what the battery voltage is. This is because the value returned by ReadADC10 is based on the VDD voltage divided by 1024 possible values (10 bit resolution). i.e: Assuming that your battery voltage is (x) and you use a 5k and 5k resistor voltage divider will give you (x)/2 or half the input voltage which is the battery voltage. If the battery voltage is 4.2 or 3.8 or 3 volts ReadADC10 will always return 512 and ReadADC will always return 128 for the previous resistor combination.

You need a voltage reference to determine the battery voltage.
 

gillestugan

Enlightened
Joined
Nov 20, 2007
Messages
242
Location
Nora, Sweden
Yes, but I will already use a 3,3V voltage regulator for power supply of the picaxe as I will use batteries with higher voltage than 5.5V, so Input voltage will never be the same as battery voltage.
I also think 8-bit resolution is enough as I then will get 0,013V steps, which should be enough. But then of course it wont hurt to have the higher resolution of the ReadADC10 .
 
Last edited:

BillyNoMates

Newly Enlightened
Joined
Jan 16, 2009
Messages
144
Location
Bristol,UK
The ADCs on the PICs all read relative to the supply: Full scale corresponds to an input = to the PIC supply, 0 corresponds to GND.

To get around this in my app, I configured the ADC input to the internal 0.6V reference (this is possible in the PIC I used). This way the ADC read tells me what fraction of the supply voltage the 0.6V reference corresponds to. Below is an extract of the assembler for this function showing the numbers I used:

; This function uses the ADC to read the internal reference *
; voltage. This is 0.6V, but the value returned by the ADC is *
; reference to the supply voltage. The higher the supply voltage, *
; the lower the ADC value. An example Table is given below: *
; ADC VCC *
; 57.0000 2.7000 *
; 53.0000 2.9000 *
; 49.0000 3.1000 *
; 46.0000 3.3000 *
; 44.0000 3.5000 *
; 41.0000 3.7000 *
; 39.0000 3.9000 *
; 37.0000 4.1000 *
; 36.0000 4.3000 *
; 34.0000 4.5000 *
; 33.0000 4.7000 *
; 31.0000 4.9000 *


Of course, using a regulated voltage for the PIC works just as well...
 

BillyNoMates

Newly Enlightened
Joined
Jan 16, 2009
Messages
144
Location
Bristol,UK
That is great! very nice looking boards! Are the vias on the LED boards enough to keep the leds cool? Why did you choose to use normal PCB material instead of copper or aluminium? cost?

Are you using PWM regulation? If so, what is the drive level when led is on? 1000mA?

Are you selling the boards/lamps? They look very professional.

I only have a couple of boards at the moment so I don't have any for sale. If there is enough interest in this particular implmentation I could consider doing another run. I'm planning on waiting until I have finished doing a nice case before I intend posting full details on this build.

I used a standard 1.6mm PCB simply because the on-line PCB supplier I used only offered this material on their prototype (low cost) runs.

The vias should be enough to provide a thermal resistance of approx 10k/W per LED with this board - more vias can reduce this a bit. I'm running the LEDs at about 2.5W (750mA drive) so the thermal pad will be about 25K above the baseplate temp....

I don't use PWM, instead I use different drive levels + different number of LEDs.

1xLED at 125mA
1xLED at 450mA
5xLED at 250mA
5xLED at 750mA

I'll post more info when I get this finished - shame the light nights are approaching, perhaps I'll have to take up caving :)
 

gillestugan

Enlightened
Joined
Nov 20, 2007
Messages
242
Location
Nora, Sweden
Yes its getting lighter very fast. I probably will have my lamps finished too late, but I also love those summer nights when it never gets dark.

I think the guys over at MTBR would be very happy to see your boards if they not already have.
 

bikerjay

Newly Enlightened
Joined
Sep 2, 2008
Messages
31
I have a non micro controller related question about this board I can not seem to find an answer for. I would to be able to identify and change the sense resistor, which is presumably on the side of the board with the inductor. What I am going for is lowering the current from 1000ma to 700ma. I am also curious what people think about using this board with a single red orange luxeon III, given its very low forward voltage.
 

gillestugan

Enlightened
Joined
Nov 20, 2007
Messages
242
Location
Nora, Sweden
I have been using AX2002 based boards with luxeonIII reds for garden illumination. As long as you are using current regulated drivers you will have no problem with the lower Vf.
 

astanapane

Newly Enlightened
Joined
May 8, 2010
Messages
61
Hello all,

i just show your posts. I'm new to this hobby according to programming MCUs and i would like to ask you if there is any HEX file for pic12f629 in order to program it and use it for personal only use.

I would like specifically to make some outdoor light for the house and also for internal use also.

Thank you very much for your help in advance.
 

manne

Newly Enlightened
Joined
Nov 8, 2006
Messages
15
Location
Germany
If someone interested to reprogram the DX linear drivers (AMC7135 with ATTINY13V), here i wrote a german tutorial (maybe google translate helps) includes a BASCOM program: http://www.messerforum.net/showpost.php?p=664718&postcount=52

It is without memory function and can be customize between 2 or 3 mode and the (256) values of the dimm mode(s) using the plated-through stars on the backside of the board.

Cause i have some older versions with the 12f629 PIC i compiled the program (without ADC and customize parts) in Mikrobasic, the EEPROM part was working fine, but got some problems to make an acceptable fast software PWM and gave up as the PIC seems to gave up too.
 
Last edited:
Top