cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement Pulse counter on STM32H723?

Arrhenius
Associate III

Hi,

In our application we are using a cooling system(i.e., a FAN/DC motor). For which I have implemented TIM1 in PWM mode to control the speed of the FAN, the story doesn't end here. The FAN provides a feedback which is called as pulse sensor which can be used to detect the actual FAN speed.

The FAN generate two clock pulses for 1rpm in a second, so for 'n' rpm 2n clock pulses are generated in a second.

Note: FAN rated maximum speed is 11500rpm

One way to read the feedback is to count the rising edge of the pulse for 1 second and put it on a simple formula to get the rpm value.

Other way is to read the pulse width and calculate its duration and map it with 1 second reference pulse width.

Kindly suggest, in what way we can count the number of pulses so as to find the actual rpm. One topic which I came across was timer input capture mode. But will that help me to count the number of rising edges ?

Hoping for a suitable answer.

P.S. Attached image is the feedback signal coming from the FAN

Thanks in advance

Regards

Arrhenius

3 REPLIES 3

> in what way we can count the number of pulses

Using a timer in external clock mode, and then reading out its count periodically e.g. once per second, timed by another timer or any other suitable way.

JW

Arrhenius
Associate III

Hi @Community member​ ,

Thanks for your response.

I thought of using input capture mode of TIM1.

I am already using TIM1 in PWM mode, so is it possible to use input capture mode along with PWM mode ?

Following are the pins,

PWM pin: PE14 (currently in use)

Input capture: PE9 (can I use this ?)

Uwe Bonnes
Principal III

Input capture is used to measure the arrival time of some edge. To use as a counter, you would need to counts these edge events. Either in the input capture IRQ or by writing the input capture value via DMA and later count the number of captured events in the DMA result ares. In any case, the PWM function and the input capture need a seperate channel. But using a dedicated counter as Jan suggested is most straightforward.