On Tue, 11 Dec 2001, Andre Abelian wrote: > Hi to all engineers, > > I need to generate 4 pulses at the same time with > Different timing and based on battery voltage if > The voltage does lower then +12 v duty cycle (on time) > Must be changed go lower then 50%. > > > > |--------------------| |------ > ______________| |____________________| > > ______________ ____________________ > | | | > |--------------------| |------ > > > ---------------------| |--------------------| > |____________________| | > ____________________ > | | | > ---------------------| |--------------------| > > > > > this is how I am thinking to do it. Find out about the frequency first > then based on that generate interrupt on every rising or falling edge > then use one of the timer to control on time thru ADC or maybe it is > better to use tables instead. Any help will appreciated I think a good way to simplify this is by defining four states. Suppose your top waveform is mapped to PORTB,0 and the others to PORTB 1,2,3. Call your states: S0, S1, S2, S3. Define them as such: S0 equ 0110b S1 equ 1010b S2 equ 0101b S3 equ 1010b (I'm assuming the the pulses are differential. If not, then you'll need 16 unique states). Then to generate the above wavform: movlw S0 movwf PORTB ... movlw S1 movwf PORTB ... movlw S2 movwf PORTB ... movlw S3 movwf PORTB ... This give you the flexibility to make this a state machine as well: cblock ADDR & 0xfc ; make sure lower two bits are zero _s0,_s1,_s2_s3 curr_state endc ;Preload states movlw S0 movwf _s0 movlw S1 movwf _s1 movlw S2 movwf _s2 movlw S3 movwf _s3 .. ; Generate the waveform: loop movf curr_state,w ; Get current state index andlw 00000011b addlw _s0 ; Index into the valid states (note the addlw) movwf FSR ;Point to current state movf INDF,W ;get the value of the current state movwf PORTB ;drive the I/O's with it. goto loop Scott -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body