Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    DIV32 only has a problem with ON INTERRUPT.

    ASM interrupts and DT_INTS has no problem with it.
    DT

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    DIV32 only has a problem with ON INTERRUPT.

    ASM interrupts and DT_INTS has no problem with it.
    Excellent news....and thanks for the quick response (I'm off to divide 2147483647 by 32767 .....just because)

  3. #3


    Did you find this post helpful? Yes | No

    Default Problem with Comparator Interupts

    Hello,

    I was trying to experiment with HankMcSpank's comparator interupt code. But am having problems getting it to compile.

    I am using,
    PIC18f4480
    PBP 2.60A
    DT_INT-18 3.3
    ReEnter-18 v?
    MPASM 5.2

    It is giving me "missing argument", Interupt(FlagReg,Flagbit) not found etc
    Error ("Int_handler"..... Error (Int_Enable

    If anyone has any ideas, I would be greatfull.

    Thanks
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Default

    The 18F4480 only has 1 interrupt flag for both comparators.

    You would use CMP_INT, then check the C1OUT/C2OUT bits in CMCON to determine which one triggered the interrupt.
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The 18F4480 only has 1 interrupt flag for both comparators.

    You would use CMP_INT, then check the C1OUT/C2OUT bits in CMCON to determine which one triggered the interrupt.
    Thank you, Darrel!

    Had the same issue with the PIC16f877A- Will revisit tonight.

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mark_s View Post
    Hello,

    I was trying to experiment with HankMcSpank's comparator interupt code.
    Be warned...it's still very much a work in progress, I've just revisited this one & noticed a whopping proble. On the basis that a picture is worth a thousand words, I just posted up a youtube video, which illustrates my last remaining problem - there appears to be bit of an ssue measuring smaller phase shifts...

    Have a look at my video on this thread...

    http://www.picbasic.co.uk/forum/show...4382#post94382
    Last edited by HankMcSpank; - 25th September 2010 at 14:28.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    Be warned...it's still very much a work in progress, I've just revisited this one & noticed a whopping proble. On the basis that a picture is worth a thousand words, I just posted up a youtube video, which illustrates my last remaining problem - there appears to be bit of an ssue measuring smaller phase shifts...

    Have a look at my video on this thread...

    http://www.picbasic.co.uk/forum/show...4382#post94382
    Hank,

    I got my code working last night , thanks to Darrel. The pic chips I am using only have one comparator interupt. By reading the output bits on each comparator and putting an IF statement in the ISR, I can read the frequency and phase like your code. My test so far is with a fixed 180 deg. I need to wire up a variable phase shifter, so that I can compare my results with yours. Not sure why you can't read below 33 deg? Maybe phase locking between the two comparators or interupt house keeping? What happens if you halve the frequency?

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mark_s View Post
    Hank,

    I need to wire up a variable phase shifter, so that I can compare my results with yours. Not sure why you can't read below 33 deg? Maybe phase locking between the two comparators or interupt house keeping? What happens if you halve the frequency?
    It all works well above a certain phase shift (depending on the signal frequency)...just when you get to the lower regions that this quirk kicks in.

    I'm sure you're sorted for a phase shift cct, there's a simple one here....

    http://www.werewoolf.org.je/graphics/apf1.gif

    ....make R1 & R2 the same value -I used 10k - the cap about 100nf & R4 a 10k pot (wired with the wiper to the ground end)....this gives about 90 degrees of phase shift @ 159Hz...if you want more phase shift,cascade a few together & use this designer http://www.aleph.co.jp/~takeda/radio/psDesigner.swf

    just be sure that the signals into your PIC comparator are identical (I square them up first - remember ...different edge 'slopes' equals different triggering points for the PIC comparators which translates into a phase measurement error - and I also check on a scope to make sure there aren't any edge timing errors intrduced prior to the PIC)

    If I half the incoming frequency (or double it), the Comp2 count remains the same (ie it won't go below 336, as I phase shift to the lower regions)...so I'm inclined to think it's housekeeping 'can't avoid' timing issue of some sort.

    there maybe one fly in my particular ointment - my PIC supply is 4V...the datasheet says that 4.5V is the minimum when using a 20Mhz External clock. (& annoyingly, I don't appear have any 5V regulators handy so now looking at dropping the clock back to 8Mhz)

    I look forward to your results so get a move on!
    Last edited by HankMcSpank; - 25th September 2010 at 19:05.

  9. #9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HankMcSpank View Post
    If I half the incoming frequency (or double it), the Comp2 count remains the same (ie it won't go below 336, as I phase shift to the lower regions)...so I'm inclined to think it's housekeeping 'can't avoid' timing issue of some sort.

    there maybe one fly in my particular ointment - my PIC supply is 4V...the datasheet says that 4.5V is the minimum when using a 20Mhz External clock. (& annoyingly, I don't appear have any 5V regulators handy so now looking at dropping the clock back to 8Mhz)
    Thats strange that halving the frequency does not change the minimum phase reading. The interupt process of saving and restorring variables should take the same amount of time weather your input frequency is 1hz or 1khz. So halving your frequency, should double your count on tmr1 while the interupt processing time remains constant. As a ratio, the lower the input frequency, the less effect processing delays have on your final value.

    Example
    Input 500Hz = 2ms or 5.5us/deg with a 33 degree lag = 183us

    Then at 250Hz = 4ms or 11.1us/deg with a 33 degree lag = 366us

    So for argument sake, lets say it takes minimum of 183us to process the interupt (not likely). If
    we plug this into the 250hz case, we get 183us/11.1us or a minimum of 16.4 degrees.

    I think there is something else going on, 183us is a long time. The power supply is pretty important and could cause havic in the analog circuits (Vref) if not regulated. If you're feelin lucky you can get 5v regulated off your USB port.

Similar Threads

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

Members who have read this thread : 10

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