Okay, I took most of your advices and got to this point where I am sampling one signal to construct another and is working very nice and smooth without any jitter (which I also realized why it was happening in the first place).
Here is the working portion of the code I would like to use TMR1 in so that I can measure time between occurrances if possible:
This is my understanding of a way to use the TMR1; Wait for something to occur then set the CAPTURE flag (PIR1.2 in this case) and read the high and low timer bits, clear the flag. Wait for something else to occur and read the high and low timer bits again, clear the flag and get the difference of the two timer values for time elapsed! Seemed simple enough but if it worked I would not be asking for direction. So the question here, can the TMR be software controlled like I'm trying to do or am I restricted to rely on the CCP1 input pin for triggering?Code:Third: PULSIN Sig3,0,S1 ' Monitor for and measure Sig3 ADCIN 1, Low_pot ' Read Low Pot setting Low_adj = ABS(Low_pot-128) ' Make pot adjustable from center IF Low_pot <128 then ' If pot on left side then make Low_set= S1-(S1/(AR/Low_adj)) ' negative adjustment ENDIF IF Low_pot >=128 then ' If pot on right side then make Low_set= S1+(S1/(AR/Low_adj)) ' positive adjustment ENDIF WHILE sig2=1: WEND ' Wait for trigger signal PULSOUT Inj2, Low_set ' Send output pulse =% of Sig3 ' input signal GOTO Third
Code:Third: TMR1H = 0 ' Clear TMR1 high byte counter TMR1L = 0 ' Clear TMR1 low byte counter T1CON.0 = 1 ' Turn on TMR1 PULSIN Sig3,0,S1 ' Monitor for and measure Sig3 Capture1 = 1 ' Set capture flag bit T1.HighByte = CCPR1H : T1.LowByte = CCPR1L Capture1 = 0 ' Clear capture flag bit ADCIN 1, Low_pot ' Read Low Pot setting Low_adj = ABS(Low_pot-128) ' Make pot adjustable from center IF Low_pot <128 THEN ' If pot on left side then make Low_set= S1-(S1/(AR/Low_adj)) ' negative adjustment ENDIF IF Low_pot >=128 THEN ' If pot on right side then make Low_set= S1+(S1/(AR/Low_adj)) ' positive adjustment ENDIF WHILE Sig2=1: WEND ' Wait for trigger signal PULSOUT Inj2, Low_set ' Send output pulse =% of Sig3 ' input signal Capture1 = 1 ' Set capture flag bit T2.HighByte = CCPR1H : T2.LowByte = CCPR1L Capture1 = 0 ' Clear capture flag bit RPM = T2-T1 HIGH Inj4 PAUSEUS RPM Low Inj4 GOTO Third END




Bookmarks