Microchip | The Embedded Control Solutions Company Register Login
Browse All
Microchip Technology
 369 Code Snippets

Building an 8-bit Thermal Camera using the PIC18F27K42

Microchip Technology

Check out this project's MPLAB Xpress Webpage to view the complete code example along with a detailed step by step write-up and description, or visit the PIC18F27K42 Device Product Page for more information.

About this Code Example

Objective

The 8-bit Thermal Camera Application Note demonstrates the use of the PIC18F27K42 microcontroller to read thermal pixel data via the I2C bus, perform image processing duties, create a thermal image, and transfer the image to an LCD via the SPI bus. The Direct Memory Access (DMA) module is also used to transfer an image file, which is stored in Program Flash Memory, to the LCD to create a ‘splash screen’ that persists while the Panasonic Grid-EYE® sensor warms up.

Thermal Camera

Thermal Camera Components:

The 8-bit thermal camera uses the following main components:

  • Panasonic Grid-EYE® Infrared Array Sensor (AMG8833)

The Panasonic Grid-EYE® Infrared Array Sensor is an 8x8 (64) pixel thermopile array sensor. The sensor features an on-board gain amplifier, Analog-to-Digital Converter (ADC), and a thermistor. The sensor communicates via the I2C bus operating at a maximum of 400 kHz.

Grid-EYE Sensor

  • Varitronix CSTN 1.44” 128x128 LCD (COG-C144MVGI-08)

The Varitronix LCD is a 1.44”, 128x128 pixel RGB Color Super-Twist Nematic (CSTN) display capable of displaying up to 65K colors. The LCD is driven with an internal Samsung S6B3306 LCD driver chip, which communicates with the PIC18F27K42 device via the SPI interface.

Varitronix LCD

  • PIC18F27K42 8-bit 64 MHz 128kB Flash microcontroller (PIC18F27K42-I/SS)

The PIC18F27K42 is a 28-lead 8-bit microcontroller that features 128 kB of Program Flash Memory and operates at 64 MHz. The PIC18F27K42 contains a rich peripheral set, although only the following peripherals were used in this application:

  • I2C module
  • SPI module
  • Timer 1 module
  • Direct Memory Access (DMA) module

PIC18F27K42 Microcontroller

  • Custom PCB

The necessary components are mounted on to a custom-made PCB.

Thermal Camera PCB

Application Operation

The application operates at 3.3V, which is generated through 2 - AAA batteries, or from USB power. When the application is first powered-up, the Grid-EYE® sensor requires a 15 second ‘warm-up’ period in order to stabilize the thermopile sensor array. Timer 1 was used to create the delay, and the DMA was used to transfer an image file to the LCD. The image, the Microchip logo, was used as a ‘splash screen’ so that the viewer is not looking at a pixelated screen during warm-up. The image persists for the duration of the delay, and once the delay has passed, Timer 1 is disabled.

At that point, the application can begin to detect temperatures. The Grid-EYE® sensor’s thermopile array detects temperatures within the 60° viewing angle, then performs amplification and filtering on each of the 64 pixels contained in the sensor. This data is then read by the PIC microcontroller over the I2C bus. Additionally, the Grid-EYE® sensor features an on-board thermistor, which reads the ambient temperature near the sensor, and is also read by the PIC.

The PIC reads the thermistor data and converts it to a usable temperature value. Next, the PIC reads all 64 pixels, converts the data into temperature values, and stores the values in a dynamic array stored in RAM. The PIC then performs an average of the thermistor value and the average temperature of all 64 pixels and uses that average as the background temperature. The background temperature is then compared to each of the 64 pixels. If a pixel’s temperature is greater than the background average, the PIC determines that the pixel is detecting an object; if the pixel’s temperature is less than the background average, the PIC determines that the pixel is detecting background temperatures. Pixels that have detected an object will be displayed on the LCD in colors based on the temperature value, while pixels detected as background temperatures are colored black.

Since the Grid-EYE® sensor only detects 64 pixels worth of temperatures, and the LCD displays 16,384 pixels (128x128), scaling must be done so that the thermal image can be easily seen by the viewer. Scaling is accomplished using a bilinear interpolation technique in which ‘missing’ pixels are created using the information from surrounding pixels.

Once the ‘missing’ pixel information is created, the new pixels, as well as the original pixels, are grouped together in another dynamic array. This array is then converted into RGB color values and transmitted to the LCD via the SPI interface. The LCD then writes the color data onto the screen, which creates the final thermal image.

Thermal Image of the Top of a Coffee Pot

Conclusion

The 8-Bit Thermal Camera Application Note shows how to create a simple thermal imaging camera. For more information on the PIC18F27K42, or any of our portfolio of products, please visit www.microchip.com.

Categories

Release History

  • Dec 4, 2018

    Version: 1.0.0

    Initial Release

Download Contact the Developer

*Required Fields


  • Current Version:1.0.0
  • Created:Dec 4, 2018
  • Updated:Dec 4, 2018
  • Downloads:694
  • MPLAB Version:MPLABX IDE
  • C Compiler:XC8 (v1.45)
  • Development Tools:Custom Board
  • Supported Devices:PIC18F27K42

Corporate News

Resources

Stay Connected

Stay up to date with the latest news from Microchip Technology.