McMajan Library Pack  v 2.00
Improve your Arduino !
Ss_Analogico.h
Go to the documentation of this file.
1 #ifndef _Analogico_h
2 #define _Analogico_h
3 
4 //#warning analogico.h
6 
7 
8 void Mc_Analog_Inist();
9 
10 
11 float Mc_SampleAnalogAvg(int,uint16_t);
12 
13 double Mc_OversampledAnalogRead(int);
14 float Mc_KalmanAnalogAvg(int,uint16_t);
15 
16 
17 
18 void Mc_SetSensorStep(struct Mc_AnalogSensor*,float);
20 
22 {
23  float min;
24  float max;
25  float mean;
26  float rms;
27  float klm;
29 
30 };
31 
32 //==============================================================================
34 {
35  int pin;
36  float sensor_range; // for example 30 (A .. sct13-030)
37  int sensor_voltage_range; // f.e. 1 (1V / 30A)
38  float sensor_step; // questo moltiplicato per la "lettura grezza" ti fornisce il valore "fisico"
39  float sensorunit;
40 };
41 
42 //==============================================================================
43 typedef struct
44 {
45  double q; //process noise covariance
46  double r; //measurement noise covariance
47  double value; //value
48  double p; //estimation error covariance
49  double k; //kalman gain
50 } kalman_state;
51 //==============================================================================
52 
53 kalman_state kalman_init(double , double , double , double );
54 void kalman_update(kalman_state*, double );
55 
56 struct Mc_AnalogLine CheckAnalogLine(int,uint16_t num=450);
57 
58 
59 #endif
void Mc_Analog_Inist()
Inizialize McMajanLibrary analogic section.
Definition: Ss_Analogico.cpp:7
float Mc_SampleAnalogAvg(int, uint16_t)
This function sample an analogic input and return the averange value.
void Mc_CalculateSensorStep(struct Mc_AnalogSensor *)
Calcolate internal parameters to give you values in original units as Ampere, Volt, etc and not only a raw value.
void kalman_update(kalman_state *, double)
This function updates a Kalman filter.
kalman_state kalman_init(double, double, double, double)
This function initialize a Kalman filter.
int sensor_voltage_range
Definition: Ss_Analogico.h:37
uint16_t counter
Definition: Ss_Analogico.h:28
double Mc_OversampledAnalogRead(int)
This function sample an analogic input using oversample algorithm.
double value
Definition: Ss_Analogico.h:47
void Mc_SetSensorStep(struct Mc_AnalogSensor *, float)
This function is useful if you need to do a "manual calibration" of the sensor.
float Mc_KalmanAnalogAvg(int, uint16_t)
This function return the kalman filtered value of samples on an analogic pin. Note: the voltage of in...