Hello, I want to set an Arduino code calculating integral from acceleration to velocity. Acceleration data will come from BNO055 modules. But, this module's library does not has velocity data. Therefore, I should calculate velocity from acceleration by using integral. How can I calculate integral for current data?
Take sum of multiplications of acceleration by time
noise will likely create an issue but to your question: acceleration is the variation of speed over time
a = ∆v / ∆t = (v - v0) / ∆t
so v = v0 + a.∆t
∆t
is expressed in seconds and a
in ms-2 and v in ms-1
So you basically sample your BNO055 at a given frequency say 20 Hz and assume that the value you read is good enough for the whole duration of the period (1/20 = 0.05s = ∆t)
Yes, just I am not sure exactly how I write velocity with current data. Other environmental effects are good enough. Thanks
well theoretically something like this
double currentSpeed = 0;
...
unsigned long startTime = micros(); // in microseconds
double currentAcceleration = readAccelerationDataFromBNO055();
double deltaT_s = (micros() - startTime) / 1000000.0; // in seconds
currentSpeed += currentAcceleration * deltaT_s;
which you might want to refine depending on how long it does take to read Acceleration Data From your BNO055 to take a sample at a known frequency
double currentSpeed = 0;
unsigned long lastSampleTime = 0;
...
if (millis() - lastSampleTime > 50) { // ~50ms sampling rate ➜ 20Hz
double currentAcceleration = readAccelerationDataFromBNO055();
double deltaT_s = (millis() - lastSampleTime) / 1000.0; // in seconds. we don't take 50ms to be more precise
currentSpeed += currentAcceleration * deltaT_s;
lastSampleTime = millis();
}
I understand thank you so much
Hi,
Understand that this will not give you INITIAL velocity.
You will have to know that before starting.
What is the application?
Tom...
Be ready to see there a huge drift. Without any drift compensation, calculated velocity would increase indefinitely in random direction - within a minute it would be already next to unusable
yes very likely that's why I said initially
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.