A/D interrupt


Closed Thread
Results 1 to 5 of 5

Thread: A/D interrupt

  1. #1
    Join Date
    Feb 2010
    Posts
    17

    Default A/D interrupt

    Hi,
    can you trigger the interrupt using the analog input?
    My project is analog input from a keypad, which is working perfect now but instead of having the software sitting there and reading the the analog input can i use interrupt instead? the AN0 input is 0 unless a key is pressed.I know you gonna ask for the code BUT I THINK this one is easy soo.. i'll ask the question as simple as this: can i use interrupt so the pic is doing something else when the A/D input = 0 ELSE goto interrupt routine?
    Many thanks for any help or suggestions.

    Best regards,
    Joe

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: A/D interrupt

    No, you can't do that as far as I know. On the other hand, most chips with an ADC also have a comparator module which output CAN trip an interrupt. If the chip you're using got one then simply connect the analog signal to the ADC input and to the comparator input and set up a suitable trip level on the "other" comparator input - should do it.

    Or, short of an on board comparator, use an external one and wire its output to RB0 - for example.

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: A/D interrupt

    Quote Originally Posted by starwick View Post
    Hi,
    the AN0 input is 0 unless a key is pressed
    If that's the case then why not generate an interrupt when the key (switch?) is pressed & then do an ADC in your interrupt routine.

  4. #4
    Join Date
    Feb 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: A/D interrupt

    Thanks for the replay.

    HenrikOlsson,
    That's what i was think excatelly, but it didn't hurt to ask.

    HankMcSpank,
    When a key is pressed AN0 go from 0-5v depend on the key pressed(ie; if 0 is pressed 0<AN0<.5V, if 1 is pressed .6<AN0<1.0V......).

    Thank you,
    Any other ideas or suggestions are appreciated.

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: A/D interrupt

    Quote Originally Posted by starwick View Post
    Thanks for the replay.

    HenrikOlsson,
    That's what i was think excatelly, but it didn't hurt to ask.

    HankMcSpank,
    When a key is pressed AN0 go from 0-5v depend on the key pressed(ie; if 0 is pressed 0<AN0<.5V, if 1 is pressed .6<AN0<1.0V......).
    Oh, now I see.

    Then what Henrik said....set a comparator to 'trip' (toggle) at anything higher than 0.4V... use that 'toggling' level to generate a comparator interrupt......do your ADC inside the comparator interrupt routine.

    Which PIC are you using? You can likely use the PIC's own internal comparator & DT's CMP_int interrupt....

    (http://darreltaylor.com/DT_INTS-14/intro.html )

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