Characterize The Performance Of The Accelerometer Biology Essay


This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

A development system, Widget #387, is designed and built in order to characterize the performance of the accelerometer ADXL322 and the additional hardware and software necessary to support the accelerometer. The design will be prototyped and demonstrated in 3 phases. This document describes Phase III of the prototype widget. The following is an overview Phase III block diagram:


Overview of Entire Widget circuit & PC interface

The outputs X and Y of the accelerometer are sent through signal conditioning to get the full scale voltage range of the microcontroller. The voltage rails of the accelerometer were between 0.1 and 3.2 volts after signal conditioning as shown in Figure-1. The code implemented, synchronized the hardware and the software of the microcontroller such that it works as an ADC. The microprocessor shall operate in two modes: manual and cycle mode. Three switches must be used. One switch to select the mode, manual or cycling and another switch is to select the channel from which the signal it is to be sampled (either 'x' or 'y'). A third switch, new for Phase III, selects whether to sample or transmit data. The microprocessor will set up the A/D to sample at a rate of 4.5 times or more than the maximum bandwidth of each accelerometer axis. The sampling rate of our microprocessor is 774Hz. The microprocessor will store 0.5 seconds of data in memory, and immediately transmit the data to Matlab once all the data has been collected. When the control input = 1 the microprocessor sends the stored sampled data to the Matlab and the Matlab will give the required plots as discussed in the results section. Test circuits are maintained, for a fast debug in case of failure of any of the different components of the system.

Phase III Requirements: Discussion of requirements matrix

As shown in the requirements matrix in Appendix A, there are several requirements to fulfill Phase III. "Shall #1" states that the data will be serially transmitted to the PC with 9600 baud rate. "Shall #2" requires that the overall widget operate within a 4% error margin. In order to do so, the signal condition has to be checked as well as the sampling rate. Also, 0.5 second of data will be captured and stored in memory. A switch will be used to select whether to sample or to transmit data. The microprocessor shall operate between two modes, cycle and manual (shall #3). In manual mode, there shall be sinusoid verification so that MATLAB plots the input sinusoid on a single axis. Also, the tilt experiment shall be done in manual mode where at a given Vref the board will be tilted to a specific angle and Matlab will auto-calculate the angle at which the LED will light up. In cycle mode, similar sinusoid verification shall be included except the X and Y values have to be parsed and then reconstructed to form the sinusoid on MATLAB. The inertial acceleration experiment also shall be done in cycle mode. As shown in the requirements matrix, the distance traveled across a sheet and a half of paper should be derived from the acceleration plots. Another key requirement is the auto-detect (shall #4). The microprocessor shall only sample when greater than +/- 10 degrees when doing the tilt experiment. Likewise, for the inertial acceleration experiment, the microprocessor shall sample only when the sample voltage goes over the threshold decided by the engineer. The auto-detect feature should be off when the input is a sinusoid. The final requirement (shall #5) deals with the MATLAB interface. MATLAB should receive serial data from the accelerometer, time and frequency plots should be automatically plotted, the final resting angle should be automatically determined during tilt measurement, and the acceleration, velocity, and distance plots should be automatically plotted during the inertial acceleration measurement.


Micro-code Flow Chart

Figure 2a below shows the flow chart of the microprocessor code. The microprocessor selects whether to operate in manual or cycle mode first. If manual mode is chosen, the axis then has to be selected. Then, it selects to sample data or to transmit data to MATLAB. If sampling data is chosen, the accelerometer has to be +/- 10 degrees. To accomplish this, the data sampled is compared to the binary value at the voltage. The code branches to store the data into port B registers and memory. The code then branches back to the main loop. However, if transmit data is chosen, data will be pulled from memory and transmitted to MATLAB. The inertial acceleration experiment was not finished on time. However, it should be implemented the same way as the tilt experiment by setting a threshold for a little force on the accelerometer. The higher the push will lead to a higher voltage, so if the data sampled from the push is higher than the threshold, the data will start getting captured.

Manual (0) or Cycle (1) Mode


X (0) or Y(1) axis

1 0

Sample (0) or Transmit (1)

0 1

Sample (0) or Transmit (1)

Compare if higher than1.8 V (+10°)


Transmit to MATLAB

Compare if lower than 1.5 V (-10°)


Store X

Compare if higher than1.8 V (+10°)

0 0

1 0


Transmit to MATLAB

Compare if lower than 1.5 V (-10°)

1 0


0 1


Store X


Store Y



Sample (0) or Transmit (1)

Compare if higher than1.8 V (+10°)

Transmit to MATLAB

Compare if lower than 1.5 V (-10°)


Store X




1 0


Figure 2a - Micro-code flow chart

Multiplexing and Sampling Theory & Impact of Memory Restrictions

In Phase III, it is required that the A/D sample both the X and the Y axes continuously so that both sinusoids can accurately be reconstructed. In order to achieve this, there are a couple of concepts. In order to select which axis to sample, a multiplexer is needed to choose either the X or the Y axis. To determine its frequency at the output of the MUX, Nyquist rate needs to be considered. According to Nyquist, the Nyquist rate should be twice the highest input frequency to avoid aliasing. Successive approximation of the A/D multiplies the Nyquist rate by 64 clock cycles. Since the A/D gives eight digital data outputs, the clock of the register needs a delay to divide the clock by 16. Figure 6a shows this situation.





50 Hz


200 Hz 8

50 Hz

Clk (Fo x 2 x 64) Clk/16

Figure 2b - Mux to select which axis to sample

200 Hz

In Figure 2b, since the limiting factor is 50 Hz, the Nyquist rate is 100 Hz. However, the switch has two inputs so the mux switching rate is two times the Nyquist rate. This makes the mux switching rate 200 Hz. For Phase III, the two inputs to the MUX are the X and Y axis. The bandwidths for both axes are 50 Hz. The sampling rate must be between 4.5x the Nyquist rate which makes it between 450 and 900 Hz.

The microprocessor accomplishes sampling by taking a sample every cycle of the bus clock. Therefore because of memory restrictions, to set the sampling rate for the microprocessor, a delay needs to be added every cycle. This delay can be achieved though the concept of decimation. Figure 6b shows the concept of decimation.

SEL 1 0 1 0 1 0 1 0

Figure 2c - Decimation diagram

0.625 ms 0.3125 ms

Using the delay loop from [2] programmed in the assembly language by repeating a NOP loop of 24 cycles 'N' amount of times. The N chosen was 497 iterations. This led to an actual sampling rate of approximately 774 Hz.

Data Collection and Results

MATLAB interface to widget

For Phase III, one of the main objectives is to allow serial transmission between the microprocessor and the PC (MATLAB). When the microprocessor samples data from the input, a serial 8 bits is returned in the accumulator. This data is then stored in memory for 0.5 seconds. When ready, the microprocessor appends a start bit to the data byte along with a parity bit even and a stop bit as shown in figure 3a.

Start bit 8 data bits parity bit stop bit

Figure 3a - Serial transmission timing diagram

The transmission was first tested on HyperTerm. The microprocessor waits for a button to be pressed on the keyboard. When the microprocessor receives the command, data will be transmitted back to the PC and displayed on the monitor. When the transmission through HyperTerm was confirmed, transmission to MATLAB was tested. When the microprocessor transmits data to MATLAB, the data will be stored in an array in binary. In this case, the input is a 50 Hz sinusoid with 3.1V peak to peak and 1.65V offset. The data sampled will be converted by multiplying the binary value by 3.3V and dividing it by 255. This will change the array to the actual voltage values. The array is then plotted against time for 'N' samples. The amount of samples taken was 38. When plotted in MATLAB, two cycles of the sinusoid are auto-plotted which confirms that serial transmission between the microprocessor and MATLAB succeeded.


One of the requirements as shown in the "Test Procedure" document is the tilt experiment. A comparator and LED are used to compare the Vref to the DAC output so that when the accelerometer is tilted to an angle that is equal to the Vref, the LED will light up. However, another requirement is that the microprocessor should start sampling when the board is over +/- 10 degree angle. To achieve this, a couple of values need to be known: the voltage output of the accelerometer at +10 and -10 degrees. The voltages were measured to be about 1.8V and 1.5V respectively. As shown in the test procedure, the data sampled is compared to the binary value of these voltages. If it is higher than 1.8V or lower than 1.5V, the data will be sampled. This way, since only 0.5 second of data is captured, the data will only be sampled when the tilt measurement needs to be conducted. The mode of the values will then be taken using MATLAB command mode() since it will most likely be the value of the angle that the LED will light up. The angle will then be calculated using equations from Phase I and II.

The following table shows the Vref and its corresponding angle:




Angle (MATLAB)

























Table 3b - Vref for demo angles

The middle left column is the output voltage from the accelerometer from either the X or the Y axis since the range is approximately the same. The middle right column is the voltage needed after the signal conditioning which set equal to the reference voltage needed by the power supply so that the comparator will set the LED on. This is done by multiplying the voltage from the accelerometer by the gain and shifting it by the offset. Given an angle, the reference voltage of the comparator is set by the power supply so that when the breadboard is tilted to the angle, the LED should be on. The MATLAB results were close to what the angles were expected to be.

Due to trouble with serial transmission in manual mode (HW9), the inertial acceleration experiment was not completed on time.

HW10 and theory & graphical analysis to determine distance from angle

The goal of HW 10 is to plot a sinusoid from cycle mode by parsing the X and Y values into two separate vectors. Data will be stored for 0.5 second as in manual mode. Since X will be sampled first and then Y, all odd samples will be X values and the even samples will be the Y values. With this in mind, X and Y values are parsed into two separate vectors by taking only the odd number samples for X and only the even number samples for Y. X will then be plotted as in manual mode which will result in a reconstructed sinusoid for two cycles. When plotting the DFT of the sinusoid, 7.111 cycles are used to determine the number of samples. The number of samples can be found by dividing the sampling rate by the input rate and then multiplying it by the number of clock cycles. This leads to a result of (774 Hz * 7.111 cycles)/50 Hz which equals to approximately 110 samples. Figure 3c shows the reconstructed sinusoid.

Figure 3c - Reconstructed Sinusoid Plotted in MATLAB

The purpose of the inertial acceleration experiment is to determine distance traveled due to the acceleration. When the accelerometer is set on a bench with both the X and Y axes parallel to the earth's surface, the concept of inertial acceleration can be tested. When the accelerometer is pushed across the bench the plotted graph with respect to time shows a sinusoid since acceleration increases and then decreases as the board comes to rest. To derive velocity from this, the integral of the sinusoid is taken. One way to do this is to use Riemann sums to calculate the area under the curve of the acceleration plot. Using trapezoidal method would be more accurate in which trapezoids are used to approximate the area under the curve. To find distance, the integral of the velocity with respect to time is taken. The graphs below show an example of this:

a(t) v(t)

t t

(d) (e)




Figure 3 d,e, f - Acceleration, Velocity, and Distance plot respectively

Since the acceleration is a sine wave, its integral is -cos(x) + C. The integral of that is -sin(x)+ Cx which is shown in the graph above. If the inertial acceleration experiment was completed, the result would look similar to the results shown above in figures 3d-f.


In Phase III, MATLAB interface with the widget was accomplished. Almost all requirements were met except for inertial acceleration. The widget was a great experience to work with and introduced many concepts. The widget consisting of an accelerometer, signal conditioning circuit, microprocessor/ADC, DAC, and comparator gave an opportunity to look at these electronics more in detail. We learned about how useful test circuits are as they can help debug problems more easily. Also, a lot about tilt measurement and comparator were learned and even though we were not able to complete the inertial acceleration experiment, we had learned a lot on determining distance traveled from acceleration through research. Lessons about serial transmission were also learned and a basic UART was implemented. Knowledge of data transmission will be very helpful in a career with signal processing. The accelerometer has been fully characterized and we can see that the accelerometer is a very useful tool using tilt and inertial acceleration concepts and is no wonder why they are used in many current technologies such as touch phones and the Wii. However, the most important lessons learned from the widget are its many components that will definitely prove useful in future work and even in future careers.

Writing Services

Essay Writing

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.