A pedometer is a device that counts the number of steps taken by a person and calculates the distance traveled by multiplying the number of steps by the length of the step. Here's a design solution for building a pedometer using the AVR MCU. The circuit not only combines all of the features of the traditional pedometer, it saves power (low power consumption is a must for a portable device) as well. The design also includes instantaneous speed measurement.
Traditional Features: We designed the pedometer using an AVR AT90S-2313 MCU, whose connection details (components and values) are shown in the figure. Different pushbuttons switch the display between steps, distance, and speed. Additional switches reset the step count, set the step length, and start/stop step counting. A step is sensed (and counted) by the up-down motion of the center of gravity every time the person wearing the pedometer takes a step. A mercury switch or any other mechanical contraption may be used to register a step, which sends a positive edge onto the INT0 line on every step. We used a 16- by 1-line LCD readout (as opposed to an LED display) because of the power-saving requirements.
The pushbuttons are constantly polled in software and debounced, and a subroutine is dedicated to implement each operation. The number of steps, distance, and speed are calculated, and the display is refreshed through an interrupt-service routine when a rising edge is observed on the interrupt pin (INT0).
Different parameter ranges were ascertained according to practical requirements. The present design could feed in a step length of 0 to 255 cm (average step length of a human being = 60 cm) and measure 0 to 65,535 steps (a distance of approximately 39 km) as well as instantaneous speed in the 9- to 65,535-cm/s range.
Power-Saving Mechanism: Power consumption is one of the most important parameters in the industry today. Here's an example of how one can design a power-efficient solution, keeping in mind the practical usability of the product and basic microprocessor programming.
In the case of a pedometer, once users put it on their belt and start walking, there's no need to use its buttons until they want to either change the display mode or reset the count, etc., again. So polling of the buttons isn't required at this time. However, counting and displaying steps, distance, or speed are required. To do this, we simply put the processor in the sleep mode if no button is pressed for 10 seconds (as an indication that the pedometer has been put on the belt).
In the sleep mode, there's no code execution, but interrupts are registered and serviced. In other words, the pedometer continues to count and display steps/distance/velocity. The processor can be reset to make all of the pushbuttons functional again, restoring its count status, value, display, etc.
In the current design, the pedometer draws 4.70 mA in sleep mode compared to 12.65 mA in normal mode. Therefore, the power requirement (where VIN = 6 V) falls down to 37.87% (25.2 mW) of the earlier value (75.9 mW). Also, because the pedometer is worn on the belt most of the time during use, this power saving translates to a similar saving in energy. This will be highly beneficial because the pedometer is a portable device with on-board power.
Enabling Speed Measurement: Speed is easily calculated by measuring the time between two interrupts. The step length is divided (in software) by this time to get the speed. Time between interrupts is measured by enabling the MCU's timer0 register, which keeps on incrementing in hardware every x (programmable) clock pulses.
We used all of the ideas presented here to build and design a pedometer that worked satisfactorily. The source code is included with the online version of this article at www.elecdesign.com. I would like to thank D.V. Gadre for helping me with queries and suggesting ideas during the pedometer's design process.