Probe to read quadrature encoder with DT_INT need help


Results 1 to 12 of 12

Threaded View

  1. #9
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Default

    These code count pulses from one pin of quadrature encoder good and fast.
    It use RB0 INT very good.
    Now I need idea to implement full reading quadrature encoder A and B inputs with count of pulses and direction indication..
    Encoder is with 500 pulses per full revolution.
    How - need idea..?
    Procesor 16F877 @ 20MHz
    Code:
    define OSC 20
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 64  ' 19200 Baud @ 20MHz, 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    ADCON1 = 7                       
    TRISB = %00000011
    a var word
    a = 0
    INTCON = %10010000 ; Enable INTE RB0 interrupt $90 
    INCLUDE "DT_INTS-14.bas" 
    INCLUDE "ReEnterPBP.bas" 
    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
        INT_Handler INT_INT,    _TEST,  PBP, yes
        endm
        INT_CREATE ; Creates the interrupt processor
    ENDASM
    
    Main: 
    if a >= 5000 then
    a = 0
    endif
    hserout [ dec a ]
    pause 100
    GOTO Main
    
    '---[INT_INT - interrupt handler]------------------------------------------
    
    TEST:
    a = a + 1
    @   INT_RETURN
    Regards Robert
    Last edited by phoenix_1; - 30th August 2009 at 21:24.

Similar Threads

  1. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 14:45
  2. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. Write and Read from eeprom
    By savnik in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 9th June 2007, 14:56
  5. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 21: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