tmrangle  2.0.0.0
Main Page

TMR Angle Click

TMR Angle Click is a Click board� perfectly suited for developing applications that range from steering angle applications with the highest functional safety requirements to motors for wipers, pumps and actuators and electric motors in general.

Click Product page


Click library

  • Author : MikroE Team
  • Date : Dec 2019.
  • Type : SPI type

Software Support

We provide a library for the TMRAngle Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for TMRAngle Click driver.

Standard key functions :

  • Config Object Initialization function.

    void tmrangle_cfg_setup ( tmrangle_cfg_t *cfg );

  • Initialization function.

    TMRANGLE_RETVAL tmrangle_init ( tmrangle_t *ctx, tmrangle_cfg_t *cfg );

  • Click Default Configuration function.

    void tmrangle_default_cfg ( tmrangle_t *ctx );

Example key functions :

  • Function read and stores negative and positive, sine and cosine parameters data.

    void tmrangle_init_sensor_data ( tmrangle_t* ctx );

  • This function will extract the maximum, minimum voltage levels, amplitude, offset, and orthogonality.

    void tmrangle_calibration_find_param ( tmrangle_t* ctx,

    tmrangle_calib_data_t* calib_param );
  • Function calculates the calibrated angle in degrees and this structure holds the current sensor calibration parameters.

    float tmrangle_get_calib_angle ( tmrangle_calib_data_t* calib_param );

Examples Description

This example reads and value in deegres, and then logs the result.

The demo application is composed of two sections :

Application Init

Initializes driver, and also write log.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
TMRANGLE_MAP_MIKROBUS( cfg, MIKROBUS_1 );
tmrangle_init( &tmrangle, &cfg );
}

Application Task

Reads angle value in degrees and logs the results.

void application_task ( void )
{
float angle;
trigonometry_t trig_set;
tmrangle_calib_data_t calibration_store_params;
trig_set.sin_45 = TMRANGLE_SIN_45;
trig_set.cos_45 = TMRANGLE_COS_45;
tmrangle_init_calib_data( &tmrangle, &calibration_store_params, &trig_set );
tmrangle_calibration_find_param( &tmrangle, &calibration_store_params );
angle = tmrangle_get_calib_angle( &tmrangle, &calibration_store_params );
log_printf( &logger, "Angle is %f deg\r\n", angle );
Delay_ms ( 1000 );
}

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.TMRAngle

Additional notes and informations

Depending on the development board you are using, you may need USB UART Click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


tmrangle_init
TMRANGLE_RETVAL tmrangle_init(tmrangle_t *ctx, tmrangle_cfg_t *cfg)
Initialization function.
TMRANGLE_MAP_MIKROBUS
#define TMRANGLE_MAP_MIKROBUS(cfg, mikrobus)
Definition: tmrangle.h:68
trigonometry_t::sin_135
float sin_135
Definition: tmrangle.h:247
trigonometry_t::max_diff_sin
int32_t max_diff_sin
Definition: tmrangle.h:241
tmrangle_init_calib_data
void tmrangle_init_calib_data(tmrangle_t *ctx, tmrangle_calib_data_t *calib_param, trigonometry_t *dev)
Initialization and stores calibration parameters function.
tmrangle_init_sensor_data
void tmrangle_init_sensor_data(tmrangle_t *ctx)
Read and stores parameters data function.
tmrangle_calibration_find_param
void tmrangle_calibration_find_param(tmrangle_t *ctx, tmrangle_calib_data_t *calib_param)
Get new calibration rotation parameters function.
application_task
void application_task(void)
Definition: main.c:62
trigonometry_t::min_diff_sin
int32_t min_diff_sin
Definition: tmrangle.h:243
tmrangle_cfg_setup
void tmrangle_cfg_setup(tmrangle_cfg_t *cfg)
Config Object Initialization function.
tmrangle_get_calib_angle
float tmrangle_get_calib_angle(tmrangle_t *ctx, tmrangle_calib_data_t *calib_param)
Calculate the calibrated angle ( degree ) function.
TMRANGLE_MAX_DIFF_SIN
#define TMRANGLE_MAX_DIFF_SIN
Definition: tmrangle.h:111
tmrangle_cfg_t
Click configuration structure definition.
Definition: tmrangle.h:165
TMRANGLE_SIN_45
#define TMRANGLE_SIN_45
Definition: tmrangle.h:115
TMRANGLE_MIN_DIFF_SIN
#define TMRANGLE_MIN_DIFF_SIN
Definition: tmrangle.h:113
TMRANGLE_SIN_135
#define TMRANGLE_SIN_135
Definition: tmrangle.h:117
TMRANGLE_COS_135
#define TMRANGLE_COS_135
Definition: tmrangle.h:118
TMRANGLE_MAX_DIFF_COS
#define TMRANGLE_MAX_DIFF_COS
Definition: tmrangle.h:112
trigonometry_t
Definition: tmrangle.h:240
tmrangle_calib_data_t
Definition: tmrangle.h:230
TMRANGLE_COS_45
#define TMRANGLE_COS_45
Definition: tmrangle.h:116
application_init
void application_init(void)
Definition: main.c:36
trigonometry_t::cos_135
float cos_135
Definition: tmrangle.h:248
trigonometry_t::sin_45
float sin_45
Definition: tmrangle.h:245
trigonometry_t::cos_45
float cos_45
Definition: tmrangle.h:246
trigonometry_t::max_diff_cos
int32_t max_diff_cos
Definition: tmrangle.h:242
TMRANGLE_MIN_DIFF_COS
#define TMRANGLE_MIN_DIFF_COS
Definition: tmrangle.h:114
trigonometry_t::min_diff_cos
int32_t min_diff_cos
Definition: tmrangle.h:244