• AVR Freaks

Hot!Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571)

Author
K.Sakai
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2020/09/29 03:38:28
  • Location: 0
  • Status: offline
2020/10/26 17:07:05 (permalink)
0

Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571)

Hi,
 
I am now considering Comparator of PIC16F15313,PIC12F1571.
But internal Hysteresis (typ 25mV) is not enough for my application.
 
Now I use 1.024V of FVR as Comparator reference,
and hopefully need total hysteresis ~100mV.
 
Is there any way to achieve hysteresis ~100mV with internal function and firmware ?
 
Also, PIC32 family reference manual show attached external solution with resistor.
(PIC32 Family Reference Manual, Sect. 39 Op amp Comparator : DS60001178B-page 39-14)
Can I use it for PIC16F15313,PIC12F1571 ?
 
K.Sakai

Attached Image(s)

#1

13 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28941
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/10/26 17:55:11 (permalink)
    +1 (1)
    You can only implement hysteresis with an external resistor if the positive input is from an external pin, not an internal signal.
    If you can feed FVR out another pin, and bring it back in via R1 & R2, then you can do it.
     

    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
    davea
    Super Member
    • Total Posts : 500
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: Tampa Bay FL USA
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/10/26 17:56:26 (permalink)
    +1 (1)
    YES
    also R2 is not needed
    if you use R1 as input
    - comp input to vref
    the logic will be reversed..
     
    post edited by davea - 2020/10/26 18:03:40
    #3
    K.Sakai
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2020/09/29 03:38:28
    • Location: 0
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/10/26 18:10:41 (permalink)
    0
    Thank you for your prompt reply.
    I understand I cannot get bigger hysteresis with internal configuration of Comparator.
     
    Anyway, we cannot achieve Schmitt buffer with CLC of PIC16F15313 ?
     
    K.Sakai
    #4
    davea
    Super Member
    • Total Posts : 500
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: Tampa Bay FL USA
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/10/26 18:29:18 (permalink)
    0
    No
    you have 2 options 
    use 3 pins with no inversion
    or 2 pins with inversion and a CLC to do another inversion if needed..
    #5
    K.Sakai
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2020/09/29 03:38:28
    • Location: 0
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/10/26 23:12:54 (permalink)
    0
    Thank you for your kind advise.
    I try to consider external hysteresis or pin ISR.
     
    K.Sakai
    #6
    davea
    Super Member
    • Total Posts : 500
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: Tampa Bay FL USA
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/10/26 23:55:05 (permalink)
    +1 (1)
    pin ISR could work but threshold will be apx 1/2 VDD and depends rise/fall to slow will cause problems 
    as any noise near threshold
    will triger lots of ISR's but if you wait in the ISR then test pin state (but dont wait for to long < 100us)
    you should be OK if it works
     
    #7
    K.Sakai
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2020/09/29 03:38:28
    • Location: 0
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/11/10 22:00:55 (permalink)
    0 (2)
    Hi,
     
    Let me add one more question.

    I achieved attached hysteresis (positive FB) with external resistors.
    (for PIC16F15313 CMP1)
    But unfortunately I hope to use RA0 for other purpose.

    If we set CMP1 output polarity as inverted, can I use negative FB to achieve hysteresis ?
    (see attached negative inverted FB)
     
    I checked it works but hope to confirm it is appropriate or not.
     
    K.Sakai

    Attached Image(s)

    #8
    davea
    Super Member
    • Total Posts : 500
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: Tampa Bay FL USA
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/11/11 00:01:54 (permalink)
    0
    can I use negative FB to achieve hysteresis ?

    absently NOT
    it will oscillate during level transition 
    if it works with negative FB
    then it will certainly work with no FB, using internal 25mv hysteresis only...
     
     
    post edited by davea - 2020/11/11 00:32:00
    #9
    ric
    Super Member
    • Total Posts : 28941
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/11/11 03:57:49 (permalink)
    +2 (2)
    davea
    can I use negative FB to achieve hysteresis ?

    absently NOT
    it will oscillate during level transition 
    ...

    You missed that he is inverting the output as well.
     

    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!
    #10
    davea
    Super Member
    • Total Posts : 500
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: Tampa Bay FL USA
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/11/11 12:19:07 (permalink)
    +1 (1)
    If we set CMP1 output polarity as inverted, can I use negative FB to achieve hysteresis ?

    so true RIC, you are good reading between the lines
    then its not negative FB
    its posititive FB and that is correct, its fine
    actually that was a clever way of moving the pins
    +1 for K.SaKai
    davea
    #11
    ric
    Super Member
    • Total Posts : 28941
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/11/11 12:27:51 (permalink)
    0
    davea
    If we set CMP1 output polarity as inverted, can I use negative FB to achieve hysteresis ?

    so true RIC, you are good reading between the lines

    I was half-way through writing a response similar to yours, when I thought "why would he even think this could work?" and read the question a bit more carefully. :)
     
     

    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!
    #12
    K.Sakai
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2020/09/29 03:38:28
    • Location: 0
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/11/11 16:35:37 (permalink)
    0
    Dear Ric, Davea,
     
    Thank you for your kind comment.
    (I take care to describe clear question.)
     
    K.Sakai
    #13
    acharnley
    Super Member
    • Total Posts : 629
    • Reward points : 0
    • Joined: 2016/05/01 06:51:28
    • Location: 0
    • Status: offline
    Re: Refer to Comparator Hysteresis (PIC16F15313,PIC12F1571) 2020/11/15 03:12:52 (permalink)
    +1 (1)
    Look at the ATtiny1616, it has three comparators with 10,25 and 50mV and a ref of 0.55v. Obviously the lower your common mode input values the more hysteresis makes a difference, i.e the 50mV at 0.55v is equal to the PIC being 100mV at 1.1v. ;)

    The comparators are also a lot faster and you have 8 bit DACs to reference from. You can get that 0.55v down /255 which gives huge hysteresis possibilities if you voltage divide the input.
     
    For example I use this chip on a 6v signal, which goes through a 470k/33k resistor, ref 0.55 -> 0.15v DAC and 50mV hysteresis. Gives IIRC about ~3.5v hysteresis.
    #14
    Jump to:
    © 2020 APG vNext Commercial Version 4.5