A new feature introduced in the AVR® DB family is the Analog Signal Conditioning (OPAMP) peripheral. In this example, the OPAMP is used together with an Analog Comparator (AC) to form a current spike detector. The fan is enabled by a TCD waveform output. This output will be shut off automatically when the current spike is detected by the detector, making it an ideal solution for applications where functional safety is needed. As an example of an application where a current spike might indicate failure or danger, is a computer fan. Under normal operation, the current consumption is nonlinear, but does not exceed a certain threshold, dependent on the fans spec. By autotuning the gain of the internal OPAMP by using the internal resistor ladders, we can automatically boost the signal to a measurable range, and automatically set a trigger level for the AC by use of the on board DAC to define what an "unnaturally" high current consumtion is, indicating a touch or something stuck in the fan.
- AN3860 - Overcurrent Protection Using the Integrated Op Amps on AVR® DB
- AVR128DB48 device page
- AVR128DB48 Curiosity Nano User Guide
- Microchip Studio 7.0.2542 or later
- Atmel AVR-Dx_DFP version 1.6.76 or later
- For the MCC MPLAB® X version of this project, please go to this repository
- For the Microchip Studio version of this project, please go to this repository
- AVR128DB48 Curiosity Nano
- A small computer fan (M1)
- 3x 1 kOhm resistor (R2, R3, R5)
- 1x 10 kOhm resistor (R6)
- 1x 0.1 Ohm current sense resistor (R1)
- 2x 100nF capasitors (C1, C2)
- 1x N-Channel MOSFET transistor (Q1)
- 1x Signal Diode (D1)
- Hook up the circuit as shown in the figure below
- For minimal noise, soldering the circuit onto a perfboard/stripboard is prefered, although a breadboard could be used with worse performance
- Connect the AVR128DB48 Curiosity Nano to a computer using a USB cable
- Download the zip file or clone the example to get the source code
- Open the .atsln with Atmel Studio
- Press Start without debugging or use CTRL+ALT+F5 hotkeys to run the application
- After the LED stops flashing, it is done calibrating
- Gently apply preassure to the fan, being very careful not to hurt yourself. The fan should now stop.
- Click the onboard button (SW1) to re-enable the fan
After going through this example, you should have a better understanding of how to combine the OPAMP and AC peripherals to make a current spike detector.