PIC16F1823, PIC Microcontroller, I2C, Digital Potentiometer

Channel: Nolan Manteufel


TIP: Right-click and select "Save link as.." to download video

Initializing link download... Initializing link download.....

Here I use a PIC microcontroller (PIC16F1823) to control a 100k digital potentiometer (MCP4018) which sets the voltage at the gate of a MOSFET (2N7002) thus controlling the current through the green LED.

The digital potentiometer is on the I2C bus. When the digital pot is disconnected (unplugged) an I2C "No Acknowledgement" (NACK) occurs. When a NACK occurs i turn on the orange LED. When communication is reestablished, i turn the orange LED off.

When the I2C clock and data wires are shorted, it causes the microcontroller to do something unexpected. It never returns to the interrupts. I enabled the Watch Dog Timer and placed the CLRWDT command in the Interrupt Service Routine. When the hardware bug causes the PIC to hang up, the WDT triggers a RESET and the microcontroller "reboots" itself.

At first glance, I2C is confusing. Actually, a solid understanding of I2C takes many hours of study spread over several days. This was my first I2C project, i recommend it for microcontroller intermediates.

I use interrupts. This allows the microcontroller to execute many lines (thousands) of code while messages are being sent. The alternative is polling the interrupt flag.

A full description of this experiment, copy of the assembly code and schematic are available here: https://sites.google.com/site/porquenoengineering/

Schematic: https://plus.google.com/photos/101942246191738597064/albums/5808375504677721041


Microchip, PICkit3
PIC Microcontroller, PIC16F1823
WatchDog Timer, Watch Dog Timer, WDT
Digital Potentiometer, MCP4018
MOSFET, 2N7000, 2N7002

Electrical and Computer Engineering,
University of Texas at San Antonio,
UTSA Engineering,