Sensor library

Committer:
noamnahum
Date:
Tue Jun 29 17:28:29 2021 +0000
Revision:
0:eb491ad3a263
Formula Sensor read library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noamnahum 0:eb491ad3a263 1 #ifndef SENSOR_H
noamnahum 0:eb491ad3a263 2 #define SENSOR_H
noamnahum 0:eb491ad3a263 3 #include "mbed.h"
noamnahum 0:eb491ad3a263 4 /*
noamnahum 0:eb491ad3a263 5 Noam Nahum and Dror Balbul 05/10/2020
noamnahum 0:eb491ad3a263 6 Sensor reading and filtering for formula student vehicle
noamnahum 0:eb491ad3a263 7 The library takes 2 diffrential sensor and calculate to the diffrence between them.
noamnahum 0:eb491ad3a263 8 this library is for the FSAE regulation For reading Pedal Sensors and Thorttle Sensors.
noamnahum 0:eb491ad3a263 9
noamnahum 0:eb491ad3a263 10
noamnahum 0:eb491ad3a263 11
noamnahum 0:eb491ad3a263 12 Note: Sensor objects use given pointers, ie Sensor_1
noamnahum 0:eb491ad3a263 13 Sensor_2, lastscope. When reading/ modifying
noamnahum 0:eb491ad3a263 14 these vars make sure we don't have possible read/write
noamnahum 0:eb491ad3a263 15 conflicts if the interrupt fires. */
noamnahum 0:eb491ad3a263 16
noamnahum 0:eb491ad3a263 17
noamnahum 0:eb491ad3a263 18 class Sensor {
noamnahum 0:eb491ad3a263 19 public:
noamnahum 0:eb491ad3a263 20 Sensor(float* Sensor_1, float* Sensor_2, float* lastscope, float* bias, float weight); // Sensor_1, (Analogin value of sensor 1)
noamnahum 0:eb491ad3a263 21 float Sensor_Value_1(); // Sensor_1 Value between 0-255
noamnahum 0:eb491ad3a263 22 float Sensor_Value_2(); // Sensor_1 Value between 0-255
noamnahum 0:eb491ad3a263 23 //int Get_Error();
noamnahum 0:eb491ad3a263 24 void ApplyFilter(float newscope);
noamnahum 0:eb491ad3a263 25 void ChangeWeight(float new_weight);
noamnahum 0:eb491ad3a263 26 int ErrorCheck();
noamnahum 0:eb491ad3a263 27 float Sensor_Sum();
noamnahum 0:eb491ad3a263 28 float Sensor_Sub();
noamnahum 0:eb491ad3a263 29 float Sensor_timer();
noamnahum 0:eb491ad3a263 30
noamnahum 0:eb491ad3a263 31 private:
noamnahum 0:eb491ad3a263 32 Timer timer;
noamnahum 0:eb491ad3a263 33 int _Error;
noamnahum 0:eb491ad3a263 34 float* _Sensor_1;
noamnahum 0:eb491ad3a263 35 float* _Sensor_2;
noamnahum 0:eb491ad3a263 36 float _Sensor_Value_1;
noamnahum 0:eb491ad3a263 37 float _Sensor_Value_2;
noamnahum 0:eb491ad3a263 38 float Sensor_sum, Sensor_sub;
noamnahum 0:eb491ad3a263 39 float _weight;
noamnahum 0:eb491ad3a263 40 float* _lastscope;
noamnahum 0:eb491ad3a263 41 float* _bias;
noamnahum 0:eb491ad3a263 42 float _Sensor_1_max;
noamnahum 0:eb491ad3a263 43 float _Sensor_1_min;
noamnahum 0:eb491ad3a263 44 float _Sensor_2_max;
noamnahum 0:eb491ad3a263 45 float _Sensor_2_min;
noamnahum 0:eb491ad3a263 46
noamnahum 0:eb491ad3a263 47 };
noamnahum 0:eb491ad3a263 48
noamnahum 0:eb491ad3a263 49
noamnahum 0:eb491ad3a263 50 #endif
noamnahum 0:eb491ad3a263 51