/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Timer usage

Username:     
Password:     
             

Forum

# 1   2008-03-26 21:24:44 Timer usage

repzak
Member
Registered: 2008-03-05
Posts: 170

Timer usage

Hello

I am trying to measre the speed of a fan, i first thought i could use the input compare register as a register for counting my input pulses, but that is not made this way sad

then i can use the input and latch the value on positive and negative edge and reset the counter once and i have the pulse time or i can get the periode time, but if i want to connect 4 fans on the same timer it seems defficult.

another way is just to use the i/o pin as interupt and count up a register, but it will happen 3000 times/min * 4 fans..

Anyone haveing a better suggestion, i am a litle stuck sad

Kasper

Offline

 

# 2   2008-03-27 09:51:54 Timer usage

graham
Member
Registered: 2008-02-23
Posts: 32

Re: Timer usage

3000 x per minute x 4 fans = 200 per second.
Assume you catch only one edge, all you have to do is configure interrupts for one edge on the connected pin, and increment a counter for that fan each time. If you go over 15 sec periods, then you can left shift the result twice (x 4), and you will have 4 RPM updates per fan per minute.
Each 15 seconds, you take the current count, multiply by 4 and store as current RPM for that channel. Zero the counter, and repeat the procedure for the next fan.

200 interrupts per second is nothing for microcontrollers these days. Not for such a simple task, anyway.

Offline

 

Board footer