Jingxi Zhang, Yang Zhang and Huifang Ni
In our daily lives, the temperature of our environment is something that we frequently
deal with—any time we check the weather, adjust the room climate control, check our
body temperature, or store something in the refrigerator, we are gauging or controlling
temperature. Temperatures usually vary over the time; for instance, a woman’s body
temperature fluctuates during her menstrual cycle, and outdoor temperatures change
dramatically between day and night, to say nothing of seasonal changes. Even in a well
controlled environment, such as a refrigerator, the temperature could change from time to
time. To record and analyze temperature changes over time can help us diagnose a
patient’s sickness, to troubleshoot a computer system malfunction, or to adjust climate
control to save energy and pollution.
For a long time, building a tiny, low-cost temperature recorder, which can be dropped
into my desktop computer chassis or attached to my body skin, has been a project I
wanted to pursue. When I received my MSP340 starter kit, I immediately realized that the
TI MSP340 is an ideal platform for my temperature recorder: it has a temperature sensor
built in, and the 16-bit sigma-delta ADC can give me very high-resolution temperature
measurements (< 0.02oC) without relying on any external component. Its low-power
clock generator and 16-bit timer counter can wake up the CPU to sample the temperature.
The runtime writable on-chip flash memory can store compressed temperature data. Best
of all, as the MSP340 runs on very low power, I may not need the bulky battery for the
processor. All I need is a tiny super capacitor—with an instant change, it could drive the
processor for hours, even days! To maximally use the MSP430 MCU and the starter kit,
my partners and I decided to use the USB controller on the starter kit to retrieve the
recorded data sample to the host PC.
Flash memory
1.2V Ref
Flash memory
segment 3
Σ∆ mod
Host PC
Timer ISR
16-bit timer
power supply
Very Low power oscillator
12 KHz
Figure 1. Temperature Recorder
System Block Diagram
Hardware Preparation
Temperature Recorder System
The electric double layer (EDL) capacitor is the high capacitance super capacitor. We
selected the Panasonic EN series (EEC-EN0F204RL, Digikey part # P11069CT-ND) for
its compact size. The capacitor is rated 3.3 V, and the capacitance is 0.2 F, which is equal
to 200,000 uF.
There is only one diode and one resistor needed to add to the existing eZ430-F2013
starter kit board, besides the super capacitor (Schematic 1). The modification is simple:
remove resistors R1 and R3 and solder a Schottky diode in place of R1 (be careful of the
diode’s polarity). Solder the R3 resistor back to the board with one end of R3 connecting
to the Schottky anode (Photo 1). Solder a 47-ohm resistor in serial with the diode to
protect an instant high current when the discharged capacitor connects to the power
supply (cut the trace on the back side of the board). We found the LED consumes a large
amount of current even when it is not programmed in use. We had to remove R2 to lower
the system power consumption. The last step is to solder the super capacitor to terminals
P1 and P14 (positive and negative pins).
0.2F Capacitor
47 ohm resistor
Photo 1. Modified eZ430-F2013 Development Kit
0.2 F
Schematic 1. Modified (in red) MSP430F2013 target
Schematic 2. JTAG/Spy-Bi-Wire Controller (From TI eZ430-F2013 User’s Guide)
Schematic 3. USB Interface (From TI eZ430-F2013 User’s Guide)
Software Implementation
The software flowcharts are shown in Figures 2, 3, 4, 5 and 6.
When the temperature recorder is powered on (when the super capacitor is discharged) or
reset by the debugger, the CPU starts the initialization steps. It first disables the watchdog
and modifies the pin10 (RST/MNI/SBWTDIO) function. Because the default setting of
pin10 is for external reset, when the temperature recorder is unplugged from the host
USB port, the voltage level at this pin drops to ground, and the device will be in the reset
mode forever. To overcome this problem, the CPU changes the pin10 function to NMI
(Non-Maskable Interrupt). The NMI interrupt is, however, not enabled (NMIIE bit in IE1
register is 0) so that the voltage level at pin10 does not affect the CPU under normal
running conditions.
Disable watchdog and RST
Configure clock module
Configure ADC module
Enable 16-bit ADC interrupt
Enable 16-bit timer interrupt
Get user input
Get next available
flash memory entry
Input =’ r’
Read data
from flash
Input =’ e’
Input =’ g’
Figure 1. Main Flowchart
Erase flash
Temperature sensor
Start ADC
to LPM1
Figure 2. Timer Interrupt Service Routine
Get a 16-bit sample
predict =
current - previous
Escape one byte in flash
memory (0xff left)
Predict --
Store 2 bytes of current
value to flash memory
Store lower byte of
predict to flash memory
to LPM3
Figure 3. ADC Interrupt Service Routine
Read flash entry
previous = 0
Read one byte from
flash memory
Is 0xFF
Read next byte
from flash memory
Is negative
Is 0xFF
Output value
Read next byte
from flash memory
Output value
Max storage
Figure 4. Read Flash Memory Data Routine
Erase flash entry
Save interrupt
Erase section 3
flash memory
Restore interrupt
Figure 5. Erase Flash Memory Routine
The DCO (Digital Controlled Oscillator) in the Basic Clock Module+ module is set to
1MHz for the main system clock (MCLK). When the device wakes up from low power
mode, the CPU is driven by this clock. The internal Very Low Power, Low Frequency
Oscillator (VLO) is enabled and set to ACLK to maintain the time clock when device is
in low power mode. The 16-bit timer is set to Up Mode and is driven by the VLO. It
wakes the CPU when it times out. Because the temperature change is usually a very slow
event, the device samples the temperature in very long time intervals. By setting the value
in the capture/compare register (TACCR0) of this timer, we can set the temperature
sampling interval to, for example, 5 minutes.
After initializing the hardware, the CPU is ready to run. It requests a command input
from the standard IO. The MSP340 Development Kit provides a serial communication
channel through the USB, and we can use it to send commands to the temperature
recorder. In order to have the user enter the command, the temperature recorder has to be
plugged into the PC host USB port. In the IAR IDE Terminal I/O window (Screenshot 1),
the temperature recorder prompts the user to enter a command character: ‘g’, ‘r’, or ‘e’
for the go, read, and erase commands, respectively (if the Terminal I/O window is not
shown, select “Terminal I/O Window” under the View menu).
The go command is for recording temperature. When the CPU receives go command, it
switches into low power mode 3 (LPM3). In this mode, the CPU and main system clock
are shut down while the VLO is running. The device consumes very low current (about
half of 1uA) in LPM3 mode. When the temperature recorder is plugged into the PC USB
port, the super capacitor starts to charge. The capacitor charges very fast, taking about 3
minutes to fully charge. The temperature recorder is now ready to use. Unplug it from the
USB port, and it starts to sample temperature.
Command prompt
Command input
Screenshot 1. Commands entered at Terminal I/O Window.
When the 16-bit timer times out, the timer interrupt wakes up the CPU. In the timer
interrupt service routine, the internal temperature sensor and the 1.2V reference are
enabled. The temperature sensor output is routed to the sigma-delta ADC. Because the
sigma-delta ADC uses serial bit filtering, it takes time for the data sampling (depends on
the over-sampling rate, OSR). Four samples are taken in one shot to let the digital filter
output settle in response to the step change at input. However, it is not necessary have the
CPU wait for sampling to finish. The MSP430 provides an ADC auto-shutdown feature
to further conserve power during ADC sampling. Once the CPU sets up the temperature
sensor and starts the ADC (one shot mode), it returns to sleep in low power mode 1
When the ADC finishes the temperature sampling and puts the 16-bit sampled data into
the data register, it turns off the ADC and signals the CPU by an interrupt. The CPU then
turns off the sensor and 1.2V reference and puts the sampled data into flash memory.
The MSP430-F2013 microcontroller has four 512-byte segments of main flash memory
for program storage. It also has four 64-byte segments of information flash memory for
data storage. The first segment of the information flash memory (segment A) stores
device calibration information from the manufacturer and is locked by default. The 3
other segments of information flash memory are available for the user. However, the total
of 192 bytes of information flash memory is too small to keep a long period of recorded
temperatures. Because the temperature recorder program code occupies only 3 segments
of main flash memory, we decided to use the last 512-byte segment of main flash
memory, segment 3, for temperature data storage. The last 32 bytes in segment 3 are
preserved for interrupt vectors. We have to share this segment’s flash memory for both
data and program interrupt vectors. The flash memory can only be erased for the entire
segment. We have to recover the interrupt vectors in the temperature data erase routine.
The sampled data is 16-bit in length. However, temperature changes slowly, and the data
sampled can be predicted from the previous sampled data with small error. We decided to
use prediction to compress the data from 16 bits to 8 bits and save flash memory storage
space: if the different between the current temperature sample and the previous
temperature sample is within ±127, we store the one-byte difference. If the difference is
over the one-byte range, we store an escape character, 0xFF, and followed by the 16-bit
sample data. Because we frequently only need to store a 1-byte difference, the flash
memory can used very efficiently. The escape character, however, is same as the -1 in the
prediction difference; we have to decrement the difference value by 1 if the difference is
negative to avoid conflicting with the escape character. Because the flash memory
locations are initialized with 0xFF, the end of recording can be easily detected when two
consecutive 0xFF values are found.
Although the current is greater when the CPU is activated for temperature sampling and
flash memory writing than when it is in low power mode, the CPU spends very a very
short amount of time in active mode when compared to the long intervals between
samples. The temperature recorder’s average power consumption is very low, in 1uA
range. The recording time can be calculated as follow:
T = C (V1-V2) / i
Where C is the capacitance of the super capacitor; V1 is capacitor’s fully charged voltage,
which equals to the super capacitor rating voltage 3.3V; V2 is the minimal working
voltage, which is equal to the MSP430 flash memory-required minimum voltage 2.2V;
and i is the temperature recorder’s average current.
In theory, the 0.2F capacitor can support the temperature for over 60 hours. In reality, the
capacitor leaks current, and although this is a tiny amount, it can affect the actual
recording period.
Because the temperature data is stored in non-volatile flash memory, it can be recovered
even after the super capacitor has drained. The recorded temperature data can be read
using the Spy-Bi-Wire interface built into the development kit. Plug the temperature
recorder to the PC USB port and launch the IAR IDE. Before connecting the IDE to the
temperature, the debugger setting has to be set to attach to the running target (Screenshot
2). If not, the debugger erases the main flash memory and reloads the code, which could
wipe out all recorded data.
After the IDE connects to the temperature recorder, the program can be restarted by
clicking the reset button on the toolbar (stop the debugger if the program is running) and
re-run the program. To log the temperature data output to a file, the Terminal I/O log has
to be set (Screenshots 3 and 4). In response to the command prompt, type an ‘r’ to read
temperature data from flash memory. The program jumps to the routine to start reading
data from flash memory. Each data read is first compared with the escape character; if
this not an escape character, the data must be a difference value predicted from the
previous temperature data. The data is added to the previous temperature (add 1 if it is a
negative number) to recover the original 16-bit data and output to the standard output
channel. If current data is an escape character, the next data value is evaluated. In the
case of 2 consecutive escape characters, the data record has hit the end of the records and
the routine returns. Otherwise, the 16-bit data from the 2 bytes following the escape
character are sent to the output channel (Screenshot 5).
The data output in the log file can be converted to temperature and plot on the Excel
To prepare a new temperature recording session, the flash memory segment 3 must be
erased (command ‘e’). The flash memory routine is simple: save the interrupt vectors,
erase the entire segment of flash memory, and restore the interrupt vectors back. The
MSP430 flash memory program/erase endurance is 100,000 cycles. The temperature
recorder is thus guaranteed for repeated use for over 274 years if the flash memory is
erased every day.
Check this
option to keep
the temperature
data in flash
Screenshot 2. Attach to running target in project option dialog
Set Terminal I/O
log file
Screenshot 3. Menu to set terminal I/O log file
Screenshot 4. Set file for terminal I/O log
Indicating the
log file is set
Recovered temperature data
in output terminal
Recorded temperature data
stored in Flash memory
(start at segment 3).
Figure 5. Temperature data are sent to log file from the flash memory
Use Temperature Recorder
The temperature recorder is easy to use. The entire USB device can be used to record
temperature (Photo 2) or the target board can be used separately (Photo 3). Because the
target board, with the super capacitor, is very tiny, it can easily be attached to a person’s
body to measure the body temperature (Photo 4).
Photo 4. Temperature recorder device can be detached from USB adaptor
Figure 7 is the 24-hour plot of a refrigerator. The temperature fluctuation (condenser on
and off) is controlled in a range of 1oC.
Figure 7. Temperature record of a refrigerator
Figure 8 is a demonstration of the tiny temperature recorder attached to skin by a medical
bandage to monitor body temperature.
Figure 8. Temperature recorder attached to skin.
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF