Skip to main content
jveith
Associate II
December 26, 2012
Question

how to use Index Track in quadrature encoder mode

  • December 26, 2012
  • 3 replies
  • 2065 views
Posted on December 26, 2012 at 18:15

have 2 timer channels (CH1+CH2) setup in quadrature encoder mode and all things work fine. The encoder (Avago HEDS 5540) has a third index channel with very narrow pulse per revolution. Is ist possible to use this signal for timer Reset or Prelaod event ? What input pin is required ? (ETR?) The CH1/2 input Frequency is above 100khz and software interrupt delay seems too slow

    This topic has been closed for replies.

    3 replies

    mehmet.karakaya
    Associate III
    December 27, 2012
    Posted on December 27, 2012 at 12:28

    you can connect index puls to an EXTI interrupt

    and this way you can zero the encoder counter

    like reference mode in a CNC machine

    jveith
    jveithAuthor
    Associate II
    December 28, 2012
    Posted on December 28, 2012 at 13:20

    same hint is already in STM32 datasheet: '' The 3rd

    (encoder) output may be connected to EXTI and trigger a Counter reset.

    My problem is, that EXTI calls a interupt service function what modifies the counter per instruction what is much to slow. Slave mode = Reset Mode is contrary to Encoder mode of a counter. How to connect reset / preload to external signal in Encoder mode ? (The Xmega can do this)
    asiflion02
    Visitor II
    January 1, 2013
    Posted on January 01, 2013 at 12:23

    This is how i have configured timer to read encoder pulses,but the counter doesnt seem to increment ,is it anything else i have to change in this..?

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8,ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

    GPIO_Init(GPIOC,&GPIO_InitStructure);

    GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_TIM8);

    GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_TIM8);

    TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);

    TIM_TimeBaseStructure.TIM_Period =2500;

    TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);

    TIM_EncoderInterfaceConfig(TIM8, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);

    NVIC_InitStructure.NVIC_IRQChannel = TIM8_UP_TIM13_IRQn;

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    NVIC_Init(&NVIC_InitStructure);

    TIM_ITConfig(TIM8, TIM_IT_Update, ENABLE);

    TIM_Cmd(TIM8, ENABLE);