Help whit tmr1 on pic16f877a


Results 1 to 16 of 16

Threaded View

  1. #13
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Help whit tmr1 on pic16f877a

    Hi Don, here my suggestion. If your max encoder count is not bigger of 65535 then you can feed your encoder pulses directly to timer1 input (pin 15 of you 16f877). Timer1 has to be set as a counter using "T1CON = %00000111" and then you have two ways to control your motor.

    1) You poll the timer1 register TMR1H and TMR1L to see when the count reaches the desired value to stop the motor.
    Or
    2) you use DT interrupt (as already suggested) and you just load the count in Timer1 register (you have to load the complement : 65535-desired count) and wait for the overflow. In other words when the count is reached the value of the timer1 counter will be 65535 and adding one pulses it will overflow invocking the interrupt. In this routine (called ISR) you will stop your motor.

    If your needed count is greater then 2^16 it it still possibile to use timer1 as a counter but in this case interrupt is mandatory.

    Cheers

    Al.
    Last edited by aratti; - 23rd July 2013 at 10:38.
    All progress began with an idea

Similar Threads

  1. Control de puertos PIC16F877A / Port Control PIC16F877A
    By martintorres in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th October 2013, 03:49
  2. Tmr1
    By BobSpencerr in forum General
    Replies: 7
    Last Post: - 13th May 2008, 20:19
  3. Replies: 9
    Last Post: - 4th February 2008, 19:12
  4. problem whit pic18f452
    By ocastrillo in forum General
    Replies: 3
    Last Post: - 9th March 2007, 16:18
  5. TMR1 How it works?
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 12th January 2007, 14:24

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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