Basic class for reading SPTE 10 bar 0-5V analog pressure sensor made by Festo
Dependents: heros_leg_readout_torque_addition heros_leg_readout_torque_addition_V3 DROPSAWTestRigCode_V4
SPTEPressureSensor.h
- Committer:
- cnckiwi31
- Date:
- 2018-10-12
- Revision:
- 1:189d6f2b0612
- Parent:
- 0:642482fd9da0
- Child:
- 2:f31829b587b4
File content as of revision 1:189d6f2b0612:
#ifndef _SPTEPSensor_H_ #define _SPTEPSensor_H_ #include "mbed.h" /** * Reading and nulling the SPTE pressure sensor made by festo (analog input) */ class SPTEPressureSensor { public: /** * @param pin_a_in PinName of analog input * @param offset of analog value (calibration data) * @param factor multiplication factor for analog value (calibration data) */ SPTEPressureSensor(PinName pin_a_in, float offset, float factor) : analog_in_(pin_a_in), kOffset_(offset), kFactor_(factor) { } /** * @return unscaled analog input value */ float getPressureRaw() { return analog_in_.read(); } /** * @return force value kOffset_ + kFactor_ * getPressureRaw(); */ float getPressure() { return kOffset_ + kFactor_ * getPressureRaw(); } /** * sets pressure scaling offset so that current output is pressure zero */ void nullPressure() { kOffset_ = kOffset_ - getPressure(); return; } /** * @return ffset of analog value */ float get_offset() { return kOffset_; } /** * @return factor multiplication factor for analog value */ float get_factor() { return kFactor_; } private: AnalogIn analog_in_; float kOffset_; const float kFactor_; }; #endif