2012-12-26 09:15 AM
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
2012-12-27 03:28 AM
you can connect index puls to an EXTI interrupt
and this way you can zero the encoder counter like reference mode in a CNC machine2012-12-28 04:20 AM
2013-01-01 03:23 AM
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);