# ADXL202 how to convert gravities to mph?

**URL:** <https://community.sparkfun.com/t/adxl202-how-to-convert-gravities-to-mph/174>\
**Category:** New Product Ideas\
**Created:** [September 7, 2004, 1:28am UTC](https://community.sparkfun.com/t/adxl202-how-to-convert-gravities-to-mph/174 "2004-09-07T01:28:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kt\_1](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kt\_1](https://community.sparkfun.com/u/kt_1)\
**Post date:** [September 7, 2004, 1:28am UTC](https://community.sparkfun.com/t/adxl202-how-to-convert-gravities-to-mph/174/1 "2004-09-07T01:28:26Z")

</div>

Anybody know how to convert gravites from the ADXL202 in MPH. Code would help!

Thanks in advance…

---

<div class="post-metadata">

**Author:** ![sparky](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/sparky/32/6021_2.png) [@sparky](https://community.sparkfun.com/u/sparky)\
**Post date:** [September 14, 2004, 8:00pm UTC](https://community.sparkfun.com/t/adxl202-how-to-convert-gravities-to-mph/174/2 "2004-09-14T20:00:47Z")

</div>

Well there’s some inherent problems with your question:

The ADXL output ‘gravities’ - or more accurately accelerations. You are wanting miles per hour - or velocity. To get velocity from acceleration, whip out your old physics books. You’ll have to integrate accel once to velocity. Integrate again and you’ll have distance.

Integrating (roughly speaking) with a PIC is not too difficult. You’ll need to check the ADXL reading multiple times a second (100hz should do) and record the gravity reading (units are m/s^2 right?).

1G = 9.81m/s^2

so for every reading you take multiply by the slice of time. For example, let’s say the ADXL is reporting .01G at a specific point in time:

.01G \* 100Hz = .01 \* (9.81m/s^2) \* 1s/100 (this is 100 hz)

delta v (change in velocity) = 0.000981m/s

This is your change in velocity. You’ve just increased speed a bit. Add this number to an overall velocity variable over time.

There are tons of problems associated with using 8-bit micros to do floating point math and big ugly numbers that I won’t go into but it can be done. Also, the ADXL has a tendancy to have reading shifts due to temperature changes. These small changes get magnified by integration.

It’s a sticky situation,

-Nathan

---

<div class="post-metadata">

**Author:** ![kt\_1](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kt\_1](https://community.sparkfun.com/u/kt_1)\
**Post date:** [September 19, 2004, 6:00pm UTC](https://community.sparkfun.com/t/adxl202-how-to-convert-gravities-to-mph/174/3 "2004-09-19T18:00:01Z")

</div>

Thanks for the infor about how to convert accelerations. I looked at the Firmware v2.1 source code and was wondering if the source for Delay.c and soft232.c are available for download?

Thanks for all your help…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/sparkfun/original/2X/d/d19eb507aca5e19aadba71e3743536c935c64e77.svg) [@system](https://community.sparkfun.com/u/system)\
**Post date:** [September 21, 2004, 4:23pm UTC](https://community.sparkfun.com/t/adxl202-how-to-convert-gravities-to-mph/174/4 "2004-09-21T16:23:22Z")

</div>

Most likely not, as they are probably libraries for the C compiler they used for the project, and hence belong to the compiler company, not Sparkfun

---

<div class="post-metadata">

**Author:** ![UberSteve](https://avatars.discourse-cdn.com/v4/letter/u/97f17d/32.png) [@UberSteve](https://community.sparkfun.com/u/UberSteve)\
**Post date:** [July 21, 2005, 5:50am UTC](https://community.sparkfun.com/t/adxl202-how-to-convert-gravities-to-mph/174/5 "2005-07-21T05:50:46Z")

</div>

I too am looking for soft232.c and delay.c so that I can further develop the SerAccel v3.

What compiler do these come with?

Cheers,

Steve
