2024-07-18 07:27 AM - edited 2024-07-18 07:32 AM
Hello, I'm developing a board to control a desk pc setup.
In addition to other things like controlling the lights, some motors and other stuff, the board has to control and monitor some PWM fans.
The fans report back the revolutions using a tachometer, in other words, I get a square signal with a frequency representing the rotation speed. The frequency to be measured will vary from 40Hz to around 2kHz.
High precision or response times are not needed.
I have to monitor around 10-12 fans, that means measuring 10-12 signal simultaneously. I'm using an STM32F427VIT6.
How would you recommend me to measure all those signals just using hardware, I don't want to create interruptions for every changing edge in the signals.
The STM32F427VIT6 has 15 timers, is there a way to do it using only a few timers? I really would like to avoid using one timer per fan.
My initial idea was to put a counter that counts the rising edges, and every few seconds it transfers the count to a variable and resets the counter. That means that when I look at the variable value I get the amount of edges in the last few seconds. From there I can get an estimate of the mean rotation speed in the last counting interval.
Is it possible to link a pin to a memory address in a way that when the pin receives a rising edge it increments the value of the memory address is pointing to by 1? Without using interruptions I mean.
Do you have any ideas?
Thank you!
2024-07-18 07:34 AM
Think is, each TIM has a single counting element. Typically each has 4 latches to capture or modulate.
You can run 32-bit TIM in maximal mode, have it latch / timestamp the edges on 4 inputs, and then delta the tick counts between events. There's an input prescaler, to latch at 1x, 2x, 4x or 8x events.
You can capture the time stamps into an array via DMA off the CCx triggers