Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 12th July 2005, 02:04 PM   #1
Default Critique on circuit and code pls?

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
-------------------------------------------------------------
Attached Thumbnails
Critique on circuit and code pls?-ssctrl.gif  
Phasor is offline  
Reply

Tags
circuit, code, critique, pls

Thread Tools
Display Modes




All times are GMT. The time now is 08:04 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker