Arduino Projects    |   Raspberry Pi  |     Electronic Circuits   |   Electronics Reference Design Library  |   AVR    |    PIC    |    8051    |    Electronic Projects

Microcontroller Based Accelerometer

Description

Contributor: 
Ashish Chauhan, Aurangabad, India

 

 

3.3.1.1.3 Pin Description: 

 

              Table (3.2) – Pin description of sensor MMA7260Q

 

 Pin No.
 Pin Name
 Description
1
g-select1
Logic input pin to select g-level
2
g-select2
Logic input pin to select g-level
3
VDD
Power supply input
4
VSS
Power supply ground
5-7
N/C
No internal connection. Leave unconnected
8-11
N/C
Unused for factory trim. Leave Unconnected
12
Sleep Mode
Logic input pin to enable product or sleep mode.
13
Zout
Z direction output voltage
14
Yout
Y direction output voltage
15
Xout
X direction output voltage
16
N/C
No internal connection. Leave unconnected
           
The given table shows us the pin configuration of MMA7260Q i.e. nothing but the Pin No. also a Pin Name and the Description of the Pin. So we can understand the sensor and configure and interface with the controller.

3.3.1.1.4 Pin-out of MMA7260Q:
The below diagram shows the Pinout diagram of MMA7260Q. So we can easily under-stand how the MMA7260Q sensor looks like and from the pinout diagram shows the where the pins comes and which pins interfacing with the microcontroller.
Because of sensor MMA7260Q small size our project size will be in small size. In this project we are using sensor MMA7160Q there are many pins which are not in using purpose so when we implementing the project that time we know that the how to put the sensors on the PCB board and easily interface with the microcontroller and making the project in less size on PCB.

 

Microcontroller based Accelerometer8

 

Figure (3.5) – Pinout of MMA7260Q

 

 
3.3.1.1.5 Circuit Connection of Sensor MMA7260Q:
 Microcontroller based Accelerometer9

 

Figure (3.6) – Accelerometer Sensor with Recommended Circuit Diagram

 

 
The upper figure shows the Accelerometer sensor of recommended circuit diagram than we can understand the where the connection comes from and the connection goes with the microcontroller and other circuitry parts.
3.3.1.1.6 MMA7260Q Interface with Microcontroller:
The given figure shows the PCB interface diagram with the microcontroller. So we can easily understand that the how the interface comes between the sensor MMA7260Q and the ATMega 89C51 microcontroller.
We can also see that which port of microcontroller is connected with the pins of the sensor. Here we are using the power supply for given the input power to the microcontroller as well as sensor also.
 Microcontroller based Accelerometer11

 

Figure (3.7) – Recommended PCB interface with microcontroller

 

 
3.3.2 ADC 0809 Interface with 89C51:
3.3.2.1 An 8-Bit ADC:
An 8-bit ADC cuts 3.3V supply into 255 steps of 12.9mV for each step. Therefore, by taking one ADC reading of the MMA6260Q at 0g (0°of tilt for an x-axis device) and 1g (90° of tilt for an x-axis device), would result in the following:
0°: 1650mV + 12.9mV = 1662.9mV, which is 0.92° resolution
     90°: 2450mV+ 12.9mV = 2462.9mV, which is 6.51° resolution
Due to the nonlinearity discussed earlier, you will see that the accelerometer is most sensitive when the sensing axis is closer to 0°, and less sensitive when closer to 90°. Therefore, the system provides a 0.92 degree resolution at the highest sensitivity point (0 degrees), and a 6.51 degree resolution at the lowest sensitivity point (90°).
3.3.2.2 A 10-Bit ADC:
A 10-bit ADC cuts 3.3V supply into 1023 steps of 3.2mV for each step. Therefore, by taking one ADC reading of the MMA6260Q again at 0g (0° of tilt for an x-axis device), would now result in the following:
0°: 1650mV + 3.2mV = 1653.2mV
90° 2450mV + 3.2mV = 2453.2mV
This results in a 0.229 degree resolution at the highest sensitivity point (0°) and a 3.26 degree resolution at the lowest sensitivity point (90°).
3.3.2.3 A 12-Bit ADC:
A 12-bit ADC cuts 3.3V supply into 4095 steps of 0.8mV for each step. Therefore, by taking one ADC reading of the MMA6260Q again at 0g (0° of tilt for an x-axis device), would now result in the following:
0°: 1650mV + 0.8mV = 1650.8mV
90°: 2450mV + 0.8mV = 2450.8mV
This results in a 0.057 degree resolution at the highest sensitivity point (0°) and 1.63 degree resolution at the lowest sensitivity point (90°). However, for 0.8mV changes, the noise factor becomes the factor to consider during design. How much noise the system has will depend on how much resolution you can get with a higher bit count.
3.3.3 LCD Interfacing:
One of the most common display devices attached to an 8051microcontroller is an LCD (Liquid Crystal Display). LCDs are a passive display. This means they do not emit light; instead, they use the ambient light in the environment. By manipulating light, they display images using very little power. LCDs are performed due to low power consumption and compact size. Liquid Crystal (LC) is an organic substance that has both a liquid form and a crystal molecular structure. In this liquid, the rod-shaped molecular are normally in a parallel array and an electronic field can be used to control the molecules.
Some of the most common LCDs connected to 8051 are 16*2 and 20*2 display. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines respectively.
 Microcontroller based Accelerometer11

 

Figure (3.8) – Diagram of LCD Display

 

3.3.3.1 Interfacing of LCD with 8051:
            The given figure shows the interfacing of LCD display with the 8051. The port 1 of the 8051 microcontroller is connected to 8 data lines i.e. DB0 to DB7. Here, there are another three control lines EN (Enable), RS (Register Select), RW (Read-Write) are connected to the Port 3 of microcontroller.
Microcontroller based Accelerometer12

 

Figure (3.9) – LCD interfacing with 8051
 

 

 

3.4 Nonlinearity:

 

As seen in Figure (3.10), the typical output of capacitive, micro-machined accelerometers is more like a sine function. The figure shows the analog output voltage from the accelerometer for degrees of tilt from -90° to +90°. The change in degrees of tilt directly corresponds to a change in the acceleration due to a changing component of gravity acted on the accelerometer. The slope of the curve is actually the sensitivity of the device.
As the device is tilted from 0°, the sensitivity decreases. You see this in the graph as the slope of output voltage decreases for an increasing tilt towards 90°. Because of this nonlinearity, the degree resolution of the application must be determined at 0° and 90° to ensure the lowest resolution is still within the required application resolution.
 Microcontroller based Accelerometer13

 

Figure (3.10) – Typical nonlinear output of X, Y and Z-Axis Accelerometers

 

 

3.5 Flow Chart:

 

The step counting algorithm is shown in Figure (3.11). When the pedometer application is started the steps counter variable and the holdoff counter variable are initialized to zero. For each new acceleration sample, if the holdoff counter is zero and the a? signal exceeds the threshold at, the steps counter variable is incremented and the holdoff counter is set to value -1.
Microcontroller based Accelerometer13

 

Figure (3.11) – Flow Chart of Acceleration

 

This holdoff value puts the algorithm in a state waiting for a sample that is not above the threshold. When this sample has been read the holdoff is set to a value N greater than zero. If the holdoff counter is greater than zero, the algorithm does not count steps but decrements the holdoff counter for each sample period until it is zero.
The purpose of the holdoff period is to prevent superfluous step counts for cases when there is ripple in the acceleration signal. In practice a value of 1 has been used for N with success. A value this small works because the ripple is typically small and there are no extra transitions of the acceleration signal across the threshold. Hysteresis could be used instead or in addition to the holdoff to improve rejection of noise and ripple.
Also, a more advanced algorithm could include smart filtering to reject false step counts. Such filtering typically introduces delays in the display of the step count because several steps must be processed to make a decision on validity. The NWSP step counter avoids advanced filtering to enable an instant display of steps and not to infringe on proprietary technology.
 

 

3.6 Circuit Diagram of accelerometer using sensor MMA7260Q

 

The figure in circuit diagram tab2 shows the circuit diagram of Accelerometer using the sensor MMA7260Q. It also shows that the appropriate circuit connection regarding the perfect acceleration of the all the three direction. In this circuit diagram we can also see and measure the vibration, shocks, heart beats and also step counting. Know the how the connection actual working with the sensors and the micro-controller also.
Here, the G-Select 1 and 2 pins are connect to the switch ports and we are given to 3V power supply than pin 3 and 4 are connected with the ground terminal and then pin number 13,14, and 15 are for the all three direction i.e. x-axis, y-axis and z-axis output signals. After that remaining all pins not connected and no internal connection over there leave them for un connected.

 

3.7 Proportional Result:
The step counter application was tested and the performance was evaluated. Figure (3.11) shows a set of acceleration signals for a short segment for one case where a subject was running. The x-axis is in the direction of the tangent of the forearm, the y-axis is parallel to it and the z-axis is perpendicular to it. Normally when a wrist-watch like device is worn tightly on the wrist and the arms are in a position for running, the x-axis of the device points downwards, the y-axis points forward in the running direction and the z-axis to the side.
The figure also includes the combined acceleration a?. The case in the figure shows an interesting phenomenon. During the first 4 seconds in the plot there is a strong signal from the x-axis sensor but in the latter part this signal has moved over to the z-axis sensor.
The reason for this is that the wrist device has been loosely fitted and has turned around the wrist during the running exercise to the side of the wrist, hanging on the downside of the arm. Each sharp spike in the waveforms of x- and y-axes corresponds to a combination of the heel strike in the gait cycle and the up–down movement of the body.
The heel strike signal is strongly softened by body spring–mass system when sensed on the wrist. On the y-axis a periodicity of half the frequency of the other axes can be observed. This is caused by the arm swinging forward and backward with the change in direction happening on each step.
This example shows that at least a sensor with two axes is needed to cover situations where the wrist device might turn around the wrist. As can be seen in the plot, the a? signal is insensitive to the change in the device orientation and has a fairly constant periodic acceleration signal with each step clearly distinguishable.
The NWSP pedometer demo application was intended for running exercise. Tests showed that the application does not count steps during walking. Figure shows the acceleration signals from the wrist during a walking exercise. The signals are very noisy and have low amplitude. From the z-axis signal some periodicity can be observed. This periodicity is caused by swinging motion of the arm and thus, the frequency is half of the step rate.
 Microcontroller based Accelerometer16

  Figure (3.13) – Acceleration signal during running

           
The combined acceleration signal a? has lost an obvious periodicity because noisy signals from x- and y-axes have been added. This makes it difficult to detect steps. In the plot around 10 seconds on the time line there are some disturbances corrupting the periodicity in axis z. This is a typical sporadic arm movement that occurs frequently while walking, making accurate step counting from the wrist very challenging for any activities other than running.
            A comparison was made against Nokia Step Counter application running on a Nokia N95 mobile phone as a reference. This application is believed to be very accurate and it is available for free from Nokia beta labs.
 Microcontroller based Accelerometer17

 

Figure (3.14) – Acceleration signal during walking

 

 
A small number of test users ran with the NWSP pedometer on the wrist and the N95 device in the pocket simultaneously counting the steps during short exercises of a few hundred steps. Results showed that the NWSP step counter acquired consistently around 30% fewer steps than the reference. This result was surprising as the contrary was expected. As there is no advanced filtering for rejecting false steps and no hysteresis to reject ripple and noise, it was expected that extra steps would be acquired by the NWSP. Also having a very low holdoff period could be expected to pass through some extra steps.
Measurements of accelerations from the wrist showed that steps can be identified from the acceleration signals. From running exercises the detection is very clear. From walking activity steps could be detected with some limited accuracy using proper algorithms. The NWSP step counting algorithm was designed for running exercise. This was done before the acceleration measurements were available and it was later verified to be functional in laboratory conditions. However, the real running test showed a significant loss of steps. The probable cause of loss of steps lies in the way the 3-axis accelerations are combined into one acceleration signal a?.
The sum of absolute values of the individual axes of acceleration may stay above the threshold at for a long time if there is interfering accelerations present from swinging arms, for example. Thus, steps are masked out by this interference. The problem could be remedied by raising the cutoff frequency of the high pass filters. As arm swinging has lower frequency accelerations than caused by the step impact it may be attenuated by the high pass filter. Another solution is to continuously monitor each acceleration axis separately and only use the one with clearest periodical signal as the source for step counting.
Reviews of pedometers have revealed very high inaccuracies in available devices based on acceleration sensors. To improve accuracy alternative sensing methods have been suggested, such as gyroscopes. As the NWSP includes gyro sensors, they could be utilized to improve the NWSP pedometer. Gyros are insensitive to linear acceleration and thus, interfering accelerations are suppressed. However, the heel strike or body up–down movement cannot be detected by this kind of sensor and the algorithm would have to rely on detecting arm swing.

 

 

 

 

Circuit Diagram

Circuit Diagram 2

Comments (8)

Nice to see this project by a

Nice to see this project by a student from BATU

 

i m too working on this type of project mma6361L

but i m geting problem in the adc interface 

so will u explain the acclerometer connected to the adc and how to read the data from  the adc to micro

 

Thank You

nice

nice

Thank you

Thank you

hi, i am using mma7361

hi, i am using mma7361 accelerometer.having problem with adc .wen i connect accelerometer to adc it doesnt show any output,but the analog output from accelerometer is coming properly.plz help me.
:-/

Check ur programme.

Check ur programme.

Thank you

Thank you

hey i need code to measure

hey i need code to measure tilt and jerk of the vehicle plz help me

 

 This  is very nice

 This  is very nice project..i am working on this project but i found problem in the programming code so can you please send me the programming code. my email :kishupatel1493@gmail.com

You are here