|Home Analog Devices Feedback Subscribe Archives 简体中文 日本語|
Full-Featured Pedometer Design Realized with 3-Axis Digital Accelerometer
Today, advanced pedometers rely on microelectromechanical systems (MEMS) inertial sensors and sophisticated software to detect true steps with high probability; MEMS inertial sensors permit more accurate detection of steps and fewer false positives. Taking advantage of the low cost and minimal space- and power requirements of MEMS inertial sensors, pedometers are being integrated into an increasing number of portable consumer electronic devicessuch as music players and mobile phones. The small, thin, low-power ADXL335, ADXL345, and ADXL346 3-axis accelerometers from Analog Devices are very suitable for such applications.
This article, based on a study of the characteristics of each step a person takes, describes a reference design using the 3-axis ADXL345 accelerometer in a full-featured pedometer that can recognize and count steps, as well as measure distance, speed, andto an extentcalories burned.
The ADXL345's proprietary (patent pending), on-chip, 32-level first-in, first-out (FIFO) buffer can store data and operate on it for pedometer applications to minimize host processor intervention, thus saving system powera big concern for portable devices. Its 13-bit resolution (4 mg/LSB) allows pedometers to even measure low-speed walking (where each step represents about 55 mg of acceleration change) with reasonable accuracy.
Figure 1. Definition of each axis.
Let's think about the nature of walking. Figure 2 depicts a single step, defined as a unit cycle of walking behavior, showing the relationship between each stage of the walking cycle and the change in vertical and forward acceleration.
Figure 2. Walking stages and acceleration pattern.
Figure 3 shows a typical pattern of x-, y-, and z- measurements corresponding to vertical, forward, and side acceleration of a running person. At least one axis will have relatively large periodic acceleration changes, no matter how the pedometer is worn, so peak detection and a dynamic threshold-decision algorithm for acceleration on all three axes are essential for detecting a unit cycle of walking or running.
Figure 3. Typical pattern of x-, y-, and z accelerations measured on a running individual.
Figure 4. Digital filter.
Figure 5 demonstrates the filtered data from the most active axis of a pedometer worn by a walking person. The peak-to-peak value would be higher for a runner.
Figure 5. Filtered data of the most active axis.
Dynamic Threshold and Dynamic Precision: The system continuously updates the maximum and minimum values of the 3-axis acceleration every 50 samples. The average value, (Max + Min)/2, is called the dynamic threshold level. For the following 50 samples, this threshold level is used to decide whether steps have been taken. As it is updated every 50 samples, the threshold is dynamic. This choice is adaptive and fast enough. In addition to dynamic threshold, dynamic precision is also used for further filtering as shown in Figure 6.
Figure 6. Dynamic threshold and dynamic precision.
A linear-shift-register and the dynamic threshold are used to decide whether an effective step has been taken. The linear-shift-register contains two registers, a sample_new register and a sample_old register. The data in these are called sample_new and sample_old, respectively. When a new data sample comes, sample_new is shifted to the sample_old register unconditionally. However, whether the sample_result will be shifted into the sample_new register depends on a condition: If the changes in acceleration are greater than a predefined precision, the newest sample result, sample_result, is shifted to the sample_new register; otherwise the sample_new register will remain unchanged. The shift register group can thus remove the high-frequency noise and make the decision more precise.
A step is defined as happening if there is a negative slope of the acceleration plot (sample_new < sample_old) when the acceleration curve crosses below the dynamic threshold.
Peak Detection: The step counter calculates the steps from the x-axis, y-axis, or z-axis, depending on which axis's acceleration change is the largest one. If the changes in acceleration are too small, the step counter will discard them.
The step counter can work well by using this algorithm, but sometimes it seems too sensitive. When the pedometer vibrates very rapidly or very slowly from a cause other than walking or running, the step counter will also take it as a step. Such invalid vibrations must be discarded in order to find the true rhythmic steps. Time window and count regulation are used to solve this problem.
Time window is used to discard the invalid vibrations. We assume that people can run as rapidly as five steps per second and walk as slowly as one step every two seconds. Thus, the interval between two valid steps is defined as being in the time window [0.2 s to 2.0 s]; all steps with intervals outside the time window should be discarded.
The ADXL345's feature of user-selectable output data rate is helpful in implementing the time window. Table 1 shows the configurable data rate (and current consumption) at TA = 25°C, VS = 2.5 V, and VDD I/O = 1.8 V.
Table 1. Data Rate and Current Consumption
This algorithm uses a 50-Hz data rate (20 ms). A register named interval records how many times the data have updated during the two steps. If the value of interval is between 10 and 100, it means that the time between two steps is in the valid window; otherwise, the interval is outside the time window and the step is invalid.
Count regulation determines whether steps are part of a rhythmic pattern. The step counter has two working states: searching regulation and found out regulation. When the step counter starts working, it works in searching regulation mode. Suppose that in regulation exists after four continuous valid steps. Then the result is refreshed and displayed, and the step counter will work in found out regulation mode. Working in this mode, the step count would be refreshed after every valid step. But if even one invalid step is found, the step counter will return to searching regulation mode and search for four continuous valid steps.
Figure 7 shows the algorithm flowchart for the steps parameter.
Figure 7. Steps parameter algorithm flowchart.
Distance per step depends on the speed and the height of user. The step length would be longer if the user is taller or running at higher speed. The reference design updates the distance, speed, and calories parameter every two seconds. So, we use the steps counted in every two seconds to judge the current stride length. Table 2 shows the experimental data used to judge the current stride.
Table 2. Stride as a Function of Speed (steps per 2 s) and Height
An interval of 2 s can be calculated accurately from the number of samples. Referring to the 50-Hz data rate, the processor can send the corresponding command to the PC every 100 samples. The processor uses a variable named m_nLastPedometer to record the step count at the beginning of every 2-s interval and a variable named m_nPedometerValue to record the step count at the end of every 2-s interval. Then the steps per 2 s is calculated by m_nPedometerValue minus m_nLastPedometer.
Although the data rate is 50 Hz, the ADXL345's on-chip FIFO makes it unnecessary for the processor to read the data every 20 ms, minimizing the burden on the host processor. The buffer has four modes: bypass, FIFO, stream, and trigger. In FIFO mode, data from measurements of the x-, y-, and z-axes are stored in FIFO. When the number of samples in FIFO equals the level specified in the samples bits of the FIFO_CTL register, the watermark interrupt is set. As previously discussed, people can run as fast as five steps per second, so the result should be refreshed every 0.2 s to show the real-time result. The processor only needs to fetch data from the ADXL345 every 0.2 s; it can be awakened by watermark interrupt. The other functions of the FIFO are also very useful. Using trigger mode, the FIFO can let us know what happens before the interrupt. Since the proposed solution does not use the other FIFO functions, they will not be discussed any further.
Table 3. Calories Expended vs. Running Speed
From Table 3, we get (3).
The unit of the speed parameter used above is m/s; converting km/h to m/s gives Equation 4.
The calories parameter would be updated every 2 s with the distance and speed parameters. So, to account for a given athlete's weight, we can convert Equation 4 to Equation 5 as indicated. Weight (kg) is a user input, and one hour is equal to 1800 2-second intervals.
If the user takes a break in place after walking or running, there would be no change in steps and distance, speed should be zero, then the calories expended can use Equation 6 since the caloric expenditure is around 1 C/kg/hour while resting.
Finally, we can add calories for all 2-second intervals together to get the total calories expended.
Figure 8. Simplified schematic of hardware system.
Figure 9. Test demo when the user is walking or running with the pedometer.
A couple of further ideas: If the application is extremely cost-sensitive, or if an analog-output accelerometer is preferred, the ADXL335a small, thin, low power, complete 3-axis accelerometer with signal-conditioned voltage outputis recommended. If PCB size is of critical importance, the ADXL346 is recommended. This low-power device, with even more built-in features than the ADXL345, is supplied in a small, thin, 3-mm × 3-mm × 0.95-mm plastic package. Its supply voltage range is 1.7 V to 2.75 V.
Copyright 1995- Analog Devices, Inc. All rights reserved.