Semi-random INT count???


Results 1 to 7 of 7

Threaded View

  1. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Semi-random INT count???

    Hi,
    A schematic would be nice but I think we've covered this before. Two encoder signals on the same pin, fighting each other, is most likely not a good solution. You mention a relay, switching between the two, and that should be fine. Just make sure the signal at the PIC input is well defined (pulled up/down) and not floating at any point.

    And Richard is spot on. If the frequeuncy of the encoder signal is anything above "a couple of Hz" you definitely do not want the LCDOUT statements within the ISR. Those two statments takes at least 5ms to exectute, then there's the rest of the ISR itself (which isn't much but still...) and the system variable save/restore. But let's say 5ms (and that's probably on the LOW side) then your input frequency can't be higher than 200Hz.

    If you have a two channel scope you can test this.
    1) Scope the input signal to the PIC with channel 1 on the scope.
    2) Set a pin high at the beginning of the ISR. Set it LOW at the end of the ISR.
    3) Scope this output of this pin with channel 2 on the scope.

    The time between the rising edge on Ch1 and the rising edge on Ch2 is the interrupt latency, the time it takes to save the system vars and "get to" the actual ISR code.
    The pulse width on Ch2 is the execution time of the ISR itself.
    Then there's the time it takes to restore the system vars and "get out" of the ISR. This is pretty much equal to the measured latency.

    Add the numbers together, ie 2*latency + ISR execution time and see what you get. Make sure you do this with a LOW(ish) input frequency to ENSURE you're not "overrunning" yourself. Then remove the LCDOUT statements from the ISR and measure again.

    /Henrik.
    Last edited by HenrikOlsson; - 24th June 2014 at 06:35.

Similar Threads

  1. is random really not so random?
    By mrpackethead in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 4th November 2011, 01:57
  2. Random
    By ruijc in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th March 2011, 12:49
  3. Using both hardware int and Timer Int together?
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th January 2010, 01:09
  4. Random
    By SELTZER in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th April 2006, 16:48
  5. Poor mans "semi" logic analyzer
    By anj in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st September 2004, 13:26

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