cancel
Showing results for 
Search instead for 
Did you mean: 

Is somehow possible to detect rising and falling edge of input signal ?

DCiko.1
Associate

HI,

I'm using STM32f4 and I'm trying to calculate rotation speed using Hall sensors.

Idea is to use TIM4 and 3 Hall sensors in 3 channels in caputre compare mode to calculate time between two edges. I know how to do that, but the problem is that I need information about the falling or rising edge to know on what angle is rotor.

I need angle to calculate rotation speed, the difference between to captures will never be exactly 60 deegres.

I' am also planing to do calibration of hall sensors to know angle precisely .

So is it possible to detect rising/falling edge using timer or is there some other way to do it ?

Thanks,

Domagoj.

1 ACCEPTED SOLUTION

Accepted Solutions
DBehe.1
Associate II

At a time you can either capture rising edge or falling edge but there is a solution initially set the register for capture the rising edge then in interrupt change that register to capture the falling edge of the pulse . 1st store the count value when rising edge is detected and when faling edge is detected minus the current counter from previous counter. this way you can measure the frequency(pulse length).

dhruti

View solution in original post

7 REPLIES 7

0693W000000W2bhQAC.png

JW

There is also an indirect mode allow for a single pin to go to two channels so for example CH1 and CH2 can capture opposite edges.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
berendi
Principal

Look up PWM input mode in the reference manual.

DBehe.1
Associate II

At a time you can either capture rising edge or falling edge but there is a solution initially set the register for capture the rising edge then in interrupt change that register to capture the falling edge of the pulse . 1st store the count value when rising edge is detected and when faling edge is detected minus the current counter from previous counter. this way you can measure the frequency(pulse length).

dhruti

bnymntrz
Associate III

It is possible to capture the rising and falling edge of the input signal using the Timer unit, our friend who has already shared the recorder above.

Laurent Ca...
Lead II

Dear @Domagoj Ciković​ 

Did an answer here help you to solve your problem?

If yes, which one?

If no, did you have still this problem to solve?

Best regards

Laurent Ca...

Laurent Ca...
Lead II

Dear @Domagoj Ciković​ 

I guess you don't have to solve this problem anymore, therefore I consider this thread solved and closed.

If not, feel free to reopen it by posting a new answer.

Best regards

Laurent Ca...