• AVR Freaks

Helpful ReplyRead speed from accelerometer

Author
dj_quaver
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2019/10/04 01:34:26
  • Location: 0
  • Status: offline
2019/12/02 22:51:40 (permalink)
0

Read speed from accelerometer

Hello everyone, I built a car with a PIC32MX microcontroller.
I want to have a speedometer but I only have an accelerometer ADXL345 that I have to connect with I2C protocol.
 
I found on stack that I could get the speed with V[k+1] = V[k] + T*A[k].
 
Does it really work?
How often will I need to do the sampling?
Also, will this technique detect if the car is at constant speed?
 
#1
Nikolay_Po
Super Member
  • Total Posts : 1932
  • Reward points : 0
  • Joined: 2012/04/01 13:49:27
  • Location: Russia, Novorossiysk
  • Status: offline
Re: Read speed from accelerometer 2019/12/03 00:49:01 (permalink)
0
No, accelerometer can sense only the change of the speed. It can't physically detect absolute speed.
#2
Nikolay_Po
Super Member
  • Total Posts : 1932
  • Reward points : 0
  • Joined: 2012/04/01 13:49:27
  • Location: Russia, Novorossiysk
  • Status: offline
Re: Read speed from accelerometer 2019/12/03 00:55:09 (permalink)
0
The most you can do it is to integrate the acceleration from a point where the speed was known. Some time after the speed was known you will have updated speed value. But because of finite accelerometer precision the acceleration integral will be more and more different from actual.
#3
dj_quaver
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2019/10/04 01:34:26
  • Location: 0
  • Status: offline
Re: Read speed from accelerometer 2019/12/03 01:31:20 (permalink)
0
I see. How long before the error is going to affect the speed measurment?
So the best I can do is to detect if my robot is on a flat surface or not?
#4
Mysil
Super Member
  • Total Posts : 3482
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: online
Re: Read speed from accelerometer 2019/12/03 04:57:30 (permalink) ☄ Helpfulby dj_quaver 2019/12/03 21:29:32
5 (2)
Hi,
Depends on your code for setting up the accelerometer, sampling frequency, and precision of calculations.
If your robot is standing still, or moving uphill or downhill at constant speed,
it will look the same as  accelerating or decelerating, to the accelerometer.
 
Continue experimenting with the accelerometer, until you can communicate with the sensor,
and determine whether it is uphill or downhill, and what the slope is, when you know that the car is standing still.
Then start calculating from that.
 
For a model car that is likely to have good acceleration, I suggest sampling and calculating 100 times/second.
You may try the following experiment:
From a standing start, light a LED when PIC detect motion. Then accelerate flat out for 10 seconds, and breake hard.
When your calculations predict zero speed, switch the LED off, and display the highest speed recorded.
If you can keep a reasonable speed estimate going for 10 or 20 seconds on flat and level ground,
then I think you have a good start.
 
There exist experimentation boards with 9dof sensors: 3 accelerometer channels, 3 gyroscope channels(rate of rotation), and 3 magnetometer channels( direction to magnetic north).
 
It can be done, it is sensors like the accelerometer you have, and other sensors,
that are used to keep stable, those  drones that fly themselves.
 
Continue experimenting, there is a lot to learn, both math and computing.
 
Regards,
    Mysil
 
 
post edited by Mysil - 2019/12/03 05:49:12
#5
Jump to:
© 2019 APG vNext Commercial Version 4.5