Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.
**broken link removed**
 
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?.
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! :D
 
I'm very dubious about the accuracy of that! :D
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.

New Articles From Microcontroller Tips

Back
Top