Thanks all guys ( Bob, Olin and Joe in mail receiving order ) As usual, language bariers have stopped me to put the right question. Bob, I need a finest resolution so every time the minimum period will be 10 seconds and no more, for 10 minutes and 10% I need to do 60 times 1 second on and 9 secons off. Olin and Joe, I'm using an internal RTC ( interrupt tmr0 based ) which is self running only in the task I need ( by activating or not the interrupts). There is no problem here, I'm using flags and semaphores. This RTC is used to display a decreasing time clock from 9.59 ( 9 minutes and 59 seconds ) to 0.00. The flow of that clock is permanent in the phase I'm talking about even the output command is not because in the same task I need to command an output nibble with the algorithm I was talking about. My ideea is to forget about the minutes and to read the seconds every time I want an output command. Then keeping the command ON a number of seconds equal with percentage/10 and OFF the number of seconds equal with ( 100 - percentage )/10 , should provide the output I need... But how to deal with a 0 second reading ( for example at 3.00 ) ? I could test the seconds and if are 0 to wait until are changing... I think this is the partial answer for my problem... there is an easyest way ? Thank you, Vasile On Mon, 1 Apr 2002, Olin Lathrop wrote: > > I have a problem here: I'm trying to understand a methode for switching > > on and off one pic output respecting an input percentage proportion from > > 10% to 90% of a pre-programmed time value ( from 10 seconds to 10 minutes > > ). With other words: > > 10% from 10 seconds means 1 second on + 9 seconds off > > 10% from 10 minutes means 60 x ( 1 second on + 9 secons off) > > ... > > 90% from 5 minutes and 30 seconds means 33 x (9 seconds on + 1 > > second off) > > > > How I can define a common algorithm which fits on any time and any > > percentage ? > > This sounds simple if you rephrase it as a PWM output lasting for a > specified time. Since your PWM period is 10 seconds, this is simple to do > in software. If 10% resolution is enough, then you only need an interrupt > every second to re-evaluate the PWM output. > > I think you already know this, Vasile, so what am missing? > > > ***************************************************************** > Embed Inc, embedded system specialists in Littleton Massachusetts > (978) 742-9014, http://www.embedinc.com > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads