This is a constant-current LED driver I made using the Picaxe 18X, ADS1115 external I2C analog to digital converter, and an IGBT to do the switching. Wanted to make it so it fits into a light socket with a socket to outlet adaptor. I've determined the LEDs need more heat sink area than they currently have. After I built this I also learned (on here) about the benefit of using MOSFET drivers, especially at high PWM frequencies, and perhaps using an inductor on the output. I'm trying to figure out how to select the proper inductor value with the available PWM frequencies on Picaxe chips.
Code:
i2cslave %10010000,i2cfast, i2cbyte
pause 50
writei2c (%00000001,%01011110,%10000011)'config register
pause 50
writei2c (%00000010, $80,$00)
pause 5
writei2c (%00000011, $7F,$FF)
pause 5
writei2c (%00000000)
pause 50
w1 = 350
w2 = 450
start:
pwmout 3, 255, w1
gosub getcurrent
if w0 < w2 then
w1 = w1 + 1 max 1023
endif
if w0 > w2 then
w1 = w1 - 1 min 10
endif
'debug
goto start
getcurrent:
w0 = 0
w5 = 0
w6 = 0
writei2c (%00000000)
readi2c 0, (b1,b0)
return
Attachments
-
358.2 KB Views: 100
-
826.6 KB Views: 107
Last edited: