Infineon OnGoing Calibration Library  1.0.1
Data Structures | Macros | Typedefs | Functions
ongocalib.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
Include dependency graph for ongocalib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ONGO_ANALOG_SENSOR_DATA
 
struct  ONGO_ROTATION_DATA_STORE
 
struct  ONGO_CALIB_DATA
 

Macros

#define RAD2DEGFACTOR   (180.00 / M_PI)
 
#define DEG2RADFACTOR   (M_PI / 180.00)
 
#define ANGLE_TOLERANCE   0.25
 
#define ANGLE_TOLERANCE_RAD   (ANGLE_TOLERANCE * DEG2RADFACTOR)
 
#define ANGLE180_RAD   (180.00 * DEG2RADFACTOR)
 
#define ANGLE45   45.00
 
#define ANGLE135   135.00
 
#define ANGLE225   -135.00
 
#define ANGLE315   -45.00
 
#define ANGLE45_H   ((ANGLE45 + ANGLE_TOLERANCE) * DEG2RADFACTOR)
 
#define ANGLE45_L   ((ANGLE45 - ANGLE_TOLERANCE) * DEG2RADFACTOR)
 
#define ANGLE135_H   ((ANGLE135 + ANGLE_TOLERANCE) * DEG2RADFACTOR)
 
#define ANGLE135_L   ((ANGLE135 - ANGLE_TOLERANCE) * DEG2RADFACTOR)
 
#define ANGLE225_H   ((ANGLE225 + ANGLE_TOLERANCE) * DEG2RADFACTOR)
 
#define ANGLE225_L   ((ANGLE225 - ANGLE_TOLERANCE) * DEG2RADFACTOR)
 
#define ANGLE315_H   ((ANGLE315 + ANGLE_TOLERANCE) * DEG2RADFACTOR)
 
#define ANGLE315_L   ((ANGLE315 - ANGLE_TOLERANCE) * DEG2RADFACTOR)
 
#define ROTATION_VALID   1u
 

Typedefs

typedef double float64_t
 
typedef struct ONGO_ANALOG_SENSOR_DATA ONGO_ANALOG_SENSOR_DATA_t
 
typedef struct ONGO_ROTATION_DATA_STORE ONGO_ROTATION_DATA_STORE_t
 
typedef struct ONGO_CALIB_DATA ONGO_CALIB_DATA_t
 

Functions

void ONGO_InitSensorData (uint32_t sinP_in_LSB, uint32_t cosP_in_LSB, uint32_t sinN_in_LSB, uint32_t cosN_in_LSB)
 Function used for ONGO_ANALOG_SENSOR_DATA_t data assignment. More...
 
void ONGO_InitCalibData (ONGO_CALIB_DATA_t *calib_param, int32_t max_diff_sin_LSB, int32_t max_diff_cos_LSB, int32_t min_diff_sin_LSB, int32_t min_diff_cos_LSB, float64_t sin_45, float64_t cos_45, float64_t sin_135, float64_t cos_135)
 Function used for ONGO_CALIB_DATA_t data initialization. The pointer of type ONGO_CALIB_DATA_t will be used to store calibration parameters. More...
 
void ONGO_InitCalibData2 (ONGO_CALIB_DATA_t *calib_param, int32_t max_SinP_LSB, int32_t max_CosP_LSB, int32_t max_SinN_LSB, int32_t max_CosN_LSB, int32_t min_SinP_LSB, int32_t min_CosP_LSB, int32_t min_SinN_LSB, int32_t min_CosN_LSB, float64_t sin_45, float64_t cos_45, float64_t sin_135, float64_t cos_135)
 Function used for ONGO_CALIB_DATA_t data initialization. The pointer of type ONGO_CALIB_DATA_t will be used to store calibration parameters. More...
 
float64_t ONGO_GetUncalibAngle (void)
 Calculates the uncalibrated angle. More...
 
float64_t ONGO_GetCalibAngle (const ONGO_CALIB_DATA_t *calib_param)
 Calculates the calibrated angle. More...
 
void ONGO_CalibrationFindParam (ONGO_CALIB_DATA_t *param_store)
 This function is used to find new calibration parameters. More...
 

Macro Definition Documentation

◆ ANGLE135

#define ANGLE135   135.00

angle position used for the calibration process.

Definition at line 35 of file ongocalib.h.

◆ ANGLE135_H

#define ANGLE135_H   ((ANGLE135 + ANGLE_TOLERANCE) * DEG2RADFACTOR)

angle position limit in radians used for the calibration process.

Definition at line 41 of file ongocalib.h.

◆ ANGLE135_L

#define ANGLE135_L   ((ANGLE135 - ANGLE_TOLERANCE) * DEG2RADFACTOR)

angle position limit in radians used for the calibration process.

Definition at line 42 of file ongocalib.h.

◆ ANGLE180_RAD

#define ANGLE180_RAD   (180.00 * DEG2RADFACTOR)

angle position in radians used for the calibration process.

Definition at line 32 of file ongocalib.h.

◆ ANGLE225

#define ANGLE225   -135.00

angle position used for the calibration process.

Definition at line 36 of file ongocalib.h.

◆ ANGLE225_H

#define ANGLE225_H   ((ANGLE225 + ANGLE_TOLERANCE) * DEG2RADFACTOR)

angle position limit in radians used for the calibration process.

Definition at line 43 of file ongocalib.h.

◆ ANGLE225_L

#define ANGLE225_L   ((ANGLE225 - ANGLE_TOLERANCE) * DEG2RADFACTOR)

angle position limit in radians used for the calibration process.

Definition at line 44 of file ongocalib.h.

◆ ANGLE315

#define ANGLE315   -45.00

angle position used for the calibration process.

Definition at line 37 of file ongocalib.h.

◆ ANGLE315_H

#define ANGLE315_H   ((ANGLE315 + ANGLE_TOLERANCE) * DEG2RADFACTOR)

angle position limit in radians used for the calibration process.

Definition at line 45 of file ongocalib.h.

◆ ANGLE315_L

#define ANGLE315_L   ((ANGLE315 - ANGLE_TOLERANCE) * DEG2RADFACTOR)

angle position limit in radians used for the calibration process.

Definition at line 46 of file ongocalib.h.

◆ ANGLE45

#define ANGLE45   45.00

angle position used for the calibration process.

Definition at line 34 of file ongocalib.h.

◆ ANGLE45_H

#define ANGLE45_H   ((ANGLE45 + ANGLE_TOLERANCE) * DEG2RADFACTOR)

angle position limit in radians used for the calibration process.

Definition at line 39 of file ongocalib.h.

◆ ANGLE45_L

#define ANGLE45_L   ((ANGLE45 - ANGLE_TOLERANCE) * DEG2RADFACTOR)

angle position limit in radians used for the calibration process.

Definition at line 40 of file ongocalib.h.

◆ ANGLE_TOLERANCE

#define ANGLE_TOLERANCE   0.25

tolerance angle used for calibration process.

Definition at line 30 of file ongocalib.h.

◆ ANGLE_TOLERANCE_RAD

#define ANGLE_TOLERANCE_RAD   (ANGLE_TOLERANCE * DEG2RADFACTOR)

tolerance angle in radians used for the calibration process.

Definition at line 31 of file ongocalib.h.

◆ DEG2RADFACTOR

#define DEG2RADFACTOR   (M_PI / 180.00)

Definition at line 29 of file ongocalib.h.

◆ RAD2DEGFACTOR

#define RAD2DEGFACTOR   (180.00 / M_PI)

Definition at line 28 of file ongocalib.h.

◆ ROTATION_VALID

#define ROTATION_VALID   1u

Definition at line 48 of file ongocalib.h.

Typedef Documentation

◆ float64_t

typedef double float64_t

Definition at line 50 of file ongocalib.h.

◆ ONGO_ANALOG_SENSOR_DATA_t

◆ ONGO_CALIB_DATA_t

◆ ONGO_ROTATION_DATA_STORE_t

Function Documentation

◆ ONGO_CalibrationFindParam()

void ONGO_CalibrationFindParam ( ONGO_CALIB_DATA_t *  calib_param)

This function is used to find new calibration parameters.

When new calibration parameters have been found, this function will do mathematical calculations, which will take more time for one moment. This function will extract the maximum, minimum voltage levels, amplitude, offset, and orthogonality. Based on the found values, it will calculate the necessary calibration parameters.

Parameters
[in]calib_paramis a pointer of type ONGO_CALIB_DATA_t, this structure holds the current sensor calibration parameters.
Returns
Nothing

Definition at line 353 of file ongocalib.c.

◆ ONGO_GetCalibAngle()

float64_t ONGO_GetCalibAngle ( const ONGO_CALIB_DATA_t *  calib_param)

Calculates the calibrated angle.

Parameters
[in]calib_paramis a pointer of type ONGO_CALIB_DATA_t, this structure holds the current sensor calibration parameters.
Returns
Returns the calibrated angle in degrees.

Definition at line 337 of file ongocalib.c.

◆ ONGO_GetUncalibAngle()

float64_t ONGO_GetUncalibAngle ( void  )

Calculates the uncalibrated angle.

This function uses differential sensor data to extract the angle.

Returns
Returns the uncalibrated angle in degrees.

Definition at line 325 of file ongocalib.c.

◆ ONGO_InitCalibData()

void ONGO_InitCalibData ( ONGO_CALIB_DATA_t *  calib_param,
int32_t  max_diff_sin_LSB,
int32_t  max_diff_cos_LSB,
int32_t  min_diff_sin_LSB,
int32_t  min_diff_cos_LSB,
float64_t  sin_45,
float64_t  cos_45,
float64_t  sin_135,
float64_t  cos_135 
)

Function used for ONGO_CALIB_DATA_t data initialization. The pointer of type ONGO_CALIB_DATA_t will be used to store calibration parameters.

This function must be called once before ONGO_CalibrationFindParam(..). Use this or ONGO_InitCalibData2(..).

Parameters
[in]calib_paramis a pointer of type ONGO_CALIB_DATA_t.
[in]max_diff_sin_LSBis the maximum differential sin signal in LSB.
[in]max_diff_cos_LSBis the maximum differential cos signal in LSB.
[in]min_diff_sin_LSBis the minimum differential sin signal in LSB.
[in]min_diff_cos_LSBis the minimum differential cos signal in LSB.
[in]sin_45is the differential sin component in LSB at a 45 deg position.
[in]cos_45is the differential cos component in LSB at a 45 deg position.
[in]sin_135is the differential sin component in LSB at a 135 deg position.
[in]cos_135is the differential cos component in LSB at a 135 deg position.
Returns
Nothing

Definition at line 200 of file ongocalib.c.

References ONGO_ROTATION_DATA_STORE::angle135found, ONGO_ROTATION_DATA_STORE::angle45found, ONGO_ROTATION_DATA_STORE::maxCos, ONGO_ROTATION_DATA_STORE::maxSin, ONGO_ROTATION_DATA_STORE::minCos, ONGO_ROTATION_DATA_STORE::minSin, ONGO_ROTATION_DATA_STORE::nr_valid_rotations, ONGO_CALIB_DATA::rotation_data, ONGO_ROTATION_DATA_STORE::X135, ONGO_ROTATION_DATA_STORE::X45, ONGO_ROTATION_DATA_STORE::Y135, and ONGO_ROTATION_DATA_STORE::Y45.

◆ ONGO_InitCalibData2()

void ONGO_InitCalibData2 ( ONGO_CALIB_DATA_t *  calib_param,
int32_t  max_SinP_LSB,
int32_t  max_CosP_LSB,
int32_t  max_SinN_LSB,
int32_t  max_CosN_LSB,
int32_t  min_SinP_LSB,
int32_t  min_CosP_LSB,
int32_t  min_SinN_LSB,
int32_t  min_CosN_LSB,
float64_t  sin_45,
float64_t  cos_45,
float64_t  sin_135,
float64_t  cos_135 
)

Function used for ONGO_CALIB_DATA_t data initialization. The pointer of type ONGO_CALIB_DATA_t will be used to store calibration parameters.

This function must be called once before ONGO_CalibrationFindParam(..). Use this or ONGO_InitCalibData(..).

Parameters
[in]calib_paramis a pointer of type ONGO_CALIB_DATA_t.
[in]max_SinP_LSBis the maximum P channel sin signal in LSB.
[in]max_CosP_LSBis the maximum P channel cos signal in LSB.
[in]max_SinN_LSBis the maximum N channel sin signal in LSB.
[in]max_CosN_LSBis the maximum N channel cos signal in LSB.
[in]min_SinP_LSBis the minimum P channel sin signal in LSB.
[in]min_CosP_LSBis the minimum P channel cos signal in LSB.
[in]min_SinN_LSBis the minimum N channel sin signal in LSB.
[in]min_CosN_LSBis the minimum N channel cos signal in LSB.
[in]sin_45is the differential sin component in LSB at a 45 deg position.
[in]cos_45is the differential cos component in LSB at a 45 deg position.
[in]sin_135is the differential sin component in LSB at a 135 deg position.
[in]cos_135is the differential cos component in LSB at a 135 deg position.
Returns
Nothing

Definition at line 258 of file ongocalib.c.

References ONGO_ROTATION_DATA_STORE::angle135found, ONGO_ROTATION_DATA_STORE::angle45found, ONGO_ROTATION_DATA_STORE::maxCos, ONGO_ROTATION_DATA_STORE::maxSin, ONGO_ROTATION_DATA_STORE::minCos, ONGO_ROTATION_DATA_STORE::minSin, ONGO_ROTATION_DATA_STORE::nr_valid_rotations, ONGO_CALIB_DATA::rotation_data, ONGO_ROTATION_DATA_STORE::X135, ONGO_ROTATION_DATA_STORE::X45, ONGO_ROTATION_DATA_STORE::Y135, and ONGO_ROTATION_DATA_STORE::Y45.

◆ ONGO_InitSensorData()

void ONGO_InitSensorData ( uint32_t  sinP_in_LSB,
uint32_t  cosP_in_LSB,
uint32_t  sinN_in_LSB,
uint32_t  cosN_in_LSB 
)

Function used for ONGO_ANALOG_SENSOR_DATA_t data assignment.

This function must be called after the data readout.

The initialized pointer will be used in the angle calculation and calibration process.

Parameters
[in]cosP_in_LSBis the sensor value in LSB corresponding to the positive cosinus.
[in]cosN_in_LSBis the sensor value in LSB corresponding to the negative cosinus.
[in]sinP_in_LSBis the sensor value in LSB corresponding to the positive sinus.
[in]sinN_in_LSBis the sensor value in LSB corresponding to the negative sinus.
Returns
Nothing

Definition at line 164 of file ongocalib.c.