2018-04-21 08:41 PM
HELLO..
I want to measure the frequency and duty cycle of the external signal. I have gone through some example available , and suggestions on website. Everywhere they are using either channel 1 or channel 2 in any of timer , unfortunately in my case signal is given to channel 4 , Is it still possible to measure duty cycle and frequency by using channel 4 , if so how to configure the same in stm cubemx ..
Can anybody suggest please , I am fully stuck with this issue ..
Thank you
#pwm-input #stm32h7 #cubemx2018-04-22 07:06 AM
The PWM Input mode pairs Channel 1 and 2.
You could use Input Capture with Channel 4, and Channel 3 (Indirect) to time stamp TIMx_CH4 along the timeline of TIMx and interrupt. You could then delta measurements in an interrupt (or sample with DMA), to measure the period and duty of an input signal.
2018-04-22 09:45 AM
Hello ..
Thanks for response ..
I am just confused , Can you please give me some more explanation, suggest some example project if possible . In stm example project they used TIM1 channel 1 as direct & channel 2 as indirect mode . I am using TIM 8 CHANNEL 4 for frequency capture and duty cycle measurements.
Suggest me how to configure the tim8 and how calculate duty cycle .
2018-04-22 10:33 AM
Use a free-running timer, use CH3 and CH4 to time-stamp different edges, and subtract values, or prior values.
2018-04-22 12:12 PM
Hello ...
Thanks for the information ..
As per my understanding I need to set channel 4 for input capture mode (direct mode) with rising edge , and channel 3 for falling edge(indirect mode) .
With the above configuration once rising edge detected i will read both channel capture values, then once falling edge detected (so this difference gives active pulse time) , and then next rising edge value give full cycle period .
Is my understanding is right , can I get both duty cycle and period with this configuration.
2018-04-22 12:26 PM
>>Is my understanding is right , can I get both duty cycle and period with this configuration.
The math and concept here should not be confusing.
If you time 3 consecutive edges A, B, C starting with a rising edge
C - A describes ticks for period
B - A describes ticks for high time
C - B describes ticks for low time
((B - A) * 100) / (C - A) describes high duty in percent
A clock ticking at 1 MHz will have ticks describing micro-seconds