Skip to main content
arapp1990
Associate II
February 21, 2017
Question

STM32 Quadrature Encoder

  • February 21, 2017
  • 3 replies
  • 1603 views
Posted on February 21, 2017 at 21:50

Hello guys,

I would like to use an quadrature encoder for a motor control application on an STM32F303K8T6.

Unfortunately the hardware gives me the following configuration:

ENCODER_OUT_A -> PA2 (TIM2_CH3)

ENCODER_OUT_B -> PA3 (TIM2_CH4)

ENCODER_OUT_Z -> PA5 (TIM2_CH1)

Is there any possibility to use CH3 and CH4 instead of CH1 and CH2 as timer count input

and

CH1 as capture timer value input?

The quadrature encoder generates 1024 per machanical revolution and get spinned up to 10krpm.

best regards

#motor-control #quadrature-encoder
This topic has been closed for replies.

3 replies

waclawek.jan
Super User
February 21, 2017
Posted on February 21, 2017 at 22:17

Is there any possibility to use CH3 and CH4 instead of CH1 and CH2 as timer count input

No.

JW

T J
Senior III
February 21, 2017
Posted on February 22, 2017 at 00:18

You may be able to use external interrupts and count the steps yourself...

1024 x 10,000 /60 = 171kHz x 4 edges, 682Khz interrupts

at 72Mhz cycle rate, its about 100 cycles per interrupt, yes it can be done, but nothing else

and if you miss a count, you are in big trouble, smashing the machine..

but it is far better to use the hardware functions provided for this purpose...

JW has the correct short answer.

Uwe Bonnes
Chief
February 21, 2017
Posted on February 22, 2017 at 00:32

What about using TIM15?

T J
Senior III
February 22, 2017
Posted on February 22, 2017 at 00:51

you actually don't need to use timers...

just interrupt pins, but it is dangerous for the machine equipment if the count is wrong and then you smash into the stop..