Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC programing? light dimmer+ more, need HELP!!!

Status
Not open for further replies.
SkinnyBoy said:
I need MORE than what the kit does though... :p lol like switching a second triac hard on, when the dimming triac reaches full brightness...

hmm....

I need help... :( *sits in the corner*

You can't expect people to custom build your project for you?, as suggested the Silicon Chip design should be able to be modified for what you want - so I suggest you start learning PIc programming!.
 
try this
PIC12F675
beware of high voltage
50Hz only

' 1MHz*64=64usec ca si tact
' 0.01/64usec=156,25 pasi
' deci Mindelay=0 si maxdelay=156 pentru 50Hz
' in acest caz prescallerul este 64 deci OPTION_REG=0x0x0101
' in acest caz bitul de overflow este INTCON.2 si se curata soft
' resetul TMR0 se face soft
' incarcarea TMR0 se face soft
' merge face sesizare intreruperi si tot restul! E FAIN!
' INITIALIZARE MCU
'
' initializare TS pe porturi
TRISIO = %00001111
'
OPTION_REG=%10000101 ' Enable pull-ups a fost 11000101
WPU=%00000111 ' Enable pull-ups on GP0, GP1
CMCON=7 ' Disable analog comparator
ANSEL=0 ' Disable analog converter
IOC.2=1
' initializare intreruperi la start numai cele pe GPIO2/INT
INTCON=%01011000
Pb_Inc var GPIO.0 ' Input for INCREMENT/ON push button
Pb_Dec var GPIO.1 ' Input for DECREMENT/OFF push button
ACline var GPIO.2 ' Input for the FullWave rectify AC line
Triac var GPIO.5 ' Output to TRIAC gate
Led var GPIO.4 ' Led output
delay var byte
onoff var bit
count_up var byte
count_dn var byte
maxbright var byte
minbright var byte
pas var byte
stare var bit
var1 var byte
prag var byte
pas1 var byte

maxbright=230
minbright=90 ' a fost 100
triac=0
delay=minbright
pas=20 ' a fost 25
pas1=2
onoff=0
count_up=0
count_dn=0
stare=0
var1=0
prag=6
on interrupt goto intrerupere
'
loop0:
gosub sunet1
triac=1
pause 500
triac=0
pause 500
triac=1
pause 500
triac=0
gosub sunet2
'
loop1:
' rutina de lighton
if pb_inc=0 or pb_dec=0 then
gosub sunet1
onoff=1
repeat
if stare=0 then
delay=delay+1
stare=1
endif
until delay=maxbright
else
goto loop1
endif
'
start:
' rutina de dimmon si dimmoff
if delay<=minbright then
onoff=0
'goto loop1
else
onoff=1
endif
if pb_inc=0 and delay<maxbright then
if stare=0 and count_up>=pas then
var1=var1+1
if var1=prag then
delay=delay+1
var1=0
endif
count_up=25
stare=1
else
endif
else
if count_up>pas1 and count_up<pas and delay<maxbright then
' count_up=0
goto lighton
else
endif
endif

if pb_dec=0 and delay>minbright then
if delay=(minbright+1) then
goto start
endif
if stare=0 and count_dn>=pas then
var1=var1+1
if var1=prag then
delay=delay-1
var1=0
endif
count_dn=25
stare=1
else
endif
else
if count_dn>pas1 and count_dn<pas and delay>minbright then
' count_dn=0
goto lightoff
else
endif
endif
goto start
'
'
'
lighton:
repeat
count_up=0
if stare=0 then
delay=delay+1
stare=1
endif
until delay=maxbright
goto start

'
lightoff:
repeat
count_dn=0
if stare=0 then
delay=delay-1
stare=1
endif
until delay=minbright
onoff=0
gosub sunet2
goto loop1


sunet1:
sound led,[102,5,104,5,106,5,108,5,110,5,112,5,114,5,116,5,118,5,120,5,122,5,124,5,126,5]
return
'
sunet2:
sound led,[126,5,124,5,122,5,120,5,118,5,116,5,114,5,112,5,110,5,108,5,106,5,104,5,102,5]
return
'
disable
intrerupere:
' pe acline
if INTCON.1=1 then
INTCON.7=0
INTCON.1=0
TMR0=delay
INTCON.5=1
INTCON.4=0
INTCON.7=1
stare=0
led=not onoff
else
endif
' pe TMR0
if INTCON.2=1 then
INTCON.7=0
INTCON.2=0
if onoff=1 then
triac=1
else
triac=0
endif
if pb_inc=0 then
count_up=count_up+1
else
endif
if pb_dec=0 then
count_dn=count_dn+1
else
endif
if pb_inc=1 and pb_dec=1 then
count_up=0
count_dn=0
endif
triac=0
else
endif
INTCON.7=1
resume
enable
 
Hello, i'm new to this site. I found it while i was searching for a code that will dim the LED I am using a PIC12F683 for controling the dimmer(potentiometer). I have used a PIC12F675 earlier.
the features of the 683 are pretty similar with the 675 except for the WDT(watch dog timer) which is the reason i used it for my project. The purpose of the 683 in my project would be to control the dimmer. There will be a POT that someone can physically twist and turn to dim/brighten the led bulb. the dimmer will be connected to PIN5 of the pic. When the person turns the button(pot), the pic will change that to a signal that goes to the dimmer pin of the circuit which inturn will control the LED. The WDT will help decrease the output power wasted when the PIC is in sleep mode(right??).
I have also found that the 683 has it's own PWM which is another problem for me. When i was using the 675, i created my own PWM cycle and was able to see what goes on code per code. The 683 has it's own built-in pwm and so i have no code just for the pwm to look at. The datasheet just gives me some equations and examples of calculating the frequency/period.
Can you tell me where i can look to get a better idea of how to set up this code? i'm in dire need of any help. I'm not a code person and i'm having a tough time getting this thing working.

Again thanks for all your help
 
More on the code for PIC12F683

The dimmer will be used so that the user will have the option to brighten or dim the output light. My problem is with the assembly code. I looked at the examples of codes posted by Nigel but couldn't find anything that would dim an LED light. Do you have a sample code that i can maybe play around with?

Thanks
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top