Thursday, June 3, 2021

Non-Contact Infrared Thermometer - Part 1

 


electronic components used in digital thermometer project

Welcome to the next installment of "Dabbling in Electronics"! Over the spring and summer of 2020, I helped a non-profit develop an open-source, non-contact infrared (IR) thermometer, the kind you point at someone's forehead and press a button or pull a trigger to take a temperature. They believed at the time that due to the COVID-19 pandemic there would become a shortage of commercial units of these thermometers for screening people for fever at businesses and non-profits. I submitted a proposal to the initial design competition, but it wasn't selected for further development. 

Mostly for the fun of learning new things, but also to validate my design choices, I decided to build a prototype of my proposed design mostly on my own. This article is the first part in a series about developing that prototype from scratch and what I learned by doing so. I will be writing this series as I progress step-by-step toward having a completed thermometer including custom printed circuit board (PCB) and 3D-printable handheld device enclosure. Right now, I will just describe the basics of the thermometer and some key design choices.

Basic Design of the Thermometer

The thermometer is based on an IR sensor that can measure from a distance the "heat glow" of an object and provide an object temperature estimate to an attached computer. The computer need not be a full-blown PC computer; it can be a barebones, low-power, inexpensive computer-on-a-chip of the sort that might be used to control a simple household appliance, something much less powerful than what runs your smartphone or tablet or laptop.

All the proposed designs for the open-source thermometer had the following major components:

  • a Melexis MLX90614-BAA IR temperature sensor (this was a requirement, because the non-profit had acquired 100 of these sensors, which were hard to get at the time)
  • a display to show the temperature or other messages
  • a pushbutton to trigger taking and displaying the temperature
  • a microcontroller unit (MCU), a low computing power computer-on-a-chip (low compared to, say, a laptop or smartphone, maybe about as powerful as the original IBM PC)

The purpose of the MCU is to coordinate the activities of

  • detecting whether the pushbutton has been pressed
  • reading a temperature from the sensor
  • displaying the temperature (or other information) on the display
  • detecting a "low battery" condition
The proposed designs other than mine specified an MCU compatible with Arduino STEM and hobbyist computers and an LED segment display.

My Design of the Thermometer

A key characteristic of my thermometer design was that I wanted it to have long battery life. The original requirements for the thermometer specified that its batteries would last at least throughout steady use during a 10-hour work day. I thought that goal was much too low and that batteries could be made to last for months.

Well, the biggest demand on the batteries in the other designs was the LED displays. These were 7-segment displays, meaning each digit was broken into 7 different little lines, with the numeral 8 requiring all the lines to be visible. Each segment required 25 milliamps (mA, thousandths of an Ampere, the unit of electrical current) at 3 Volts. Lighting up an entire numeral 8 would require 7 times that, or 175mA. There was also a decimal point, so 8 elements had to be lit, at a total current draw of 200mA.

Now, there were 4 digits in the display, but there is an engineering trick called time-division multiplexing that saves some resources, in this case whereby the digits are only lit up one at a time, in a round-robin fashion. The cycling of the round-robin is done so quickly, humans do not see any flashing or flickering due to persistence of vision. So the 200ma is enough to keep the display looking like every segment and decimal point is lit up simultaneously.

Another limitation of LED displays is that they can be difficult to read in bright light, especially sunlight. An LCD can be very readable in bright light because it depends on reflecting (or blocking) light rather than transmitting it.

The MCU and the sensor use some current, but their combined needs are less than 2mA, well less than the 25mA needed just to light up just one segment of the display. So, under heavy use, the LED-based thermometers could draw up to about 200mA. Since an alkaline AA cell is good for about 1800 mA-hours (mAh), the LED-based thermometers could have a battery life under heavy use of as low as 9 hours (1800mAh / 200mA = 9h).

Decision: minimize number and cost of parts

I wanted to keep the design simple and small and minimize the parts cost of the device. That suggested running batteries with no voltage regulators. The design had to operate in the range of 2.6V to 3V because the sensor required a minimum of 2.6V to operate, so a "low battery" indication was required when battery voltage was too low to run the sensor but still high enough to run the MCU and display.

My final list of components was

  • the temperature sensor (~$20 when I bought a few)
  • a PIC MCU (~$2)
  • a display (<$2)
  • a pushbutton switch (<$0.50)
  • 2 AA alkaline batteries
  • the circuit board (cost TBD)
  • any needed additional hardware, such as wires, battery contacts, connectors, and screws (cost TBD)

Decision: use LCD instead of LED

I chose to use a liquid crystal display (LCD) instead, because it draws only about 1/1000 the current of a comparable LED display. I estimated my thermometer would draw a peak current of almost 2mA, 1.5mA of that being drawn by the sensor. So, under heavy use, the LCD-based design should have a worst-case battery life of about 900 hours (1800mAh/2mA = 900h). 

The tradeoff here is that LCD displays are more complicated to control than LED displays. They are also prone to different causes of damage than LEDs. With an LED display, you simply apply DC power to each element, and that element of the display lights up. LCDs are more complicated to drive, since they require AC power that meets certain conditions. That meant special LCD driver hardware was needed. Microchip's application note AN658 does a good job of explaining how LCDs work.

Decision: use a PIC MCU instead of an Arduino-compatible MCU

Having chosen LCD over LED, there were two options for the LCD driver: an external driver or one built in to the MCU. Wanting to keep the part count small to reduce cost and circuit board size, I chose to go with a built-in LCD driver.

The other designs chose Arduino-compatible MCUs, because many makers (STEM students and hobbyists) are familiar with them. Since the Arduino-compatible MCUs do not have built-in LCD driver modules, I had to look elsewhere. I started and ended by looking at Microchip PIC MCUs.

I learned about PICs from a friend who used to design power supplies for medical devices. Microchip, the manufacturer, makes over 1000 models of MCU in the PIC line, each sporting a different mix of features. PICs are used in many industrial applications, including medical devices, and are widely available and inexpensive. So, I tried to see if there were any suitable PIC models. My search narrowed to the PIC16(L)F191XX family of MCUs because it had the following features:

  • will operate at 1.8V to 3.6V (LF version), which was a larger operating range than that of the sensor (the F version operates at 2.3V to 5.5V)
  • is very power-efficient
  • has an LCD driver module with optional, step-up/step-down charge pump (voltage converter) enabling it to hold constant LCD voltage, and therefore contrast, as battery voltage declines with use
  • supports multiplexed and static (unmultiplexed) LCDs (multiplexed LCDs require fewer electrical connections than static ones)
  • has a compatible I2C/SMBus two-wire interface for communicating with the temperature sensor
  • has through-hole versions available, which would help with easy breadboarding of a prototype and hand soldering of the final circuit board
  • has a way to detect a low-battery condition without using any extra parts
  • can be (re)programmed after it has been permanently installed in a circuit

I originally proposed using the PIC16F19176-I/P model MCU. It comes in a 40-pin PDIP package (two rows of 20 pins). But I later changed to a PIC16LF19156-I/SP after picking a different LCD allowed me to get away with a 28-pin SPDIP MCU (two rows of 14 pins) that is also physically narrower than my originally proposed MCU choice, potentially allowing for a more compact circuit board and device.

Publishing the Design

I decided, like the original thermometer project, to open-source my design. All source code and manufacturing-ready design files will be provided, freely available for anyone to use for any purpose, commercial or non-commercial. It will be published on GitHub, a popular repository for open source projects, at https://github.com/kamorrissey/pic-ir-thermometer.

Conclusion

Not much action in this article, just laying the groundwork.

In the next installment of the series, I will go into the first thing I tackled: getting the PIC to display something on an LCD. I was starting from scratch, with no parts, equipment, or tools, and no hands-on experience with PICs or LCDs. I'll be telling you what I had to acquire and learn. And I'll be sure to tell you about the crucial detail that blocked me for months from making this first step work.

By the way, the IR sensor appears in the opening photo as the round can with an "eye" mounted to a small, rectangular circuit board. The "eye" is a window letting IR radiation into the device. Part of the LCD display is visible at the left, mounted to a "breakout board" because its pin spacing was too narrow for the standard prototyping circuit boards (breadboards).

Until next time...