Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MODSERIAL FATFileSystem
omegaPX209/omegaPX209.cpp@10:085ab7328054, 2017-10-23 (annotated)
- Committer:
- danstrider
- Date:
- Mon Oct 23 12:50:53 2017 +0000
- Revision:
- 10:085ab7328054
- Parent:
- 9:d5fcdcb3c89d
- Child:
- 14:85b64a4d08e8
checked out on the hardware
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mkelly10 | 9:d5fcdcb3c89d | 1 | /* |
mkelly10 | 9:d5fcdcb3c89d | 2 | Matthew Kelly |
mkelly10 | 9:d5fcdcb3c89d | 3 | October 24th, 2013 |
mkelly10 | 9:d5fcdcb3c89d | 4 | The purpose of this class is to define a a data structure with all of the necessary information and member functions... |
mkelly10 | 9:d5fcdcb3c89d | 5 | to fully describe a single ultrasonic transducer for use in a relative positioning system. |
mkelly10 | 9:d5fcdcb3c89d | 6 | */ |
mkelly10 | 9:d5fcdcb3c89d | 7 | |
mkelly10 | 9:d5fcdcb3c89d | 8 | #include "mbed.h" |
mkelly10 | 9:d5fcdcb3c89d | 9 | #include "omegaPX209.hpp" |
mkelly10 | 9:d5fcdcb3c89d | 10 | |
danstrider | 10:085ab7328054 | 11 | omegaPX209::omegaPX209(PinName pin): |
danstrider | 10:085ab7328054 | 12 | depthP(pin) |
mkelly10 | 9:d5fcdcb3c89d | 13 | { |
mkelly10 | 9:d5fcdcb3c89d | 14 | } |
mkelly10 | 9:d5fcdcb3c89d | 15 | |
danstrider | 10:085ab7328054 | 16 | void omegaPX209::initialize() { |
mkelly10 | 9:d5fcdcb3c89d | 17 | P = 0; // Pressure [psi] |
mkelly10 | 9:d5fcdcb3c89d | 18 | cal = 12; // Volts per psi |
mkelly10 | 9:d5fcdcb3c89d | 19 | multiplier = 3.3; // Maximum voltage in |
mkelly10 | 9:d5fcdcb3c89d | 20 | } |
mkelly10 | 9:d5fcdcb3c89d | 21 | |
danstrider | 10:085ab7328054 | 22 | float omegaPX209::getPsi() { |
mkelly10 | 9:d5fcdcb3c89d | 23 | P = depthP*multiplier*cal; |
mkelly10 | 9:d5fcdcb3c89d | 24 | return P; |
mkelly10 | 9:d5fcdcb3c89d | 25 | } |
danstrider | 10:085ab7328054 | 26 | |
danstrider | 10:085ab7328054 | 27 | // math sourced from http://www.kylesconverter.com/pressure/feet-of-water-to-pounds-per-square-inch |
danstrider | 10:085ab7328054 | 28 | float omegaPX209::getDepth() { |
danstrider | 10:085ab7328054 | 29 | P = getPsi(); // read the sensor |
danstrider | 10:085ab7328054 | 30 | float pascals = (P * 6894.76) - (14.7 * 6894.76); // convert psi to Pascals |
danstrider | 10:085ab7328054 | 31 | float depth_m = pascals / (density_of_water_g_cc * 1000 * 9.80665); // convert Pa to fluid depth in meters |
danstrider | 10:085ab7328054 | 32 | float depth_ft = 3.28084 * depth_m; // convert meters to feet |
danstrider | 10:085ab7328054 | 33 | |
danstrider | 10:085ab7328054 | 34 | return depth_ft; |
danstrider | 10:085ab7328054 | 35 | } |