Critique on circuit and code pls?

Status
Not open for further replies.

Phasor

Member
Ok folks, I haven't worked much with microcontrollers yet, so I thought I'd submit my first "real" uC project for critique amongst everyone. Tell me if my code is wrong, or anything else.

Basically, it is a "Sunrise simulator". On power-up, it slowly turns on a lamp from dim to bright, over a few minutes.

Schematic is shown below. And yes, I know I'm using a non-isolated transformerless supply - it's intended to be hidden behind a light switch, where stray fingers can't get to it!

I'm using a PICAXE-08M. Preliminary code follows:
-------------------------------------------------------------
main:

LET minutetimer = 0 'Counts time until next brightness increase
LET phasedelay = 9 'Delay between Zero cross and triac triggering in millisec
setint %0000001,%0000001 'Interrupt for zero crossing

goto main


interrupt:

pause phasedelay
high 2 'Trigger triac
pause 1
low 2
LET minutetimer = minutetimer + 1

if (minutetimer >= 3000 && phasedelay > 0) {

LET phasedelay = phasedelay - 1 MIN 0 'phasedelay must not go negative
LET minutetimer = 0 'Counter reset

}

setint %0000001,%0000001

return
-------------------------------------------------------------
 

Attachments

  • ssctrl.gif
    19.8 KB · Views: 323
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…