Quote Originally Posted by dan gill
Ok guys,

I've tried the reset deal and the comparison deal. I'm driving an R/C servo, so I can't use any other pause other than the 50Hz update pause. I need the tmr1L to do everything in the background without upsetting the servo refresh rate. I used the COUNT command and it would work the best for what I'm doing if it didn't require such a long pause for the count. I spoke with Charles at MELABS and suggested the tmr1 use. Here's a snippet of the program code. I can't use the tmr0 either. I need the pinout. There is no room to use a larger chip either.

Chip is a 16F690


PROGRAMSET:

SEROUT LCD,R,[I,LINE4]
SEROUT LCD,R,["PROGRAMSET"]
A=0
high LED4 'TURN ON GREEN LED TO SHOW SYSTEM READY
FOR A= 1 TO 50 '1 SECOND TIME LOOP COUNTER FOR TMR1L
IF A=50 THEN GROUNDSPEED 'LOOP FOR CHECKING GROUNDSPEED
IF SW1=1 AND SW2=1 THEN RESET 'push switch 1 first
HIGH SERVO
PAUSEUS (1000+S)
LOW SERVO
PAUSE 16
NEXT A
GOTO PROGRAMSET



GROUNDSPEED: 'CHECKS GROUNDSPEED EVERY 1 SECOND

SEROUT LCD,R,[I,1]
SEROUT LCD,R,[I,LINE1]
SEROUT LCD,R,["GROUNDSPEED"]
SEROUT LCD,R,[I,LINE2]
SEROUT LCD,R,["TMR1L=",#TMR1L]
IF TMR1L>60 THEN TIMERRESET 'TMR1L RESETS IF SPEED GREATER THAN 60
HIGH SERVO
PAUSEUS (1000+S)
LOW SERVO
PAUSE 16

My program works wonderfully if I could just get the last of the code to work.
Do you guys think I could use a smaller reset and check it like Henrik has suggested. The only problem I can see with the method is what if the program happens to check the timer when it's resetting? That would give a false reading. The absolute bottom line is I must be positive of when the shaft is no longer rotating, or at the very least, moving very slowly. Once the shaft stops moving, I can tell the servo to move, but not before. I really am upset that I have over 3000 words of code and that I can't figure out what is probably only a few words to complete the program.

I really appreciate all the help. Thanks.

Dan
Hi Dan,
isn't there more to this code? Where are your variable declarations? Are there more subroutines? It's just really hard to guess what you have and harder to copy/paste into pbasic compiler so as to work on this for you, if parts are missing.
JS