Introduction

Author: Johan Vaarlid and Martin Mostad, Microchip Technology Inc.

The Timer/Counter type D (TCD) on the AVR® DB features an asynchronous event input that can be used to shut down the output under fault conditions. This application note will demonstrate and explain how to detect overcurrent, by using the configurable internal OPAMP (Analog Signal Conditioning) and Analog Comparator (AC) to detect a fan motor failure and send this detection as a signal to the asynchronous event input of the TCD, shutting down the load. Figure 1 outlines the working principle:

Figure 1. Overcurrent Protection Circuit Schematic

In normal operation, the TCD output pin is controlling the speed of a fan via a transistor gate. The Analog Comparator (AC) monitors the fan current through a current-sense amplifier implemented using the integrated operational amplifiers on the microcontroller.

R1 is the current shunt resistor, which generates a voltage from the current that passes through the motor. R2 limits the current into the microcontroller in the event of a high-voltage spike on R1.

The AC is configured to send an event as soon as the fan current rises above a selected threshold. A possible cause for such a current spike is a fan stopped by a mechanical obstacle. The event system of the device is configured to route the event from the AC to an RS-latch in the Configurable Custom Logic (CCL) which stops the TCD output.

On fan failure, the rising current triggers the AC to send an event to the S-port of the RS-latch making the output Q high. This signal is then sent to the TCD failure event. Thanks to its asynchronous event input, the TCD will abort driving the fan and shut off the supply current.

After the fan supply was interrupted by the TCD, application-specific actions can be implemented, depending on the application. Some possible actions include attempted restart, operation abort, or failure signaling. In this example, we have made a simple restart algorithm initiated by clicking the button on the AVR128DB48 Curiosity Nano.

This application is one example of an implementation of functional safety. One way a current spike can occur in a fan motor is when the motor experiences strain, for example from a finger or object stuck in or pressing on the fan blades. In such an event, an automatic shutdown can be used to protect the end user from injury and to reduce the chance of damage.

The example code for replicating the results described in this application note is available on GitHub.

Additional details on AC, TCD, CCL, OPAMP, device performance and general configuration are available in the device data sheet.