WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

Pressure

Supports pressure measurement in Pascals (Pa).
For conversion to other units then see: http://en.wikipedia.org/wiki/Pascal_(unit)
Since all of the devices have been implemented in the same way then it means that you can swap one device for another by only changing the #include and the MAKE command used to create the device.
So here is the generic way to work with a <DEVICE> of a given <MAKE> and <MODEL>:-
// Include the relevant sensor file
#include "Sensors/Pressure/<MAKE>/<MODEL>.h"
// Create the device
<DEVICE> myPressure = MAKE_<DEVICE>(ADC pin);
In your appInitHardware you should initialise the device:-
pressureInit(myPressure);
Then in your main loop you can read the sensor using:-
pressureRead(myPressure);
The value can then be read independently into a variable of type 'PRESSURE_TYPE':-
PRESSURE_TYPE pascal = myPressure.pressure.pa;
This can be printed out using:
rprintf("Pascals=%ld", pascal);
Or dumped to the current rprintf destination using:-
pressureDump(myPressure);
Pressure readings are often used to calculate altitude or depth under water. WebbotLib provides these calculations for you as follows:-
double depth = pressureRelativeDepth(myPressure);
returns the underwater depth in meters of the device relative to when power was turned on. So make sure your vessel is floating on the surface when it is switched on.
double altitude = pressureAltitude(myPressure);
returns the current altitude (in air) in meters above, or below, sea level.
double height = pressureRelativeAltitude(myPressure);
returns the altitude of the device (in air) in meters above, or below, the location where the power was turned on. Note that this is only equivalent to the height above ground if the whole terrain is totally flat.

 

File

 

Valid XHTML 1.0 Transitional