HRI board firmware  v2.1
Microcontroller firmware of the board used during the HRI labs.
Functions
Driver / Incremental encoder

Driver for an incremental encoder. More...

Functions

void enc_Init (void)
 Initialize the incremental encoder driver. More...
 
float32_t enc_GetPosition (void)
 Gets the current motor shaft angle, measured by the encoder counter. More...
 
void enc_SetPosition (float32_t newPosition)
 Set the position offset. More...
 

Detailed Description

Driver for an incremental encoder.

This driver uses a timer of the STM32, configured as a quadrature decoder.

Call enc_Init() first in the initialization code. Then, call enc_GetPosition() to get the decoded value. The output value is the paddle position in degrees, taking the reduction ratio into account.

Function Documentation

◆ enc_GetPosition()

float32_t enc_GetPosition ( void  )

Gets the current motor shaft angle, measured by the encoder counter.

Return values
Thecurrent angle of the motor shaft [deg].

◆ enc_Init()

void enc_Init ( void  )

Initialize the incremental encoder driver.

This function initialize the timer 5 as a quadrature decoder, and set the current paddle position to zero.

◆ enc_SetPosition()

void enc_SetPosition ( float32_t  newPosition)

Set the position offset.

The new position offset is computed such that the given position will now be returned by enc_GetPosition() if the paddle remains at this physical position.

Parameters
newPositionthe new paddle position.