3 years, 12 months ago.

how do i configure counters to clock pulses from 4 encoders


I'm working on a project with the F401RE where I need to read 4 encoders simultaneously to synchronise 4 motors using PID, i've tried applying the QEI.h library but does not seem to work and the high level side of it is making me confused i'm more comfortable thinking low level.

I'm currently reading the manual to see how to configure the counters but i have no experience in the syntax to set up the counter registers, is there anyone that can provide me with an example on how I may go about assigning a pin to a counter and configuring the counters? Any guidance will be greatly appreciated it.

Thank you.

1 Answer

3 years, 12 months ago.

Have a look at https://developer.mbed.org/users/gregeric/code/Nucleo_Hello_Encoder/

You may run into trouble if trying to use all 4 available hardware encoders and also PWM etc

Accepted Answer

Hi David thank you for your reply, I'll try the code once my new board arrives, luck has it that mine just decided to stop working, LED3 and LED1 gone solid red...

I was thinking of powering the motors with 4 PWMs, but I was unaware of this problem, the reference manual says that timers 1 to 5 and 8 can interface quadrature encoders, would it be possible to produce different duty cycles based on 1 timer on each channel of that timer?

posted by spacestream Spacestream 10 Apr 2016