tmr1 on 16f690


Closed Thread
Results 1 to 9 of 9

Thread: tmr1 on 16f690

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Missing code

    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

  2. #2
    dan gill's Avatar
    dan gill Guest


    Did you find this post helpful? Yes | No

    Smile Yippee. I got it.

    I started messing around with Henrik had said about resetting the timer. I ran the timer thru a one second loop and if the tmr1L>0 then I reset the timer.
    I then ran a counter to count up only when tmr1L was zero. The only way to have it be zero, was for the timer to quit counting. I used a count up to 3 just to be sure it wasn't just counting really slow and it works great. It may not be perfect, but it get the rev/second so close that it really doesn't matter for my application. Thanks guys for all the suggestions. you helped me a lot.

    Dan

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Terrific!

    Hi Dan,
    glad you got it. Check your private mail too!

Similar Threads

  1. Simple TMR1 application example needed
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th February 2010, 09:52
  2. TMR1 external LP xtal setup check
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th October 2009, 18:11
  3. Replies: 2
    Last Post: - 7th October 2009, 00:06
  4. 16f877A and tmr1 external crystal question
    By comwarrior in forum General
    Replies: 3
    Last Post: - 13th July 2009, 00:40
  5. Measuring change of frequency with PIC
    By Aussie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th July 2007, 01:47

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts