Watchdog Timer

Thread Starter

rabhishek91

Joined Feb 14, 2013
51
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.:)
 

Attachments

JohnInTX

Joined Jun 26, 2012
4,787
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.
 

Thread Starter

rabhishek91

Joined Feb 14, 2013
51
It would work, but not a good way to do it.
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?
 

Markd77

Joined Sep 7, 2009
2,806
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.
 

Thread Starter

rabhishek91

Joined Feb 14, 2013
51
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.
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 ?
 

Thread Starter

rabhishek91

Joined Feb 14, 2013
51

Markd77

Joined Sep 7, 2009
2,806
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.
 

Thread Starter

rabhishek91

Joined Feb 14, 2013
51
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.
Thanks again sir. :)
 
Top