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.
Fork of analoghalls5 by
sensors.h
00001 #ifndef __SENSORS_H 00002 #define __SENSORS_H 00003 00004 #include "includes.h" 00005 00006 class CurrentSensor { 00007 public: 00008 virtual float GetCurrent() {return 0.0f;} 00009 virtual void Zero() {} 00010 }; 00011 00012 class VoltageSensor { 00013 public: 00014 virtual float GetVoltage() {return 0.0f;} 00015 virtual void Zero(){} 00016 }; 00017 00018 class PositionSensor { 00019 public: 00020 virtual float GetPosition() {return 0.0f;} 00021 }; 00022 00023 class TempSensor { 00024 public: 00025 virtual float GetTemp() {return 0.0f;} 00026 }; 00027 00028 class AnalogCurrentSensor: public CurrentSensor { 00029 public: 00030 AnalogCurrentSensor(PinName pin, float volts_per_amp); 00031 virtual void Zero(); 00032 virtual float GetCurrent(); 00033 private: 00034 float _zero_level, _volts_per_amp; 00035 AnalogIn *_in; 00036 }; 00037 00038 class AnalogVoltageSensor: public VoltageSensor { 00039 public: 00040 AnalogVoltageSensor(PinName pin, float scale); 00041 virtual void Zero(); 00042 virtual float GetVoltage(); 00043 private: 00044 float _zero_level, _scale; 00045 AnalogIn *_in; 00046 }; 00047 00048 class AnalogHallPositionSensor: public PositionSensor { 00049 public: 00050 AnalogHallPositionSensor(PinName pin_a, PinName pin_b, float cal1_a, float cal2_a, 00051 float cal1_b, float cal2_b, float offset); 00052 virtual float GetPosition(); 00053 private: 00054 float _cal1_a, _cal2_a; 00055 float _cal1_b, _cal2_b; 00056 float _offset; 00057 AnalogIn *_in_a, *_in_b; 00058 }; 00059 00060 class NtcTempSensor: public TempSensor { 00061 public: 00062 NtcTempSensor(PinName pin, float r_25, float ntc_b, float r_divider); 00063 virtual float GetTemp(); 00064 private: 00065 float _ntc_a, _ntc_b, _r_divider; 00066 AnalogIn *_in; 00067 }; 00068 00069 class Throttle { 00070 public: 00071 Throttle(PinName pin, float min, float max); 00072 float GetThrottle(); 00073 private: 00074 float _min, _max; 00075 VoltageSensor *_in; 00076 }; 00077 00078 #endif
Generated on Fri Jul 15 2022 12:15:05 by
1.7.2
