Skip to main content
iguffick
Associate II
October 30, 2008
Question

Encoder interface

  • October 30, 2008
  • 3 replies
  • 885 views
Posted on October 30, 2008 at 04:34

Encoder interface

    This topic has been closed for replies.

    3 replies

    jonathan239955
    Visitor II
    May 17, 2011
    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.

    iguffick
    iguffickAuthor
    Associate II
    May 17, 2011
    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.

    jaroslaw2
    Associate III
    May 17, 2011
    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 ]