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.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
}
#define TMRANGLE_MAP_MIKROBUS(cfg, mikrobus)
Definition tmrangle.h:68
void tmrangle_cfg_setup(tmrangle_cfg_t *cfg)
Config Object Initialization function.
TMRANGLE_RETVAL tmrangle_init(tmrangle_t *ctx, tmrangle_cfg_t *cfg)
Initialization function.
void application_init(void)
Definition main.c:36
Click configuration structure definition.
Definition tmrangle.h:165
Application Task
Reads angle value in degrees and logs the results.
{
float angle;
log_printf( &logger, "Angle is %f deg\r\n", angle );
Delay_ms ( 1000 );
}
#define TMRANGLE_MAX_DIFF_COS
Definition tmrangle.h:112
#define TMRANGLE_MAX_DIFF_SIN
Definition tmrangle.h:111
#define TMRANGLE_MIN_DIFF_SIN
Definition tmrangle.h:113
#define TMRANGLE_SIN_45
Definition tmrangle.h:115
#define TMRANGLE_MIN_DIFF_COS
Definition tmrangle.h:114
#define TMRANGLE_COS_135
Definition tmrangle.h:118
#define TMRANGLE_SIN_135
Definition tmrangle.h:117
#define TMRANGLE_COS_45
Definition tmrangle.h:116
void tmrangle_calibration_find_param(tmrangle_t *ctx, tmrangle_calib_data_t *calib_param)
Get new calibration rotation parameters function.
void tmrangle_init_sensor_data(tmrangle_t *ctx)
Read and stores parameters data function.
void tmrangle_init_calib_data(tmrangle_t *ctx, tmrangle_calib_data_t *calib_param, trigonometry_t *dev)
Initialization and stores calibration parameters function.
float tmrangle_get_calib_angle(tmrangle_t *ctx, tmrangle_calib_data_t *calib_param)
Calculate the calibrated angle ( degree ) function.
void application_task(void)
Definition main.c:62
Definition tmrangle.h:230
Definition tmrangle.h:240
float sin_45
Definition tmrangle.h:245
int32_t max_diff_sin
Definition tmrangle.h:241
int32_t min_diff_cos
Definition tmrangle.h:244
float cos_45
Definition tmrangle.h:246
float sin_135
Definition tmrangle.h:247
int32_t max_diff_cos
Definition tmrangle.h:242
int32_t min_diff_sin
Definition tmrangle.h:243
float cos_135
Definition tmrangle.h:248
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.