cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder interface

iguffick
Associate II
Posted on October 30, 2008 at 04:34

Encoder interface

3 REPLIES 3
iguffick
Associate II
Posted on May 17, 2011 at 12:48

I have an encoder interface setup, using the auto-reload to loop around for the CPR of the encoder (i.e. 0-799).

Can the timer(s) be setup to give an underflow/overflow to chain to a longer (32 bit) reading.

Or can the timers be chained to give this behaviour.

Thanks for any help.

jonathan239955
Associate
Posted on May 17, 2011 at 12:48

I'd like to know how you set up your encoder interface. I haven't found any good examples anywhere.

As for chaining timers in encoder mode to get 32 bits, that would be a nice feature, wouldn't it? I have done it for two timers, but not in encoder mode. It should be pretty much the same as long as you are only going in one direction. The additional complication is that you could be overflowing or underflowing, but the update trigger doesn't tell the slave timer which one it was. Your only option might be to increment/decrement the upper word in an ISR.

jaroslaw2
Associate II
Posted on May 17, 2011 at 12:48

Hi,

I couldn't find any example as well.

I have done it like that.

Code:

<BR> <BR> TIM2->CCMR1=(u16)0xF1F1; <BR> TIM2->CCMR2=(u16)0x0000; <BR> TIM2->SMCR=(u16)0x0003; <BR> TIM2->CR1=(u16)0x0001; <BR> TIM2->CR2=(u16)0x0000; <BR> TIM2->CCER=(u16)0x0011; <BR> TIM2->PSC=(u16)0x0000; <BR>

Then to read value:

Code:

<BR> TempEnkoder=(short)TIM2->CNT; <BR>

[ This message was edited by: jaroslaw.oska on 30-10-2008 09:05 ]