1. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Hi everyone.:)
    Today i learnt about watchdog timer in my college and thought of trying it using ATmega32.

    My objective is to set watchdog timer condition at 20 seconds (approx.) and light the LED.
    Is it possible ? According to the datasheet(attached below) in the Watchdog Timer Prescaler select maximum time-out is 2.2 seconds.
    Is it possible to generate timeout at 20 seconds ?

    Can i make use some variable to keep track of its time out and then decide ?
    Ex- If the variable equal to 10 (i.e 10 time outs ) then light an LED.

    Also WDT oscillation cycles are nothing but WDT operating frequency right ?:confused:

    I am sorry to post lot of questions.Please help.
    Thanks in advance.:)
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,348
    1,029
    A WDT timer is a backup that RESETS the processor if it is allowed to expire. In use, properly operating software refreshes the WDT within its programmed time. If that time expires, the processor gets reset to restart the bad program.

    If you want to flash an LED, use one of the internal timers, not the WDT. Your approach is like telling time by asking someone to bang you over the head once an hour. It would work, but not a good way to do it.

    Yes, the 'cycles' represent the base frequency of the WDT. Those are sent into a postscaler to increase the time before it expires.

    The WDT is a simple RC oscillator. Its cycle time will vary with temperature, voltage etc. Again, its meant as a last resort to recover from locked-up code, not to implement program timing.
     
    rabhishek91 likes this.
  3. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Thanks for your reply sir. Your right.

    "Yes, the 'cycles' represent the base frequency of the WDT. Those are sent into a postscaler to increase the time before it expires".
    Can you throw some light on postscaler ?
    Currently max available is 2,048K . Can the oscillator cycle be increased more than this value?
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    The only time I'd use it for timing is if I wanted a very low power but fairly inaccurate timer.
    If the ATmega is anything like a PIC then the watchdog timer can run in sleep mode using only around a microamp.
    What I did was first calibrate the watchdog timer (set a real timer, wait for the watchdog timer to expire, then use the real timer value to decide how many watchdog overflows are in a minute). If you can, recalibrate periodically. If you don't calibrate, the accuracy could be way off, check the datasheet for temperature and part to part variation.
    Then set a variable for the number of times the watchdog needs to timeout, put the device to sleep, and every time it wakes up decrease the timer. When it gets to zero turn your LED on.
     
    rabhishek91 likes this.
  5. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Thank you sir. This is what they taught me today but i couldn't follow it. Now i got the nut and bolts involved in it.

    Sir do ATM's (Automated Teller Machine) use the same principle for Timeout ?
     
  6. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
  7. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
  8. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    There are almost certainly also microprocessors in the ATM as well as the Windows machine, for motor control, reading sensors to pass to the PC, etc. I think it would be hard to find information about exactly how they work, but at a guess if they use watchdog timers it would be for the purpose of detecting if the main program has failed, not for timing.
     
  9. rabhishek91

    Thread Starter Member

    Feb 14, 2013
    51
    1
    Thanks again sir. :)
     
Loading...