Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Thank you for the quick reply.

    I'm actually working with an ESC that has 11 bit resolution so that is why I was looking for 0.5us steps. I'm not sure how much difference it will make but I wanted to try it out anyway.

    I really appreciate the help!

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Really? Who makes the ESC? On the other hand, I doubt you will notice a difference, but hey go for it!!
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Aug 2011
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Quote Originally Posted by cncmachineguy View Post
    Really? Who makes the ESC? On the other hand, I doubt you will notice a difference, but hey go for it!!
    It is a Castle Creations ESC........when I spoke to one of their engineers they said all of their ESCs have 2048+ speed steps. I know I can get away with the 8 bit resolution of a standard ESC......but as an engineer I need to get the best (i.e. overkill!) solution!

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    The part I can't get through my thick head is this, how small of a change can we cause to happen in 20mS to a spinning mass? So if the motor were actually spinning 20,000, then thats 9.75 rpm per bit at 11 bit resolution. On the other hand, getting the extra bit from the PIC may cause less time available to do other things. Mind you I have never looked at PWPS.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Hi. I am trying to make this Rotary Encoder work with DT-INTS on a 16F1827 device.

    It gets once in the interrupt routine and never seem to exit.

    Here is the code so far driving me crazy.

    Code:
    ASM
      __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CP_ON & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
      __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _LVP_OFF & _STVREN_OFF & _BORV_25
    ENDASM
    
    DEFINE OSC 32
    
    OSCCON= %11110000   'PLL enabled, Internal RC-8MHz
     
    ' Set LCD Data port
    DEFINE LCD_DREG PORTA
    ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 0
    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTA
    ' Set LCD Register Select bit
    DEFINE LCD_RSBIT 4
    ' Set LCD Enable port
    DEFINE LCD_EREG PORTB
    ' Set LCD Enable bit
    DEFINE LCD_EBIT 3
    ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2
    ' Set command delay time in us
    DEFINE LCD_COMMANDUS 1500
    ' Set data delay time in us
    DEFINE LCD_DATAUS 44
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    'Initializing Registers
      PORTB = 0:PORTA = 0
      TRISB = $33
      TRISA = 0
      
      ADCON0 = 0
      ADCON1 = 0
      ANSELA = 0
      ANSELB = 0
    
      INTCON = $88 ' Binary 10001000
      
      IOCBP=$30
      IOCBN=$30
      
      OPTION_REG = 0
      
      WPUB=$33
      
    eeprom 0,[2,0,3,1,1,3,0,2]
    led       var portb.4   
    Flag      var bit
    wsave     VAR BYTE    $70     SYSTEM  ' alternate save location for W 
    Q_New     var Byte
    Q_Old     var byte
    M_Count   var byte [4]
    P_Count   var byte [4]
    Q_Count   var word
    temp      var byte
    
    clear
         
    For Q_Old = 0 to 3
    Read Q_Old,M_Count[Q_Old]
    Read Q_Old + 4,P_Count[Q_Old]
    Next Q_Old
         
      Q_Count = 0   
        Q_New = 0
        Q_Old = 0
         Flag = 0  
          
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type,  Resetflag?                
            INT_Handler    IOC_INT,      _Encoder,  pbp,     yes       
        endm
        INT_CREATE                   ; Creates the interrupt processor
    ENDASM
    @ INT_ENABLE IOC_INT            ; enable external (INT) interrupts
    
    '---------------------------- Initialize LCD ----------------------------
    
    Lcdout $fe, 1                               ' Clear LCD screen
    Lcdout "System Ready"                       ' Display message
    Pause 500                                   ' Wait .5 second
    Q_Count=50
    
    Goto Main_Loop
    
    Encoder:                                    ' ISR 
        Q_New = PortB.5 + PortB.5 + PortB.4         ' get port status 
        
        If M_Count[Q_Old] = Q_New then              ' if M_Count code satisfied then minus
                  temp=temp+1
                  if temp=4 then
                    temp=0
                    Q_Count = Q_Count - 1
                    Flag = 1                       ' set flag to true to update display
                  endif
        goto Q_Skip
        endif
        
        If P_Count[Q_Old] = Q_New then              ' if M_Count code satisfied then plus
                  temp=temp+1
                  if temp=4 then
                    temp=0
                    Q_Count = Q_Count + 1
                    Flag = 1
                  endif                       ' set flag to true to update display
        endif
        
    Q_Skip:
        Q_Old = Q_New
        toggle portb.6                               ' update Q_Old Byte
    @ INT_RETURN
    
    
    Main_Loop:   
    if Flag = 1 then
        Lcdout $fe, 1                              ' Clear LCD screen
        Lcdout dec Q_Count                         ' Display encoder position (counts)
        Flag = 0                                   ' reset flag to false, display updated
    endif
    
    pause 100
    
    goto Main_Loop
    
    
    Thanks,
    Ioannis

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Ioannis,

    On those chips, the IOCIF bit is read-only and only gets cleared when ALL of the IOCBF flags are clear.
    So you can set the INT_Handler's ResetFlag option to NO.

    Then be sure the IOCBF flags are cleared before exiting the ISR.
    Also, take a look at section 13.4 in the datasheet regarding clearing the flags.
    DT

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Excellent! Works terrific now.

    These chips are a little pain in setting them.

    Thanks Darrel.

    Ioannis

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 22:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 21:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 21:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 07:32
  5. Replies: 1
    Last Post: - 1st November 2006, 04:11

Members who have read this thread : 4

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