Introduction: Arduino Watchdog With LM358 Op-Amp
This is a simple schematic that allows the use of the chip LM358 Op-Amp as a Watchdog for the Arduino board.
Step 1: Needed Components
- 1 x LM358 Chip
- 1 x 1N4001 Diode
- 1 x 100uF Capacitor
- 2 x 1uF Capacitor
- 4 x 220K Resistor
- 4 x 100K Resistor
Step 2: Explanation
- R1 and C1 values define the circuit timeout (RC);
- C2 guarantees that only transitions (beats) are considered as Heartbeats;
- R6 centers the heartbeats at zero volts avoiding this way false triggering;
- The resistors pairs R2+R3 and R4+R5 define the threshold voltage for the first and the second Op-Amp respectively;
- Each Op-Amp has its own reference voltage resistors to avoid disruption of the first Op-Amp and consequent reset triggering;
- Both Op-Amps work in inverting mode so that HIGH inputs result in LOW outputs and vice versa;
- The Diode D1 enables the discharge of the Capacitor C1 but avoids its charge trough the second Op-Amp;
- The second Op-Amp discharges the Capacitor C1 before triggering the first Op-Amp whenever receives a beat;
- C3 guarantees that the reset pin doesn't remain low when the first Op-Amp is triggered and its pin 1 goes LOW;
- The voltage divider R7 and R8 are there so that the drop impulse goes bellow 2.5 volts able to trigger the Arduino reset.
Step 3: How to Use
- In the Arduino loop function, insert an if statement that will switch the Pin D4 HIGH and LOW alternately;
- If for some reason the Pin D4 remains HIGH or LOW for more than the timeout, the Arduino RESET will be activated;
- After the previous RESET activation, this Watchdog will remain inactive until a new HIGH beat is received;
- For different devices from Arduino you may need to change the value of the R7 and R8 resistors so that the negative impulse goes below the 2.5 volts threshold when triggered and remains above it when not (reset condition);
- Case you are using a DIY arduino board, most likely you have a 10K pull-up resistor in its reset pin. In this case the resistors R7 and R8 should be of similar scale, meaning, 10K and 22K respectively. All this because the LM358 is not a Rail to Rail Op-Amp, meaning that the output won't fully swing between 5 and 0 volts. In this case the swing of the reset output is only 2 volts, and because of that the R7 and R8 need to be such so that this output won't be superior to 4 volts in normal operation (4 - 2 = 2 < 2.5 arduino reset threshold). For better understanding learn about Voltage Dividers.
Step 4: Schematic
Here is the Schematic in PDF.
We have a be nice policy.
Please be positive and constructive.