I can suggest the following approch:
Read cycle and ontime word variables
Compare the the two variables and adjust ontime to cycle if ontime is greater then cycle
IF ONTIME>CYCLE THEN ONTIME=CYCLE
If you don't want offtime=0 then you can add the proper offset
IF ONTIME>=CYCLE THEN ONTIME=(CYCLE-OFFSET)
Set high output pin
loop for for the cycle delay and check ontime
when loop reach ontime value set low output pin
continue the loop till you reach the cycle time.
Ontime will be adjustable and always within cycle time
Al.
Last edited by aratti; - 6th November 2008 at 15:07.
All progress began with an idea
Bookmarks