Introduction: Analog to Digital Conversion Tutorial

Hey guys, I am a teaching assistant for an introduction to engineering class for biomedical engineering majors at Vanderbilt University this semester. I created this video to explain analog-to-digital conversion to them because time ran out during class and I did not get to this point in the lecture. I ran across the Teach It! Instructables contest and thought if I already had the video created, why not enter it into the contest, so here goes.

The video gives a simple introduction to analog-to-digital conversion and then explains how this relates to reading data from an accelerometer using an Arduino. For those of you who do not know, as the name suggests, an accelerometer measures the gravitational pull on the device. This particularly accelerometer measures acceleration in the x, y, and z axes. The accelerometer I am using in the demo is the MMA7361 and the datasheet can be found online. The datasheet will give more in-depth info of the accelerometer itself. If you search "MMA7361 filetype:pdf" in Google, it should pop right up. It is also attached in this Instructable. If you are not used to reading datasheets, it may be a little intimidating. Please feel free to ask if you have any questions. Additionally, the accelerometer module that I am using was purchased on Amazon from Virtuabotix, if you are interested. Anyways, here's my video. The video itself is self-sufficient, but I highlighted the major parts of it in steps if you want a quick summary. I hope you learn something from it. And if you have any questions, please feel free to ask.

If you like my Instructable, please consider voting for it in the Instructables Teach It! Contest.

Step 1: What Is Analog-to-Digital Conversion

Analog-to-digital conversion (ADC) is the process is taking a variable signal and "digitizing" the signal so that a computer can process it.

Step 2: Bits Or... Number of States

An Arduino has a 10-bit ADC, meaning that the voltages that the Arduino is reading from some sensor (in our case the sensor is an accelerometer) is represented by a number in the range of 0-1023. The max voltage an Arduino reads is 5 V and the smallest is 0 V. These voltages are represented by 1023 and 0 respectively.

A discussion on bits can get a little more extensive and a little outside the scope of this Instructable, so feel free to explore this a little more on your own or ask me in the comments section.

Step 3: Converting From Voltage to ADC Output and Vice-Versa

If you are reading a voltage of 2.5 V, you can calculate the Arduino's ADC output by doing a simple proportion. Oftentimes, you are reading an unknown voltage and want to use the Arduino's ADC output to determine what voltage you are sensing. Simply modify the proportion accordingly.

Step 4: Understanding Accelerometers

We can use an Arduino to sense the voltage outputted by an accelerometer. This voltage corresponds to an acceleration.

Step 5: Accelerometer Top-Side Up

If we have the accelerometer top-side up, these are the values we can expect to get from the Arduino's ADC.

Sorry I used "x" as my variable in this example. We are calculating the acceleration in the "z-axis." Using "x" as my variable is a habit. "x" was the first variable of choice in my Algebra classes.

Step 6: Accelerometer Bottom-Side Up

If we have the accelerometer bottom-side up (z-axis down), these are the values we could expect.

Again, we are calculating acceleration in the z-axis not "x."

Step 7: Wrap-up

Anyways, that's it. I hope you learned something from this.

If you liked my Instructable, please consider voting for it in the Instructables Teach It! Contest.

Comments

author
stringstretcher (author)2014-11-17

Nicely done. Question: Are we really measuring an acceleration (change in velocity) or are we determining the orientation of the device by a gravitational pull? Not meaning to nitpick, I am in a learning mode here :P I like your instructables, you seem a fine teacher.

author
ohoilett (author)stringstretcher2014-11-18

Good question. I would say that we are measuring acceleration because gravity is an acceleration (change in velocity), that's pulling us to the earth. Also, not only will you get gravitational acceleration, but if we say the accelerometer is right side up, the z-axis would experience acceleration due to gravity (actually it would be the acceleration of the device to counteract gravity, so +1g instead of -1g, this is the standard that the developers have chosen) and the x and y axis would have accelerations of 0. Now if we move in the positive x-axis, the accelerometer would measure an acceleration in that axis as well, not due to gravity, this is linear or dynamic acceleration. I think I know what you are getting at (correct me if I am wrong). An accelerometer doesn't measure velocities at different points in time and calculates the rate of change (delta velocity / delta time). Instead, it measures the force applied by a mass on a sensor buried inside the integrated circuit itself. Whenever the accelerometer moves, this tiny mass hits a sensor (the mechanisms of this vary with different accelerometers) which creates a force. With using F=ma, we can calculate acceleration. So, if I am remembering correctly, that would be instantaneous acceleration (acceleration at a point in time) as opposed average acceleration (velocity at point 2 - velocity at point 1 divided by time elapsed).

But you can also get orientation if you do vector analysis.

I did a little Google searching to try to get a good answer to your question.

http://www.explainthatstuff.com/accelerometers.html

author
stringstretcher (author)ohoilett2014-11-25

Thanks for taking the time to give such a detailed explanation! The article you linked was very well written. The illustrations show a mechanical sensor on that little chip. I never knew that! The device then measures its orientation after being calibrated. You cannot power one off, change its position, power on and get an accurate reading, since it is relative. Is this correct? But, power on, read and then move for a new reading and you are measuring an acceleration caused by a change by the forces applied. Simple! I learned a lot here, thanks again!

author
ohoilett (author)stringstretcher2014-12-27

Glad the explanation helped. I am not sure about the calibration. If I were to guess, I would say that you are right about calibrating each power up cycle. Happy hacking!

author
MsSweetSatisfaction (author)2014-09-23

Nice job explaining a complex concept. Thanks for sharing!

author

Thanks!

About This Instructable

5,137views

24favorites

License:

Bio: Graduate student at Purdue University, biomedical engineer, electronics enthusiast, educator, trying to learn a little about engineering and programming
More by ohoilett:LiPo Battery Breadboard Power SuppliesSuper Simple Electrocardiogram (ECG) CircuitPulseSim - Photoplethysmograph (Heartbeat) Analog Simulator
Add instructable to: