# integral function in PIC microcontroller

Status
Not open for further replies.

#### Electronic2050

##### New Member
hi to all
anybody have c function for PIC microcontroller to calculate integral
from output of ADXL330 accelerometer chip for measuring distance.

#### Russ Hensel

##### New Member
If you take the readings at regular intervals all you have to do is a running total, to the highest precision you can afford.
There are other methods that do some interpolation between points like simpsons method. Stick to integer math if you can, for as much as you can.

I realize this is not quite an answer to the question you asked.

#### birdman0_o

##### Active Member
Does the data sheet have the equation which converts the frequency into an acceleration? You could just integrate that by hand, then plug the integral into the program. Which uC are you using?

#### Nigel Goodwin

##### Super Moderator
How can you measure distance with an accelerometer?.

#### JimB

##### Super Moderator
How can you measure distance with an accelerometer?.
The accelerometer measures acceleration.
Velocity is the integral with respect to time of acceleration.
Distance is the integral with respect to time of velocity.

This is the basis of inertial navigation systems.

JimB

#### Nigel Goodwin

##### Super Moderator
The accelerometer measures acceleration.
Velocity is the integral with respect to time of acceleration.
Distance is the integral with respect to time of velocity.

I'm aware of that - but an accelerometer only gives an output during acceleration, once you reach a steady speed it's of no help as there's no output.

#### birdman0_o

##### Active Member
You will know which speed you are at though and can make calculations from that An acceleration of 1m/s^2 of 1 sec will leave you at 1m/s!
And if ds/dt = 0 then you are not moving #### JimB

##### Super Moderator
I'm aware of that - but an accelerometer only gives an output during acceleration, once you reach a steady speed it's of no help as there's no output.

If there is no acceleration then either the speed is some constant value or zero (not moving).
The processor should know what the state is and calculate from there.
So after a period of acceleration, the speed should be known, when the acceleration drops to zero the processor continues integrating the speed to calculate the distance travelled.

JimB

#### Nigel Goodwin

##### Super Moderator
If there is no acceleration then either the speed is some constant value or zero (not moving).
The processor should know what the state is and calculate from there.
So after a period of acceleration, the speed should be known, when the acceleration drops to zero the processor continues integrating the speed to calculate the distance travelled.

I'm very dubious about the accuracy of that! #### JimB

##### Super Moderator
I'm very dubious about the accuracy of that! This is the sort of thing which submarines use for navigation when submerged, I have no idea what their accuracy is but the equipment to implement it is a bit bigger than a little accelerometer from RS/Farnell/Digikey coupled to a PIC on a bit of Veroboard!

Theoretically it is quite easy, but in practice there is a bit more to it if you want an accurate one.

JimB

Last edited:
Status
Not open for further replies.

Replies
3
Views
2K
Replies
1
Views
2K
Replies
0
Views
1K
Replies
15
Views
3K
Replies
2
Views
2K 