Anda di halaman 1dari 15

PEDOMETER

REPORT

ARDUINO CODE FOR MEASURING STEPS


ALEJANDRO BENITO
ALBA TOBAJAS
MARTA GAITAN
SOFIA GIL

INDEX
INTRODUCTION ......................................................................................................... 3
HARDWARE ............................................................................................................... 6
ALGORITHMS AND SOFTWARE .................................................................................. 7
EXPERIMENTS ......................................................................................................... 11
Unexpected problems ..................................................................................................... 11
Previous experiments. ..................................................................................................... 12
Evaluation experiments: .................................................................................................. 13
CONCLUSIONS ......................................................................................................... 14
BIBLIOGRAPHY ........................................................................................................ 15

INTRODUCTION
As technology keeps developing so does our need to not only live, longer but also, in a
more comfortable way. Thanks to this there are available in the market a lot of
different tracking devices. During the past few weeks we have developed a tracking
system.
The aim of this report is to explain the development and work of our pedometer.

Objectives:

The purpose of this project is to develop a pedometer that is able to measure the steps
done at different speed. This pedometer must be also able to discard “fake positives”
such as jumping or bending the knee without generating any movement at all.

The variable applied in the accelerometer in order to apply when the individual is
moving is the module.

This is the formula applied:
double module = sqrt(pow(xG, 2) + pow(yG, 2) + pow(zG, 2));

The module is used as it is independent to the orientation of the accelerometer,
therefore no matter in which position the accelerometer is in order to obtain the data.

As we are measuring an analog signal, this signal is extremely affected to any kind of
noise around. Such as, nearby electric currents or the Arduino board itself. Therefore,
a filter must be applied, in order to get rid of all this unwanted info.

In this project, an average filter is applied. This is the easiest filter to use in order to
obtain a clean output without unwanted noise. The filter will get a number of inputs
and will generate an average based on this series of input, which will eventually be the
output.


In this image, it is written down the general form on of the filter itself. Being M the
number of samples taken for doing the average value and being y the output
generated. [1]

3


This image is an example of the formula being applied. Here one output will be
generated out of five different inputs.





Here these images show that the left one is an uncleaned signal and the one on the
right is an image with the filter being applied. But there is a drawback when applying
this kind of digital filters. In this case when the average number applied is big
(depending obviously in what is being measure). In our specific case, this number was
around 9. The filtered value was smooth, but apart from deleting the unwanted noise
also some valuable info was lost in the process.


Even though this filter is good in order to clean the noise of a signal it is not

4
appropriate for frequency domain encoded signals. This is due to the fact that,
when the frequency sample is met, in the case of the 3 point is in the 0,33
more less. From that point on the filter will alter heavily the frequency.
Furthermore, the more points are applied the quicker the alterations the signal will
receive and the bigger these alterations will be.








































5
HARDWARE
An accelerometer is an electromechanical device that measures acceleration forces.
These forces may be static or dynamic. Accelerometer sensors commonly measure the
displacement of a mass with a position measuring interface circuit. This measurement
is converted into a digital electrical signal through analog-to-digital converter (ADC) for
digital processing. [2]


By measuring the amount of static acceleration due to gravity, it can find out the angle
the device is tilted at with respect to the earth. By sensing the amount of dynamic
acceleration we can analyse the way the device is moving. [3]
The basic accelerometer operation is the Newton’s second law of motion where the
acceleration of a body/mass is directly proportional to the net force in the same
direction acting on the body. It is important to know that the accelerometer really
measures force, not acceleration. The accelerometer has a sensing capacitance in which
the acceleration is related to change in the capacitance of a moving mass, this technique
is known for its high accuracy, stability, low power dissipation, and a simple structure to
build.
To select an accelerometer, it is important to take into account its key characteristics,
such as the bandwidth, the sensitivity, the voltage noise, the zero-g voltage, the
frequency response and the dynamic range.
The chosen accelerometer is the MMA8452Q which is a smart low power, three-axis,
capacitive MEMS accelerometer with 12 bits of resolution. It is packed with embedded
functions with flexible user programmable options, configurable to two interrupts pins.
It has user selectable full scales of ±2g/±4g/±8g with high pass filtered data as well as
non-filtered data available real time.


Accelerometers are generally low-power devices. The required current typically falls in
the micro or milliamps range, with a supply voltage of 5V or less, in our case we are using
3,3V.
In this project the goal is to measure steps with the accelerometer. There are different
ways to place it to measure all the steps such as the hand, the hips, the belly button, the
leg… After several trials it was decided what would be a proper spot to place the device.
This is, the belly button. Is a proper place to install the accelerometer and count steps,
as the gravity centre is near this point when a person is stand up or walking.
If the accelerometer is placed, for example in the hand, the obtained result is how many
times the hand is moved, as if they were steps. In the ‘experiments’ paragraph is going
to explain in a wider detail why it should be placed in the belly button.

6
ALGORITHMS AND SOFTWARE
For developing this project, a state machine is built to differentiate the outputs and the inputs
of each state. There are three states, the initial one, that is when the accelerometer does not
move, so the result is that is not measuring anything. If mysignalF is bigger than zero, it goes to
the positive_signal state, mysignalF is the filtrated module of x, y and z coordinates. When the
input mysignalF is less than zero, the next state is negative_signal. More accurate description
about the code is written below.



If mysignalF > -0.05 à old_max = maximo;
maximo = -1.0;

If mysignalF > maximo à maximo = mysignalF;





If mysignalF > 0.05à old_min = minimo;
minimo = 1.0;

If mysignalF < minimo à minimo = mysignalF;
if (flag2 == 0 && (old_max - old_min > 0.20)) {

if ((millis() - tpaso) > 500) {
pasos++;
tpaso = millis();
}

flag2 = 1;
}


When the state is in positive signal and mysignalF is bigger than -0.05, the old maximum
becomes the maximum, and the maximum is -1 (that value was pre-set by trial and error, it
should be adjusted depending on the person). In the opposite, when mysignalF is bigger than
the actual maximum, the maximum is set to the value of mysignalF. The same happens more
or less with the minimum, the only difference is that if it finds a minimum and a maximum,
setting a difference of time, the number of steps will be increased in one. The time when you
did the last step, becomes the reference for the new step, and if the difference is smaller than
half second, that step will not be counted. [5]

7
As shown in these two graphs of steps (one from analog devices and the other one from a
Matlab code), it can clearly differentiate one maximum and one minimum peak for each step.
In our code, when the maximum and the minimum are found, the number of steps are
increased in one. [1] [4]

8


In the next page some resulting graphs of the code are showed and explained.

Here both signals are represented, the blue one is the signal without any filter. In these graphs
the difference between the filtrated one and the non-filtrated is so clear, the filtered one has
less peaks, so it is easier to count a step.

9

To count a step, the maximum and the minimum are checked and the number of steps is
increased in one. If the difference is less than a value, the program takes away that step. Also if
the program finds two maximums and two minimums in less than half second, just one step is
counted.

The problem of serial plotter of the Arduino, is that it auto-adjusts the values of the graph. If
more than one graph is represented, the axis cannot be seen clearly, so the maximums and the
minimums are not well differentiated.

10
EXPERIMENTS
Unexpected problems
Along the experiment there were some issues whether with the hardware, as
with the software. The problems were detected testing our code, some of them were
detected easily, but some others not.

The first of the issues were with the calibration, since it was hard to locate in the
code. At first the calibration code were included into the loop, but at the end was
decided to be locate outside the loop. This was because the calibration is needed just
once, and not every time the accelerometer make a measurement, so a different
function was made, that we call in the setup. This make the code clearer and elegant.

When the code was tried in the
Mac, there were some troubles with the
graphics, because the program used
(Serial Chart) did not work in OS, so the
experiments were made in a Windows
laptop. But finally found out that the
serial plotter from Arduino works in OS.
Other error was the wire
connection, since every time we move
the device, some wires get disconnected.
To solve this, a red tape was used to fix every wire, and the accelerometer to the Arduino
board.
The code to count the steps were complex at first, since the code did not count
the steps properly. Trying to found the reason, a damage was discovered on the
hardware, so it was changed. The Arduino board was change once, and the
accelerometer twice, before the code works.
To make the count code properly was a problem, because of the code. At first,
each movement that the accelerometer measures, the steps increases in one, but this
method count more steps than expected. Changing the code, at the end the count of
the steps depended on the time and on the graphics. With a flag for the change from
positive to negative on the graphics of the Serial Plotter, so each time the graph change
from positive to negative, it is a step.
Double steps were detected because of the force applied on the steps, or
because the damping of the shoes. For this reason, the counting of steps change to
depend on the time, so if the accelerometer goes from positive to negative in less than
five hundred milliseconds, then it does not count a step.

Because of the different person, and shoes used, the threshold had to change
many times, until one that works properly was found, that was other issue, because at
first we did the accelerometer detect some steps, those with more force, but some
others not.
As it was say before, the accelerometer and the Arduino board have to be
change. This was because of the junctions. There were some junctions on the Arduino
board that were damaged, so they did not work properly. The same happened with the

11
accelerometers, some of them had damaged junctions, and some of them did not
measure properly.
Other found error was the Bias values, since the first values did not correspond
with the real values, so when the device count the steps, it have wrong values.


Previous experiments.

In the Electronics’ subject the group members made an accelerometer practice,
in which they saw how it works, and how the axes were placed.
By the way the accelerometer moves, the values change. To prove if it works
properly with the xV, yV, and zV values, those values were printed, and check that
were equals to the calculated Bias, 1.64 in the case of the x; 1.65, in the case of the y,
and 1.67 in the case of the z.
If the accelerometer wasin the x axe, the xV value must be zero, and the yV and
zV value must b 1.65 and 1.67 respectively. If it was on the y axe, then the yV value will
be zero, and the xV and zV will be 1.64, and 1.67. And, for the z axe, will be de zV value
zero, and the xV and yV values will be 1.64 and 1.65.


In Sensors and actuators’ subject the group made a practice of a button and a
remote control, so use that practice to implement the control for activate and
deactivated the device was decided.
The reason to use a remote control, because it was easiest to implement for us,
and it will be a little different than use the button.
Finally, the control be able to stop, and run the device, with no issues, using the
code of the practice.





12

Evaluation experiments:

Different experiments were make, with the members of the group.
The first experiment was with a different threshold, and the result were wrong. Each
member walks 30 steps through corridor. In that experiment only Victor and Alejandro
had god results, but Marta, Alba and Sofia had wrong values. So the threshold had to
change.
The second experiment was jumping. The results show that when a member jump, the
accelerometer counts 3 steps, instead of one. One when the person bends, other
when the person jumps, and other when the person lands.
The third experiment were running, the results where that the accelerometer count
more steps, because the movement of the accelerometer is bigger.
This time the threshold was 0.05, and the experiments were: walk 30 steps, walk 60
steps, walk 10 steps quickly, and walk 10 steps slowly.
30 steps’ experiment:
Name Walk steps Count steps (1st) Count steps (2nd)
Alba 30 29 33
Alejandro 30 31 30
Marta 30 26 29
Sofía 30 29 30

60 steps’ experiment:
Name Walk steps Count steps
Marta 60 58
Sofía 60 57

10 slow steps’ experiment:
Name Walk steps Count steps
Marta 10 (slow) 10
Sofía 10(slow) 9

10 fast steps’ experiment:
Name Walk steps Count steps
Marta 10 (fast) 7
Sofía 10 (fast) 7

As the table show, this time the results were not good. It was expected to have more
steps, because the person walks faster and the steps will have more force, but while
the experiment was make, the member that was looking at the monitor observes that
while the other member was walking the accelerometer did not count the two or three
first steps.





13
CONCLUSIONS
The main difficulty doing the project was hardware problems, Arduino board changes
were done because some of the ports were damaged so some changes were made in
the connections until the problem was found, the damaged part was the Arduino
board. Wires were replaced because they were damaged also. The accelerometer was
giving some problems in the measurements in the different positions so a change was
done on it twice until the correct measurements were found.
Writing the steps source code in Arduino the threshold values were not taken into
account so it did not count the precise steps. The way to adjust the threshold was
found taking account the minimum and the maximum peak of the steps and when it
crosses the threshold it count a step. A defined time was added to remove false
positives.
Doing the experiments, the perfect place to put the accelerometer was found and it
was the belly button because is human gravity centre. At first, the accelerometer was
placed in the hips but it lose so much steps in the opposite hip the accelerometer was
placed.
In the Median filter has a big value that can lose a lot of important information.
Something to improve that error that can be done is in previous experiments try to
implement the steps’ velocity, frequency or the calories to be more precise in the
median filter and have more real values without losing information.
In the experiment of 10 fast steps the expected values was more steps than the fixed
steps, but the results are the opposite, it count less st [5]eps because the first step was
not taken into account.

Something that can done to improve that project would be place the Arduino board
with the accelerometer and all the connexions in a box and tied all together, because
one of the problems that was found is the disconnection of the wires while doing the
experiments. The remote control will be put outside the box to turn on or off easily.















14
BIBLIOGRAPHY

[1] S. W. Smith, «Analog Devices,» 1999. [En línea]. Available:
http://www.analog.com/media/en/technical-documentation/dsp-
book/dsp_book_Ch15.pdf. [Último acceso: 16 Diciembre 2016].
[2] M. Dadafshar, 17 Marzo 2015. [En línea]. Available:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/5830. [Último
acceso: 18 Diciembre 2016].
[3] «Sparkfun Accelerometer,» [En línea]. Available:
https://www.sparkfun.com/products/12756. [Último acceso: 18 Diciembre 2016].
[4] J. Scarlett, «Analog Devices,» 19 Noviembre 2007. [En línea]. Available:
http://www.analog.com/media/en/technical-documentation/application-
notes/47076299220991AN_900.pdf. [Último acceso: 16 Dicembre 2016].
[5] N. Zhao, «Full-Featured Pedometer,» 1 Junio 2010. [En línea]. Available:
http://www.analog.com/en/analog-dialogue/articles/pedometer-design-3-axis-
digital-acceler.html. [Último acceso: 16 Diciembre 2016].


15

Anda mungkin juga menyukai