|
| ( 01 Nov 2010 ) |
| By Robert Most, Ferris State University, Big Rapids, Michigan |
|
Microcontrollers usually require a watchdog timer to bring high currents or high voltages into a safe condition. Many microcontrollers have built-in watchdog timers for this purpose. You may, however, prefer that an external circuit be the judge. An external watchdog circuit checks the integrity of the microcontroller’s code, bringing the outputs to a safe state when it judges that the microcontroller’s firmware has gone awry. Conditions such as errant code or failed hardware can cause these issues.
You have many options for designing an interface between your external timer and the microcontroller. For example, you can use a port pin, which yields a flexible and adaptable way to couple with almost any microcontroller.
In applications that require energizing an output or series of outputs, you need an enable signal. You can use this enable signal to energize a relay providing power to an output device. Turning the enable signal into a watchdog signal is therefore a wash in terms of port-pin usage. The implementation of this watchdog circuit requires the output port pin to toggle, rather than stay at a constant state.
Most microcontroller code has a main loop that is always either performing a task or calling larger functions and interacting with interrupt-service routines. If an errant task, unforeseen bug, or unintentional vector executes, the main loop either gracefully reinitializes or becomes stuck indefinitely. Either situation breaks the execution of the main loop. When that situation occurs, the timer needs to remove power from your circuits.
You can implement the watchdog timer by toggling a port output whenever the main loop runs, provided that the main loop executes 10 to 100,000 times/sec. Figure 1 demonstrates this concept. You can implement this watchdog philosophy in several ways.
You must allow for variability in the rate of the toggle signal because extraneous interrupts and other nondeterministic events may cause variability in the main loop’s execution loop time. If the watchdog circuit is not sufficiently forgiving, it may lead to false triggers, defeating its purpose. The recovery time of the watchdog timer is the maximum time between toggling events in duration. This scenario can happen when the system is in a recovery, or “limphome,” mode. This circuit can accommodate the recovery duration, but, if it deems necessary, the recovery operation can disable the watchdog timer’s output. Listing 1 is a document containing sample code.
The circuit in Figure 2 uses two bipolar transistors. The second transistor is simply a relay driver. The circuit works by removing the dc component from the incoming toggling square wave, rectifying and creating an average dc value. This wave feeds transistor Q1, biased such that a prolonged absence of pulses turns it off, thus turning off Q2 and the relay. Changing the value of C2 also changes how quickly the watchdog timer reacts to an absence of pulses. The circuit accepts toggling frequencies of 10Hz to 100kHz.
Changing the value of capacitor C2 changes the range of compliance frequencies that the main loop generates. The circuit also functions with a 3.3V processor, but either the relay must have its own 5V supply or you must use a lower- voltage relay.
|
| |
|
|
|
|
| |
|
|
| |
|
|
| |
|
|
| 25/4/2012 |
|
| 25/4/2012 |
|
| 24/4/2012 |
|
| |
|
|
|
|
|
|
|
| |
|
| |
|
| 30/3/2012 |
|
| 22/3/2012 |
|
| 1/3/2012 |
|
| |
|
|
|
|
|