Hi George,
If it is not a secret government project, can you post your code?
-------------------------
Hi George,
If it is not a secret government project, can you post your code?
-------------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Sure, all it does is dims a light down after 20 minutes of being on.
@ device pic10F202, mclr_off, protect_off, wdt_off
TRISIO = %1100
triac VAR GPIO.2
trigger VAR GPIO.3
dim VAR WORD
Time VAR WORD
Time2 VAR BYTE
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 AND b0 = 2 Then dim = dim + 1 'if over 20 min then start dimming dim period 4 cycles = 10 mins
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 trigger points and trigger triac
IF trigger = 1 Then lowside 'wait for phase to go low
GPIO.5 = 0 'weight input to sense zero crossing
PauseUs dim 'wait for dim period
Output triac 'fire triac
triac = 0
PauseUs 400
Input triac
HighSide:
IF trigger = 0 Then HighSide
GPIO.5 = 1
PauseUs dim
Output triac
triac = 0
PauseUs 400
Input triac
GoTo start
It's the down side of those nifty 10Fs with most compiler. The use of assembler is handy in this case... but i'll have a look at this one to see what i can do...
Last edited by mister_e; - 9th October 2006 at 03:58.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
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
Good luck!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
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hey steve - that looks like some funky stuff yr doing there - tho it's still saying that it's unable to fit variable b0. Any easy way to solve it? Else I'm gonna move to a 12F - seems such a waste tho as I'm only using 2 I/Os. I'm trying to design it for a production run - so I did like the cost and form of the 10F.
be sure you copy past the whole thing above. It compile ok to me. I did few minors change to the one you posted before.
I guess about a IF (condition a) AND (condition b) then... line... right?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hey - copied it all across and it compiled thanks - however - it won't program :s
"ROM programming error at address 0x0000
Good 0x0025
Bad 0x0FE7"
Any ideas on what that could mean?
Thanks
Brendon
Bookmarks