Showing results for 
Search instead for 
Did you mean: 

STM32F103 & Encoder Mode

Associate III

Dear community,

I work on a 'robot' with odometrie.
Each geared DC motor have a rotarty magnetic encoder ( AS5047P).
I use Quadrature Output to Encoder mode. It's works but i have some questions...

> get_value

Whathever the configuration on STMCube, the value given by tim4->CNT is a decrease value.
My setting > Prescaler =0 / Counter Mode = 0 / Counter Periode = 60000.
A timer is set for read value each 500us.
My question, is how set the register value at 0. The register value increase up to the time interrup for read the data, next re-set the register at 0.

> Interrupt
I would like replace the timer (for read value) by an interrupt when the register is full.
Like this, my speed_correction(PID) function will be call in function of speed and not periodically...

if you have an idea.. thanks 🙂

Associate III

For the first question, it's done... i have to change the polarity of one of timer.
My seconde question is always in progress.