Help with Analog Interrupt


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    I actually just checked and you can use the AD_INT -- A/D Converter Interrupt in his 14 bit version as well... So you don't have to use an 18F

    Thanks Darrel

    http://darreltaylor.com/DT_INTS-14/intro.html
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    brid0030, Why not look for a PIC that has an analog comparator with an interrupt available. That way the PIC can sleep indefinitely untill the voltage comparator is triggered at which time you can wake and make a measurement then time stamp the data and, back to sleep...

    Dave Purola
    N8NTA

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The A/D interrupt fires when an A/D conversion is complete. This is handy for entering sleep mode, and having the PIC wake up when the A/D conversion is complete. With the oscillator shut down during sleep, you get much more stable A/D readings.

    The comparator can also wake the PIC from sleep on change of a comparator output. This would work too, but I would check the Electrical Specifications section of the data sheet for current draw.

    A/D, comparator, Vref, WDT, etc,, they all draw current during sleep. Which one is best depends on your power budget, and application. Wake up on comparator output change would probably let the PIC sleep for longer periods.

    This PIC also has an ultra low-power wake-up option if you really need to squeeze power consumption down during sleep. Look for AN879 on the Microchip site.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    Thanks for these suggestions. I'm still not clear how to implement them, but I have some direction for future reading. It sounds as if using "ON INTERRUPT" is generally to be avoided. I'm still not sure whether it will miss events that start and end during a long command, but it definitely would not provide the most elegant solution.

    I've looked into Darrel Taylor's interrupt system, and will have to do some more research before I can grasp what is going on. Using the ultra-low-power wake up module is quite tempting. I use a large external battery so power consumption is not that big an issue, but why not save as much as possible? I don't know how to implement the module, but there is some asm code in application note AN879 (http://ww1.microchip.com/downloads/e...tes/00879C.pdf), so perhaps I can start there. If anyone has ever used the low-power wake up, I would love to see some examples.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Here's something to start with. I've converted the assembler example in the app note to PBP for you with one exception. It does not use interrupts. This just uses the ultra low-power wake-up feature to wake from sleep. Global interrupts are disabled.

    With a 10K / 1uF RC network on RA0, it wakes up & toggles RC5 ~ once every 34 seconds.
    Code:
    @ device  pic16F688, intrc_osc_noclkout, wdt_off, mclr_off, protect_off
     ' Note: Default internal osc is set to 4MHz
    
    SleepyTime: 
        'BCF STATUS, RP0 ;Bank 0
        'BSF PORTA, 0 ;Set RA0 data latch
         PORTA.0 = 1
         
        'MOVLW H’7’ ;Turn off
        'MOVWF CMCON0 ;comparators
         CMCON0 = 7
         
        'BSF STATUS, RP0 ;Bank 1
        'BCF ANSEL, 0 ;RA0 to digital I/O
         ANSEL.0 = 0
         
        'BCF TRISA, 0 ;Output high to
         TRISA.0 = 0
         
        'CALL CapDelay ;charge capacitor
         PAUSE 100 ' change to suite your RC circuit
         
        'BSF PCON, ULPWUE ;Enable ULP Wake-Up
         PCON.5 = 1
        
        'BSF IOCA, 0 ;Select RA0 IOC
         IOCA.0 = 1
        
        'BSF TRISA, 0 ;RA0 to input
         TRISA.0 = 1
         
        'MOVLW E’10001000’ ;Enable interrupt
        'MOVWF INTCON ;and clear flag
         INTCON = %00001000 ' Note bit 7 is clear since we're not vectoring to an int handler
         
        'SLEEP ;Wait for IOC
         @ SLEEP
         
         INTCON.0 = 0  ' clear int flag on wake-up
    
    Main: ' Do whatever you need here on wakeup
         ' insert your code here
         
         TOGGLE PORTC.5  ' do your stuff here before entering sleep mode again
         GOTO SleepyTime ' do the ultra low-power wake-up thing again afterwards
         END
    An interesting note on this one is that is works whether you clear the int flag or not!
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default Thanks!

    Above and beyond, Bruce. You are the greatest.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  4. Interrupt Problem
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th November 2005, 20:58
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 1

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