cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement 3 encoders using encoder mode in STM32F103C8?? the operation need to be in parallel in the same time.

Ejunior007
Associate II
 
3 REPLIES 3
TDK
Guru

Encoders are independent, so using 3 is fundamentally the same as using 1 except that you set it up on 3 different timers.

You can have up to 4 encoders on the STM32F103C8 by configuring each of TIM1/TIM2/TIM3/TIM4. CubeMX will happily generate the startup code for you.

If you feel a post has answered your question, please click "Accept as Solution".
MM..1
Chief III

Or you can use one timer for sampling interrupt and check GPIO states , this way you can use AB encoders Numfreegpio/2

for 1 encoder works just fine. i use HAL_TIM_IC_CaptureCallback for haldle some variables and turn te count into the position. But for 3 encoders doesnt work in the same way.

my code for 1 encoder:

uint32_t counter = 0;

int16_t count = 0;

int16_t position = 0;

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)

{

counter = __HAL_TIM_GET_COUNTER(htim);

count = (int16_t)counter;

position = count/12; // encoder resolution 12 counts/mm

}