1. Introduction
The operating clock frequency of most modern microcontroller units (MCUs) used in Wireless Sensor Networks (WSNs), such as Alf and Vegard’s reduced instruction set computing (RISC) processor (AVR), peripheral interface controller (PIC), mixed signal processing (MSP), and 8051, is fixed [
1,
2]. The clock source is an internal/external crystal oscillator/resonator. The energy used by such MCUs can be decreased by reducing the current consumption. Reduced current consumption can be achieved by reducing the operating clock frequency of the MCU. The result of such energy saving is a long sensor node operation lifetime. A sensor node always includes a short instruction to read a sensor value and to complete data transmission. Most of the energy is used for transmitting the data to the target node. For example, the energy required to read the temperature with a 16-bit resolution is very small as compared with that required to send this value to a target node/server every minute. However, if the sensor node is of the image type or has a considerable amount of data that needs to be processed [
3], the MCU needs more time to process the data before transmitting them to the other module. Examples of data processing include image compression, data compression, data integrity checking, and data encryption.
The time consumed by the MCU to process data depends on the operating clock frequency, the architecture of the MCU, and the data size. The energy consumption of data processing is currently increasing significantly, and with this increase, may approach or exceed that of data transmission. This means that the data-processing energy is also an important factor and thus should be reduced at the sensor node. Many means of reducing the processing energy exist, e.g., replacing the MCU with an field programmable gate array (FPGA) [
4,
5,
6], employing a mixed FPGA/MCU [
7,
8], and improving the MCU algorithm [
9,
10].
When the sensor node is of the image type, the data size increases hugely. The raw data size of an image sensor may be range from 1 kilobyte to 100 kilobytes, depending on the image resolution. This amount of raw image data is not suitable for sending via wireless communication and, thus, the amount of raw data must first be reduced by applying an appropriate method. A popular image compression scheme is joint photographic experts group (JPEG) compression [
11,
12]. JPEG is a lossy compression scheme that can convert a two-dimensional image pixel to frequency components and coefficients. Most of the high-frequency components of the image are lost during the compression process, but this loss is not detected by the human eye.
In JPEG compression, first the data are divided into blocks of 8 × 8 pixels. Then, quantization, zigzag scan, and discrete cosine transform (DCT) are performed. All these operations consume processing time of the MCU/FPGA. In the case of an MCU, the data are processed in the sequence of instruction, block by block of the image. The energy consumption of the MCU depends on its operating frequency and architecture. In the case of the FPGA, the image compression is performed by using logic synthesis and parallel processing, which is much more energy efficient than MCU processing. However, the cost of an FPGA that can support image compression is very high compared to that of an MCU. An additional advantage of an MCU over an FGPA is that the firmware of the system can be upgraded over wireless communication, which provides greater flexibility. Many MCU venders support in-application programming (IAP) [
13,
14]. The code together with the IAP concept allow the MCU to program itself, which is an advantage in terms of maintenance.
In many studies in the literature, attempts have been made to improve the instructions used in the JPEG compression process in MCU-based image compression [
15,
16,
17,
18]. The authors of [
15] improved data loading and restoration by replacing the zigzag scan with a lookup table. In [
16], the authors improved the processing speed by using parallel instruction. The floating-point in the C program is mapped to integers [
17] with the purpose of increasing the precision of the MCU. The results reported in [
18,
19,
20] show that the energy consumed by FPGA-based image compression is greatly reduced as compared with that of MCU-based image compression. The results include many details of the energy consumed in each task, e.g., image capturing, segmentation, and morphology. In [
20], the authors implemented a zonal DCT to reduce the number of alternating current (AC) coefficients. The results indicate a significant reduction in the energy consumption. The authors of [
21] reduced the energy consumption by integrating processors, the image processing unit, and wireless communications into a single unit using a very-large-scale integration (VLSI) design. Their paper also presents battery-aware task scheduling to control the current consumption of a task so that it remains within a certain range. In [
22], the authors designed a JPEG image compression scheme for a capsule endoscope based on an ARM Cortex M3 processor with a JPEG compression engine. This device is effective for human body images. The MCU receives a JPEG image from an external JPEG compression engine, the energy consumption of which is lower than that of the MCU.
An additional means of reducing the energy consumption of image compression is to reduce the number of data retransmissions. In [
23], the authors presented an architecture and protocol for energy-efficient image transmission on FPGA-based hardware. The image is divided into smaller blocks and effective queue control is used to reduce the packet error rate. The number of retransmissions is reduced and, thus, the energy consumption is also reduced. Data compression is another interesting topic in WSN research areas. A sensor node may collect many data records and send all the records to a target node at a predefined time. The results presented in [
24] show that the optimal parameters can be designed for compression on a TI MSP430 series, which runs on a fixed operating clock frequency. The energy efficiency on an MCU-based platform without the energy consumption of the radio frequency (RF) circuit was presented in [
25]. The RF part of a sensor node receives energy from the RF harvester circuit and does not consume any of the battery’s energy, while the MCU, which has to consume energy supplied by a battery, is in deep sleep mode and waits for an interrupt signal from the RF circuit.
Thus far, in the literature no studies exist that focus on saving energy by considering the operating clock frequency of the MCU. In some MCUs that contain a phase lock loop (PLL), the user can set the operating clock frequency dynamically to achieve the desired performance. From datasheets and experiments, we found that an increase in the operating clock frequency leads to an increase in the current consumption. However, the current consumption does not increase at the same rate as the operating clock frequency. This is because an MCU contains many components, the current consumption of which is either dependent on or independent of the operating clock frequency. The relation of the current consumption of no-wait state instruction sets to the operating clock frequency [
26] can be estimated by
, where m is a constant value and depends on the MCU architecture,
is the operating clock frequency, and
is the current consumption of the MCU, which is independent of the operating clock frequency. If, for example, the operating clock frequency is increased two-fold, the increase in current consumption is less than two-fold, whereas, the application code can be completed more than two times faster. This means that if the application code contains no wait-state instruction sets, the total energy consumption of the application code can be reduced if the MCU operating clock frequency is higher.
Normally, the processing of a sensor node can be divided into three steps: (1) retrieve the data from the sensor; (2) process the data; and (3) transmit the data via wireless communication. The application codes in Steps 1 and 3 contain a wait-state instruction set, because of the delay time and waiting time in the data bus. In this processing period, we can set the MCU operating frequency to the lowest value, but the data bus peripheral still operates correctly. In Step 2, the code contains a no-wait instruction set. In this period, we set the MCU operating frequency to the highest value to save energy. In this paper, a technique for switching the MCU operating clock frequency is newly proposed in order to reduce the energy consumption of MCU-based sensor nodes. The experimental results show that the proposed technique can reduce the energy consumed more effectively than a fixed operating clock frequency in many applications, e.g., JPEG compression, cyclic redundancy check (CRC), and the Lempel–Ziv–Oberhumer (LZO) method. The results confirm that this technique can be used to improve the energy saving of MCU-based sensor nodes. It has two major attractive advantages: low cost and the upgraded flexibility of the platform.
Notations: there are many technical terms used as acronyms in this paper.
Table 1 is presented in order to improve the readable quality of this paper.
2. Clock-Frequency Switching Technique
A high performance MCU running at high speed always contain a phase lock loop (PLL) unit. The PLL boosts input frequency to a higher frequency, e.g., from 12 MHz to 72 MHz. It is the responsibility of the designer to choose an appropriate operating frequency. For example, the MCU must operate at 48 MHz to provide appropriate universal serial bus (USB) operation, regardless of the input frequency.
Some applications do not need to run at a specific frequency. In the case of sensor nodes, we attempt to keep the clock frequency of the MCU as low as possible to maintain a low-level current consumption. This is because many sensor nodes contain a much shorter time for data acquisition than for data transmission. However, in the case of a long data task, it is possible that the processing time may be close to or greater than the transmission time. The reduction in the energy consumption for such a long data task affects the total energy consumption of the sensor node.
The energy consumption of a fixed frequency can be described as:
where
is the energy required for data processing and
is the energy required for data transmission.
The energy required by a typical sensor node for processing is very small compared with that required for transmission energy, e.g., reading the analog input from the analog input pin of the MCU takes a few milliseconds. The value of the term is thus very small as compared to that of . However, in the case of a long data processing time, such as that required for image compression, data integrity checking, and data compression, it takes more time to complete the processing and thus the term is the dominant term of the total energy consumption. In a fixed frequency platform, such as a low cost 8-bit MCU that does not contain a PLL unit, one means of reducing the processing energy is to improve the instruction code or acquire an off-the-shelf module to provide better energy consumption; however, the cost of the node is also increased.
An MCU that contains a PLL unit cannot exploit the benefits of a frequency-switching technique that allows the MCU to operate at high frequency in the data-processing period and then return to low-frequency operation for the data transmission period. The relation between the execution time and the operating frequency is:
where
is the execution time,
is the constant value depending on the MCU architecture, and
is the operating frequency.
When the operating frequency is increased, the execution time is decreased. However, from many datasheets and experimental results, we found that the current consumption is increased as a function of the operating frequency. The relation is:
where
is the current consumption of the MCU at the operating frequency,
is the multiplier of the new higher operating frequency and
> 1, and
is a low operating frequency of the MCU.
The processing energy during
is:
The processing energy at high frequency in terms of low frequency is:
The processing energy at low frequency is:
Finally, a comparison of the energy consumed at high frequency (5) and at low frequency (6), on the left and right side of (7), respectively, reveals that less energy is consumed at the higher frequency.
In the transmission part, the transmission energy of the MCU is the energy expended when the MCU transmits a data packet to a target node successfully; that is, the sender receives an acknowledge packet of all the data packets that it sent. The transmission time period may vary depending on the conditions of the wireless networks, e.g., the number of hops, quality of signal, and level of noise. 802.15.4 PHY allows 127 bytes per packet at 2.4 GHz. The RF band rate is 250 Kbps. We assume the condition of the acknowledgement timing is the best case and the address length is 16 bit. The total duration of the transmission period is:
where
is the total transmission time in ms and
is the data size in bytes.
Then, the total energy consumed by the MCU for the best case transmission is:
where
is the transmission energy,
is the average current consumption of the MCU, and
is the supply voltage of the MCU, which is 3.3 V.
Now, suppose that only the data processing is considered and the data acquisition period is ignored. The energy consumption of data processing and transmission when the operation is fixed at a low frequency is:
where
is the energy consumed by the MCU operating at a fixed low frequency and
is the energy consumed by the PLL locked at a low frequency.
Next, the proposed technique allows the MCU to operate at high frequency during the data-processing period and then return to low-frequency operation during the data-transmission period. This is represented by
where
is the energy of the MCU when the frequency-switching technique is applied,
is the energy of the PLL locked at high frequency, and
is the energy of the PLL locked at low frequency.
It should be noted that there exists an issue based on (11): the data-processing period must not contain any wait-state instructions; if it does, the frequency-switching technique cannot be used to achieve energy reduction.
Figure 1 shows the difference between operating at a fixed frequency and when the frequency is switched. In the transmission period, the MCU always operates at the lowest frequency, because a wait-state is included in the communication with the transceiver. Some examples of applications that can benefit from the switching technique are cyclic redundancy check (CRC), image compression, and data compression. In this study, all three examples were implemented to validate the benefit of the proposed technique.
CRC is useful for checking data integrity. A sender node appends the CRC code at the end of the data packet. The receiver node receives packets and checks all the data packets that include the CRC code. If the resulting value is zero, this means the packet is valid and then the data packet is passed to the upper layer for further processing. The implementation of the CRC in this study was based on C programming, that is, a lookup table, because it offers the best MCU performance. There are various CRC polynomials that are suitable for each application [
27].
As an image-compression scheme, JPEG compression was selected for our demonstration, because JPEG is a popular image type widely used in many sensor node applications.
Finally, for data-compression, in this study the LZO method was selected because it requires a low memory footprint so that it is suitable for an MCU-based platform. LZO compression is lossless data compression, which allows the receiver to receive data that are exactly the same as the original data transmitted by the sender.
3. Experimental Details
3.1. Hardware
The ARM7 MCU family, LPC2387, was selected for use in all experiments. This MCU has a PLL unit that can boost input crystal frequency up to 72 MHz. The MCU has an Static RAM (SRAM) of 64 K bytes for general purpose memory. This SRAM is used for many data-processing operations. The experimental environment is shown in
Figure 2. The direct current (DC) input voltage power supply was stepped down to 3.3 V to supply the MCU and the MAX232. RS-232 communication was employed to debug the MCU and to set the parameters, such as data length, for the MCU operation for each experiment. The current consumption of the MCU was measured by a simple resistor in series with the current path to the ground. A resistor value of 0.5 ohm was selected for all experiments. Note that the resistor value should be kept as low as possible, so that it does not affect the voltage drop across the resistor, which may cause the MCU to stop operating.
The voltage across the resistor was amplified to the appropriate level so that it could easily be analyzed by the digital oscilloscope. In our experiment, the amplify gain was set to 50. The USB port from the digital oscilloscope was for data transfer/setup, so that the data points could easily be saved on the computer in many file different formats, including bmp and csv.
3.2. Software
The compiler suite used for compiling the source code was ARM with GNU Compiler Collection (GCC). This is freeware that has a command line style. First, the program initializes scripts, which are implemented in assembly language. These initializing sections set up the stack for each operation mode of the Acorn RISC Machines (ARM) processor, clear the memory, and then jump to the main function.
The main function is written using C programming. It contains one-time initialized code and continues with forever loops. In the initial section, it sets a sleep mode, real-time lock (RTC) for wakeup period, memory, and universal asynchronous receiver-transmitter (UART), and then, waits for a command string from the PC. The command string contains parameters, e.g., data size and quality. After receiving a command string, the MCU goes to sleep mode with a periodic wakeup periodically 15 s for energy measurement. The parameters of the MCU are as follows.
Exp: experimental applications: CRC-8, CRC-32, JPEG, and LZO.
FsEn: operating modes: either the frequency-switching technique or a fixed frequency.
Len: data length for CRC-8 and CRC-32.
Qual: quality of compression for JPEG.
TxEn: choice of only data processing or including data transmission.
To measure the amount of energy, the MCU is woken up every 15 s and then the PLL is set, as shown in
Figure 1.
When the MCU is woken up from the sleep mode, it sets the PLL according to the FsEn parameter. If the value of FsEn is zero, the MCU operating frequency is set to 4 MHz. This is the lowest frequency for this MCU that allows communication to be operated correctly. If the value of FsEn is 1, the MCU operates with the frequency-switching technique and the operating frequency is set to 72 MHz, which is the maximum frequency for this MCU. After the PLL has been locked, the MCU runs the code according to the Exp parameter.
If the Exp parameter is CRC-8 or CRC-32, the code is run using the Len parameter. If Exp is JPEG, the code is run using the Qual parameter. If Exp is LZO, no additional parameters are needed, because the data size is fixed to 500 bytes.
The final parameter is TxEn. If its value is zero, the MCU goes to sleep mode immediately after completing a data processing operation. If the value is 1, the MCU performs a transmission process to send data to the target node. The time spent during this period is according to the parameter Len in (4) for CRC-8 and CRC-32. If Exp is JPEG, Len is assigned a compressed image data length. If Exp is LZO, Len is assigned the compressed data length of sample data records.