Сбор информации о погодных условиях
Dependencies: RF24 USBDevice mbed
Thermistor.h@1:8766173d267f, 2015-10-19 (annotated)
- Committer:
- pro100kot14
- Date:
- Mon Oct 19 22:03:12 2015 +0000
- Revision:
- 1:8766173d267f
???????? ?????, ??????????? ?????????? ? ????????? ?????? ? ??????????????.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pro100kot14 | 1:8766173d267f | 1 | #ifndef Thermistor_H |
pro100kot14 | 1:8766173d267f | 2 | #define Thermistor_H |
pro100kot14 | 1:8766173d267f | 3 | |
pro100kot14 | 1:8766173d267f | 4 | #include "mbed.h" |
pro100kot14 | 1:8766173d267f | 5 | #include <math.h> |
pro100kot14 | 1:8766173d267f | 6 | /** |
pro100kot14 | 1:8766173d267f | 7 | * Reads the resistance of thermistor and using Steinhart–Hart equation |
pro100kot14 | 1:8766173d267f | 8 | * converts it to Celsius |
pro100kot14 | 1:8766173d267f | 9 | * |
pro100kot14 | 1:8766173d267f | 10 | */ |
pro100kot14 | 1:8766173d267f | 11 | class Thermistor{ |
pro100kot14 | 1:8766173d267f | 12 | public: |
pro100kot14 | 1:8766173d267f | 13 | /** |
pro100kot14 | 1:8766173d267f | 14 | * Constructor. In the calculations used a model of |
pro100kot14 | 1:8766173d267f | 15 | * the resistance of a semiconductor at different temperatures - |
pro100kot14 | 1:8766173d267f | 16 | * The Steinhart–Hart equation. Need to set the coefficients a, b, c. |
pro100kot14 | 1:8766173d267f | 17 | * |
pro100kot14 | 1:8766173d267f | 18 | * @param inputChanel The analog input is connected to the sensor |
pro100kot14 | 1:8766173d267f | 19 | * @param a Steinhart–Hart coefficient |
pro100kot14 | 1:8766173d267f | 20 | * @param b Steinhart–Hart coefficient |
pro100kot14 | 1:8766173d267f | 21 | * @param c Steinhart–Hart coefficient |
pro100kot14 | 1:8766173d267f | 22 | */ |
pro100kot14 | 1:8766173d267f | 23 | Thermistor(AnalogIn inputChanel, double a, double b, double c); |
pro100kot14 | 1:8766173d267f | 24 | |
pro100kot14 | 1:8766173d267f | 25 | /** |
pro100kot14 | 1:8766173d267f | 26 | * The temperature in degrees Celsius |
pro100kot14 | 1:8766173d267f | 27 | * @returns Temperature |
pro100kot14 | 1:8766173d267f | 28 | */ |
pro100kot14 | 1:8766173d267f | 29 | double getTemperature(); |
pro100kot14 | 1:8766173d267f | 30 | |
pro100kot14 | 1:8766173d267f | 31 | /** |
pro100kot14 | 1:8766173d267f | 32 | * Set error value used in the calculation. |
pro100kot14 | 1:8766173d267f | 33 | * The resulting resistance is computed as <real resistance> - error; |
pro100kot14 | 1:8766173d267f | 34 | * @param error Error in Ohms |
pro100kot14 | 1:8766173d267f | 35 | */ |
pro100kot14 | 1:8766173d267f | 36 | void setError(double error); |
pro100kot14 | 1:8766173d267f | 37 | |
pro100kot14 | 1:8766173d267f | 38 | /** |
pro100kot14 | 1:8766173d267f | 39 | * Error value used in the calculation |
pro100kot14 | 1:8766173d267f | 40 | * The resulting resistance is computed as <real resistance> - error; |
pro100kot14 | 1:8766173d267f | 41 | * @returns Error in Ohms |
pro100kot14 | 1:8766173d267f | 42 | */ |
pro100kot14 | 1:8766173d267f | 43 | double getError(); |
pro100kot14 | 1:8766173d267f | 44 | |
pro100kot14 | 1:8766173d267f | 45 | /** |
pro100kot14 | 1:8766173d267f | 46 | * Set a coefficient of Steinhart–Hart equation |
pro100kot14 | 1:8766173d267f | 47 | * @param a a-coefficient |
pro100kot14 | 1:8766173d267f | 48 | */ |
pro100kot14 | 1:8766173d267f | 49 | void setCoefficientA(double a); |
pro100kot14 | 1:8766173d267f | 50 | |
pro100kot14 | 1:8766173d267f | 51 | /** |
pro100kot14 | 1:8766173d267f | 52 | * Set b coefficient of Steinhart–Hart equation |
pro100kot14 | 1:8766173d267f | 53 | * @param b b-coefficient |
pro100kot14 | 1:8766173d267f | 54 | */ |
pro100kot14 | 1:8766173d267f | 55 | void setCoefficientB(double b); |
pro100kot14 | 1:8766173d267f | 56 | |
pro100kot14 | 1:8766173d267f | 57 | /** |
pro100kot14 | 1:8766173d267f | 58 | * Set c coefficient of Steinhart–Hart equation |
pro100kot14 | 1:8766173d267f | 59 | * @param c c-coefficient |
pro100kot14 | 1:8766173d267f | 60 | */ |
pro100kot14 | 1:8766173d267f | 61 | void setCoefficientC(double c); |
pro100kot14 | 1:8766173d267f | 62 | |
pro100kot14 | 1:8766173d267f | 63 | /** |
pro100kot14 | 1:8766173d267f | 64 | * a coefficient of Steinhart–Hart equation |
pro100kot14 | 1:8766173d267f | 65 | * @returns a coefficient |
pro100kot14 | 1:8766173d267f | 66 | */ |
pro100kot14 | 1:8766173d267f | 67 | double getCoefficientA(); |
pro100kot14 | 1:8766173d267f | 68 | |
pro100kot14 | 1:8766173d267f | 69 | /** |
pro100kot14 | 1:8766173d267f | 70 | * b coefficient of Steinhart–Hart equation |
pro100kot14 | 1:8766173d267f | 71 | * @returns b coefficient |
pro100kot14 | 1:8766173d267f | 72 | */ |
pro100kot14 | 1:8766173d267f | 73 | double getCoefficientB(); |
pro100kot14 | 1:8766173d267f | 74 | |
pro100kot14 | 1:8766173d267f | 75 | /** |
pro100kot14 | 1:8766173d267f | 76 | * c coefficient of Steinhart–Hart equation |
pro100kot14 | 1:8766173d267f | 77 | * @returns c coefficient |
pro100kot14 | 1:8766173d267f | 78 | */ |
pro100kot14 | 1:8766173d267f | 79 | double getCoefficientC(); |
pro100kot14 | 1:8766173d267f | 80 | |
pro100kot14 | 1:8766173d267f | 81 | private: |
pro100kot14 | 1:8766173d267f | 82 | AnalogIn input; |
pro100kot14 | 1:8766173d267f | 83 | //Thermistor error in Ohms |
pro100kot14 | 1:8766173d267f | 84 | double error; |
pro100kot14 | 1:8766173d267f | 85 | double a, b, c; |
pro100kot14 | 1:8766173d267f | 86 | }; |
pro100kot14 | 1:8766173d267f | 87 | |
pro100kot14 | 1:8766173d267f | 88 | #endif |