2016-10-13 01:30 AM
Hi, I would like to read pwm output from as5048 encoder and I dont know how to do it. I understand this pwm frame, but how I may read output pwm step by step?
http://ams.com/eng/content/download/438523/1341157/143015 page 27.2016-10-13 05:52 AM
So couldn't you use a TIM in PWM Input Mode with a minimal prescaler, and CH1/CH2 providing period/duty. Confirm the period matches 1 KHz, and check duty and divide down into 4096 points. ie check min/max points, and scale
Review other PWM Input examples..2016-10-14 01:49 AM
I do something like this, it is proper way to read pwm signal from encoder?
void TIMERS_Configuration(void) { TIM_ICInitTypeDef TIM_ICInitStructure; TIM_ICInitStructure.TIM_Channel = TIM_Channel_2; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; // _Falling TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.TIM_ICFilter = 0x0; TIM_PWMIConfig(TIM3, &TIM_ICInitStructure); TIM_SelectInputTrigger(TIM3, TIM_TS_TI2FP2); TIM_SelectSlaveMode(TIM3, TIM_SlaveMode_Reset); TIM_SelectMasterSlaveMode(TIM3, TIM_MasterSlaveMode_Enable); TIM_Cmd(TIM3, ENABLE); TIM_ITConfig(TIM3, TIM_IT_CC2, ENABLE);}void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);}float IC2Value, DutyCycle, Frequency;void TIM3_IRQHandler(void) { TIM_ClearITPendingBit(TIM3, TIM_IT_CC2); IC2Value = TIM_GetCapture2(TIM3); if (IC2Value != 0) { DutyCycle = (TIM_GetCapture1(TIM3) * 100) / IC2Value; Frequency = SystemCoreClock / IC2Value; } else { DutyCycle = 0; Frequency = 0; }}2016-10-14 09:53 AM
Hi,
Try to preceed like the ready-to-use example ''TIM_InputCapture'' in at this path: STM32Cube_FW_F1_V1.4.0\Projects\STM3210E_EVAL\Examples\TIM\TIM_InputCaptureIf you are using Standard peripheral libray , it willl be the ''InputCapture'' example at this path: STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\TIM\InputCapture-Hannibal-