Encoder problem


Closed Thread
Results 1 to 7 of 7

Thread: Encoder problem

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89


    Did you find this post helpful? Yes | No

    Default

    Thanks mister_e ,

    this is my code, i use timer as counter.
    but it count upto 256 and reset to 0, I see datasheet timer0 is 8 bit
    how i set to tomer1 on pic16f877

    '-------- PIC16F84A -----------------------
    DEFINE OSC 16 ' use 16 MHZ oscillator
    INCLUDE "MYLCD.BAS" ' LCD ON PORTB

    input PORTA.4

    OPTION_REG = %10110000 ' TMR0 clock source : RA4/T0CKI
    ' increment on low to high transition
    ' Prescaler assign to WDT
    ' WDT rate 1:1


    INTCON = %10100000 ' Enable global interrupt
    ' Enable TMR0 overflow interrupt

    ClockInput var PORTA.4 ' Input pin for signal
    COUNTER var word ' Result of count to be send to 7 segment display
    OverFlowVar var word


    COUNTER = 0 ' set initial value of count
    TMR0 = 0 ' reset prescaller
    on interrupt goto MyInit



    LOOP:
    lcdout $fe,1
    lcdout "count ", dec5 COUNTER
    pause 20

    COUNTER = OverFlowVar+ TMR0
    OverFlowVar = 0 ' Reset OverFlowVar
    goto Loop


    disable
    MyInit:

    OverFlowVar = OverFlowVar + 65535
    INTCON.2 = 0 ' clear overflow flag
    TMR0 = 0 ' reload TMR0
    resume
    enable

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    As per the datasheet you'll have to use the PORTC.0 pin.
    Code:
    T1CON=%00000110 ' Prescaller 1:1
                    ' osc=off
                    ' no synchro
                    ' ClockSource external PORTC.0
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 15:45
  2. Instant Int and encoder (Elect. Gearing)
    By boroko in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 29th November 2009, 03:29
  3. Problem implement "Henrik" incPID
    By phoenix_1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th September 2009, 15:36
  4. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 09:12
  5. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 22:56

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