• AVR Freaks

Hot!PIC16F - A Logic Conundrum

Author
acharnley
Super Member
  • Total Posts : 307
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
2019/06/20 02:43:07 (permalink)
0

PIC16F - A Logic Conundrum

Hi All,

This revolves around a PIC16F15323 but the problem isn't too chip specific. I have two CLC's left and no timers though I can make timer2 available and if pushed I can up the chip to get a more.

So imagine if you will a comparator senses an over-voltage condition and disables a mosfet or relay. Once the condition clears the switch should only re-engage when an AC line is at zero-cross (so using the ZDC). You can see this logic at the bottom of the picture.

The problem is the switch is toggling at the AC frequency. What actually need to happen is the logic at the top of the picture.

Let me know if you have any ideas!

Thanks!

Andrew




Attached Image(s)

#1

3 Replies Related Threads

    NorthGuy
    Super Member
    • Total Posts : 5495
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: PIC16F - A Logic Conundrum 2019/06/20 09:04:28 (permalink)
    +1 (1)
    What you want to do is impossible. Look at the falling edge of your desired output signal. At the point where you want the falling edge to be, it is not known whether the next peak will exceed the comparator threshold (in which case you want to continue high), or not (in which case you want to switch low). Impossible to see the future is.
    post edited by NorthGuy - 2019/06/20 09:05:48
    #2
    cvm
    Super Member
    • Total Posts : 282
    • Reward points : 0
    • Joined: 2011/09/16 05:16:15
    • Location: 0
    • Status: offline
    Re: PIC16F - A Logic Conundrum 2019/06/20 09:19:21 (permalink)
    0
    volatile uint8_t over_voltage = 0;
     
    comparator rising edge irq
        over_voltage = 3;
        mosfet_off();
    zcd irq (rising and falling)-
        if( over_voltage && (--over_voltage == 0) ){
            mosfet_on();
        }
     
    the comparator rising edge irq turns off mosfet, sets a value to 3
    the zcd irq looks for the third crossing where it then knows the previous (half) cycle has not tripped the comparator 
     
     
    >and no timers 
    the nco can be used a a timer, if you didn't already know
    post edited by cvm - 2019/06/20 09:47:11
    #3
    acharnley
    Super Member
    • Total Posts : 307
    • Reward points : 0
    • Joined: 2016/05/01 06:51:28
    • Location: 0
    • Status: offline
    Re: PIC16F - A Logic Conundrum 2019/06/20 14:24:17 (permalink)
    0
    Cheers CVM, that's pretty much the same as what I managed. I was hoping for a hardware method but concluded it was difficult or impossible.

    Nice little --over_voltage == 0 trick, not seen that before.
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5