Tool Libs
UMIT-TIROL Institute of Automation and Control Engineering library collection
 
Loading...
Searching...
No Matches
TIMER::Encoder Class Reference

Quadrature Encoder support. More...

#include <encoder.h>

Classes

struct  Conf
 Encoder constructor. More...
 

Public Member Functions

void measure ()
 measure the sensor
 
int16_t getValue ()
 return the counter value of the timer connected to the encoder
 
double getPosition ()
 return current value of encoder with overflow correction
 
void zero ()
 reset encoder position
 

Detailed Description

Quadrature Encoder support.


Class Documentation

◆ TIMER::Encoder::Conf

struct TIMER::Encoder::Conf

Encoder constructor.

make sure the pins for the encoder are on channels 1 and 2 of the used timer.

Parameters
timMicrocontroller Timer Peripheral (e.g. TIM2)
aAlternate Function initialized pin A
bAlternate Function initialized pin B
factorall encompassing conversion factor from encoder value to needed unit
Examples:
  • 4-bit/revolution rotary encoder, position in degrees:
    factor = 1 / pow(2, 4) * 360; 
  • 12-bit/revolution rotary encoder, position in radiants:
    factor = 1 / pow(2, 12) * M_PI; 
  • 10-bit/revolution rotary encoder, position in m traveled with a 6cm radius wheel:
    factor = 1 / pow(2, 10) * M_PI * 0.06; 
Collaboration diagram for TIMER::Encoder::Conf:
[legend]

Member Function Documentation

◆ measure()

void TIMER::Encoder::measure ( )
inline

measure the sensor

do this periodically to update encoder state

◆ getValue()

int16_t TIMER::Encoder::getValue ( )
inline

return the counter value of the timer connected to the encoder

Returns
16bit counter value

◆ getPosition()

double TIMER::Encoder::getPosition ( )
inline

return current value of encoder with overflow correction

Returns
position, based on initialized factor

The documentation for this class was generated from the following file: