Continue to Site

# 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.

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.

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?

How can you measure distance with an accelerometer?.

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

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.

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

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

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!

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
11
Views
1K
Replies
18
Views
3K
Replies
88
Views
9K
Replies
23
Views
3K
Replies
11
Views
3K