Probe to read quadrature encoder with DT_INT need help


Closed Thread
Results 1 to 12 of 12

Hybrid View

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

    Unhappy Probe to read quadrature encoder with DT_INT need help

    When I compile MCSP return next error's (compile with MPASM).
    PBP 2.50C
    Procesor 16F877 @ 20MHz.
    ERROR's:
    error[128]877 qei.asm 87 : Missing argument(s)
    error[118]877 qei.asm 87 : Overwriting previus address contents (2007)


    Code:
    @ __config & _WDT_ON & _PWRTE_OFF & _BODEN_ON & _LVP_OFF & _CP_OFF & _DATA_CP_OFF
    '@ Device pic16F877, HS_OSC, BOD_ON, PWRT_OFF, WDT_ON, PROTECT_OFF
        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
        old_val VAR BYTE
    	new_val VAR BYTE
    	direction_bit VAR BIT
    	enc_counter VAR WORD
        enc_counter = 10000
    	new_val = PORTB & %00000011
        TRISB = %00000011
        INCLUDE "DT_INTS-14-0.bas"     ' Base Interrupt System
        INCLUDE "ReEnterPBP-0.bas"     ' Include if using PBP interrupts
        
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _QEI,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
     ENDASM
    @ INT_ENABLE   INT_INT     ; enable external (INT) interrupts
    rs232:
        pause 1     
        goto rs232
        
        QEI:
        
    	old_val = new_val
    
    	new_val = PORTB & %00000011
    	
    	IF new_val = old_val Then again
    
    	direction_bit = old_val.bit0 ^ new_val.bit1
    	
    	IF direction_bit = 1 Then  
    	
    			enc_counter = enc_counter + 1
    		
    	else
    		
    		enc_counter = enc_counter - 1
    		endif
    		hserout [dec enc_counter]
    	again:
    @ INT_RETURN
    Last edited by phoenix_1; - 30th August 2009 at 12:14.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Code:
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _QEI,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
     ENDASM
    _QEI label ; PBP and yes not correctly allined. Change as per the following

    Code:
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,         _QEI,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
     ENDASM
    Al.
    All progress began with an idea

  3. #3
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Default

    Code:
    @ __config & _WDT_ON & _PWRTE_OFF & _BODEN_ON & _LVP_OFF & _CP_OFF & _DATA_CP_OFF
    '@ Device pic16F877, HS_OSC, BOD_ON, PWRT_OFF, WDT_ON, PROTECT_OFF
        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
        old_val VAR BYTE
    	new_val VAR BYTE
    	direction_bit VAR BIT
    	enc_counter VAR WORD
        enc_counter = 10000
    	new_val = PORTB & %00000011
        TRISB = %00000011
        INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
        INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    RBC_INT,         _LED,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
     ENDASM
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts
        rs232:
        pause 1     
        goto rs232
        
        LED:
        
    	old_val = new_val
    
    	new_val = PORTB & %00000011
    	
    	IF new_val = old_val Then again
    
    	direction_bit = old_val.bit0 ^ new_val.bit1
    	
    	IF direction_bit = 1 Then  
    	
    			enc_counter = enc_counter + 1
    		
    	else
    		
    		enc_counter = enc_counter - 1
    		endif
    		hserout [dec enc_counter]
    	again:
    @ INT_RETURN
    PBP 2.47 , 250 or 250C in all version same errors ???

    can you edit and post my code full please sir?
    Last edited by phoenix_1; - 30th August 2009 at 14:52.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    Your error is double ...

    1)

    Code:
    @ __config & _WDT_ON & _PWRTE_OFF & _BODEN_ON & _LVP_OFF & _CP_OFF & _DATA_CP_OFF
    do not use " & " before the first data : WDT_ON ...

    2)

    You have to comment the CONFIG lines already existing in your 16F877 .inc file ( PBP folder ) if you want custom ones ... see FAQ for details.

    Alain
    Last edited by Acetronics2; - 30th August 2009 at 15:19.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Default

    Acetronics your help is 100% work.
    Thank's many thanks man.
    And one question more...how DT interupt can be fast ?
    Last edited by phoenix_1; - 30th August 2009 at 15:28.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by phoenix_1 View Post
    And one question more...how DT interupt can be fast ?
    Hi,

    I do not know exactly ...

    but it's roughly the time to save and restore all the PBP variables in use, added to the "classic" ASM interrupts time ...

    You can Use the MPLAB SIM ... You will have a very good idea !

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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