Accelerometer Project
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- dlebby3
- Posts: 9
- Joined: Wed Feb 18, 2015 4:47 pm
Accelerometer Project
I'm looking to obtain real-time velocity readings on the serial monitor using an ADXL 335 3 axis accelerometer. Obviously acceleration is the time derivative of velocity but I'm not sure what the most efficient/accurate way of coding this would be. I'm interested in finding the magnitude of velocity in m/s of an object based on x,y,and z outputs of the accelerometer. I have the accelerometer calibrated and the output in 'gs"
- adafruit_support_bill
- Posts: 88150
- Joined: Sat Feb 07, 2009 10:11 am
Re: Accelerometer Project
To calculate an estimated velocity using an accelerometer, you need to know the starting velocity, then you integrate the change in velocity over time.
For example, if your sample rate is 10ms (1/100th of a second), your incremental change in velocity is the acceleration (in m/s^2) divided by 100. Added to your previous velocity, that will be your new velocity.
Obviously, this type of relative measurement is subject to cumulative errors, so it is often augmented by GPS data to correct any long-term drift.
For example, if your sample rate is 10ms (1/100th of a second), your incremental change in velocity is the acceleration (in m/s^2) divided by 100. Added to your previous velocity, that will be your new velocity.
Obviously, this type of relative measurement is subject to cumulative errors, so it is often augmented by GPS data to correct any long-term drift.
- dlebby3
- Posts: 9
- Joined: Wed Feb 18, 2015 4:47 pm
Re: Accelerometer Project
Awesome! Thanks for your help. It seems that attempting to measure feet velocities of around 0.5 m/s would require a more precise accelerometer. Could you recommend once capable?
- adafruit_support_bill
- Posts: 88150
- Joined: Sat Feb 07, 2009 10:11 am
Re: Accelerometer Project
For slower speeds, you want to look for an accelerometer with a relatively low measurement range. The ADXL335 is already pretty low at +/- 3G. Anything lower than that is going to be a fairly specialized sensor.
- dlebby3
- Posts: 9
- Joined: Wed Feb 18, 2015 4:47 pm
Re: Accelerometer Project
I'm using an Uno to retrieve data from an MPU 6050 accelerometer via I2C serial protocol. I want to use the acceleration value I obtain from the accelerometer to control the LED strip. Just using a simple 3 part conditional for 3 ranges of acceleration to control three colors red green and blue. The accelerometer code is perfect and I have a code for the LEDs that works on its own but I am having trouble integrating the pieces from the LED code into the accelerometer code.
attached is my LED code.
Do you have any tips?
Thanks!
David
attached is my LED code.
Do you have any tips?
Thanks!
David
- Attachments
-
- code_pic.JPG (67.88 KiB) Viewed 259 times
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Accelerometer Project
When you post code please use the
Code: Select all
tags or click the </> button on the reply form and paste your code between the [code] tags. Your code does a colorwipe but has no accelerometer code. What happens when you run the actual code?
- adafruit_support_bill
- Posts: 88150
- Joined: Sat Feb 07, 2009 10:11 am
Re: Accelerometer Project
Please post the accelerometer code you are trying to integrate this with.
Please be positive and constructive with your questions and comments.