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.
sensors/PSE530.cpp@0:f0de320e23ac, 2017-12-01 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Dec 01 06:16:31 2017 +0000
- Revision:
- 0:f0de320e23ac
- Child:
- 10:88e5b8157167
OLED display for GAS pressure started working
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Rhyme | 0:f0de320e23ac | 1 | #include "mbed.h" |
| Rhyme | 0:f0de320e23ac | 2 | #include "PSE530.h" |
| Rhyme | 0:f0de320e23ac | 3 | |
| Rhyme | 0:f0de320e23ac | 4 | /** |
| Rhyme | 0:f0de320e23ac | 5 | * SMC PSE530 pressure sensor |
| Rhyme | 0:f0de320e23ac | 6 | * analog output 1.0V - 5.0V |
| Rhyme | 0:f0de320e23ac | 7 | * 1.0V : 0 |
| Rhyme | 0:f0de320e23ac | 8 | * 5.0V : 1MPa |
| Rhyme | 0:f0de320e23ac | 9 | * (at 0.6V : -0.1MPa) |
| Rhyme | 0:f0de320e23ac | 10 | * Our sensor I/F converts 0-5V to 0-3V |
| Rhyme | 0:f0de320e23ac | 11 | * So we suppose V = Analog Float Value : Pressure |
| Rhyme | 0:f0de320e23ac | 12 | * 0.6V = 0.2 : 0 |
| Rhyme | 0:f0de320e23ac | 13 | * 3.0V = 1.0 : 1MPa |
| Rhyme | 0:f0de320e23ac | 14 | */ |
| Rhyme | 0:f0de320e23ac | 15 | |
| Rhyme | 0:f0de320e23ac | 16 | /** |
| Rhyme | 0:f0de320e23ac | 17 | * conversion from Pa to kgf/cm2 |
| Rhyme | 0:f0de320e23ac | 18 | * 98,066.5 Pa = 1 kgf/cm2 |
| Rhyme | 0:f0de320e23ac | 19 | * 1 Pa = 1 / 98066.6 kgf/cm2 |
| Rhyme | 0:f0de320e23ac | 20 | */ |
| Rhyme | 0:f0de320e23ac | 21 | |
| Rhyme | 0:f0de320e23ac | 22 | PSE530::PSE530(AnalogIn *ain) |
| Rhyme | 0:f0de320e23ac | 23 | { |
| Rhyme | 0:f0de320e23ac | 24 | _ain = ain ; |
| Rhyme | 0:f0de320e23ac | 25 | } |
| Rhyme | 0:f0de320e23ac | 26 | |
| Rhyme | 0:f0de320e23ac | 27 | PSE530::~PSE530(void) |
| Rhyme | 0:f0de320e23ac | 28 | { |
| Rhyme | 0:f0de320e23ac | 29 | if (_ain) { |
| Rhyme | 0:f0de320e23ac | 30 | delete _ain ; |
| Rhyme | 0:f0de320e23ac | 31 | } |
| Rhyme | 0:f0de320e23ac | 32 | } |
| Rhyme | 0:f0de320e23ac | 33 | |
| Rhyme | 0:f0de320e23ac | 34 | float PSE530::getPressure(void) |
| Rhyme | 0:f0de320e23ac | 35 | { |
| Rhyme | 0:f0de320e23ac | 36 | float value = 0.0 ; |
| Rhyme | 0:f0de320e23ac | 37 | value = 1000000 * _ain->read() ; /* 1MPa at 1.0 */ |
| Rhyme | 0:f0de320e23ac | 38 | value = value / 98066.5 ; /* Pa -> kgf/cm2 */ |
| Rhyme | 0:f0de320e23ac | 39 | return( value ) ; |
| Rhyme | 0:f0de320e23ac | 40 | } |