• AVR Freaks

Hot!Pin input analog to digital signal detection

Author
acharnley
Super Member
  • Total Posts : 610
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
2020/01/17 08:11:17 (permalink)
0

Pin input analog to digital signal detection

I have an AC source which I've cleaned and limited via a capacitor and resistor. It offers the signal you can see on the oscilloscope. Normally I'd run it through a comparator however I've used all 4 on-board ones up and there's no floorspace for an external. There is a zener clamp on the PIC input side and the pin protection diodes are being used as you can see in the display. Current is very minimal, less than 1mA so no problem here.

I hook the signal into a JK set to flip-flop and output onto an LED. At 15.5Hz I should see a pattern of 7.25Hz roughly on the LED. In fact, the pattern is completely random, so it's not working as I'd like.

I've played with setting the pin into TTL and ST modes. I suspect that the PIC's pin can't handle the slew rate of the signal, otherwise I'm out of ideas?



Attached Image(s)

#1

4 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28363
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Pin input analog to digital signal detection 2020/01/17 23:48:23 (permalink)
    0
    acharnley
    I have an AC source which I've cleaned and limited via a capacitor and resistor. It offers the signal you can see on the oscilloscope.

    There's no oscilloscope trace, and you didn't describe it at all, so we have no idea what your signal looks like.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    acharnley
    Super Member
    • Total Posts : 610
    • Reward points : 0
    • Joined: 2016/05/01 06:51:28
    • Location: 0
    • Status: offline
    Re: Pin input analog to digital signal detection 2020/01/18 03:32:19 (permalink)
    0
    Oops
     

    Attached Image(s)

    #3
    ric
    Super Member
    • Total Posts : 28363
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Pin input analog to digital signal detection 2020/01/18 03:36:51 (permalink)
    +1 (1)
    That's going too high, too low, and that step on the leading edge is stopping right in the transition region.
    I'm not surprised you're getting bad results.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    acharnley
    Super Member
    • Total Posts : 610
    • Reward points : 0
    • Joined: 2016/05/01 06:51:28
    • Location: 0
    • Status: offline
    Re: Pin input analog to digital signal detection 2020/01/18 05:38:16 (permalink)
    +1 (1)
    Yes it is an arse of a signal, that form is the clean version, under load it suffers harmonics.

    I've managed a solution, I stuck the signal into the CWG and it has deadband control on the leading/falling edge event (nice!), it cleans it up enough to get a perfect square wave. Pipe through a CLC and into Timer1 for measurement. Seems to be working well.
    #5
    Jump to:
    © 2020 APG vNext Commercial Version 4.5