Not tested but assuming you're not using any Gosubs... it could work.
Inspiration taken bellow
http://www.picbasic.co.uk/forum/show...light=modifier
Sure it could be dangerous.... compile O.K
Code:
@ device pic10F202, mclr_off, protect_off, wdt_off
TRISIO = %1100
asm
dim=SOFT_STACK
Time=SOFT_STACK + 2
Time2=SOFT_STACK_PTR
endasm
dim VAR WORD ext
Time VAR WORD ext
Time2 VAR BYTE ext
b0 VAR BYTE
Clear
GPIO = 0
dim = 100
Start:
time = time + 1 'increment timer in 1/50 seconds
IF time > 30000 Then 'make a 10 min increment
time = 0
time2 = time2 + 1
EndIF
b0 = b0 + 1 'increment for every 4 phase cycles
IF b0 >= 3 Then b0 = 0
IF (time2 >= 2) then
if b0 = 2 Then dim = dim + 1 'if over 20 min then start dimming dim period 4 cycles = 10 mins
endif
IF dim > 7500 Then dim = 7500 'down to dim level - 9000 = off, 7500 approx 15%
if time2 > 72 then 'turn off after 12 hours
dim = 9000
time2 = 73 'prevent from cycling
endif
LowSide: 'look for GPIO.3 points and GPIO.3 GPIO.2
IF GPIO.3 = 1 Then lowside 'wait for phase to go low
GPIO.5 = 0 'weight input to sense zero crossing
PauseUs dim 'wait for dim period
TRISIO.2=0 'fire GPIO.2
GPIO.2 = 0
PauseUs 400
TRISIO.2=1
HighSide:
IF GPIO.3 = 0 Then HighSide
GPIO.5 = 1
PauseUs dim
TRISIO.2=0
GPIO.2 = 0
PauseUs 400
TRISIO.2=1
GoTo start
Good luck!
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks