Shop OBEX P1 Docs P2 Docs Learn Events
Simplest watchdog circuit - Page 2 — Parallax Forums

Simplest watchdog circuit

2

Comments

  • tonyp12tonyp12 Posts: 1,950
    edited 2017-05-07 14:26
    Pick-and-place cost is roughly based 9cent for each part and how many reels you use, they round it up if they are flexibly that you can add more parts later.

    Don't use 1970's idea of a extra large cap as a time delay, use parts invented in the last 2 years for any new design.
    What if the pin that reset the watchdog get stuck low?, though ac-couple it to a mosfet-gate could help to prevent that,

    Watchdog should be used to prevent that a brownout causing mcu to hang, not for sloppy programming.

    Any modern mcu have for example: Watchdog Timer with dedicated RC oscillator @ 50 nA



  • william chanwilliam chan Posts: 1,326
    edited 2017-05-07 14:48
    tonyp12 wrote: »
    Don't use 1970's idea of a extra large cap as a time delay, use parts invented in the last 2 years for any new design.

    Hi tony,

    In the olden days, available electrolytic capacitors will have too much leakage to implement such a circuit.
    47uF ceramic capacitors are fairly new parts with almost no leakage, so it should be ok.

    Hi Peter,

    Will consider your good advice.
  • tonyp12tonyp12 Posts: 1,950
    edited 2017-05-07 15:50
    http://ladyada.net/library/rccalc.html
    3.3v input, a 500K ohm with a 47uF with the comparator set to 3.1v gets you ~60seconds.

  • tonyp12 wrote: »
    http://ladyada.net/library/rccalc.html
    3.3v input, a 500K ohm with a 47uF with the comparator set to 3.1v gets you ~60seconds.

    This is within expectations, which is why i choose 3M ohm resistor for 2-3 minutes timeout.
  • >choose 3M ohm resistor

    Going with such large value, you could run in to input impedance problems.
    A comparator "may" be OK, but a mcu input pin anything over 500K and it will not work.

  • William, it goes without saying, have you built and tested the circuit that you call "final"? I'd like to hear if it works as intended even with some other capacitor you have on hand. A 47µF capacitor in 1206 will have a terrifically high-Q dielectric with a wide tolerance and abysmal temperature coefficient. About positive feedback, as shown in your "final" it has three 20kohm resistors, and that makes the range of voltage for the capacitor to be 1/3 of the power supply. Okay, but you could expand the thresholds and increase the time interval by leaving 20k for the feedback but make the resistor stack from 50k or even 100k values. I think that comparator has rail to rail inputs.

    Just because I suggested a solution using the comparator per your request, that doesn't mean I think it is the best way to go.

    About the PIC solution, one drawback is that once you have it on a circuit board, you have to program it ($ and potential to forget). Although you can program it to do exactly what you want, the flip side is that you might prefer a chip hard-coded as a silicon state machine, it only does what it does. You won't need a watchdog for the watchdog. The dedicated watchdog/reset chips embody a lot of engineering experience.
  • jmgjmg Posts: 15,140
    edited 2017-05-07 20:50
    Here is the 47uF 20% capacitor from Murata Japan.

    Some simple checks :

    RC CAP solution :
    $0.30660 @ 50 Murata Electronics North America CAP CER 47UF 4V X6S 0805 47µF ±20% 4V X6S
    plus
    $0.28200 @ 50 AS393MTR-G1 COMP OC 8SOIC 2 V ~ 36 V, 1mA Icc

    Some low cost MCU solutions :

    $0.51520 @ 50 PIC12F1571-I/MS MCU 8BIT 1.75KB FLASH 8MSOP 6io 1.75KB (1K x 14) 2.3 V ~ 5.5 V A/D 4x10b, D/A 1x5b

    $0.3000 @ 50 N76E003AT20 Nuvoton 8B MCU 18kF 1kR TSSOP20 2.4V to 5.5V 16 MHz -40℃ to +105℃. 6uA typ WDOG Icc, 10% WDT Osc
    ( $0.3000 @ 50 from Avnet, $0.63 @ 100+ from https://direct.nuvoton.com/en/n76e003at20 )

    The small package PIC MCU Peter suggested costs less than your BOM CAP+COMP, and will draw less power.
    My latest minimal-price fave, the Nuvoton N76E003AT20 costs less than your 47µF cap alone !!

    However, whilst these MCU parts do need programming, they are highly flexible devices, and have Voltage Monitors, and ADCs included.
    ie they can do a lot more watching than just time.


    Or, there are Dedicated Timer parts :
    These do not need any programming, and cannot crash, but are more niche.....

    No CAP needed, good precision, very low Icc
    0.73800 @ 50 TPL5010DDCR Texas Instruments IC TIMER W/WATCHDOG TSOT-23-6 1.8 V ~ 5 V 35nA

    Multisourced, generic logic device, cheap caps + divider.
    0.34800 @ 50 CD4541BPWR Texas Instruments IC OSC PROG TIMER 100KHZ 14TSSOP

    If you are watching a RaspPi, then WDOG Icc scarcely matters, but there are other applications where long sleep times and very low idle powers matter.

  • jmg wrote: »
    RC CAP solution :
    $0.30660 @ 50 Murata Electronics North America CAP CER 47UF 4V X6S 0805 47µF ±20% 4V X6S
    plus
    $0.28200 @ 50 AS393MTR-G1 COMP OC 8SOIC 2 V ~ 36 V, 1mA Icc

    I suppose 1206 are cheaper than 0805 when it comes to large capacity capacitors.
    Also different countries and different vendors quote vastly different prices.
    Maybe RS is dumping the AS393 in Malaysia at below costs. ( USD 5 cents only )

    The Nuvoton N76E003AT20 is interesting, but normally a design engineer would not jump into a new controller. ( too risky )
    A design engineer would normally use parts he is familiar with.
  • william chanwilliam chan Posts: 1,326
    edited 2017-05-08 02:20
    William, it goes without saying, have you built and tested the circuit that you call "final"? I'd like to hear if it works as intended even with some other capacitor you have on hand.
    It should work, as I have experience in using this comparator and the 47uF capacitor as a timer in a solar powered light with PIR sensor.
    However, in that application, the timing depends on the discharge of the capacitor instead of charging.
    I can get about 7-8 minutes of light before the capacitor discharges to near zero volts.
    The AS393 is good at comparing near ground voltages.
    A 47µF capacitor in 1206 will have a terrifically high-Q dielectric with a wide tolerance and abysmal temperature coefficient.
    I think Q only matters for RF frequencies, whereas in this application, it is almost DC.
    About positive feedback, as shown in your "final" it has three 20kohm resistors, and that makes the range of voltage for the capacitor to be 1/3 of the power supply. Okay, but you could expand the thresholds and increase the time interval by leaving 20k for the feedback but make the resistor stack from 50k or even 100k values. I think that comparator has rail to rail inputs.
    Actually the AS393 datasheet does mention that the common mode input range is from Ground to VDD - 1.7v
    what this probably means is that near VDD, the input comparisons may not be so accurate.
    For this reason, I am thinking to power the comparator with 5V but still bias the inputs at 3.3v
  • Just know that MLC caps are not the kind of caps you would use for timing as the capacitance varies not only with temperature but also with voltage and there may be some hysteresis there too.

    Also, the small PICs themselves are very reliable and include their own watchdog in case you wanted to watchdog the watchdog :) lol However I have used these in huge volumes in scores or products over the years that run 24/7 without a hitch. If you allow for a 5-pin header or at least the holes then you can use a PICKIT to load up the board with the image. Alternatively on a more compact design I have vias strategically placed so I can use a pogo pin header to load the PICs. Even if you aren't familiar with the PIC, it is a very simple beast and he software you could write in a few hours or I could give you a few different assembler files to get you started.
  • I've used these things to program 8-pin micros in situ:

    13153-01.jpg&maxx=50&maxy=0

    No need for special pads or pogo pins. Just a cable to your programmer and enough clearance around the micro to accommodate the clamp.

    -Phil
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-05-08 05:42
    I've used these things to program 8-pin micros

    Well that's an idea but I don't think they'd do my MSOP packs!

    You can even see the vias around the chip that I use to program this part.

    498 x 475 - 83K
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2017-05-08 05:27
    William,
    I meant to say that the capacitor is high K, not high Q. Kind of opposite things. I do appreciate your desire to do this with parts and knowledge at hand.

    The thresholds are skewed because the output of the comparator is open collector, so the 10k pullup resistor enters into the math for the thresholds. On a 3.3V supply, with 20k for the other resistors to the (+) input of the comparator, the thresholds would be at 1.1 and 2.0625 volts. So as you noted, that upper threshold violates the common mode input range of the comparator. So a 5V supply would be better. I attached my schematic again but added the design equations for the lower and upper thresholds. By playing with the resistor values you can make the thresholds move up or down or further apart.


  • ercoerco Posts: 20,244
    Tracy, you remain my role model and national treasure. Every post a gem!
  • tonyp12tonyp12 Posts: 1,950
    edited 2017-05-08 17:21
    If you are going with cap, at least use a voltage supervisor that have a separate sense pin. (instead of budling your own from ~8 parts).

    STM1831L24WY6F:
    http://www.mouser.com/ProductDetail/STMicroelectronics/STM1831L24WY6F/?qs=sGAEpiMZZMunEhqKs81nFI/Zy2It2StCxckM8DfFnLE=
  • tonyp12 wrote: »
    If you are going with cap, at least use a voltage supervisor that have a separate sense pin. (instead of budling your own from ~8 parts).
    STM1831L24WY6F:
    http://www.mouser.com/ProductDetail/STMicroelectronics/STM1831L24WY6F/?qs=sGAEpiMZZMunEhqKs81nFI/Zy2It2StCxckM8DfFnLE=

    Voltage Brown Out detectors and Watchdog Timers are totally different animals.

  • It seems there are 2 schools of thought when it comes to electronics design.

    The first school prefers to use the latest high tech parts.
    The second school prefers to use commonly available parts.
  • jmgjmg Posts: 15,140
    It seems there are 2 schools of thought when it comes to electronics design.

    The first school prefers to use the latest high tech parts.
    The second school prefers to use commonly available parts.

    Or, the third school of thought, uses available and modern parts, with a leaning toward the highest volume usage parts, as they are generally cheaper.

  • It seems there are 2 schools of thought when it comes to electronics design.

    The first school prefers to use the latest high tech parts.
    The second school prefers to use commonly available parts.

    Not really true as it is not as simple as a preference. If I don't have access to something like a little PIC chip which I have the tools for then I will make do with a simple but limited circuit as I have done on occasion. If I am designing for high volume and lowest cost then I would use "a circuit" that will do what it needs to do taking into account manufacturing costs including pnp, pcb size etc. This might even mean that a PIC or special chip is used in place of the circuit that has a lower bare BOM cost.

    If I am not concerned about a few cents and I mean "a few cents" then I take the more flexible and predictable and "simpler" route of using one tiny little PIC chip (or equivalent). Any circuit that has wide variations and may need to be trimmed is not "simple". A 47uf MLCC is not a precise "timing" element for starters.

    But as I mentioned previously, just allow for both on the pcb, because that is what I would do if I was being pressed for "lowest cost" but had doubts about one approach.
  • ercoerco Posts: 20,244

    Whenever we "feed the dog", we are holding it off from firing the reset. It is a full fledged watchdog in all sense of the word.

    Seems more akin to a dead man switch or missing pulse detector in reverse.

  • erco wrote: »

    Whenever we "feed the dog", we are holding it off from firing the reset. It is a full fledged watchdog in all sense of the word.

    Seems more akin to a dead man switch or missing pulse detector in reverse.

    I don't think it is detecting a pulse, just a low, so it is possible for the watchdog to get stuck if the processor I/O is stuck low and then everything is stuck. It is after all a "simple" watchdog.

  • So a 5V supply would be better. I attached my schematic again but added the design equations for the lower and upper thresholds. By playing with the resistor values you can make the thresholds move up or down or further apart.

    Hi Tracy,
    How did you manage to derive these complicated equations?
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2017-05-09 18:41
    William,
    Divide and conquer! The equations come from thinking about resistor voltage dividers under two conditions. One with the output of the comparator low, effectively grounding one end of R1. The other with the comparator output an open circuit, so the series connection of R1 and R4 are effectively connected to 3.3V Vdd.

    In the first case you have the parallel resistors R1 and R2 to ground, R = R1*R2/(R1+R2) . And that is a voltage divider with R6 on top.
    Vx = Vdd * R / (R + R6)
    . = Vdd * (R1*R2/(R1+R2)) / ((R1*R2/(R1+R2) + R6)
    From then on out it's algebra. Start by multiplying top and bottom by (R1+R2), to simplify.
    Vx = Vdd * R1*R2 / R1*R2 + R6*(R1+R2)
    . = Vdd *R1*R2 / (R1*R2 + R1*R6 + R2*R6)
    The Vupper case is similar, except there is the added complication that R4 is now in series with R1.
    248 x 201 - 14K
    227 x 191 - 15K
  • 65cent (100 units) you get a 124sec watchdog, I guess you feed it by resting the value over i2c
    But you also get a rtc as a bonus.
    https://www.digikey.com/product-detail/en/nxp-usa-inc/PCF85263ATL-AX/568-11541-1-ND/4928009
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2017-05-10 20:04
    Okay, since this thread is sort of old vs new way of doing things, here is a version using a programmable unijunction transistor. This device is kind of like a comparator and reset rolled into one. It compares the voltage on its anode with the voltage on its gate. When the capacitor voltage exceeds the gate voltage (+ one diode drop), the transistor fires and dumps all of the charge through to the cathode and then the capacitor starts charging again. In this case, the charge dump turns on the 2N3904 to generate a short reset pulse.

    I was kind of surprised to find the PUT available as a device on Digikey's schemelt online drawing program. They do carry the 2N6028 but only in a TO92 package. The only SMT version MMBT6028 listed seems to be from a Russian company, Planeta. The CA3097 transistor array also seems to be discontinued, with its PUT combined with a couple of transistors, an SCR and a zener. I like those 4-layer devices. Very handy sometimes.
    341 x 238 - 28K
  • jmgjmg Posts: 15,140
    Okay, since this thread is sort of old vs new way of doing things, ...
    What about old tech, in newer packaging ? ;)

    A 1G14 single gate Schmitt can make a very simple RC oscillator, for BOM savings.
    Next, add a Digital Transistor, (also called Pre biased or Resistor Equiped Trx ) to discharge the cap via a base-pulse, and voila, you have a Watchdog in just 4 parts.

    74AHCT1G14SE-7 SOT353 0.04860 @ 1000
    DTC143EET1G TRANS PREBIAS NPN 0.2W SC75 0.02271 @ 1000
    + chosen RC of uF.MegOhms.
    or, if you want greatly skewed RC, still a single package, but a dual NPN(reset) + PNP(faster discharge, No Rbe)
    RN4990FE,LF(CB Toshiba TRANS NPN/PNP PREBIAS 0.1W 0.05516 @ 1000
  • PUTs as a solution, ye gads, what next!? Tunnel diodes?
    That's strange, I only see the SMT version CMPP6208 listed with 3,000 in stock which must be a full reel but one off they are $3 each.
  • jmgjmg Posts: 15,140
    PUTs as a solution, ye gads, what next!? Tunnel diodes?
    That's strange, I only see the SMT version CMPP6208 listed with 3,000 in stock which must be a full reel but one off they are $3 each.

    You can of course, also make your own PUT with PNP + NPN devices, like this

    MBT3946DW1T1G ON Semi TRANS NPN/PNP 40V 0.2A SC88 $0.04321 @ 1000
  • jmg wrote: »
    A 1G14 single gate Schmitt can make a very simple RC oscillator, for BOM savings.
    Next, add a Digital Transistor, (also called Pre biased or Resistor Equiped Trx ) to discharge the cap via a base-pulse, and voila, you have a Watchdog in just 4 parts.

    Hi jmg,

    Can share the actual circuit please?
Sign In or Register to comment.