Infineon One Point Calibration Library  1.0.1
Functions
onecalib.c File Reference
#include "onecalib.h"
Include dependency graph for onecalib.c:

Go to the source code of this file.

Functions

void ONECALIB_InitSensorData (uint32_t sinP_in_LSB, uint32_t cosP_in_LSB, uint32_t sinN_in_LSB, uint32_t cosN_in_LSB)
 Function used for ANALOG_SENSOR_DATA_t data assignment. More...
 
void ONECALIB_InitCalibData (CALIB_DATA_t *calib_param)
 Function used for CALIB_DATA_t data initialization. The pointer of type CALIB_DATA_t will be used to store calibration parameters. More...
 
float64_t ONECALIB_GetAngle (const CALIB_DATA_t *calib_param)
 Calculates the calibrated angle if calibration has been performed, else the uncalibrated angle. More...
 
float64_t ONECALIB_GetUncalibAngle (void)
 Calculates the uncalibrated angle. More...
 
float64_t ONECALIB_GetCalibAngle (const CALIB_DATA_t *calib_param)
 Calculates the calibrated angle. More...
 
void ONECALIB_CalibrationFindParam (CALIB_DATA_t *calib_param, bool rotate_CW, bool rotate_CCW)
 This function is used to extract the calibration parameters. It should called until calib_param.full_calibration_performed is true. To extract the correct rotation, the input parameter rotate_CW should be true until calib_param.rotation_data_CW.calibration_done is true(while the magnet is spinning in CW direction). Same for the CCW direction. While calib_param.full_calibration_performed is false only the differential uncalibrated angle is available. More...
 

Function Documentation

◆ ONECALIB_CalibrationFindParam()

void ONECALIB_CalibrationFindParam ( CALIB_DATA_t *  calib_param,
bool  rotate_CW,
bool  rotate_CCW 
)

This function is used to extract the calibration parameters. It should called until calib_param.full_calibration_performed is true. To extract the correct rotation, the input parameter rotate_CW should be true until calib_param.rotation_data_CW.calibration_done is true(while the magnet is spinning in CW direction). Same for the CCW direction. While calib_param.full_calibration_performed is false only the differential uncalibrated angle is available.

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.

Usage example:

------------------- CALIBRATION FOR CW DIRECTION -------------------------------
while (!calibration_store_params.rotation_data_CW.calibration_done) {
// read sensor data
ONECALIB_CalibrationFindParam(&calibration_store_params, true,
false);
}
------------------- CALIBRATION FOR CCW DIRECTION -------------------------------
UART_Transmit(&UART_0, message_ccw, sizeof(message_ccw) - 1);
while (!calibration_store_params.rotation_data_CCW.calibration_done) {
// read sensor data
ONECALIB_CalibrationFindParam(&calibration_store_params,
false, true);
}
------------------- GET CALIBRATED ANGLE DATA ----------------------------------
if (calibration_store_params.full_calibration_performed) {
angle_read = ONECALIB_GetCalibAngle(&calibration_store_params);
}
Parameters
[in]calib_paramis a pointer of type CALIB_DATA_t, this structure holds the current sensor calibration parameters.
[in]rotate_CWis a bool that is true if the rotation is in clockwise direction.
[in]rotate_CCWis a bool that is true if the rotation is in counter-clockwise direction.
Returns
Nothing

Definition at line 468 of file onecalib.c.

References ROTATION_DATA_STORE::calibration_done, and CALIB_DATA::rotation_data_CW.

◆ ONECALIB_GetAngle()

float64_t ONECALIB_GetAngle ( const CALIB_DATA_t *  calib_param)

Calculates the calibrated angle if calibration has been performed, else the uncalibrated angle.

This function checks the stored calibration parameters and returns a angle value, no matter if the calibration procedure has been performed.

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

Definition at line 372 of file onecalib.c.

◆ ONECALIB_GetCalibAngle()

float64_t ONECALIB_GetCalibAngle ( const CALIB_DATA_t *  calib_param)

Calculates the calibrated angle.

Don't use this if the calibration procedure has not been performed. This function dosen't check the stored calibration parameters and returns the calibrated angle value.

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

Definition at line 414 of file onecalib.c.

◆ ONECALIB_GetUncalibAngle()

float64_t ONECALIB_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 397 of file onecalib.c.

◆ ONECALIB_InitCalibData()

void ONECALIB_InitCalibData ( CALIB_DATA_t *  calib_param)

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

This function must be called once before ONECALIB_CalibrationFindParam(..).

Parameters
[in]calib_paramis a pointer of type CALIB_DATA_t.
Returns
Nothing

Definition at line 301 of file onecalib.c.

◆ ONECALIB_InitSensorData()

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

Function used for 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 242 of file onecalib.c.