McMajan Library Pack  v 2.00
Improve your Arduino !
Ss_Analogico.cpp File Reference
#include "Ss_Analogico.h"
+ Include dependency graph for Ss_Analogico.cpp:

Go to the source code of this file.

Functions

void Mc_Analog_Inist ()
 Inizialize McMajanLibrary analogic section. More...
 
void Mc_CalculateSensorStep (struct Mc_AnalogSensor *sensore)
 Calcolate internal parameters to give you values in original units as Ampere, Volt, etc and not only a raw value. More...
 
void Mc_SetSensorStep (struct Mc_AnalogSensor *sensore, float value)
 This function is useful if you need to do a "manual calibration" of the sensor. More...
 
float Mc_SampleAnalogAvg (int localpin, uint16_t campioni)
 This function sample an analogic input and return the averange value. More...
 
float Mc_KalmanAnalogAvg (int localpin, uint16_t campioni)
 This function return the kalman filtered value of samples on an analogic pin. Note: the voltage of input pin must be stable. This function is useful to read the right value removing the background noise. More...
 
double Mc_OversampledAnalogRead (int pin)
 This function sample an analogic input using oversample algorithm. More...
 
kalman_state kalman_init (double q, double r, double p, double intial_value)
 This function initialize a Kalman filter. More...
 
void kalman_update (kalman_state *state, double measurement)
 This function updates a Kalman filter. More...
 
struct Mc_AnalogLine CheckAnalogLine (int pin, uint16_t num)
 Test analogic line. More...
 

Function Documentation

§ CheckAnalogLine()

struct Mc_AnalogLine CheckAnalogLine ( int  pin,
uint16_t  num 
)

Test analogic line.

This function samples an analogic input to read lower, higher , mean and, rms values. inoltre - althought you can see the number of samples and the kalmann filtered value. This last value is useful to test lines wich signal is stable (or may be it).

Parameters
pinis the analogic pin you want to test
numis the number of "grid waves" you want to sample (default 450 if you don't specify values).
Returns
this funtion return a Mc_AnalogLine structure.

Definition at line 130 of file Ss_Analogico.cpp.

References kalman_init(), Mc_AnalogLine::klm, Mc_AnalogLine::max, Mc_SampleAnalogAvg(), Mc_AnalogLine::mean, Mc_AnalogLine::min, and kalman_state::value.

+ Here is the call graph for this function:

§ kalman_init()

kalman_state kalman_init ( double  q,
double  r,
double  p,
double  intial_value 
)

This function initialize a Kalman filter.

Parameters
qprocess noise covariance
rmeasurement noise covariance
pestimation error covariance
valueinitial value
Returns
initialized kalman filter.

Definition at line 93 of file Ss_Analogico.cpp.

References kalman_state::p, kalman_state::q, kalman_state::r, and kalman_state::value.

+ Here is the caller graph for this function:

§ kalman_update()

void kalman_update ( kalman_state state,
double  measurement 
)

This function updates a Kalman filter.

Parameters
stateis the actual kalman filter pointer
measurementis the new value you want to filter
Returns
this funtion DON'T retrun nothing because the original filter is modificated

Definition at line 110 of file Ss_Analogico.cpp.

References kalman_state::k, kalman_state::p, kalman_state::q, kalman_state::r, and kalman_state::value.

+ Here is the caller graph for this function:

§ Mc_Analog_Inist()

void Mc_Analog_Inist ( )

Inizialize McMajanLibrary analogic section.

Definition at line 7 of file Ss_Analogico.cpp.

+ Here is the caller graph for this function:

§ Mc_CalculateSensorStep()

void Mc_CalculateSensorStep ( struct Mc_AnalogSensor sensore)

Calcolate internal parameters to give you values in original units as Ampere, Volt, etc and not only a raw value.

Parameters
sensoreis the pointer to the sensor

Definition at line 22 of file Ss_Analogico.cpp.

References Mc_AnalogSensor::sensor_range, Mc_AnalogSensor::sensor_step, Mc_AnalogSensor::sensor_voltage_range, and Mc_AnalogSensor::sensorunit.

§ Mc_KalmanAnalogAvg()

float Mc_KalmanAnalogAvg ( int  localpin,
uint16_t  campioni 
)

This function return the kalman filtered value of samples on an analogic pin. Note: the voltage of input pin must be stable. This function is useful to read the right value removing the background noise.

Parameters
localpinis the input pin of Arduino
campioniis the number of samples you want to do.
Returns
this function return the kalman filtered value of the samples.

Definition at line 58 of file Ss_Analogico.cpp.

References kalman_init(), kalman_update(), Mc_OversampledAnalogRead(), and kalman_state::value.

+ Here is the call graph for this function:

§ Mc_OversampledAnalogRead()

double Mc_OversampledAnalogRead ( int  pin)
inline

This function sample an analogic input using oversample algorithm.

Parameters
pinis the input pin of Arduino
Returns
this function return the reded value

Definition at line 77 of file Ss_Analogico.cpp.

+ Here is the caller graph for this function:

§ Mc_SampleAnalogAvg()

float Mc_SampleAnalogAvg ( int  localpin,
uint16_t  campioni 
)

This function sample an analogic input and return the averange value.

Parameters
localpinis the input pin of Arduino
campioniis the number of samples you want to do.
Returns
this function return the averange value of the samples.

Definition at line 42 of file Ss_Analogico.cpp.

References Mc_OversampledAnalogRead().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

§ Mc_SetSensorStep()

void Mc_SetSensorStep ( struct Mc_AnalogSensor sensore,
float  value 
)

This function is useful if you need to do a "manual calibration" of the sensor.

Parameters
sensoreis the sensor pointer you want to calibrate
valueis the manual calibration of the sensor

Definition at line 32 of file Ss_Analogico.cpp.

References Mc_AnalogSensor::sensor_step.