cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 - Quadrature + toggling

dibs
Associate II
Posted on June 10, 2014 at 00:33

Can you use a single timer to make a quadrature divider? What I mean by this is can you take in a quadrature signal, have the timer increase its CNT register and then toggle channels 3 & 4 based upon a particular CNT value?

 

This would require channels 1&2 acting as quadrature inputs and channels 3&4 acting as toggling outputs. If this is not possible, can you tell me why? My initial attempts at this failed, so I am trying to figure out if there is something about the peripheral that causes this to not be possible.

Thanks in advance,

#stm32f4 #toggling #quadrature #qei
3 REPLIES 3
Posted on June 10, 2014 at 00:50

I would think that output compare and toggle modes would be viable on Ch 3 and 4, but honestly not something I've had cause to try.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jpeacock2399
Associate II
Posted on June 10, 2014 at 15:59

In encoder mode the counter runs in both directions, depending on quadrature phase.  Then there's the edge jitter problem where the low bit of the counter oscillates if the encoder stops on an edge.  I imagine the output of a divider would have a strange waveform.

I can see where an encoder clock divider could be used as some form of tachometer output.  I use channel 3 on an encoder timer to capture the index pulse so no particular reason why you can't configure the extra channels for output.

  Jack Peacock
dibs
Associate II
Posted on June 11, 2014 at 18:42

Assuming a perfect input, I have tested that this does work.

A jittery input would indeed cause problems with this method. Any ideas on how to deal with this?