update with altimeter, swimfile.txt endleg.txt, etc see changes_13sep.txt also reset_PI()
Dependencies: mbed MODSERIAL FATFileSystem
Sensors/Sensors.cpp@104:426224a55f5f, 2019-09-13 (annotated)
- Committer:
- joel_ssc
- Date:
- Fri Sep 13 19:15:40 2019 +0000
- Revision:
- 104:426224a55f5f
- Parent:
- 102:0f430de62447
slight change includes reset_PI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tnhnrl | 73:f6f378311c8d | 1 | #include "Sensors.hpp" |
tnhnrl | 73:f6f378311c8d | 2 | #include "StaticDefs.hpp" |
tnhnrl | 73:f6f378311c8d | 3 | |
tnhnrl | 73:f6f378311c8d | 4 | Sensors::Sensors() { |
tnhnrl | 73:f6f378311c8d | 5 | _reference_voltage = 5.0; //check this against actual v_ref |
tnhnrl | 73:f6f378311c8d | 6 | } |
tnhnrl | 73:f6f378311c8d | 7 | |
tnhnrl | 73:f6f378311c8d | 8 | // extrapolated from graph if V_s = 5.0 |
tnhnrl | 73:f6f378311c8d | 9 | // https://www.nxp.com/docs/en/data-sheet/MPXA6115A.pdf |
tnhnrl | 73:f6f378311c8d | 10 | float Sensors::getInternalPressurePSI() { |
tnhnrl | 73:f6f378311c8d | 11 | return ( ( 22.029 * ( _reference_voltage * adc().readCh5() / 4095.0 ) + 10.884 ) * 0.145038 ); // Press_Xducer (on-board) |
tnhnrl | 73:f6f378311c8d | 12 | } |
tnhnrl | 73:f6f378311c8d | 13 | |
tnhnrl | 73:f6f378311c8d | 14 | float Sensors::getVoltageInput() { |
tnhnrl | 73:f6f378311c8d | 15 | return ( adc().readCh6() / 4095.0 * _reference_voltage * 7.8 ); |
tnhnrl | 73:f6f378311c8d | 16 | } |
tnhnrl | 73:f6f378311c8d | 17 | |
tnhnrl | 73:f6f378311c8d | 18 | float Sensors::getCurrentInput() { |
tnhnrl | 73:f6f378311c8d | 19 | return ( adc().readCh7() / 4095.0 * _reference_voltage ); |
tnhnrl | 73:f6f378311c8d | 20 | } |
tnhnrl | 73:f6f378311c8d | 21 | |
tnhnrl | 74:d281aaef9766 | 22 | //currently using BCE CS line for this data |
tnhnrl | 73:f6f378311c8d | 23 | float Sensors::getAltimeterChannelReadings() { |
tnhnrl | 74:d281aaef9766 | 24 | return adc().readCh2(); //channel 2 (third channel) from the schematic |
joel_ssc | 102:0f430de62447 | 25 | } |
joel_ssc | 102:0f430de62447 | 26 | float Sensors::getAltimeterReading_m() { // edit by CAM added by jcw 11sep2019 |
joel_ssc | 102:0f430de62447 | 27 | return _altimeter_slope * adc().readCh2() + _altimeter_intercept; |
joel_ssc | 102:0f430de62447 | 28 | } |
joel_ssc | 102:0f430de62447 | 29 | |
joel_ssc | 102:0f430de62447 | 30 | void Sensors::setAltimeterSlope(float S){ |
joel_ssc | 102:0f430de62447 | 31 | _altimeter_slope = S; |
joel_ssc | 102:0f430de62447 | 32 | return; |
joel_ssc | 102:0f430de62447 | 33 | } |
joel_ssc | 102:0f430de62447 | 34 | |
joel_ssc | 102:0f430de62447 | 35 | void Sensors::setAltimeterIntercept(float I){ |
joel_ssc | 102:0f430de62447 | 36 | _altimeter_intercept = I; |
joel_ssc | 102:0f430de62447 | 37 | return; |
tnhnrl | 73:f6f378311c8d | 38 | } |